Skip to content

Instantly share code, notes, and snippets.

@jameshfisher
jameshfisher / trie.go
Created May 15, 2010 19:05
A trie structure, storing []byte elements, implemented in Go
package trie
import (
"container/vector"
"sort"
)
// A 'set' structure, that can hold []byte objects.
// For any one []byte instance, it is either in the set or not.
type Trie struct {
# Download all current FAA sectional GeoTIFFs (zipped)
import urllib, os, csv
from lxml.html.soupparser import fromstring
FAA_CHART_URL = 'http://aeronav.faa.gov/index.asp?xml=aeronav/applications/VFR/chartlist_sect'
BASE_CONTENT_URL = 'http://aeronav.faa.gov/'
DOWNLOAD_DIR = 'download'
data = urllib.urlopen(FAA_CHART_URL).read()
@minrk
minrk / checkconstants.py
Created January 27, 2011 04:47
compare constants in zmq.h to czmq.pxd
#!/usr/bin/env python
"""A simply script to scrape zmq.h and zmq/core/czmq.pxd for constants,
and compare the two. This can be used to check for updates to zmq.h
that pyzmq may not yet match.
"""
from __future__ import with_statement
import os
import sys
@erikfrey
erikfrey / gist:865355
Created March 11, 2011 02:20
Threadpool crashes gevent
from threadpool import ThreadPool
import random
import gevent
import gevent.pool
iterations = 1000000
max_stack_depth = 50
def source(tp):
for i in xrange(0, iterations):
@DavidYKay
DavidYKay / gist:912765
Created April 10, 2011 21:52
"Can Code Be Like Literature" - Jeremy Ashkenas
Jeremy
Absolutely brilliant
both technically
and oratorically
He wrote CoffeeScript
1st place 5k
21 min, 3 seconds
<7min mile
Big picture
@codysoyland
codysoyland / temporary_settings.py
Created June 21, 2011 21:47
Context manager for monkey-patching django settings (useful in unit tests)
# Example usage:
# with temporary_settings(CELERY_ALWAYS_EAGER=True):
# run_task.delay() # runs task with eager setting enabled.
from contextlib import contextmanager
from django.conf import settings
@contextmanager
def temporary_settings(**temp_settings):
orig_settings = {}
@carljm
carljm / postactivate
Created July 12, 2011 18:21
Yo dawg, I heard you like Ruby...
#!/bin/bash
# This hook is run after every virtualenv is activated.
export OLD_GEM_HOME=$GEM_HOME
export GEM_HOME=$VIRTUAL_ENV/gems/
export GEM_PATH=
export PATH=$VIRTUAL_ENV/gems/bin:$PATH
@mcroydon
mcroydon / sillyproto.go
Created January 12, 2012 00:01
Performance-oriented silly text-based protocol server in go.
package main
import (
"bufio"
"flag"
"fmt"
"io"
"log"
"net"
"net/textproto"
@nathanborror
nathanborror / gist:2884560
Created June 6, 2012 20:29
Mediator Pattern
define([], function(obj) {
var channels = {};
if (!obj) obj = {};
obj.subscribe = function(channel, subscription) {
if (!channels[channel]) channels[channel] = [];
channels[channel].push(subscription);
return channels[channel].length -1;
};
@piscisaureus
piscisaureus / pr.md
Created August 13, 2012 16:12
Checkout github pull requests locally

Locate the section for your github remote in the .git/config file. It looks like this:

[remote "origin"]
	fetch = +refs/heads/*:refs/remotes/origin/*
	url = git@github.com:joyent/node.git

Now add the line fetch = +refs/pull/*/head:refs/remotes/origin/pr/* to this section. Obviously, change the github url to match your project's URL. It ends up looking like this: