This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/env sh | |
EXCLUDES="htdocs mod py vendor tools client qa test" | |
stdlib_dir=`python -c 'import os; print os.path.dirname(os.__file__)'` | |
stdlib=`find $stdlib_dir -maxdepth 1 -name '*.py' -exec basename {} .py \;;\ | |
find $stdlib_dir -maxdepth 2 -name __init__.py -exec dirname {} \; | xargs -L1 basename` | |
find `[ -n "$1" ] && echo $1 || echo .` \ | |
-not \( -false \ |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
''' | |
parse these: http://www.w3.org/Protocols/rfc2616/rfc2616-sec3.html#sec3.3 | |
''' | |
import datetime | |
import re | |
import pytz | |
# |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import random | |
try: | |
import cPickle as pickle | |
except ImportError: | |
import pickle | |
import greenhouse | |
import junction | |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import select | |
import zmq | |
ctx = zmq.Context() | |
requester = ctx.socket(zmq.REQ) | |
replyer = ctx.socket(zmq.REP) | |
replyer.bind("inproc://testology") | |
requester.connect("inproc://testology") |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
yield """<!-- | |
browsers won't actually display data as it comes in until there is a certain | |
minimal amount already received, so this prefix is just to send something to | |
push the browser over that limit so that the stuff we care about will be | |
rendered immediately. | |
nope, the previous paragraph wasn't enough (for chrome at least). so, what's | |
new with you? *sigh*, this forced conversation just feels so awkward. | |
it's ok, we ALREADY have around 40% of the padding we need! I think I'll take |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import math | |
import sys | |
import traceback | |
def minus1(x): | |
return x - 1 | |
def plus1(x): | |
return x + 1 |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
class WeakMethodRef(object): | |
def __init__(self, method): | |
if getattr(method, "im_self", None): | |
self.obj = weakref.ref(method.im_self) | |
elif getattr(method, "im_class", None): | |
self.obj = weakref.ref(method.im_class) | |
else: | |
self.obj = None | |
if getattr(method, "im_func", None): |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
from cStringIO import StringIO | |
class SizeBoundFile(object): | |
"""a length-limiting file object wrapper | |
it reads from the underlying file object but never past the given size, so | |
it is suitable for use around a socket.makefile() file given a particular | |
Content-Length -- reading from this simulates EOF rather than reading into | |
the next message. |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
$ python -m timeit -s "import collections; Point = collections.namedtuple('Point', ('x', 'y'));" "Point(5, 11)" | |
1000000 loops, best of 3: 0.739 usec per loop | |
$ python -m timeit "(5, 11)" | |
10000000 loops, best of 3: 0.0267 usec per loop | |
$ python -m timeit -s "import collections; p = collections.namedtuple('Point', ('x', 'y'))(5, 11)" "x, y = p" | |
10000000 loops, best of 3: 0.134 usec per loop | |
$ python -m timeit -s "p = (5, 11)" "x, y = p" | |
10000000 loops, best of 3: 0.0678 usec per loop | |
$ python -m timeit -s "import collections; p = collections.namedtuple('Point', ('x', 'y'))(5, 11)" "p.x" | |
10000000 loops, best of 3: 0.15 usec per loop |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
127.0.0.1 s.meebocdn.com | |
127.0.0.1 www.meebo.com | |
127.0.0.1 meebo.com |