Skip to content

Instantly share code, notes, and snippets.

View philly-mac's full-sized avatar

Philip H. MacIver philly-mac

View GitHub Profile
@philly-mac
philly-mac / tmux cheat sheet
Created January 23, 2013 03:30
List of tmux commands and descriptions
start a new session tmux OR
tmux new OR
tmux new-session
re-attach a detached session tmux attach OR
tmux attach-session
re-attach an attached session (detaching it from elsewhere) tmux attach -d OR
tmux attach-session -d
re-attach an attached session (keeping it attached elsewhere) tmux attach OR
tmux attach-session
detach from currently attached session ^b d OR

tmux cheatsheet

start new:

tmux

start new with session name:

tmux new -s myname
@philly-mac
philly-mac / gist:3205929
Created July 30, 2012 09:53
Load jQuery only if has not already been loaded
if (typeof jQuery == 'undefined') {
function getScript(url) {
var script = document.createElement('script');
script.src = url;
var head = document.getElementsByTagName('head')[0],
done = false;
// Attach handlers for all browsers
script.onload = script.onreadystatechange = function() {
@philly-mac
philly-mac / gist:1438906
Created December 6, 2011 16:47
tar encrypt and spilt a file
# Encrypt and split
tar cj file.txt | openssl des3 -salt -k password | split -b 100m -d - 'test-encrypt'
# Unencrypt
cat file.txt | openssl des3 -d -k password | tar xjf -
@philly-mac
philly-mac / gist:1162650
Last active September 26, 2015 21:37
Because I always forget the syntax of some git commands
# <remote> is usually origin
# Check out remote branch
git checkout -b <local-branch-name> <remote>/<remote-branch-name>
# Delete local branch
git branch -D <local-branch-name>
# Delete remote branch
git push <remote> :<remote-branch>
@philly-mac
philly-mac / gist:1146015
Created August 15, 2011 10:28
Split And Join files
# Tar
$ tar -cvvzf <archive-name>.tar.gz /path/to/folder
# Split
$ split -b 1M <archive-name>.tar.gz "parts-prefix"
#Join
$ cat parts-prefix* > <archive-name>.tar.gz
@philly-mac
philly-mac / gist:1115330
Created July 30, 2011 08:29
remove dead symlinks
find -L . -type l -print0 | xargs -0 --no-run-if-empty rm
@philly-mac
philly-mac / gist:1087331
Created July 17, 2011 07:51
Change disk label in Linux
e2label device [ new-label ]
#!/usr/bin/env ruby
puts `egrep -i ".*#{ARGV.join(".*")}.*" /etc/hosts`