Skip to content

Instantly share code, notes, and snippets.

@elijahr
elijahr / gist:3165026
Created July 23, 2012 17:59
activate virtualenvs automatically
#### automatically activate virtualenvs named 'pyenv'
#### just put this at the end of your ~/.bashrc file
workon_virtualenv() {
if [ -e "${PWD}/pyenv" ]; then
deactivate >/dev/null 2>&1
source "${PWD}/pyenv/bin/activate"
fi
}
virtualenv_cd() {
@elijahr
elijahr / gist:3132934
Created July 17, 2012 23:37
work on virtualenv
#### automatically activate virtualenvs - from http://toranbillups.com/blog/archive/2012/4/22/Automatically-activate-your-virtualenv
workon_virtualenv() {
if [ -e "${PWD}/pyenv" ]; then
deactivate >/dev/null 2>&1
source "${PWD}/pyenv/bin/activate"
fi
}
virtualenv_cd() {
cd "$@" && workon_virtualenv
@elijahr
elijahr / domready.js
Created March 22, 2012 17:10
basic DOM ready handling, sans jQuery
function init(){
// do some stuff to the DOM
}
if (document.addEventListener) {
document.addEventListener('DOMContentLoaded', init, false);
} else {
window.onload = init;
}
@elijahr
elijahr / ssh-copy-id.sh
Created March 19, 2012 16:10
ssh-copy-id.sh
#!/bin/sh
# Shell script to install your public key on a remote machine
# Takes the remote machine name as an argument.
# Obviously, the remote machine must accept password authentication,
# or one of the other keys in your ssh-agent, for this to work.
ID_FILE="${HOME}/.ssh/id_rsa.pub"
if [ "-i" = "$1" ]; then
@elijahr
elijahr / .bash_profile
Created February 2, 2012 17:16
elijahr .bash_profile
#!/bin/bash
#######
# My .bash_profile
#######
export LANG=en_US.UTF-8
parse_git_branch() {
git branch --no-color 2> /dev/null | sed -e '/^[^*]/d' -e 's/* \(.*\)/\ \1/'
@elijahr
elijahr / rfr.py
Created August 24, 2011 18:13
A script to aid in refactoring a git-managed codebase
#!/opt/pypy/bin/pypy
# easy project refactoring.
import os
import shutil
from subprocess import Popen
def build_parser():
"""
@elijahr
elijahr / gist:1051754
Created June 28, 2011 18:08
parse tweets
// based on http://www.simonwhatley.co.uk/parsing-twitter-usernames-hashtags-and-urls-with-javascript
String.prototype.parseTweet = function(){
return this
.replace(/[A-Za-z]+:\/\/[A-Za-z0-9-_]+\.[A-Za-z0-9-_:%&~\?\/.=]+/g, function(url) {
return url.link(url);
})
.replace(/[@]+[A-Za-z0-9-_]+/g, function(u) {
var username = u.replace("@","")
return u.link("http://twitter.com/"+username);