Monday, June 2, 2008

Smalltalk

Ok, this has me impressed:
One of our applications is an energy trading platform, parts of which have a stringent bug-fix time requirement: 15 minutes from bug report till fix or our customer gets hit with crippling fines. Those applications are deployed without sealing them, so when we get a bug report we connect to the machine and see an open debugger on the thread that failed while the rest of the application happily purs along; we modify the code and/or data in the debugger and hit the continue button, nearly always within this 15 min time frame. We then code up a permanent fix in our shop and hoist this permanent patch in the production server /while/ it is running. Again something that is mostly impossible in dead-code systems.

Mr. Reinout Heeck is talking about Smalltalk. Recently it has come in the news again because this company repurposed their Smalltalk VM to run Ruby, with great performance boosts. Their VM is not entirely ready but is meant to replace most of the Ruby on Rails stack. They're calling it MagLev (geddit? rails-maglev hee hee :)).

It sure sounds mightily impressive: an environment that automatically persists objects, has them available to many concurrent worker threads (including across hosts) with a fully transactional model and is zippy to boost... now almost available for a scripting language that has its users cooing with pleasure! Throw in some of that live debugger salsa and I'm sold.

Sometimes, life is good. Cue the Louis Armstrong playlist, please.

Friday, February 8, 2008

PQI i810 2GB USB flash drive mini review

I just bought a PQI i810 2GB flash drive, and I must say I'm very happy with it.

I did some benchmarks on it, and I attained 10MB/s write speeds and 30MB/s read speeds on my Mac. For something so small that I can have it in my pocket at all times, that's astounding!

It's shaped like a small square, and it can slide out the USB connector using a small switch. It feels sturdy either slid out or retracted, and it fits snugly in the USB port.

Bottom line: If you're looking for a USB flash drive that's small enough to always have on you, get this one. Heartily recommended!

Saturday, January 5, 2008

AirPortAtheros5424.kext and pkgutil

So I boot my Mac in verbose mode, mostly for the geekiness factor. But sometimes, you see a problem that needs fixing.

First off, to turn on verbose booting permanently, simply run "sudo nvram boot-args=-v" on the command line. nvram is the interface to the OpenBoot BIOS environment of PowerPC based macs. To my surprise, this works with Intel systems as well. It's one of those little things that make Apple such a great software company.

The error that caught my attention was:

a link/load error occured for kernel extension /System/Library/Extensions/IO80211Family.kext/Contents/PlugIns/AirPortAtheros5424.kext
You can grep for this error in your /var/log/system.log .

I did some searching and came up empty-handed, which is why I'm posting this. I think this is a leftover from upgrading my system from 10.4 to 10.5.

I'm pretty sure, because 10.5 now has a package database! You can actually find out which package installed a file now (provided the file was part of a package and not a drag'n'drop installer of course).

You can query this database using the command pkgutil. Just typing it at the command line will give you a lengthy usage statement. The option we're interested in is --file-info:

$ pkgutil --file-info /System/Library/Extensions/IO80211Family.kext/Contents/PlugIns/AirPortAtheros.kext
volume: /
path: System/Library/Extensions/IO80211Family.kext/Contents/PlugIns/AirPortAtheros.kext

pkgid: com.apple.pkg.BaseSystem
pkg-version: 10.5.0.1.1.1192168948
install-time: 1194966975
uid: 0
gid: 0
mode: 40755

So we know that the AirPortAtheros.kext plugin is installed by Leopard. The same search for AirPortAtheros5424.kext comes up empty, however.

Therefore we can conclude that AirPortAtheros5424.kext isn't owned by anything Leopard installed, and therefore I moved it away. The error is now gone and my wireless card is still functional.

I guess doing this doesn't buy you much but at least reading this taught you about the pkgutil command ;-)

Thursday, June 14, 2007

From Safari to Firefox, and back again!

Well, I have to say, I love the new Safari 3.0 beta.

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
So I switched, and suffered through the things that aren't so nice about Firefox, such as no real integration with OS X (Keychain, application launching etc), some graphical glitches and general clunkiness.

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
For extra chunkyness, they added a Web Inspector as well, which more or less shows what Firebug would show. All you need to do to see it is enable the Safari debug menu and it's right there. Firebug is still slightly more useable, and it allows you to change the page while it's loaded, but still kudos to Apple for adding it!

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

Here's an extremely interesting video to watch:
The Great Global Warming Swindle
It makes a case for the following two statements:
  1. Yes, the Earth is obviously getting warmer
  2. No, humankind doesn't have all that much to do with it
It shows very convincing science which indicates man-made CO2 has nothing to do with global warming. It looks like we're just in it for the ride.

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

Update: Now on github

Have you ever done the following?

$ type duk
duk is a function
duk ()
{
   du -k "$@" | sort -n
}

$ sudo duk /tmp
sudo: duk: command not found
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:
$ 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
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!)
# 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