Tuesday, March 31, 2009

Trivial for-each sugar

A snippet of for-each syntatic sugar for Java loops:

for (final Person person : each (ALICE, BOB, CAT))

And elsewhere:

public static <T> T[] each(final T... array) {
    return array;

Wednesday, March 25, 2009

Java code beautifier

Where are the Java code beautifiers? My criteria:

  1. Formats in standard SUN Java style
  2. Works on JDK5+ Java code
  3. No licensing required—free as in beer

Not very many criteria! And yet … very little turned up that did not violate one requirement or the other. I came up with exactly one match: Jacobe, personal edition.

Wednesday, March 04, 2009

Two miracle utilities: rlwrap and screen

Two miracle utilities: rlwrap and screen.


Ever wish you had nice command-line editing like BASH but the tool you are using is hopeless? rlwrap is the tool for the job: it is a readline wrapper for any program that reads from stdin. A classic use case is wrapping sqlplus.


Say you have an on-again, off-again shell session you come back to throughout the day. You could keep a shell window open all day. But what if you change machines, say from a laptop to a desktop and back again? screen is the tool for the job: it is a full-screen window manager for terminal sessions. Disconnect from the current session, keep screen running in the background, and reconnect later at your convience. Nothing is lost.