Command Line Argument Parsing in Java

Paul Brown @ 2006-01-11T08:21:00Z

Command line argument parsing in Java is one of those things that makes me scratch my head — "Hasn't someone gotten this right yet, for my definition of right?" When we needed a library for PXE, I played with Commons CLI (including the stillborn version 2), Martian's JSAP, John Lloyd's approach (complete with 2,000-line core class — Gah!), and whatever else Google had to offer. (Kohsuke's args4j and Sam's take weren't around at the time.) Commons CLI was good enough for initial work, but I wrote my own once I got frustrated enough with it. My requirements were:

  • Multiple valid command line argument combinations per command with single help output.
  • Match-based selection of which combination format applies.
  • Nested logical (e.g., XOR or AND) relationships between arguments within a combination.
  • Multiple named, ordered, non-flagged (i.e., no -x) arguments with multiplicities and good help output, like for cp with 1..n "from" files and a single "to" directory.

Maybe I'll package up my version, but a similarly picky person would probably find something objectionable in form or function and write their own anyway. (And, for that matter, it's a pleasant afternoon's diversion to do so.)

(comment bubbles) 3 comments

Ah, Sleep

Paul Brown @ 2006-01-11T07:23:00Z

There are certain things that your parents only tell you once you've locked yourself into having a child. For instance, I found out that my sleep habits as a baby drove my parents to use drugs. That is, they used drugs on me after ten months of sleeplessness. They may have gone to a vet at the time, but at least these days, you have to be an epileptic dog or cat to get a prescription for phenobarbitol. I still sleep less than a "normal" person is supposed to, although I've never been able to shake my urge to take a catnap at around 2PM. (Coffee and a good croissant seem to be a workable substitute for the catnap.)

Learning to walk and learning to talk are straightforward, or at least apparently so, as a combination of demonstration and natural inclination make it almost inevitable, but you wouldn't think that a baby would have to learn how to sleep. At least so far, Emme's nailing her other milestones well ahead of the statistically official schedule, but good sleep habits are proving elusive. Taking her to bed with us was a sanity measure when she was tiny, restless, and hungry, and maybe it was karma after we'd presumptuously assured ourselves that we would never co-sleep. Stern looks from our pediatrician aside, I felt good about the choice, and now that Ferber has partially recanted, I can feel good about having an authority say that it's OK. (I wonder if the people in the NYT picture really look like that when they wake up...)

Eventually, however, three's a crowd, especially if the third person wakes up in a bad mood every couple of hours. (Other than a hit of boob juice (duh), Old McDonald and my down-tempo version of the Lumberjack Song appear to be her two favorite appeasements...) We read the books by the usual suspects, and we even tried one round of Maximum Weissbluth (short version: put baby in crib, come back in morning) when Emme was about 6 months old, back before she could crawl. Emme would have none of it — in addition to complaining profusely and at length, she used the nighttime hours to rip the bumper off her crib and learn how to get from her back to sitting up, so we bagged it after five days with no improvement. (At nine months, she's walking if given something to push along, and if we put her in her crib, she's on her feet in a flash and likes to hold onto the rails and jump up and down or see how long she can stand without falling over...)

With Holiday travel behind us, it's time to give sleep training another shot, albeit by other means. The goal is to communicate to the child what's expected and to have them understand that it will be firmly enforced but that it's not really that unpleasant. With that as the guiding principle, we're armed with a new nighttime routine, an indefinite timeline, and will see how it goes.

(comment bubbles) 0 comments

Settled in Seattle

Paul Brown @ 2006-01-02T20:53:00Z

I'm sure that someone can outdo my current personal best for amount of life change in six months from April to October, but those six months have been a personal best for me that I hope will endure at least for a little while. In chronological order: we welcomed Emme; FiveSight released PXE into open source; I retired from FiveSight; I took a position at Amazon; I moved my (new) family out to Seattle, on Father's Day; I switched roles at Amazon, from Werner's group to Global Payments; we sold our condo in Chicago; we bought a house in Seattle; and Intalio acquired FiveSight. The rest of the year, even considering that this was my first holiday crunch at Amazon, was quiet by comparison.

I was born and grew up in Portland and have always considered myself a Northwest ex-pat, so moving to Seattle has been a kind of homecoming. I could write about the little differences between the Chicago and Northwest cultures, but I think the stark contrast between Seattle's progressive residential recycling program and Chicago's blue bag charade should be sufficient. (The smoking ban is nice, too.)

Seattle itself has been great. We spent a couple of months in temporary housing in Belltown, walking distance from the Pike Place Market. And, with the last of the boxes finally getting emptied, we're settled into our house in Fremont. Among other things, we're a short walk from the zoo, close to great coffee, good sandwiches, just up the hill from amazing croissants and a real farmer's market in Ballard, and just across Aurora from good, authentic pizza in Wallingford. (La Follia is still better...) Seattle does lack a world-class art museum, but I'm willing to content myself with being close to North Cascades, Mt. Rainier, and Olympic National Parks.

(comment bubbles) 0 comments

Feedburner-izing typo in Fifteen Minutes

Paul Brown @ 2005-12-29T17:35:00Z

I finally got around to signing up with FeedBurner for the main Atom feed for mult.ifario.us; the new preferred feed is http://feeds.feedburner.com/Multifarious, but I'm going to hold off on 301ing aggregators for the time being. It was easier than I thought to get the FeedBurner feed and some auto-subscribe chicklets displayed in typo, thanks to a well-designed sidebar API. In fact, it took all of 15 minutes to read the README on sidebar plugins, fire up a text editor, write the 16 lines of ruby and 46 lines of rhtml for the sidebar, fix some typos, bounce lighttpd, et voilá...

On the downside, the code for autodiscovery is not cleanly modularized in typo, so I stopped at the sidebar. A more thorough integration would require a more thorough refactor (or at least a hack to hard-code the FeedBurner URL), as the autodiscovery feed code is spread between a superclass and a base class in the controllers. (Yuck.)

(comment bubbles) 0 comments

How to Break-Up a Big Block of Silly Putty™

Paul Brown @ 2005-12-28T23:07:00Z

Over on the Google blog, Clay Bavor commented about purchasing 250 pounds of Silly Putty™ (or perhaps a roughly equivalent but off-brand mixture of silicone oil and boric acid) but having trouble dividing it up once it coalesced into a single mass.

Counterintuitively, one way to get a piece of putty off of a lump is to hit it really hard — the lump will shatter. For example, dropping the 250-pound blob of putty from the clock tower on the Stanford quad (ideally without hitting anyone) would probably have worked. At least as far as I know, this is because the putty is a dilatant non-Newtonian fluid, i.e., viscosity increases with shear force. (Now that I think about it, using something like a wire cheese slicer but moving it very slowly would also probably have worked well.) Under stress, the physical properties of a dilatant polymer depend on the properties (brittle, elastic, malleable) of the molecules, but my knowledge ends there. Based purely on the boron and silicon, would be that the limiting behavior of Silly Putty™ is that of a glass, but I honestly don't know.

(comment bubbles) 2 comments

Getting Bugaboo Religion

Paul Brown @ 2005-12-27T23:45:00Z

We went east to visit Hien's side of the family this year, and that meant traveling across a two-hop, cross-country trek with a teething baby. (She got her two front teeth for Christmas, among other things.) The trip went about as well as it possibly could have.

Instead of the faithful Frog, we took one of the standard, low-end umbrella strollers to gate check and then use during the stopovers. I will admit to having doubts about the Frog's freakonmic cost-effectiveness in comparison with the $25 umbrella stroller, but I've always appreciated the Frog in a manly way: it's a sturdy, well-designed, well-made piece of equipment with lots of attachments, and both Hien and Emme like it. (Also, if you read about the babies that other manufacturers, e.g., Graco or Evenflo, have injured or worse, you have to think carefully about what you buy and whom you trust. For example, the 105 injuries from collapsing highchairs was the scariest of the list for me.) After pushing, pulling, and otherwise manhandling the umbrella stroller around Denver and Chicago (O'Hare) during layovers, I truly appreciate the Frog. (The O'Hare Children's Museum was a godsend since Emme was able to crawl around freely for an hour or so.)

The umbrella stroller was clearly designed to be lightweight and to fold compactly, but it fails basic ergonomics as a stroller. My chief gripe is that the rear wheels are exactly the same distance apart as my feet, so I have to walk hunched over like Quasimodo, sashay along with one foot in line with the other like a runway model on a catwalk, or trip over the stroller every couple of strides. That, and the geometry of the front end and the use of a pair of wheels on each side makes the wheels equally likely to slide sideways on a smooth surface as to spin into alignment for forward motion. Next time, considering that we have the necessary accessory, we'll just schlep the Frog.

(comment bubbles) 0 comments

Logical Fallacies Blog

Paul Brown @ 2005-12-24T06:10:00Z

I was happy to find, via Bill de hÓra, a blog on logical fallacies:

The fallacist, like the zoo-keeper, develops an affectionate relationship with his specimens. He keeps them correctly labelled in their separate enclosures, and looks them over from time to time pausing to stroke a petitio principii, or allowing an ignoratio elenchi to nuzzle against his hand. [...] I take a very broad view of fallacies. Any trick of logic or language which allows a statement or a claim to be passed off as something it is not, has an admission card to the enclosure reserved for fallacies.

Fallacy fanciers may also enjoy a trip to Dan Bernstein's collection of post hoc ergo propter hoc instances collected from the wild.

(comment bubbles) 0 comments

All Posts contains 397 items in 57 pages of 7 items each:
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57