Skip to content

Instantly share code, notes, and snippets.


Simon Litchfield litchfield

View GitHub Profile
litchfield / gist:bd66ad8cf4586674abe5
Created May 18, 2015
Sample sublime project conf
View gist:bd66ad8cf4586674abe5
"path": "site",
"folder_exclude_patterns": [
View gist:91e0f24e3cbfa2852bbc
export EDITOR='nano'
export PATH="/Applications/$PATH"
export HISTSIZE=10000
export HISTFILESIZE=10000
#export PROMPT_COMMAND='echo -ne "\033]0;`hostname -s`\007"'
export LSCOLORS=gxfxcxdxbxegedabagacad
export PIP_DOWNLOAD_CACHE=$HOME/Library/Caches/pip-downloads
alias ls='ls -aGp'
alias ll='ls -la'
litchfield / grouper.html
Created Apr 16, 2015
Javascript grouping example
View grouper.html
<script src=""></script>
function group(data, groupby) {
var grouped = {}
litchfield /
Created May 5, 2014
Django Forms add_error() backport for <1.7
from django import forms
from django.forms.forms import NON_FIELD_ERRORS
class AddErrorMixin(object):
"Backport add_error() for django <1.7"
def add_error(self, field, msg):
field = field or NON_FIELD_ERRORS
if field in self._errors:
litchfield /
Created Apr 24, 2012
Django DurationField
from django import forms
from django.db import models
def split_duration(value):
if value:
return ( '%02d' % (value // 3600),
'%02d' % ((value % 3600) // 60),
'%02d' % (value % 60),
return ('00', '00', '00')
litchfield /
Created Oct 12, 2011
Double decode utf8 and cp1252
#!/usr/bin/env python
Ever had a mysqldump of utf8 data stored in latin1 tables, dumped in utf8 and
munged with windows cp1252?
If so this is your friend. Just pipe it through this little baby and spare
yourself hours of unicode hell- it'll take your dirt and spit out clean utf8.
You can also import it and use it in your python code.