Skip to content

Instantly share code, notes, and snippets.

View philchristensen's full-sized avatar

Phil Christensen philchristensen

View GitHub Profile
@philchristensen
philchristensen / svn-color.py
Created August 10, 2010 20:20
Color-Coded `svn status`

First there was: http://snipplr.com/view/15246/color-coded-svn-status

Then there was: http://snipplr.com/view/16540/color-coded-svn-status-v2

A few days ago, I found a handy script online that colorized the output of SVN status. It worked pretty well, but needed a little polish and a couple of tweaks to make it use more common Python idioms. As I continued to use it and fix bugs and inefficiencies, I ended up replacing nearly every line in the original, but it was still a great starting point.

Additional changes include ANSI word-wrapping, a configurable tab expansion feature (for better code alignment), the 'colorizedSubcommands' sequence so that only applicable commands get colorized, use of proper subprocess module calls so that piping through less will work (for example, try svn-color diff | less -r to see colorized diff output).

To use, stick it somewhere, make executable (`chmod 7

@philchristensen
philchristensen / init_deferred_example.py
Created November 8, 2010 16:46
a method decorator to enable asynchronous object construction in Twisted
from twisted.internet import defer, reactor
from twisted.enterprise import adbapi
def deferredInit(deferredName):
"""
Mark a method as waiting on deferred initialization.
"""
def _deferredInit(func):
def __deferredInit(self, *args, **kwargs):
initDeferred = None
@philchristensen
philchristensen / git-prompt.bash
Created December 19, 2010 20:20
add current git branch to shell prompt
function parse_git_branch {
ref=$(git symbolic-ref HEAD 2> /dev/null) || return
echo "#"${ref#refs/heads/}
}
export PS1="\u@\h:\w\[\e[31;40m\]\$(parse_git_branch)\[\e[0m\] \$ "
@philchristensen
philchristensen / svn-prompt.bash
Created February 16, 2011 15:29
add current svn branch to shell prompt
function parse_svn_branch {
if [ -d '.svn' ]; then
ref=$(svn info | grep URL | awk -F/ '{print $NF}' 2> /dev/null) || return
cur=$(pwd | awk -F/ '{print $NF}' 2> /dev/null) || return
if [ $ref != $cur ]; then
echo "#$ref"
fi
fi
}
@yeti-detective
yeti-detective / gifit.sh
Last active July 22, 2021 15:59
This function will let you make MacOs screen captures into .gif files by running `gifit <input_filename> <gif pixel size ie: 1200x800> <output_filename>`
function gifit {
gifthis=1
input_file=""
output_file=output.gif
gifsize=900x600
if [[ $# -eq 0 ]]; then
gifthis=0
echo "Usage: gifit <input_mov_file> <gif pixel size ie: 1200x800> <output_gif_filename>"
echo " converts mov files into <gif_size> gif files"
fi