Skip to content

Instantly share code, notes, and snippets.

View 0atman's full-sized avatar
🦀
Oxidising

Tristram Oaten 0atman

🦀
Oxidising
View GitHub Profile
@0atman
0atman / sixty.py
Created October 25, 2010 13:51
An implimentation of (10+2)*5
#!/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 October 25, 2010 15:37
Simple git hook to auto deploy a django app to an 'unstable' testing server.
#!/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 October 25, 2010 15:46
Simple makefile that cleans a Python project
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 November 1, 2011 15:32
"tracks to json playlist" rewrite
"""
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 July 16, 2012 13:49
Run Django tests on change
while inotifywait -r -q -q -e close_write *;
do ./manage.py test -v0 --failfast;
done
@0atman
0atman / resume.py
Created October 30, 2012 11:06
resume
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.
#!/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 December 14, 2012 11:51
tweak model, run this
./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 December 19, 2012 15:07
Finds all subclasses of `clazz` in `module`, returns a list.
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 December 12, 2015 09:49
DRAFT Blackgate Research Liscence (BGRL), Based on the ISC License (http://en.wikipedia.org/wiki/ISC_license)
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/."