Skip to content

Instantly share code, notes, and snippets.

Simon Litchfield litchfield

  • Sydney
Block or report user

Report or block litchfield

Hide content and notifications from this user.

Learn more about blocking users

Contact Support about this user’s behavior.

Learn more about reporting abuse

Report abuse
View GitHub Profile
@litchfield
litchfield / gist:bd66ad8cf4586674abe5
Created May 18, 2015
Sample sublime project conf
View gist:bd66ad8cf4586674abe5
{
"folders":
[
{
"path": "site",
"folder_exclude_patterns": [
"node_modules",
".sass-cache",
".tmp",
"dist"
View gist:91e0f24e3cbfa2852bbc
export EDITOR='nano'
export PATH="/Applications/Postgres.app/Contents/Versions/9.4/bin:/usr/local/bin:/usr/local/sbin:/usr/local/share/python:$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
litchfield / grouper.html
Created Apr 16, 2015
Javascript grouping example
View grouper.html
<html>
<script src="https://ajax.googleapis.com/ajax/libs/jquery/2.1.3/jquery.min.js"></script>
<script>
// FUNCTION
function group(data, groupby) {
var grouped = {}
@litchfield
litchfield / add_error.py
Created May 5, 2014
Django Forms add_error() backport for <1.7
View add_error.py
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:
self._errors[field].append(msg)
else:
@litchfield
litchfield / duration.py
Created Apr 24, 2012
Django DurationField
View duration.py
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
litchfield / doubledecode.py
Created Oct 12, 2011
Double decode utf8 and cp1252
View doubledecode.py
#!/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.
You can’t perform that action at this time.