This file contains 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 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)] |
This file contains 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
# 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 |
This file contains 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/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): |
This file contains 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
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 |
This file contains 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
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 |
NewerOlder