Skip to content

Instantly share code, notes, and snippets.

@jacobian
jacobian / replication_fabfile.py
Created January 27, 2011 18:05
A fab task to start pg9 hot standby.
def start_replication():
"""
Begin Postgresql standby
"""
# Stop pg on the slave machine.
with settings(host_string=env.db_slave):
run('service postgresql-9.0 stop')
# Create the backup on the master machine
with settings(host_string=env.db_master):
@andymccurdy
andymccurdy / crier.py
Created December 11, 2010 01:09
Crier: simple introspection for long-running Python processes
import pprint
import os
import sys
import threading
import time
import traceback
_crier = None
def init_crier(temp_dir='/tmp'):
"Initialzies Crier, ensuring it's only created once in the process"
@adamkirkwood
adamkirkwood / gist:590165
Created September 21, 2010 18:08
Add this to you bash profile for some delicious git awesomeness
function parse_git_branch {
ref=$(git symbolic-ref HEAD 2> /dev/null) || return
echo "("${ref#refs/heads/}")"
}
RED="\[\033[0;31m\]"
YELLOW="\[\033[0;33m\]"
GREEN="\[\033[0;32m\]"
PS1="$RED\$ \w$YELLOW \$(parse_git_branch)$GREEN\$ "
@patrys
patrys / abstract.py
Created September 17, 2010 11:59
Parametrized apps for Django
class AbstractMixin(object):
_classcache = {}
@classmethod
def contribute(cls):
return {}
@classmethod
def construct(cls, *args, **kwargs):
attrs = cls.contribute(*args, **kwargs)