Skip to content

Instantly share code, notes, and snippets.

#!/bin/sh
#
# This is an example of using HGEDITOR to create of diff to review the
# changes while commiting.
# If you want to pass your favourite editor some other parameters
# only for Mercurial, modify this:
case "${EDITOR}" in
"")
EDITOR="vi"
In [1]: %psource Tiger
class Tiger(models.Model):
call = models.CharField(max_length=255, blank=True)
In [2]: tony = Tiger()
In [3]: tony.call = u'Grrrreeeeeeeeaaaaaatttt'
In [4]: tony.save()
def migrate():
"""apply all pending db migrations"""
django_admin('migrate')
def django_admin(arguments):
require('target', provided_by=['stage', 'live'])
settings = '%(project)s.configs.%(target)s.settings' % env
cmd = '%(venv)s/bin/dj
#!/bin/bash
# subshell for `set -e` and `trap`
(
set -e # fail immediately if there's a problem
# use `git-up` if installed
# if type git-up > /dev/null 2>&1
# then
# exec git-up
# fi
@require_POST
def receive(request):
try:
fname = request.GET['qqfile']
except KeyError:
return HttpResponseBadRequest(json.dumps({
'success': 'Miss
@rob-b
rob-b / gist:1018875
Created June 10, 2011 14:01
git glf somefile.py
git log --format=%H --follow -- "$@" | xargs --no-run-if-empty git show --stat
@rob-b
rob-b / gist:1018888
Created June 10, 2011 14:07
git glp # with no args will show unpushed changs
#!/bin/bash
function git_current_tracking
{
local BRANCH="$(git describe --contains --all HEAD)"
local REMOTE="$(git config branch.$BRANCH.remote)"
local MERGE="$(git config branch.$BRANCH.merge)"
if [ -n "$REMOTE" -a -n "$MERGE" ]
then
echo "$REMOTE/$(echo "$MERGE" | sed 's#^refs/heads/##')"
else
@rob-b
rob-b / gist:1089832
Created July 18, 2011 15:19
modified git-hack
#!/bin/bash
set -o errexit
CURRENT_BRANCH=`git branch | grep '\*' | awk '{print $2}'`
[[ -n `git config gitflow.branch.develop` ]] && DEVELOPMENT_BRANCH=`git config gitflow.branch.develop`
if [ -z ${DEVELOPMENT_BRANCH} ]
then
[[ -n `git branch | grep master` ]] && DEVELOPMENT_BRANCH=master
fi
@rob-b
rob-b / gist:1211324
Created September 12, 2011 14:02
shortening
sudo('chown www-data:www-data '
'%(path)s/releases/%(release_name)s/ebay/assets/ -R' % env)
cmd = 'chown www-data: -R'
path = '%(path)s/releases/%(release_name)s/ebay/assets' % env)
sudo('%s %s' % (cmd, path)
@rob-b
rob-b / gist:1232445
Created September 21, 2011 15:53
obtain route53 records
import boto
import sys
def dns_entries(zone_name):