Sunday, December 16, 2012

Update Twitter Using Python Tweepy


I just spending sometime to play with tweepy. This post will show how to use that lib to access Twitter API.

First, install python (obviously). Second, install (if not installed yet) easy_install a tool to install python package easily. Refer to this http://pypi.python.org/pypi/setuptools

Go to console and check if easy_install instalation.



Now install tweepy module if not available yet.


Next create application in twitter so we can access the API. Go to this URL: https://dev.twitter.com/apps and create new application


Please note in there is a configuration to set application type.


After application has been created, we need some special authorization to access API. Twitter use OAuth. There are 4 important values that we have to note:
OAuth Consumer Key
OAuth Consumer Secret


and
Access Token
Access Token Secret


The last two are the token which is granted by our application user later.

Enough for configuration, now go to python console (I am using iPython) evaluate following code:

import tweepy
# provide all the keys and secrets
CONSUMER_KEY = 'the_key'
CONSUMER_SECRET = 'the_secret'
ACCESS_TOKEN = 'the_token'
ACCESS_SECRET = 'the_token_secret'
auth = tweepy.OAuthHandler(CONSUMER_KEY, CONSUMER_SECRET)
auth.set_access_token(ACCESS_TOKEN,ACCESS_SECRET)
api = tweepy.API(auth)

# do anything you want now
api.friends()
api.update_status('Hello world from Tweepy')

Thursday, December 13, 2012

A Short Reflection of Age Increment


"Life is beautiful. Be grateful for everything you have but keep fighting to achieve every of your dreams"


Age is nothing rather than just a number increment. However the increment of age should be a great moment to do self evaluation. More mature a person should made him more wise and not the opposite, older but become more childish. Hopefully I can became the first type.

Like several years before, this writing will try to reflect what I feel and what I want to be afterwards. Indirectly it will be a kind of evaluation and resolution.

Start from evaluation. I get married now for more than full year. Although I am having long distance marriage but still, more or less I have to try and be more mature compared at the time I was single. But I think I have to be more expressive to show my love to my wife because at the other side my wife also always give many gifts and surprises. Including this wonderful video for my birthday.


And also an awesome cake surprise



Second I already work in Singapore for more than full year as well. There many things I have learnt for that range time. More demanding job and multicultural environment for instance. All of those things are shaping and improving me more.

Next is about what I want to achieve. I want to make it simple and less material oriented. "I want to be always grateful and humble in life". To do some tangible elaboration, I want to be an expert in my field but at the same time can give significant positive impact  to society, perhaps by being a speaker, writer, teacher or just a good programmer which can make some positive contribution (hopefully not become too cliche) for a better world. More specific, I want to be a good father this year (hopefully Allah can trust me). I want to have some shelter for my family soon. I want to write a book to leave trace that I've never exist in this world. Want to have some more wonderful job and activity.

So different with previous year post I don't want to make too long bullshit explanation bit instead just make small thing become true. "To be more grateful and more humble".

For the closing I just want to make same quote by myself for reminder to myself. "Life is beautiful. Be grateful for everything you have but keep fighting to achieve every of your dreams".