Skip to content

Instantly share code, notes, and snippets.

@jonbalbarin
jonbalbarin / bestbashpromptever.sh
Created April 12, 2011 14:30
best bash prompt ever
function parse_git_branch {
ref=$(git symbolic-ref HEAD 2> /dev/null) || return
echo "("${ref#refs/heads/}")"
}
# PS1 prompt color vars
export PROMPT_DIRTRIM='2' #only works with bash 4.x
RED="\[\033[1;31m\]"
YELLOW="\[\033[0;33m\]"
@jonbalbarin
jonbalbarin / .screenrc
Created April 12, 2011 14:45
my screen rc
startup_message off
defscrollback 10000
altscreen on
bindkey -k F2 kill #f12
bindkey -k F1 detach #f11
hardstatus alwayslastline
hardstatus string "%{.K.}%D %M %d %C:%s%a | %-Lw%{.K.}%{= rW}%50>%n* %t%{-}%+Lw%<"
shell -bash
@jonbalbarin
jonbalbarin / .gitconfig
Created April 13, 2011 13:51
my gitconfig
[diff]
tool = opendiff
[color]
ui = auto
[alias]
graph = log --graph --decorate --pretty=short
findbranch = "! git branch -a | ack $1"
[user]
name = My Name
@jonbalbarin
jonbalbarin / .gitignore
Created April 14, 2011 16:22
my global git ignore...basically the vi, vim, and eclipse stuff from https://github.com/github/gitignore
.DS_Store
*.swp
*.swo
.*.sw[a-z]
*.un~
Session.vim
*.pydevproject
.project
.metadata
bin/**
@jonbalbarin
jonbalbarin / prettyjson.sh
Created April 20, 2011 14:35
pretty print json
#in .bash_profile...
function prettyjson
{
if [ $1 ]; then
curl -s $1 | python -mjson.tool
else
echo "specify a url";
fi
}
@jonbalbarin
jonbalbarin / gist:972698
Created May 14, 2011 22:19
switching between ubuntu and chromeos on the cr48
#set ubuntu as default
function bootUBUNTU {
sudo cgpt add -i 6 -P 5 -S 1 /dev/sda
}
#set chromeos as default
function bootCHROMEOS {
sudo cgpt add -i 6 -P 0 -S 1 /dev/sda
}
set number
syntax on
filetype on
filetype plugin on
set expandtab
set tabstop=4
set softtabstop=4
set shiftwidth=4
set wildmenu
@jonbalbarin
jonbalbarin / .bash_profile
Created July 7, 2011 16:22
a tip calculator in python
alias tippy='python ~/path/to/this/thing/tip.py -s'
@jonbalbarin
jonbalbarin / throttle.sh
Created July 14, 2011 00:06
throttling bandwidth to emulate mobile devices (when running simulators)
# stick this in your .bash_profile
alias throttle150='sudo ipfw pipe 1 config bw 150Kbps && sudo ipfw add 1 pipe 1 src-port 80'
alias throttle300='sudo ipfw pipe 1 config bw 300Kbps && sudo ipfw add 1 pipe 1 src-port 80'
alias throttleOff='sudo ipfw delete 1'
@jonbalbarin
jonbalbarin / gist:1223571
Created September 17, 2011 02:50
making a category on a class to contain its protocol methods
////////////////////////////////////////////////////////////////////////////////
// MyProtocol.h
////////////////////////////////////////////////////////////////////////////////
@protocol MyProtocol <NSObject>
-(void) thisThingDidDoSomething:(OriginalThing*)sender;
-(void) thisThing:(OriginalThing*)sender didDoSomethingWithThing:(Thing*)thing;
@end
////////////////////////////////////////////////////////////////////////////////