Skip to content

Instantly share code, notes, and snippets.

@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())
@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 / 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 / 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 / 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 / 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 / plurals.py
Created January 17, 2013 11:44
really stupid plural checker.
def is_plural(a,b):
"""a really stupid pluralisation checker, english only
returns true if b is standard form plural of a (or vis-a-versa) as defined by these rules:
adds s or es
subs y for ies
subs f or fe for ves
based on http://en.wikipedia.org/wiki/English_plural this should cover regular and near-regular plurals
"""
if len(a) == len(b):
#all [near-]regular plurals are longer, so:
@gearmonkey
gearmonkey / bif_energy.md
Last active March 26, 2019 17:01
DIY cycling energy drink, recipe and info

Hummingbird Feed

Recipe

  • 40g maltodextrin (I source mine from myprotein.com)
  • 1g maelic acid (about half a teaspoon, this is a food safe acid, also available at myprotein.com)
  • 5g sugar (a couple pinches, table sugar or demerara work well)

Combine all ingrediants in a 550ml bottle. Shake vigourously.

@gearmonkey
gearmonkey / linked data resources
Created February 6, 2014 16:35
Linked Data things
http://linkeddata.org/
sir TBL's old but useful intro/manifesto http://www.w3.org/DesignIssues/LinkedData.html
a video of the point of it all http://www.youtube.com/watch?v=zwbs4ej0gpc
Tom Heath (he's a data scientist at The ODI) has a book (free html version) http://linkeddatabook.com/editions/1.0/
RoR content negs – https://github.com/Swirrl/contentnegotiation

Fun and Plausible Solutions is a full stack digital agency that focuses on building bespoke data tooling for companies of all shapes and sizes. Their website can be found at http://funandplausible.com .