Skip to content

Instantly share code, notes, and snippets.

View sente's full-sized avatar

Stuart Powers sente

View GitHub Profile
#! /bin/bash
DIR=`dirname $0`
progname=`basename $0`
PRG=`cd $DIR; pwd `/$progname
if [ -r /etc/default/backup_etc ]
then
. /etc/default/backup_etc
fi

Note to Self

Be Confident

Tests build confidence. Write 'em. They'll save your ass, and they'll let you take a chainsaw to your code without being afraid of unintended consequences.

Be Lazy

@zed
zed / .gitignore
Created January 23, 2009 16:49
Generate performance plot
*.db
*.xy
*.pdf
*.png
*.pyc
*.pyo
# Rename an email address in all old commits.
# WARNING: Will change all your commit SHA1s.
# Based off of the script from here:
# http://coffee.geek.nz/how-change-author-git.html
git filter-branch -f --commit-filter '
if [ "$GIT_COMMITTER_EMAIL" = "joern.zaefferer@googlemail.com" ];
then
GIT_AUTHOR_EMAIL="joern.zaefferer@gmail.com";
GIT_COMMITTER_EMAIL="joern.zaefferer@gmail.com";
git commit-tree "$@";
@RichardBronosky
RichardBronosky / comment
Last active May 22, 2018 02:29
ipython ipshell pattern
"""
if you pass arguments to django-admin.py (like --settings=...) they also get
passed to IPShell, unless you explicitly specify argv to contain an empty list.
The oneliner below works. It has a short url of http://j.mp/ipshell
pull it into vim with...
:r!curl -sL j.mp/ipshell
"""
@astanin
astanin / compare.py
Created October 14, 2010 15:20
Compare two aligned images of the same size
#!/usr/bin/env python
"""Compare two aligned images of the same size.
Usage: python compare.py first-image second-image
"""
import sys
from scipy.misc import imread
from scipy.linalg import norm
@RichardBronosky
RichardBronosky / jquery oneliner
Created November 20, 2010 02:46
This is the shortest line of code for getting jquery into a js console (Chrome, Safari, Firefox, etc.)
($=document.createElement('script')).src='http://j.mp/jqueryjs';(document.getElementsByTagName('head')[0]).appendChild($)
@agile
agile / InsertTabComplete.vim
Created January 4, 2011 16:07
drop this in ~/.vim/plugins and you can complete in insert mode using the tab key
function InsertTabWrapper()
let col = col('.') - 1
if !col || getline('.')[col - 1] !~ '\k'
return "\<tab>"
else
return "\<c-p>"
endif
endfunction
inoremap <tab> <c-r>=InsertTabWrapper()<cr>
@drewconway
drewconway / twitter_network.py
Created January 17, 2011 18:31
A function, which given a list of Twitter users, creates NetworkX object of relationships.
def twitter_network(users, api, user_type="search", alt_type="friend"):
"""
Given a list of Twitter users, create NetworkX object of relationships.
args: users List of Twitter users as strings
user_types Type string for entries in 'users'
"""
twitter_network=nx.DiGraph()
# Iteratively create network with appropriate type data
users=list(users)
for u in users:
@toamitkumar
toamitkumar / gist:952211
Created May 2, 2011 19:35
Inspect and test routes on console (Rails 3)
$ rails console
Loading development environment (Rails 3.0.6)
ruby-1.8.7-p334 :001 > r = Rails.application.routes
Gives you a handle of all the routes (config/routes.rb)
#Inspect a named route:
ruby-1.8.7-p334 :005 > r.recognize_path(app.destroy_user_session_path)
=> {:action=>"destroy", :controller=>"sessions"}