Skip to content

Instantly share code, notes, and snippets.

Tristram Oaten 0atman

View GitHub Profile
@0atman
0atman / sixty.py
Created Oct 25, 2010
An implimentation of (10+2)*5
View sixty.py
#!/usr/bin/env python
#
# sixty.py, a (10+2)x5 implimentation.
# http://www.43folders.com/2005/10/11/procrastination-hack-1025
#
# Copyright 2009 Tristram Oaten
# This program is distributed under the
# terms of the GNU General Public License
# see <http://www.gnu.org/licenses/>
@0atman
0atman / post-receive
Created Oct 25, 2010
Simple git hook to auto deploy a django app to an 'unstable' testing server.
View post-receive
#!/bin/sh
#
# An example hook script that is called after a successful
# commit is made.
#
# To enable this hook, make this file executable.
echo "Starting auto-deploy..."
cd /usr/share/django
@0atman
0atman / makefile
Created Oct 25, 2010
Simple makefile that cleans a Python project
View makefile
clean:
find ./ -name '*~' -exec rm -f {} \;
find ./ -name '#*' -exec rm -f {} \;
find ./ -name 'Thumbs.db' -exec rm -f {} \;
find ./ -name '*.pyc' -exec rm -f {} \;
@0atman
0atman / views.py
Created Nov 1, 2011
"tracks to json playlist" rewrite
View views.py
"""
Python features bingo.
I hope you enjoy reading this as much as I enjoyed writing it!
"""
import json
def tracks_to_json_playlist(tracks, playlist=None):
'''
Takes a queryset of tracks and returns a json playlist
'''
@0atman
0atman / gist:3122826
Created Jul 16, 2012
Run Django tests on change
View gist:3122826
while inotifywait -r -q -q -e close_write *;
do ./manage.py test -v0 --failfast;
done
View resume.py
from datetime import date, timedelta
from textwrap import wrap
years = timedelta(weeks=52)
tris = {
"fullname": "Tristram Oaten",
"email": "tris@blackgateresearch.com",
"bio": """I specialise in functional and object-oriented Javascript,Python and Django development
and high-availability Linux systems administration in a heterogeneous environment.
View xvfb
#!/bin/bash
if [ -z "$1" ]; then
echo "`basename $0` {start|stop}"
exit
fi
case "$1" in
start)
/usr/bin/Xvfb :99 -ac -screen 0 1024x768x8 &
@0atman
0atman / migrate.sh
Created Dec 14, 2012
tweak model, run this
View migrate.sh
./manage.py schemamigration cms --auto; ./manage.py migrate && ./manage.py graph_models cms -g -o cms.svg && ./manage.py runserver_plus
@0atman
0atman / find_subclasses.py
Created Dec 19, 2012
Finds all subclasses of `clazz` in `module`, returns a list.
View find_subclasses.py
def find_subclasses(module, clazz):
"""
Finds all subclasses of `clazz` in `module`, returns a list.
Source: http://stackoverflow.com/a/408465
"""
return [
cls for name, cls in inspect.getmembers(module)
if inspect.isclass(cls) and issubclass(cls, clazz)
]
@0atman
0atman / BGRL
Last active Dec 12, 2015
DRAFT Blackgate Research Liscence (BGRL), Based on the ISC License (http://en.wikipedia.org/wiki/ISC_license)
View BGRL
Copyright (c) 2013 Blackgate Research.
This work is made available under the terms of the Creative Commons Attribution-ShareAlike 3.0 license,
http://creativecommons.org/licenses/by-sa/3.0/."
You can’t perform that action at this time.