Skip to content

Instantly share code, notes, and snippets.

import timeit
from django.conf import settings; settings.configure()
from django.dispatch import Signal
def handle(sender, **kw):
pass
handlers10 = [lambda **kw: None for i in range(10)]
handlers100 = [lambda **kw: None for i in range(100)]
import httplib2
from oauth import oauth
CONSUMER_KEY = 'szvErAxSLbVn25RD'
CONSUMER_SECRET = 'WxbMH22kUkjRgUz4'
CALLBACK_URL = 'http://jacobian.org/'
class TimetricOAuthClient(oauth.OAuthClient):
request_token_url = 'http://timetric.com/oauth/request_token/'
authorization_url = 'http://timetric.com/oauth/authorize/'
import os
import time
import readline
import ipy_defaults
import IPython.ipapi
import ipy_stock_completers
ip = IPython.ipapi.get()
o = ip.options
Function was called by...
ncalls tottime cumtime
/Users/jacob/Projects/Django/upstream/django/utils/datastructures.py:119(values) <- 283 0.000 0.000 /Users/jacob/Projects/Django/upstream/django/db/models/base.py:498(_collect_sub_objects)
11388678 61.910 70.411 /Users/jacob/Projects/Django/upstream/django/db/models/loading.py:134(get_models)
39 0.000 0.000 /Users/jacob/Projects/Django/upstream/django/db/models/sql/query.py:1077(change_aliases)
5 0.000 0.000 /Users/jacob/Projects/Django/upstream/django/db/models/sql/subqueries.py:424(as_sql)
@jacobian
jacobian / gist:95443
Created April 14, 2009 21:33
.screenrc
hardstatus alwayslastline
hardstatus string "%{gk}[ %{G}%H %{g}][%= %{wk}%?%-Lw%?%{r}(%{W}%n*%f %t%?(%u)%?%{r})%{w}%?%+Lw%?%?%= %{g}][%{B} %m/%d %{W}%c %{g}]"
startup_message off
vbell off
The goal of Summer of Code is to get your project written, reviewed, and
ultimately merged back into Django's trunk. We want your project to
succeed, and we approved it because we think you've got a good chance of
pulling it off.
However, this is easier said than done. You'll need to work hard,
communicate effectively with the community, and pass a rigorous peer
review. Your mentor -- and Django's committer team in general -- will give
you as much support as possible, but ultimately the onus is on your
shoulders to get this done.
# Django: validate that an uploaded file is a valid PDF
import pyPdf # from http://pybrary.net/pyPdf/
from pyPdf.utils import PdfReadError
class DocumentForm(forms.ModelForm):
pdf = forms.FileField()
class Meta:
model = Document
#!/usr/bin/env python
"""
Regex for URIs
These regex are directly derived from the collected ABNF in RFC3986
(except for DIGIT, ALPHA and HEXDIG, defined by RFC2234).
They should be processed with re.VERBOSE.
"""
# -*- coding: utf-8 -*-
"""
Example Usage
=============
>>> import datetime
>>> start = datetime.date(2009, 6, 21)
>>> g1 = daterange(start)
import logging
class Silence(logging.Handler):
def emit(self, record):
pass
logging.getLogger("jellyroll").addHandler(Silence())