Skip to content

Instantly share code, notes, and snippets.

Avatar

Natalie Downe natbat

View GitHub Profile
@simonw
simonw / reindenting_middleware.py
Created Jun 4, 2013
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.
View reindenting_middleware.py
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')
@natbat
natbat / TimeSince.php
Created Nov 10, 2011
Works out the time since, takes a an argument in unix time (seconds)
View TimeSince.php
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'),
);
@epicserve
epicserve / Django Enviroment Setup on Mac OSX 10.6.2 (Snow Leopard).markdown
Created Feb 22, 2010
Django Enviroment Setup on Mac OSX 10.6.2 (Snow Leopard)
View Django Enviroment Setup on Mac OSX 10.6.2 (Snow Leopard).markdown

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