Read Samuel L. Jackson's most recent quotable tweet on your desktop.
In celebration of Mr. Jackson's recent arrival to the Tweetosphere, this simple variation on the Latest Tweet as a Quote submission from dozdozdoz lets you focus more of your attention on this great cultural icon.
This Latest Tweet as a Quote variation can be easily modified for your favorite tweeting quote-smith. You can replace Mr. Jackson's username and spelled out name where they each appear once near the bottom of the script.
I must admit there's probably a better way to go about this, like parsing the RSS feed on his Twitter profile page. But this way was fun for me as a <24 hour Geektool user and beginner programmer.
Get your API details from Twitter. Twitter has a set of documentation that walks you through this process. Fill in the form on the Twitter developer site and you will receive a CONSUMERKEY, CONSUMERSECRET, ACCESSKEY and ACCESSSECRET.
Add these details into the text below where they are requested and copy/paste the script into Notepad.
Save as JacksonQuote.py. Make a note of the path.
Load Terminal and type: 'easy_install tweepy' without the quotes. (tweepy powers this script, if this install fails then you may need to install setuptools for Python)
Add the following as a GeekTool shell command
'python /Users..[insert full file path here]../TweetQuote.py'
import tweepy, os, sys, re # Declare OAuth varibles. CONSUMER_KEY = '...' CONSUMER_SECRET = '...' ACCESS_KEY = '...' ACCESS_SECRET = '...' keyfile = "authkeys.dat" auth = tweepy.OAuthHandler(CONSUMER_KEY, CONSUMER_SECRET) auth.set_access_token(ACCESS_KEY, ACCESS_SECRET) api = tweepy.API(auth) # Break string into multiple lines def para(text): return reduce(lambda line, word, width=50: '%s%s%s' %(line, ' \n'[(len(line)-line.rfind('\n')-1 + len(word.split('\n',1)) >= 50)], word), text.split(' ')) # Convert html entities into Unicode def unescape(text): def fixup(m): text = m.group(0) if text[:2] == "&#": try: if text[:3] == "&#x": return unichr(int(text[3:-1], 16)) else: return unichr(int(text[2:-1])) except ValueError: pass else: try: text = unichr(htmlentitydefs.name2codepoint[text[1:-1]]) except KeyError: pass return text return re.sub("&#?\w+;", fixup, text) # Script type = api.user_timeline(screen_name="samuelljackson",count=30) for result in type: if result.text.find('@')==-1 and result.text.find('http://')==-1: twtt = result.text print para(unescape(twtt)) + "\n" + "\n- " + "Samuel L. Jackson" break