Skip to content

Instantly share code, notes, and snippets.

@mbadran
mbadran / odupdate.sh
Created Aug 3, 2010
update OpenDNS network IP (insecurely)
View odupdate.sh
#!/bin/sh
ip=`curl -s https://secure.internode.on.net/webtools/showmyip?textonly=1`
curl -s -u <username>:<password> https://updates.opendns.com/nic/update?hostname=<network>&myip=$ip
@mbadran
mbadran / gist:368116
Created Apr 16, 2010
case insensitive matches()
View gist:368116
testString.matches("(?i)^[a-b]*$");
// (?i) toggles case insensitive matching
// also works for m, s, and x modes
// http://www.regular-expressions.info/modifiers.html
@mbadran
mbadran / gist:368113
Created Apr 16, 2010
commandline tips
View gist:368113
#ctrl-z
# put a process in the background
fg
# bring a background process into the foreground
tail -f filename
# follow a in real time (eg. a log file)
#ctrl-s
# suspend display on the terminal
View gist:215569
Surround a heredoc with quotes and you can continue the code on the same line:
render :status => 404, :text => <<-'EOH' and return unless setup
article not found<br/>
I, as a server, have failed<br/>
https?
EOH
Quotes also give you more freedom/creativity with the terminal ID:
@mbadran
mbadran / gist:133130
Created Jun 20, 2009
handy apt-get commands
View gist:133130
apt-get update
apt-get dist-upgrade
apt-cache search <package>
apt-get install <package>
apt-get remove <package>
apt-get --purge remove <package>
@mbadran
mbadran / gist:130470
Created Jun 16, 2009
make popd silent in bash
View gist:130470
alias popd="popd > /dev/null"
@mbadran
mbadran / gist:130469
Created Jun 16, 2009
replace cd in bash to (silent) pushd
View gist:130469
alias cd="pushd $@ > /dev/null"
@mbadran
mbadran / gist:130447
Created Jun 16, 2009
improve the bash prompt (basic)
View gist:130447
PS1="[$?/\T]\h:\w% "
@mbadran
mbadran / gist:130444
Created Jun 16, 2009
improve the ls command in bash (basic)
View gist:130444
alias l="ls -lahF"