Skip to content

Instantly share code, notes, and snippets.

View christoomey's full-sized avatar

Chris Toomey christoomey

View GitHub Profile
@christoomey
christoomey / log.js
Created April 29, 2011 00:29
Wrapper for console.log
// usage: log('inside coolFunc',this,arguments);
// http://paulirish.com/2009/log-a-lightweight-wrapper-for-consolelog/
window.log = function(){
log.history = log.history || []; // store logs to an array for reference
log.history.push(arguments);
if(this.console){
console.log( Array.prototype.slice.call(arguments) );
}
};
@christoomey
christoomey / ssh-key-copy-cmd.sh
Created April 17, 2011 17:58
Copy a public key to a remote host
# Copy the id_rsa.pub public key from local box to remote server
user@hostname "echo `cat ~/.ssh/id_rsa.pub` >> ~/.ssh/authorized_keys"
@christoomey
christoomey / stringInterpolation.js
Created April 16, 2011 20:56
Extend String prototype to include a subs method to interpolate a string
// From Douglas Crockford's http://javascript.crockford.com/remedial.html
//
// Usage:
// var person = { name: "James", age: 22 };
// var template = "Hello {name}, how does it feel to be {age}?";
// var personalGreeting = template.subs(person);
// => "Hello James, how does it feel to be 22?"
if (!String.prototype.subs) {
String.prototype.subs = function (o) {
@christoomey
christoomey / gist:805138
Created February 1, 2011 00:17
Some useful steps in setting up my webfaction image
# Install git http://docs.webfaction.com/software/git.html#git-install-home
# Install vim <current-version> using techniques above, ie wget, configure, make, make install
echo 'alias python=python2.6' > ~/.bash_profile # Set default python => 2.6
easy_install-2.5 -s ~/bin -d ~/lib/python2.5 python-dateutil # Get dateutil, also, general python module
http://docs.webfaction.com/software/git.html#git-install-home
import sys.path
@christoomey
christoomey / gist:801888
Created January 29, 2011 14:51
Python tab completion using readline
#!/usr/bin/python
import readline
readline.parse_and_bind("tab: complete")
class VolcabCompleter:
def __init__(self,volcab):
self.volcab = volcab
def complete(self,text,state):
@christoomey
christoomey / gist:760246
Created December 30, 2010 20:21
Have git output the contents of a deleted file from the commit before it was deleted
function git_show_deleted_file {
# Rev-list command gets commit that deleted the file, ^ gets prior commit
git show $(git rev-list -n 1 HEAD -- $1)^:$1
}
@christoomey
christoomey / gist:759231
Created December 29, 2010 23:44
Git aware command T functions. Use git repo top level as Command T context, else top level
function! Command_T_Local() "Go to the root of the git repo, then CommandT
"Ask git for the root of the git repo (as a relative '../../' path)
let git_top = system('git rev-parse --show-cdup')
let git_fail = 'fatal: Not a git repository'
if strpart(git_top, 0, strlen(git_fail)) == git_fail
" Above line says we are not in git repo. Ugly. Better version?
call Command_T_Work()
else
" Move working dir to root of repo, then CommandT
execute ":cd ./" . git_top