Git-like Command Line Programs in Ruby

bash-148836_960_720These days, Git-like command line is the de facto standard. Surely you’ve seen this pattern before:

$ matrix take --with-water red.pill

When it comes to command line option parsing in Ruby, there are quite a few frameworks to choose from (OptionParser, GLI, Commander, Main, Escort, Thor and maybe a few more), but choosing the right one is difficult. After spending some time with each (read: hair pulling), I believe that Thor is currently the best option, and here’s why:

  • It supports the Git-like command line pattern out of the box.
  • It’s actively maintained and used by other popular frameworks (i.e. Rails).
  • It allows one to create short, readable code.
  • It keeps surplus features out of the code base.
  • It has a Bash auto-complete generator (sort of).
  • It supports multiple occurrences of the same option. This feature is (surprisingly) lacking from the other frameworks, but is quite common on the wild, i.e. $ docker run -it --env ACCEPT_LICENSE=y --env GOBLIT=bar ...

My advice is that you don’t waste your time fiddling with the other frameworks.

Git-like Command Line Programs in Ruby

Eclipse Helios will not start on RHEL v6.4

If you happen to run an older version of Eclipse (v3.6) – such as the case with IBM Operational Decision Manager v8.5 – on Linux RHEL v6.4, you might encounter the following GPF as Eclipse starts:

----------- Stack Backtrace ----------->
(0x00000035F020E01C [ld-linux-x86-64.so.2+0xe01c])
(0x00000035F0214715 [ld-linux-x86-64.so.2+0x14715])
(0x00007FB7FAD1783F [libxul.so+0x11ca83f])
(0x00007FB7FAD3E497 [libxul.so+0x11f1497])
(0x00007FB7FAD40269 [libxul.so+0x11f3269])
(0x00007FB7FAD404AD [libxul.so+0x11f34ad])
(0x00007FB7FAD40EB0 [libxul.so+0x11f3eb0])
NS_InitXPCOM2_P+0x3f8 (0x00007FB7FAD1ADD2 [libxul.so+0x11cddd2])
Java_org_eclipse_swt_internal_mozilla_XPCOM__1NS_1InitXPCOM2+0x12 (0x00007FB8699EDA3E [libswt-mozilla-gtk-3659.so+0x6a3e])
(0x00007FB87E28C75F [libj9vm26.so+0x3375f])

To fix it, edit your eclipse.ini file, and add the following at the bottom:
-Dorg.eclipse.swt.browser.UseWebKitGTK=true

Eclipse Helios will not start on RHEL v6.4

Change the font size of the JDT views of Eclipse on OS X

On OS X, the default font size of the Java Package Explorer of Eclipse is too small. To change it, open the file e4_default_mac.css located in the ${ECLIPSE_HOME}/plugins/org.eclipse.platform_*/css directory. Note that the exact path depends on the version of Eclipse you have.

At the bottom of the file, add the following:

#org-eclipse-jdt-ui-PackageExplorer Tree {
   font-size: 16;
}

This means that any Tree widget who’s parent has the CSS ID of #org-eclipse-jdt-ui-PackageExplorer will be affected. See this blog for more information on CSS styling in Eclipse.

To do the same for the Outline View, add the following:

#org-eclipse-ui-views-ContentOutline Tree {
   font-size: 16;
}

Now save the file, restart Eclipse and that’s it.

For a more pleasant editing experience, install the Chrome Theme plugin from the Marketplace, open Preferences | General | Appearance | Chrome Theme, select the CSS tab and pase the above text to the Custom CSS editor. To find the CSS IDs of other UI elements in Eclipse, install the CSS Spy plugin from the Marketplace and go treasure hunting. Good Luck!

Change the font size of the JDT views of Eclipse on OS X

Remapping the tilde key (~) in Linux guest running in VMWare Fusion

When running a Linux guest in VMWare Fusion, the ‘~’ (tilde) key is remapped to the ‘§’ key. Here’s how to bring the tilde back to its natural place on the Mac keyboard.

In the Linux guest, create the file ~/.xmodmaprc (for Red Hat) or ~/.Xmodmap (for SUSE), with the following line:
keycode 94 = grave asciitilde
Save the file and then restart X.

Note that this only works for X, i.e., it doesn’t work when your runlevel is smaller than 5.

Remapping the tilde key (~) in Linux guest running in VMWare Fusion

Annotate the background picture with the Hostname, MAC and IP addresses

  1. Get the list of Ethernet interfaces into an array of tuples {name,mac,ip} (Note that the name of the interface is postfixed with a colon ‘:’):

    INTERFACES=($(ip addr | grep -A2 "[1-9]: eth[0-9]:" | awk '{print $2}'))
    IF_NAME=${INTERFACES[0]%?}
    IF_MAC=${INTERFACES[1]}
    IF_IP=${INTERFACES[2]}
  2. Annotate a picture and save the resulting picture to ${HOME}/.annotated_bg.pic:

    SOURCE_PIC=/usr/share/backgrounds/abstract/Waves.png
    convert \
      -pointsize 45 -fill white \
      -gravity SouthWest \
      -annotate +50+50 \
        "$(hostname)\n" \
        "${IF_MAC}\n" \
        "${IF_IP}" \
      ${SOURCE_PIC} ${HOME}/.annotated_bg.pic
  3. Tell Gnome to use the new background picture:

    gconftool-2 --set /desktop/gnome/background/picture_filename --type string "${HOME}/.annotated_bg.pic"
Annotate the background picture with the Hostname, MAC and IP addresses

Is the Nikon WT-4a up to the task?

I’m thinking of buying the new D800, but I wonder if the WT-4a is up to the task?

Slow as a WT-4a. Picture by Jürgen Schoner from Wikipedia.

I currently own the D700 and WT-4a. I usually shoot and inspect the image on my Mac, right away. The time it takes for the WT-4a to put a 12MP image on my Mac is about 5-10 seconds. It’s slow, but bearable. Power consumption per image is huge – the WT4-a battery lasts for about 30-45 minutes of work. In fact, I always have 2 spare batteries standing by.

That being said, and given the 36MP size of the D800 images, I doubt that I’ll be able to continue and use the WT-4a. Even the new WT-5a is only twice as fast as the WT-4a, and anyhow, it only works with the D4. Doh.

To sum up: there’s a need for a brand new, blazing fast, power-efficient WiFi option for the D800. Of course, a built-in solution would be the best.

Is the Nikon WT-4a up to the task?