Alvin Alexander | Java, Scala, Unix, Perl, Mac OS X

Perl rules! Yesterday I needed a program that would print a file in reverse, i.e., last line first, first line last. Before I could fret "man, how am I going to do this?", a powerful two-line program spewed forth:

@lines = <>;
print reverse @lines;

Life is good.

What's a beanshell? From the source: "BeanShell is a small, free, embeddable, Java source interpreter with object scripting language features, written in Java. BeanShell executes standard Java statements and expressions, in addition to obvious scripting commands and syntax."

Teaching a brief OO class yesterday, I'm reminded of several things, including Argo/Poseidon as a free UMLish tool, and GRASP, which springs from Wirfs-Brock responsibility-driven design.

A quiet little Memorial Day Sunday so far. Had a fun problem with Postgres yesterday. Here's a little ditty on what to do when you get the nasty "duplicate key" error message, and you know it's wrong.

I had an interesting circumstance happen with Postgres (PostgreSQL) and I want to remember how I fixed the problem.

Somehow I had four entries in a database table, but the key for that table thought that there were only two entries. I don't yet know how this happened, but at the time I didn't care, I just needed to get past the problem. The details of the problem, and the fix, follow.

In my case the table name was carrier, and this table and the key were created like this:

While my real job and the search for a motorcycle occupy most of my time, check out the Mono project, an open source implementation of the Microsoft .NET framework. Ad-aware, from Lavasoft is a free tool for removing "spyware" from your Windows PC. If that link doesn't work you can get the download from ZDnet.

The folks that have created IntelliJ have really done some nice things for those of us that use open source tools. Of course one tool we all use is CVS for source code control, and the IntelliJ/CVS integration is pretty sweet.

At the urging of co-workers I've started working with the IntelliJ IDE. Here's what I've learned so far about configuring line numbers, caret position, and configuring IntelliJ to work with Ant.

The fact that IntelliJ is off-the-shelf ready to work with Ant is a great, great feature. It's also simple to configure and use.

Assuming that you already know how to use Ant, and you have a build.xml file ready to go, just follow these steps to (a) configure your build script to run from within IntelliJ, and (b) run Ant:

Or, what to do when you want the caret here:

When I first fired up IntelliJ and started using it to edit a Java file, one of the first things I wanted to do was to be able to see line numbers within the file.

Configuring IntelliJ to show line numbers is a no-brainer. Here's how to do it:

  • Select Tools | IDE Options
  • Select Editor
  • In the Display group, click Show line numbers
  • When you're finished here, click OK

That's it. Do this and you're ready to go.


Weird human emotion: I find myself angry at Jim for dying. Sitting at a bar last night, a friend brought some pictures that included one with a group of us, including Jim. Of course in the picture we're all at a bar, smiling and raising our glasses to the camera. Every time I see a picture, hear his name, or walk by his office, I keep saying "Dammit Jim, why did you have to go?" I know it isn't anything he wanted to do, it just happened, but that's what my brain keeps saying.

The other day I was asked why I allow pop-up banners on this web site. Two reasons: first, the matter of economics; second, to encourage you to use the free, open source Mozilla browser.

Mozilla is very feature competitive with IE (even ahead in some areas), truly cross-platform, and also lets you control ad content better than any other browser, including pop-ups and pop-unders. I guess because it's not a "part of the operating system", it also doesn't seem to have all of those pesky patches and security problems.


Just returned from a short trip to the northern outskirts of Chicago, Illinois. Wow, can it rain.

On the computer side of life, have you ever found yourself needing a copy of the stuff (source code, etc.) in a CVS repository, without all the CVS admin files? Here's a quick tutorial on how to use the cvs export command.

Can I get a copy of the source code (without the repository)?

The other day someone not familiar with CVS asked if they could have a copy of the source code for the DDConnectionBroker project, an Open Source project from I said sure, I'd be glad to provide a copy of the source code, stripped of all the CVS directories/files. To do this, all I had to do was run the "cvs export" command.

One of my favorite Java subjects is code optimization and performance. Here I'd like to show you a couple of neat things you can learn with the javap -c command. This command lets you disassemble Java bytecode.

The first thing you need to have for this exercise is a little sample Java code. So in the examples below I create two test Java classes, appropriately named and Although it's not explicitly stated below, the steps I'm going to follow are these:

On Saturday, May 4, 2002, the day of the Kentucky Derby, Jim Kimmel, a friend and co-worker, passed away. He had a heart attack while doing something he loved, riding his bike with his friends. You are missed very much Jim.

So today is the big day, the fastest two minutes in sports, and I need to start cooking for the party. If the race doesn't interest you, maybe my Java and OO programming reading list might suit your style. Place your bets...