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 / bump_package_version.py
Created March 20, 2015 15:02
A script for increasing the version in an npm project's package.json.
#! /usr/bin/env python
"""
A script for increasing the version in an npm project's
package.json.
"""
import argparse
import json
import sys
@0atman
0atman / django_template_decorator.py
Last active August 29, 2015 14:19
A decorator to render the view with a template
from django.shortcuts import render_to_response
def with_template(template):
"""
A decorator to render the view with a template. The view just
returns a contect dictionary. eg:
@with_template('index.html')
def index_view(request):
@0atman
0atman / deploy-docker.sh
Last active August 29, 2015 14:26
deploys a docker-compose project using docker-machine to digital ocean
find . -exec rm -rf {} \; || true
git clone git@github.com:${GITHUB_USERNAME}/${GITHUB_PROJECT}.git .
git checkout ${GIT_BRANCH}
docker-machine rm ${GITHUB_PROJECT}-${GIT_BRANCH} || true # while testing
docker-machine create ${GITHUB_PROJECT}-${GIT_BRANCH} --driver digitalocean --digitalocean-access-token TOKEN
eval "$(docker-machine env ${GITHUB_PROJECT}-${GIT_BRANCH})"
docker-compose -f docker-compose-machine.yml up -d
@0atman
0atman / Caddyfile
Last active August 29, 2015 14:28
Caddy & pelican
0.0.0.0:2020
gzip
log access.log
git git@github.com:0atman/0atman.com.git git {
interval 5
then make html
}
@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 / 11-trackpoint-wheel-emulation.conf
Created September 24, 2015 13:41
/usr/share/X11/xorg.conf.d/11-trackpoint-wheel-emulation.conf
Section "InputClass"
Identifier "Trackpoint Wheel Emulation"
MatchProduct "PS/2 Generic Mouse"
MatchDevicePath "/dev/input/event*"
Option "EmulateWheel" "true"
Option "EmulateWheelButton" "2"
Option "EmulateWheelTimeout" "200"
Option "YAxisMapping" "4 5"
Option "XAxisMapping" "6 7"
EndSection
@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