Skip to content

Instantly share code, notes, and snippets.

tedkaemming@reventon % sudo ipfw pipe 1 config bw 128Kbit/s delay 200ms
tedkaemming@reventon % sudo ipfw add 1 pipe 1 src-port 8000
00001 pipe 1 ip from any 8000 to any
@dcramer
dcramer / track_data.py
Created December 6, 2010 19:15
Tracking changes on properties in Django
from django.db.models.signals import post_init
def track_data(*fields):
"""
Tracks property changes on a model instance.
The changed list of properties is refreshed on model initialization
and save.
>>> @track_data('name')
#!/usr/bin/env python
"""
Nagios plugin to check PostgreSQL 9 streaming replication lag.
Requires psycopg2 and nagiosplugin (both installable with pip/easy_install).
MIT licensed:
Copyright (c) 2010 Jacob Kaplan-Moss. All rights reserved.
@tkaemming
tkaemming / post-receive
Created January 7, 2011 23:07
a git post-receive hook to autoupdate to the new HEAD. good for push deploys for a static or PHP site.
#!/bin/sh
cd ..
env -i git reset --hard
@codysoyland
codysoyland / post-checkout
Created January 18, 2011 20:19
place in .git/hooks/post-checkout to delete empty directories and pyc files
#! /bin/sh
echo "Purging pyc files and empty directories..."
# Start from the repository root.
cd ./$(git rev-parse --show-cdup)
# Delete .pyc files and empty directories.
find . -name "*.pyc" -delete 2>&1 > /dev/null &
find . -type d -empty -delete 2>&1 > /dev/null &
from threading import local
_blah = local()
class StopThatShit(Exception):
pass
def patch():
from django.db.backends import util
from django import template
@mtigas
mtigas / gist:1335214
Created November 2, 2011 22:57
Because you've always wanted a terminal screen tracking a live stream of "bieber" tweets.
@tkaemming
tkaemming / gist:1337204
Created November 3, 2011 17:57
use iptables to proxy tcp traffic on port 80 to 8080. helpful to simulate a web machine being behind an ELB without changing configuration or having to spool up another vm/start another nginx instance
iptables -t nat -A PREROUTING -p tcp --dport 80 -j REDIRECT --to-port 8080
@tkaemming
tkaemming / pre-commit.sh
Created December 7, 2011 06:36
bash pre-commit script to run pyflakes and pep8 checks
#!/bin/bash
ERROR_LIST=$(find . -name \*.py -not -path \*migrations/\* -not -path \*settings/\* -not -path \*vendor/\* -not -path \*node_modules/\* | xargs pyflakes)
RETVAL=$?
if [[ $RETVAL -ne 0 ]]; then
echo "Encountered errors during pyflakes check, cowardly refusing to commit."
echo "$ERROR_LIST"
exit $RETVAL
fi
(function ($) {
$.fn.placeholder = function (_options) {
var defaults = {
blank: '',
className: 'default'
},
options = $.extend({}, defaults, _options || {});
return this.each(function () {