Saturday, 18 February 2017

Facebook+Python=Awesome

Do you like python? Do you use facebook?
If the answer is yes why not use facebook via python.
Below is the code to use facebook via python .This program has been inspired by http://www.geeksforgeeks.org/send-message-to-fb-friend-using-python
 Disclaimer of Warranties and Limitation of Liability.
a.Unless otherwise separately undertaken by the author, to the extent possible, the author offers the Licensed Material as-is and as-available, and makes no representations or warranties of any kind concerning the Licensed Material, whether express, implied, statutory, or other. This includes, without limitation, warranties of title, merchantability, fitness for a particular purpose, non-infringement, absence of latent or other defects, accuracy, or the presence or absence of errors, whether or not known or discoverable. Where disclaimers of warranties are not allowed in full or in part, this disclaimer may not apply to You.
b.The disclaimer of warranties and limitation of liability provided above shall be interpreted in a manner that, to the extent possible, most closely approximates an absolute disclaimer and waiver of all liability.
Check out fbchat's policies before continuing.
# This code to be considered under GPLv3.Use it under your responsibility.
Code:
>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>
#Please use it carefully.Ensure loging out by using a browser
#Required dependencies:
#   requests
#   lxml
#   beautifulsoup4
#   fbchat
def main():
    '''main function: initiation of fbchat and login'''
    import fbchat
    from getpass import getpass
    username = str(raw_input("Username: "))
    client = fbchat.Client(username, getpass())
    '''
    #For sendig same message to specific number of clients
    no_of_friends = int(raw_input("Number of friends: "))
    for i in xrange(no_of_friends):
        name = str(raw_input("Name: "))
        friends = client.getUsers(name)  # return a list of names
        friend = friends[0]
        msg = str(raw_input("Message: "))
        ask = 'O'
        while ask.upper()!='Y' and ask.upper()!='N':
            ask = raw_input('Are you sure about sending this message to'+friend+'(Y/N):')
            if ask.upper()=='Y':
                sent = client.send(friend.uid, msg)
                if sent:
                    print("Message sent successfully!")
            elif ask.upper()=='N':
                print("Message was not sent .")'''
    def choicefrnd(friends):
        '''choose freind from list'''
        try:
             chno=input('Enter index of friend: ')
             friend = friends[chno-1]
             return friend
         except:
             print 'Please give index number as printed above from 1 to n'
             choicefrnd()
    def talk():
        '''talk with friends. Contains main loop and sub loops'''
        ch='y'
        while ch=='y':   
            name = str(raw_input("Name: "))
            friends = client.getUsers(name)  # return a list of names
            for i in xrange(len(friends)):
                print str(i+1)+str(friend[i])
            if len(friends)>=1:
                friend=choicefrnd(friends)
                msg = str(raw_input("Message: "))
                ask = 'O'
                while ask.upper()!='Q':
                   
                    ask = raw_input('Are you sure about sending this message to'+friend+'(Y/N):')
                    if ask.upper()=='Y':
                        sent = client.send(friend.uid, msg)
                        if sent:
                            print("Message sent successfully!")
                    elif ask.upper()=='N':
                        print("Message was not sent .")
                    elif ask.upper()=='Q':
                        break
                    else:
                        print 'Could not decipher your answer.'
                    print 'Press q to quit chatting this friend'
            else:
                pass           
        else:
            pass
        talk()
        client.logout()
main()

Sunday, 25 September 2016

Wednesday, 2 March 2016

Monday, 11 January 2016

This game has been made by PA Games SSDDR.It is Licensed under cc.Run the named game.py to play.The registration code is 5369 .Go to PA Games SSDDR website to download.
Creative Commons License
Games by PA Games is licensed under a Creative Commons Attribution-NonCommercial 4.0 International License.
Here is the post :
Here is a package of 4 games in one.To run this games you would need Python2.7.x version. Other information about installation are given in detail in User manual.This game has been made by PA Games SSDDR.It is Licensed under CC.Run the file named game.py to play.The registration code is 5369 .Click on Download.
Creative Commons License
Games 1.1 by PA Games SSDDR. is licensed under a Creative Commons Attribution-NonCommercial 4.0 International License.This game runs on Windows, Mac OS, Linux, Android(CLI)etc.

Friday, 3 July 2015

A python program to print the following pattern?
      1
    121
   12021
  1204021
120404021
Click on download.

Tuesday, 16 June 2015

This is code for isosceles 123 triangle pattern in python, download.
This is code for isosceles abc triangle pattern in python, download.
This is code for word counter in python, download.

Sunday, 17 May 2015

This is a program to find hcf of two numbers in python. Click on download.
This is a program to find lcm of two numbers in python. Click on download.

Thoughts on measuring one way speed of light

The One-Way Speed of Light Problem is a fundamental issue in physics and philosophy of science concerning whether the speed of light in one...