Skip to content

Instantly share code, notes, and snippets.

@willread
willread / gist:5921944
Last active December 19, 2015 07:58
Configure a debian 7.0 server to run multiple node.js apps
su root
cd ~
# Install dependencies
apt-get update
apt-get install git-core curl build-essential openssl libssl-dev sudo vi
# Build node
git clone https://github.com/joyent/node.git
cd node
./configure --openssl-libpath=/usr/lib/ssl
make
@willread
willread / gist:5593619
Created May 16, 2013 17:49
Make URLs in a string clickable.
"string http://domain.tld/path with a URL".replace(/(http[s]?:\/\/)([^\s]+)/, "<a href='$1$2'>$2</a>")
@willread
willread / gist:5585578
Created May 15, 2013 17:11
Remove filename.extension and all references to it from all branches of a Git repo.
git filter-branch --force --index-filter 'git rm --cached --ignore-unmatch filename.extension' --prune-empty --tag-name-filter cat -- --all
git push origin master --force
@willread
willread / gist:5523843
Last active December 17, 2015 00:49
Outputs a css file containing a class declaration for each image file in the current folder, with the binary contents of those images base64 encoded as data urls as well as their width and height. Dots in filenames are replaced with underscores. Using the images is as simple as <img class="filename_extension">, where an image called "filename.ex…
for f in `ls | egrep "\.jpg|\.jpeg|\.gif|\.png$"`; do echo -e ".`echo $f | tr . "_"` {\n\twidth: `identify -format '%w' $f`px;\n\theight: `identify -format '%h' $f`px;\n\tbackground: url(data:image/${f#*.};base64,"; openssl base64 -in $f | tr -d "\n" | tr -d "\r"; echo -e ");\n}\n"; done > images.css
@willread
willread / gist:5518072
Created May 4, 2013 16:57
Create a clean gh-pages branch.
# delete any existing branch
git branch -D gh-pages
git push origin --delete gh-pages
# create new branch and switch to it
git checkout -b gh-pages
# remove all but git files
rm -rf $(ls -a | egrep -v '^(\.|\.\.|\.git)$')
# create an empty index.html and commit it
touch index.html
git add -A
@willread
willread / gist:5511519
Created May 3, 2013 17:17
Replace references to filename.png in a CSS file with an embedded, base64 encoded copy of the file.
sed -i -e "s|filename.png|data:image/png;base64,$(openssl base64 -in filename.png | tr -d '\n')|g" filename.css
@willread
willread / gist:5510463
Created May 3, 2013 16:09
Configure git to cache credentials for a while and not bother me so much.
git config --global credential.helper cache
@willread
willread / gist:4260107
Created December 11, 2012 16:34
Import jQuery Via Developer Console
((function(){j=document.createElement("script");j.src="http://code.jquery.com/jquery-latest.pack.js";document.getElementsByTagName("head")[0].appendChild(j);})())
@willread
willread / gist:4253091
Created December 10, 2012 20:24
Multiple file uploads with CURL
curl -X POST -F "files[]=file1.jpg" -F "files[]=file2.jpg" … http://url.com
@willread
willread / gist:4206178
Created December 4, 2012 16:58
Tunnel into a local HTTP server
gem install localtunnel
tunnel -k ~/.ssh/some.pub 8080