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
import os | |
import shutil | |
import urllib2 | |
import zipfile | |
from lxml import etree # requires lxml & friends | |
# TODO: | |
# - Total vote counts | |
# - County-level results |
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
var intcomma = function(value) { | |
// inspired by django.contrib.humanize.intcomma | |
var origValue = String(value); | |
var newValue = origValue.replace(/^(-?\d+)(\d{3})/, '$1,$2'); | |
if (origValue == newValue){ | |
return newValue; | |
} else { | |
return intcomma(newValue); | |
} | |
}; |
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
# inspired by dopplr's color squares | |
# http://blog.dopplr.com/2007/10/23/in-rainbows/ | |
from hashlib import md5 | |
from string import Template | |
hood_block = Template(""" | |
<div class="neighborhood" id="$cityid"> | |
<div class="neighborhood-color" style="background-color:#$bghex;"></div> | |
<div class="neighborhood-text">$cityname</div> |
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
/* syntax.css for pygments */ | |
/* from http://github.com/mojombo/tpw/blob/master/css/syntax.css */ | |
.highlight { background: #ffffff; } | |
.highlight .c { color: #999988; font-style: italic } /* Comment */ | |
.highlight .err { color: #a61717; background-color: #e3d2d2 } /* Error */ | |
.highlight .k { font-weight: bold } /* Keyword */ | |
.highlight .o { font-weight: bold } /* Operator */ | |
.highlight .cm { color: #999988; font-style: italic } /* Comment.Multiline */ | |
.highlight .cp { color: #999999; font-weight: bold } /* Comment.Preproc */ |
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
# from python docs (http://docs.python.org/library/decimal.html) | |
def moneyfmt(value, places=2, curr='', sep=',', dp='.', | |
pos='', neg='-', trailneg=''): | |
"""Convert Decimal to a money formatted string. | |
places: required number of places after the decimal point | |
curr: optional currency symbol before the sign (may be blank) | |
sep: optional grouping separator (comma, period, space, or blank) | |
dp: decimal point indicator (comma or period) |
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
<div class="html5audio"> | |
<div id="no-ogg" style="display:none;"> | |
<div id="flash-player"> | |
<a href="foo.mp3">Download Audio</a> | |
</div> | |
</div> | |
<audio controls> | |
<source src="foo.mp3" type="audio/mpeg" /> | |
<div id="flash-player"> | |
<a href="foo.mp3">Download Audio</a> |
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
/* | |
dribbble custom selection css | |
from http://dribbble.com/stylesheets/master.css | |
*/ | |
/* custom selection colors */ | |
::-moz-selection { | |
color: #fff; | |
color: rgba(255,255,255,.85); |
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
# from simonw's code to djangopeople.net | |
import re | |
notalpha_re = re.compile('[^a-zA-Z0-9]') | |
def derive_username(nickname): | |
nickname = notalpha_re.sub('', nickname) | |
if not nickname: | |
return '' | |
base_nickname = nickname | |
to_add = 1 |
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
#! /bin/sh | |
### BEGIN INIT INFO | |
# Provides: nginx | |
# Required-Start: $all | |
# Required-Stop: $all | |
# Default-Start: 2 3 4 5 | |
# Default-Stop: 0 1 6 | |
# Short-Description: starts the nginx web server | |
# Description: starts nginx using start-stop-daemon |
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
javascript:var%20h=location.href,a="www.scpr.org",b="localhost:8000";function%20s(){if(h.search(a)!=-1)z();else%20if(h.search(b)!=-1)y();else%20return%20false}function%20x(c){location.href=c}function%20y(){x(h.replace(b,a))}function%20z(){x(h.replace(a,b))}s(); |