Skip to content

Instantly share code, notes, and snippets.

View banterability's full-sized avatar

Jeff Long banterability

View GitHub Profile
<select name='day'>
<option value="1">1</option>
<option value="2">2</option>
<option value="3">3</option>
<option value="4">4</option>
<option value="5">5</option>
<option value="6">6</option>
<option value="7">7</option>
<option value="8">8</option>
<option value="9">9</option>
from fabric.api import *
[...]
def gzip_assets():
"""
GZips every file in the assets directory and places the new file
in the gzip directory with the same filename.
"""
local('python gzip_assets.py')
@banterability
banterability / bookmarklet.js
Created April 27, 2010 22:25
Bookmarklet to switch between production & development environments
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();
@banterability
banterability / nginx.sh
Created May 14, 2010 00:19
Init script for Nginx
#! /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
@banterability
banterability / derive_username.py
Created May 15, 2010 00:03
Derive next available username
# 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
@banterability
banterability / snippet.css
Created May 18, 2010 23:33
custom text selection colors
/*
dribbble custom selection css
from http://dribbble.com/stylesheets/master.css
*/
/* custom selection colors */
::-moz-selection {
color: #fff;
color: rgba(255,255,255,.85);
@banterability
banterability / snippet.html
Created May 21, 2010 21:04
html5 with a fallback for mp3-hating firefox with a fallback to flash with a fallback to a link
<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>
@banterability
banterability / moneyfnt.py
Created May 24, 2010 18:52
convert decimal to formatted currency string
# 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)
/* 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 */
@banterability
banterability / color_hoods.py
Created August 11, 2010 17:55
unique colors for each neighborhood of South Los Angeles
# 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>