Skip to content

Instantly share code, notes, and snippets.

@gearmonkey
gearmonkey / TotC_random_draw.py
Created October 12, 2012 14:26
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] th
"""
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]
@gearmonkey
gearmonkey / karmapolice.json
Created June 29, 2012 15:06
the response from The Echo Nest's demo song search, but with the audio_summary bucket (also, I prettified it for readability) - fetched from http://developer.echonest.com/api/v4/song/search?api_key=N6E4NIOVYMTHNDM8J&format=json&results=1&artist=radiohead&
{"response":
{"status":
{"version": "4.2",
"code": 0,
"message": "Success"},
"songs": [
{"audio_summary":
{"key": 7,
"mode": 1,
"time_signature": 4,
@gearmonkey
gearmonkey / worldcitiesfilter.py
Created May 22, 2012 09:50
a quick filter to get rid of null entries in the world cities db
'''
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])
@gearmonkey
gearmonkey / icwsm.py
Created July 18, 2011 12:30 — forked from jhofman/icwsm.py
script to scrape pdfs and paper info for icwsm2011
#!/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())
@gearmonkey
gearmonkey / firealarm.out
Created May 13, 2011 17:10
firealarm sample out
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!
@gearmonkey
gearmonkey / sentiment_tweets.py
Created May 10, 2011 11:17
grab a tweet and push it to the mm sentiment analyzer
#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())