Posts

Showing posts from 2016

How to extract tweets from python.

#Import the necessary methods from tweepy library from tweepy.streaming import StreamListener from tweepy import OAuthHandler from tweepy import Stream #Variables that contains the user credentials to access Twitter API access_token = "access_token" access_token_secret = "access_token_secret" consumer_key = "access_token_secret" consumer_secret = "access_token_secret" #Replace the following with yours #This is a basic listener that just prints received tweets to stdout. class StdOutListener(StreamListener):     def on_data(self, data):         print data         return True     def on_error(self, status):         print status if __name__ == '__main__':     #This handles Twitter authetification and the connection to Twitter Streaming API     l = StdOutListener()     auth = OAuthHandler(consumer_key, consumer_secret)     auth.set_access_token...

Send SPAM messages to fb friends using python

The python code is............ import fbchat from getpass import getpass user = str ( raw_input ( "Username: " )) client = fbchat.Client(user, getpass()) no = int ( raw_input ( "Number of friends: " )) for i in xrange (no):      name = str ( raw_input ( "Name: " ))      friends = client.getUsers(name)      friend = friends[ 0 ]      msg = str ( raw_input ( "Message: " ))     for i in range(100):     #Change the number 100 to your choice         sent = client.send(friend.uid, msg)      if sent:          print ( "Message sent successfully!" ) For this fbchat module is required. Insall it by executing sudo pip install fbchat   Explenation: First username & password of fb is asked. Enter it to login. Then type ...

MODULO 10^9 + 7 output.

The  modulo  operation is the same as  the remainder of the division .   a  modulo  b  is  c , means that the remainder when a is divided by b is c.It is represented by the ‘%’ operator in many programming languages. For eg: 5%2=1 What is the necessary of MODULO 10^9+7 : The largest integer data type in C/C++ is the  long long int ; its size is 64 bits and can store integers from ( –2^63 ) to ( +2^63 -1 ) . Integers as large as  9 X 10^18  can be stored in a  long long int . But in problems like calculating the number of permutations of a size n array, even this large range may prove insufficient. We know that the number of permutations of a size n array is  n! . Even for a small value of n, the answer can be very large. Eg, for n=21, the answer is 21! which is about 5 x 10^19 and too large for a long long int variable to store. This makes calculating values of large factorials difficult. So, instead of asking th...

Toggle the string case

#include <stdio.h> int main() {     char str[100];     int i;     gets(str);     for(i=0;str[i]!=NULL;i++)     {     if(str[i]>='A'&&str[i]<='Z')     {     str[i]+=32;     }     else if(str[i]>='a'&&str[i]<='z')     {     str[i]-=32;     }     }     printf("%s",str);     return 0; }