Skip to content

Instantly share code, notes, and snippets.

View natbat's full-sized avatar

Natalie Downe natbat

View GitHub Profile
@epicserve
epicserve / Django Enviroment Setup on Mac OSX 10.6.2 (Snow Leopard).markdown
Created February 22, 2010 15:29
Django Enviroment Setup on Mac OSX 10.6.2 (Snow Leopard)

Django Enviroment Setup on Mac OSX 10.6.2 (Snow Leopard)

Install Homebrew

sudo mkdir /usr/local
sudo chown -R `whoami` /usr/local
curl -L http://github.com/mxcl/homebrew/tarball/master | tar xz --strip 1 -C /usr/local
brew install git
cd /usr/local
git init
@natbat
natbat / TimeSince.php
Created November 10, 2011 10:39
Works out the time since, takes a an argument in unix time (seconds)
function time_since($original) {
// array of time period chunks
$chunks = array(
array(60 * 60 * 24 * 365 , 'year'),
array(60 * 60 * 24 * 30 , 'month'),
array(60 * 60 * 24 * 7, 'week'),
array(60 * 60 * 24 , 'day'),
array(60 * 60 , 'hour'),
array(60 , 'minute'),
);
@simonw
simonw / reindenting_middleware.py
Created June 4, 2013 10:48
Because sometimes the fact that template tag indentation screws up the indentation in view source really bugs me. No, we don't run this in production.
import re
leading_tab_re = re.compile('^(\t+)')
class ReindentingMiddleware(object):
def process_response(self, request, response):
return response
if not response['Content-Type'].startswith('text/html'):
return response
content = response.content
lines = content.split('\n')