Skip to content

Instantly share code, notes, and snippets.

powellc /
Created February 1, 2010 00:22 — forked from heckj/
Forked for my own vps info.
#!/usr/bin/env python
from __future__ import with_statement # needed for python 2.5
from fabric.api import *
from fabric.contrib.console import confirm
# ================================================================
# using this fabfile expects that you have the python utility
# fabric installed locally, ssh access to, and your
# ssh public key associated with the account ''
# The purpose of this file is to, as quickly as possible, set up a home directory
# with all the creature comforts I expect.
# For this to work:
# 1. Add ssh keys to github and personal git repo
# 2. sudo aptitude install zsh git-core
mkdir $HOME/.virtualenvs
# terminfo and termcap for nice 256 color terminal
# allow bold colors - necessary for some reason
attrcolor b ".I"
# tell screen how to set colors. AB = background, AF=foreground
termcapinfo xterm 'Co#256:AB=\E[48;5;%dm:AF=\E[38;5;%dm'
# erase background with current bg color
defbce "on"
powellc / .zshrc
Created September 15, 2010 16:33
export TERM=xterm-256color
# Default the box color to red, but change to differentiate boxes or VPSs
export BOXCOLOR="%{$fg[red]%}"
# Path to your oh-my-zsh configuration.
export ZSH=$HOME/.oh-my-zsh
# Set to the name theme to load.
# Look in ~/.oh-my-zsh/themes/
### This script simply parses ifconfig and loads a box's main IP into a shell variable
IP="" # store IP
case $OS in
Linux) IP=`ifconfig | grep 'inet addr:'| grep -v '' | cut -d: -f2 | awk '{ print $1}' | grep 24 `;;
diff --git a/src/adzone/ b/src/adzone/
index 347e85e..271e36d 100644
--- a/src/adzone/
+++ b/src/adzone/
@@ -8,8 +8,15 @@ class AdManager(models.Manager):
Returns a random advert that belongs to the specified category and zone
- try:
- ad = self.get_query_set().filter(category__slug=ad_category, zone__slug=ad_zone).order_by('?')[0]
powellc /
Created March 7, 2011 20:21
A development script to run django with gevent instead of flup
import sys
from gevent import monkey; monkey.patch_all()
from gevent.wsgi import WSGIServer
import os
import traceback
from django.core.handlers.wsgi import WSGIHandler
from import call_command
powellc /
Last active October 1, 2023 19:14
Bash script to backup all postgresql databases on a server, run with cron once a day or 5 times a day, whatever. Just updated it so it ignores your postgres db, and also bzips the backups and adds a symlink to a latest directory. Sweet.
# Location to place backups.
#String to append to the name of the backup files
backup_date=`date +%d-%m-%Y`
#Numbers of days you want to keep copie of your databases
databases=`psql -l -t | cut -d'|' -f1 | sed -e 's/ //g' -e '/^$/d'`
for i in $databases; do if [ "$i" != "postgres" ] && [ "$i" != "template0" ] && [ "$i" != "template1" ] && [ "$i" != "template_postgis" ]; then
powellc /
Last active December 11, 2015 17:08
MySQL backup script for nightly dumps that clean up after a certain number of days and keep a symlink to the latest one so you can easily setup a webserver to provide dumps for development purposes
HN=`hostname | awk -F. '{print $1}'`
# Remove backups older than 10 days
powellc /
Last active December 11, 2015 17:48
Change owner of all tables in a PG database, great for those times when your dev user doesn't match production or whatever.
echo "Your database name [Enter]: "
read YOUR_DB
echo "New owner name [Enter]: "
# First alter tables
for tbl in `psql -qAt -c "select tablename from pg_tables where schemaname = 'public';" $YOUR_DB` ; do
psql -c "alter table $tbl owner to $NEW_OWNER" $YOUR_DB ;