Skip to content

Instantly share code, notes, and snippets.

#!/usr/bin/env python
# Benchmark: lambda vs. operator.itemgetter
from datetime import datetime
from random import randint
from timeit import Timer
def create_random_datetime_dict():
return [(i, datetime.fromtimestamp(randint(1230768000, 1262303999)))
for i in xrange(200000)]
# sort committers by how many lines they have committed to a git repo
find . -name '*.py' -exec git blame -p {} \; | awk '/committer / { print $2 | "sort | uniq -c"}' | sort -r
#!/usr/bin/python
# Benchmark pop 1st element for collections.deque vs. list
import timeit
if __name__=='__main__':
number = 1
#print timeit.timeit("for v in xrange(10): c1.insert(0, v)", "c1 = []", number=number)
#print timeit.timeit("for v in xrange(10): c1.appendleft(v)", "from collections import deque; c1 = deque()", number=number)
for r in (1,10,100,1000,5000,10000,100000):
Hosting static files with appengine
## app.yaml
default_expiration: "7d" <--- Sets the Expires header
handlers:
- url: (.*)/
static_files: static\1/index.html
upload: static/index.html
Hosting Sphinx docs at GitHub
-----------------------------
Before: Run sphinx-quickstart in docs/
1. Follow "Project Pages" instructions from http://pages.github.com/ to create a gh-pages branch
2. Add Sphinx html build dir as git submodule:
git checkout master
git submodule add -b gh-pages git@github.com:arthurk/django-disqus.git docs/_build/html