Skip to content

Instantly share code, notes, and snippets.

Phil Christensen philchristensen

Block or report user

Report or block philchristensen

Hide content and notifications from this user.

Learn more about blocking users

Contact Support about this user’s behavior.

Learn more about reporting abuse

Report abuse
View GitHub Profile
@yeti-detective
yeti-detective / gifit.sh
Last active Oct 30, 2019
This function will let you make MacOs screen captures into .gif files by running `gifit <input_filename> <output_filename>`
View gifit.sh
function gifit {
gifthis=1
input_file=""
output_file=""
if [[ $# -eq 0 ]]; then
gifthis=0
echo "Usage: gifit <input_mov_file> <output_gif_filename>"
echo " converts mov files into 600x400 gif files"
fi
if [ $# -eq 1 ]
@philchristensen
philchristensen / svn-prompt.bash
Created Feb 16, 2011
add current svn branch to shell prompt
View svn-prompt.bash
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
}
@philchristensen
philchristensen / git-prompt.bash
Created Dec 19, 2010
add current git branch to shell prompt
View git-prompt.bash
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 / init_deferred_example.py
Created Nov 8, 2010
a method decorator to enable asynchronous object construction in Twisted
View init_deferred_example.py
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 / svn-color.py
Created Aug 10, 2010
Color-Coded `svn status`
View svn-color.py

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

You can’t perform that action at this time.