Skip to content

Instantly share code, notes, and snippets.

View aparrish's full-sized avatar

Allison Parrish aparrish

View GitHub Profile
@aparrish
aparrish / twitter_search.py
Created April 3, 2011 15:58
simple twitter search api client
import json
import urllib
import time
def search_twitter(query, callback, maxpages=10):
resp = urllib.urlopen('http://search.twitter.com/search.json%s' % query)
data = json.loads(resp.read())
for item in data['results']:
callback(item)
if 'next_page' in data and maxpages > 1:
@aparrish
aparrish / poem.py
Created April 3, 2011 15:59
generate simple poem from twitter search results
from twitter_search import search_twitter
import random
import sys
import re
class Thingy(object):
def __init__(self, words):
self.words = words
self.begins = dict([(word, []) for word in words])
self.ends = dict([(word, []) for word in words])
@aparrish
aparrish / draw_average_word.py
Created April 7, 2011 12:21
drawing the average N-letter word using processing.py
import array
wordlen = 8
charwidth = 32
charheight = 64
def fillbuf(pg, font, word, buffer):
pg.beginDraw()
pg.background(0)
pg.fill(255)
@aparrish
aparrish / tip_poetics.py
Created April 11, 2011 03:13
simple poetry mashups with the foursquare venues api
import urllib
import sys
import time
import json
import random
import re
# to get your own client id/client secret, go here:
# https://foursquare.com/oauth/
foursq_client_id = sys.argv[1]
@aparrish
aparrish / simpleca.py
Created April 13, 2011 14:18
simple cellular automata + text in processing.py
# requires processing.py: https://github.com/jdf/processing.py
#
# you'll need pcsenior.ttf (from here: http://www.zone38.net/font/) in a data/ directory
# (though you can also use any font you'd like)
from random import randrange
class Cell(object):
def __init__(self, status):
self.current = status
isobel:~ adam$ curl -s "https://search.twitter.com/search.json?q=everything&rpp=100" | python -mjson.tool | perl -nle 'print join " ", (split / /, $1)[0..5] if /"text":.*(everything [a-zA-Z ]+)",/i'
EVERYTHING RIGHT NOW OMG
EVERYTHING done by Hank G
everything new york
everything through crist who gives me
everything better
everything is
everything hard af he be looking
everything will happen in the last
everything in my power not to
isobel:~ adam$ python -c 'import itertools, sys; [sys.stdout.write("e" + "".join(i) + "g\n") for i in itertools.permutations("everything"[1:-1])]' | head -50
everything
everythnig
everytihng
everytinhg
everytnhig
everytnihg
everyhting
everyhtnig
everyhitng
isobel:~ adam$ perl -le 'for $c ('a'..'z') { $_ = "everything"; s/[aeiou]/$c/g; print }'
avarythang
bvbrythbng
cvcrythcng
dvdrythdng
everytheng
fvfrythfng
gvgrythgng
hvhrythhng
ivirything
@aparrish
aparrish / everything nick montfort can do
Created April 20, 2011 02:10
(I cheated: you need sowpods.txt for this.)
isobel:~ adam$ perl -nle 'chomp;push@w,$_ if"everything"=~/$_/;END{{print join" ",map{$w[rand @w]}0..rand(4);print""if++$i%3==0;redo}}' <~/Documents/Code/sowpods.txt |head -40
thin hi thing thin
every eve
thin very eve hing
eve every
eve hi hin
everything thin hin
er everything
isobel:~ adam$ echo everything | perl -le 'print $_ x (ord($_) - ord('a')+1) for split //, <>'
eeeee
vvvvvvvvvvvvvvvvvvvvvv
eeeee
rrrrrrrrrrrrrrrrrr
yyyyyyyyyyyyyyyyyyyyyyyyy
tttttttttttttttttttt
hhhhhhhh
iiiiiiiii
nnnnnnnnnnnnnn