Friday, July 27, 2007
Happy System Administrator Appreciation Day
Thursday, June 14, 2007
From Safari to Firefox, and back again!
I was an avid Safari user until a few months ago. I switched to Firefox for the following reasons:
- Asks before closing a window with tabs
- Able to reopen tabs after crash (with the Session Manager add-on, it even saves text you were typing in forms!)
- Allows opening a tab in a new window (but needs to refetch the page)
- Less annoying download status (with the Download Statusbar plugin)
- Absolutely kick-ass website debugger: the Firebug add-on.
- Extensibility through add-ons and themes
- Works with slightly more websites
Consider me biased, once you're used to being given applications that Just Work and do the sensible thing 99.9% of the time, you become, shall we say, sensitive to less well thought-out applications. Firefox is an impressive effort, but in part due to its cross-platform requirements, it's somewhat lacking on OS X. Safari goes the extra mile for you, like slowing down Flash animations when you're not looking at them, and waiting until you look at a tab to activate animations.
And now Apple released version 3.0 beta of Safari, for free, including a Windows version! Magically, Apple's engineers have seen the things I disliked about Safari 2.0 and fixed them:
- Asks before closing a window with tabs
- Able to reopen tabs after crash (from the History menu)
- Allows opening a tab in a new window, you can just drag it off the bar (without refetching!)
- You can even move a window back to a tab bar, all with spiffy animations of course
Safari 3.0 has those little touches you get from Apple, for example extra-visible highlighting when searching for something, or resizeable text boxes for when those forms just aren't big enough. Very nice.
Heartily recommended. Download it now.
Friday, May 25, 2007
Global Warming
The Great Global Warming SwindleIt makes a case for the following two statements:
- Yes, the Earth is obviously getting warmer
- No, humankind doesn't have all that much to do with it
But, on the other hand, check out this link for a thorough debunking of the video.
Monday, May 21, 2007
Using bash functions under sudo
Have you ever done the following?
duk is a function that will show you directory sizes under a given pathname (or the current directory), nicely sorted by size, largest at the bottom just above your next prompt. It's very handy, put it in your .bashrc ;-). sudo doesn't know what to do with "duk" however, since it's not a system command. Therefore, I wrote a function that is a front-end to sudo. It parses the command line you give it, and expands any functions or aliases that you call. For bonus points, it shows you the full command line as the shell receives it before you type your password. Use it as follows:$ type duk duk is a function duk () { du -k "$@" | sort -n } $ sudo duk /tmp sudo: duk: command not found
Looks like I'll need to do some cleaning up in /tmp. Full source follows. To use it, place a source ~/.sudo.bash (for example) in your .bashrc after copying the code to your ~/.sudo.bash, or copy the full code to your .bashrc. Then, simply use sudo as you would before. This function handles all sudo arguments. There is one extra argument, -x, which expands arguments as you, not as root. This is needed in some corner cases. (Update: New version which no longer uses sed and handles spaces in sudo options!)$ source sudo.bash $ sudo duk /tmp /opt/local/bin/sudo -- bash -x -v -c duk () { du -k "$@" | sort -n };"duk" '/tmp' Password:[...]3648 /tmp/synergy-1.3.1/lib 6184 /tmp/synergy-1.3.1 20128 /tmp/prarora 1294048 /tmp/tmp 5304016 /tmp
# Wrap sudo to handle aliases and functions # Wout.Mertens@gmail.com # # Accepts -x as well as regular sudo options: this expands variables as you not root # # Comments and improvements welcome # # Installing: source this from your .bashrc and set alias sudo=sudowrap # You can also wrap it in a script that changes your terminal color, like so: # function setclr() { # local t=0 # SetTerminalStyle $1 # shift # "$@" # t=$? # SetTerminalStyle default # return $t # } # alias sudo="setclr sudo sudowrap" # If SetTerminalStyle is a program that interfaces with your terminal to set its # color. # Note: This script only handles one layer of aliases/functions. # If you prefer to call this function sudo, uncomment the following # line which will make sure it can be called that #typeset -f sudo >/dev/null && unset sudo sudowrap () { local c="" t="" parse="" local -a opt #parse sudo args OPTIND=1 i=0 while getopts xVhlLvkKsHPSb:p:c:a:u: t; do if [ "$t" = x ]; then parse=true else opt[$i]="-$t" let i++ if [ "$OPTARG" ]; then opt[$i]="$OPTARG" let i++ fi fi done shift $(( $OPTIND - 1 )) if [ $# -ge 1 ]; then c="$1"; shift; case $(type -t "$c") in "") echo No such command "$c" return 127 ;; alias) c="$(type "$c")" # Strip "... is aliased to `...'" c="${c#*\`}" c="${c%\'}" ;; function) c="$(type "$c")" # Strip first line c="${c#* is a function}" c="$c;\"$c\"" ;; *) c="\"$c\"" ;; esac if [ -n "$parse" ]; then # Quote the rest once, so it gets processed by bash. # Done this way so variables can get expanded. while [ -n "$1" ]; do c="$c \"$1\"" shift done else # Otherwise, quote the arguments. The echo gets an extra # space to prevent echo from parsing arguments like -n while [ -n "$1" ]; do t="${1//\'/\'\\\'\'}" c="$c '$t'" shift done fi echo sudo "${opt[@]}" -- bash -xvc \""$c"\" >&2 command sudo "${opt[@]}" bash -xvc "$c" else echo sudo "${opt[@]}" >&2 command sudo "${opt[@]}" fi } # Allow sudowrap to be used in subshells export -f sudowrap
Saturday, January 6, 2007
A cute desktop clock for OS X
Tuesday, January 2, 2007
Control iTunes over SSH
ssh -t mysystem ./iTunesCLI (when stored in your home directory)
ssh -t mysystem iTunesCLI (when stored in /usr/bin)The -t option is needed to make keystrokes be recognized immediately. SSH tips:
- Use an SSH agent so you don't have to type your password every time. For OS X, try for example SSH Keychain
- The hostname for the remote machine is most likely machinename.local. For example, my Mac Mini is hooked up to the stereo and is called mini-me. I just run "ssh -t mini-me.local iTunesCLI".