Skip to content

Instantly share code, notes, and snippets.

@slinkp
slinkp / thing.wkt
Created June 1, 2011 16:55
a large multipolygon in the Boston, MA area.
SRID=4326;MULTIPOLYGON (((-70.9290019999999970 42.3321949999999987, -70.9289399999999972 42.3321550000000002, -70.9286939999999930 42.3319070000000011, -70.9286859999999990 42.3318669999999955, -70.9283549999999963 42.3315169999999981, -70.9283549999999963 42.3314990000000009, -70.9283159999999953 42.3314719999999980, -70.9283159999999953 42.3314540000000008, -70.9282850000000025 42.3314319999999995, -70.9282620000000037 42.3313969999999955, -70.9282240000000002 42.3313750000000013, -70.9282089999999954 42.3313349999999957, -70.9281539999999922 42.3312809999999971, -70.9281539999999922 42.3312629999999999, -70.9281079999999946 42.3312370000000016, -70.9279920000000033 42.3311039999999963, -70.9279159999999962 42.3310379999999995, -70.9279159999999962 42.3310150000000007, -70.9278379999999942 42.3309399999999982, -70.9278389999999916 42.3309220000000010, -70.9277459999999991 42.3308199999999957, -70.9277230000000003 42.3307620000000000, -70.9276459999999958 42.3306639999999987, -70.9275149999999996 42.33058499
@slinkp
slinkp / virtualenv_doctests.patch
Created April 12, 2011 19:03
Fixes virtualenv issue 109
diff --git a/virtualenv.py b/virtualenv.py
index f49f3a3..b16aacb 100755
--- a/virtualenv.py
+++ b/virtualenv.py
@@ -337,7 +337,7 @@ class Logger(object):
def level_matches(self, level, consumer_level):
"""
- >>> l = Logger()
+ >>> l = Logger([])
import re
import string
import sys
import optparse
from django.contrib.gis.gdal import DataSource
from ebpub.metros.models import Metro
from ebpub.streets.models import Block
from ebpub.streets.name_utils import make_pretty_name
from ebpub.utils.text import slugify
@slinkp
slinkp / django_dummycache.py
Created December 8, 2010 04:12
A do-nothing cache implementation for Django. Useful for manual testing, debugging, performance comparisons, etc.
Duh. Django has this already.
@slinkp
slinkp / django_generic.wsgi.py
Created December 7, 2010 19:04
Generic mod_wsgi script for Django in a virtualenv
"""
evolved over a couple of deployment of a couple apps...
dropping it here so i don't forget it.
Drop this somewhere in your virtualenv, edit the two environment vars,
and you're done.
"""
import os
os.environ['DJANGO_SETTINGS_MODULE'] = 'CHANGE ME'
--- tests.py.orig 2010-11-29 13:41:10.538521131 -0500
+++ tests.py 2010-11-29 15:14:34.528520210 -0500
@@ -408,6 +408,18 @@
'function () { return 1; }',
media_url=media_url)
+
+ def assertFilenamesAlmostEqual(self, name1, name2):
+ # Occasionally we get a failure because the clock ticked to
+ # the next second after the file was rendered.
## SETUP
pw@slinktopp2 ~ $ cd tmp/
pw@slinktopp2 tmp $ virtualenv test_django_static
New python executable in test_django_static/bin/python2.6
Also creating executable in test_django_static/bin/python
Installing distribute......................................................................................................................................................................................done.
pw@slinktopp2 tmp $ cd test_django_static/
pw@slinktopp2 test_django_static $ source bin/activate
(test_django_static)pw@slinktopp2 test_django_static $ pip install django django-static
@slinkp
slinkp / Import mbox to google groups using procmail
Created November 8, 2010 21:42
google-groups-forwarder.rc
# Hacky way to import an mbox archive into a google group.
# Use this like so:
# formail -t -s procmail google-groups-forwarder.rc < foo.mbox
# Limitations: archives are not sorted by date.
SHELL=/bin/sh
VERBOSE=yes
MAILDIR=/tmp/Mail #you better make sure it exists
LOGFILE=/tmp/procmail.log #recommended
@slinkp
slinkp / sshwrap.sh
Created October 19, 2010 14:49
horrible ssh wrapper hack that changes background of currently running roxterm window based on hostname.
function sshwrap {
# A wrapper for ssh that sets roxterm's background image based on the
# hostname.
# We do most of this in bash because it handles wrapping interactive
# commands and TTYs well, which Python does not (at least not without
# jumping through major hoops a la Pexpect).
# The bits that I could not bear to do in bash are done in inline Python.
# Yes, this is hideous.
"""
Test out 20 binary-search functions harvested from
http://reprog.wordpress.com/2010/04/19/are-you-one-of-the-10-percent/
See results at the bottom.
"""
import random
failures = {}