Saturday
May152010

migration to squarespace

I'm in the process of moving from jumpline.com and blogger to squarespace.com. Please let me know if you run into any broken links or mis-placed apostrophes. You know how I hate those. 

Wednesday
Oct142009

Java foreach loops on empty collections

I've been worrying about whether I need to check for null when invoking a foreach loop on a collection that might be empty. The answer is, nope, I don't need to check for an empty list; java just Does The Right Thing.

List<Object> list = new ArrayList<Object>();
logger.info("here's a list that was always empty: " + list.toString());
for (Object o: list) {
logger.info("here's an object: " + o.toString());
}
logger.info("done");

...yields this output:
INFO: here's a list that was always empty: []
INFO: done

These alternate ways of expressing the same loop also all execute without a problem, even for an empty list:

for (int i = 0; i < list.size(); i++) {
Object o = list.get(i);
logger.info("here's an object: " + o.toString());
}
for (int i = 0; i < list.size(); i++) {
Object o = list.get(i);
logger.info("here's an object: " + o.toString());
}

That's just a detail that's been bugging me, and now I understand the behavior. For what it's worth, I couldn't find this issue addressed in the JSR.

Wednesday
Apr222009

best of ben

Sunday
Apr192009

graphical diff for git on mac os x

I just configured git to use FileMerge for diffs. FileMerge is a pretty graphical diff tool. I couldn't find quite the right invocation via google, so here's what I did:


  1. Create ~/bin/git-diff-driver.sh with these contents:
    #!/bin/sh
    /usr/bin/opendiff "$2" "$5"

  2. Make it executable
    chmod ugo+x ~/bin/git-diff-driver.sh


  3. Make git use this little script for diffs. Edit ~/.gitconfig to include these lines:
    [diff] 
    external = "/Users/ben/bin/git-diff-driver.sh"


Now the next time that you call git diff HEAD FileMerge will open. GUI sweetness.

Monday
Feb232009

missing out on flex?

Last week I finally started using an AIR application, TweetDeck, because my brother said it was cool. Now I'm reading about Flex and AIR, and I have to say, I might have been missing out on a good thing. It looks to me like Flex and AIR are together a powerful front-end platform for building nice applications... where by nice I mean the things that Ben Shine traditionally loves: smooth, swoopy, delicate, rounded, subtle, surprising, shiny.
This bears investigation.