This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| """ | |
| TotC_random_draw.py | |
| An emulator of the random draw process from | |
| Trial of the Clones by Zach Weinersmith | |
| process in the book is to flip to a random page | |
| and using the number in the corner for game | |
| mechanics. | |
| call it like this: | |
| >python TotC_random_draw.py [number of draws] | |
| then it prints the outcome[s] |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| {"response": | |
| {"status": | |
| {"version": "4.2", | |
| "code": 0, | |
| "message": "Success"}, | |
| "songs": [ | |
| {"audio_summary": | |
| {"key": 7, | |
| "mode": 1, | |
| "time_signature": 4, |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| ''' | |
| filter out all the null population entries from the world cites database http://www.maxmind.com/app/worldcities | |
| ''' | |
| import csv | |
| with open('worldcitiespop.txt') as fh: | |
| reader = csv.DictReader(fh) | |
| cities_pop = [line for line in reader if line['Population']] | |
| #print all the cities in the UK with a population above 200,000 | |
| print '\n'.join(['{0}: {1}'.format(entry['City'], entry['Population']) for entry in cities_pop if entry['Country']=='gb' and int(entry['Population']) > 200000]) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| #!/usr/bin/env python | |
| from lxml import etree | |
| from urllib import urlopen | |
| if __name__=='__main__': | |
| url = 'http://www.aaai.org/ocs/index.php/ICWSM/ICWSM11/schedConf/presentations' | |
| tree = etree.parse(urlopen(url), etree.HTMLParser()) | |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| fetching the conversation at http://www.exquisitetweets.com/collection/RodBegbie/402 | |
| Is the conversation a flame war? | |
| yes | |
| Where's the troll? | |
| http://twitter.com/JohnONolan/status/63027551760691200 | |
| Author: John O'Nolan username: JohnONolan | |
| Now stop feeding the trolls! |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| #grab some data from twitter | |
| data = loads(urllib2.urlopen("http://api.twitter.com/1/statuses/show/{0}.json".\ | |
| format(twitter_id)).read()) | |
| tweet_content = data["text"] | |
| #push to sentiment analysis | |
| raw_senti = loads(urllib2.urlopen(\ | |
| "http://apib1.semetric.com/musicmetric/sentiment?token="+\ | |
| API_KEY, data = tweet_content).read()) |
NewerOlder