Skip to content

Instantly share code, notes, and snippets.

View gist:323673
Hosting Sphinx docs at GitHub
Before: Run sphinx-quickstart in docs/
1. Follow "Project Pages" instructions from to create a gh-pages branch
2. Add Sphinx html build dir as git submodule:
git checkout master
git submodule add -b gh-pages docs/_build/html
View gist:333123
Hosting static files with appengine
## app.yaml
default_expiration: "7d" <--- Sets the Expires header
- url: (.*)/
static_files: static\1/index.html
upload: static/index.html
# 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):
View gitcommitblamestats.txt
# 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/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)]
#!/usr/bin/env bash
# goes through directories, checks if it's a svn/hg/git repo and updates them
for i in $(ls -d */); do
echo $i;
if [ -d "$i/.git" ]; then cd $i; git pull; cd ..; fi
if [ -d "$i/.hg" ]; then cd $i; hg pull -u; cd ..; fi
if [ -d "$i/.svn" ]; then svn up $i; fi
# This will scrape the django trac pages and output two files with ticket counts
# ticket-status-all.txt: assigned | repoened | new
# ticket-meta-all.txt: has_patch | needs_docs | needs_tests | needs_better_patch
# You can then use these numbers to make a plot in gnuplot or R
# Note: This was just a test; it's better to use the TRAC API.
DATE=$(date +%Y-%m-%d)
wget "" -O 1
#!/usr/bin/env python
# encoding: utf-8
import sys
import os
from docutils.core import publish_parts
from docutils.writers import html4css1
# Install LaTeX Beamer for TeX Live
# Arthur Koziel
#!/usr/bin/env python
# encoding: utf-8
Text Labels as png with Pango/Cairo
import os
import cairo