Skip to content

Instantly share code, notes, and snippets.

View reiddraper's full-sized avatar
🍹

Reid Draper reiddraper

🍹
View GitHub Profile
make[1]: *** [libraries/Cabal/Cabal/dist-boot/package-data.mk] Segmentation fault (core dumped)
make[1]: *** Waiting for unfinished jobs....
make[1]: *** [utils/hsc2hs/dist/package-data.mk] Segmentation fault (core dumped)
make: *** [all] Error 2
make -j8 131.49s user 2.92s system 99% cpu 2:15.43 total
Here's an explanation from 30k ft. of the generator namespace. There are three monads
involved, one of which simply contains the other two (but is not a monad transformer). They're
not named explicitly like this in the module, but let's call them: RoseTree, Generator and Gen.
Gen is the monad that is a wrapper around Gen (RoseTree a), to use Haskell types. A RoseTree
is simply an n-ary. In Haskell, it'd be defined like:
data RoseTree a = RoseTree a [RoseTree a]
In Clojure I represent it as a two-element vector, the first element being the node's value,
and the second being a lazy-sequence of the children. Since we use a lazy-seq, we can
def gist_test():
a = 'test' * 5
return a
import urllib2
url = 'http://google.com'
response = urllib2.urlopen(url)
print response.read()
import networkx as nx
G = nx.read_gpickle('lebanese.mp3.graph.gpickle')
# pos has the x, y coordinates of the nodes
pos = nx.spring_layout(G)
# you'll need to figure out how to draw the edges yourself though I think
# drawing
D = nx.DiGraph()
n = G.nodes()
m = {}
for i, x in enumerate(n):
m[x] = i
for a,b in G.edges():
#!/usr/bin/env python
import web
urls = ('/(.*)', 'hello')
app = web.application(urls, globals())
class hello:
def GET(self, name):
return 'hello, world'
@reiddraper
reiddraper / gist:333224
Created March 15, 2010 19:30
supervisord.conf
[inet_http_server] ; inet (TCP) server disabled by default
port=127.0.0.1:9001 ; (ip_address:port specifier, *:port for all iface)
;username=user ; (default is no username (open server))
;password=123 ; (default is no password (open server))
[supervisord]
logfile=/tmp/supervisord.log ; (main log file;default $CWD/supervisord.log)
logfile_maxbytes=50MB ; (max main logfile bytes b4 rotation;default 50MB)
logfile_backups=10 ; (num of main logfile rotation backups;default 10)
loglevel=info ; (log level;default info; others: debug,warn,trace)
#!/usr/bin/env python
"""
Fetch all a user's Last.fm scrobbles by paging through their recent tracks
Usage: ./fetch.py <username> [<start_page> [<end_page>]]
Be aware: You may end up with duplicated data if the user is scrobbling
when you fetch for tracks. Make sure you check for dupes when you process
the XML later
"""
import httplib
h = httplib.HTTPConnection('www.google.com', 80)
h.request('GET', '/', headers = {'Cookie': 'Cookie1=foo; Cookie2=bar'})
z = h.getresponse()
z.status
z.read()