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

Ever need a program to extract some lines from the middle of a file, say lines 50-500 of a 10,000 line file? Well, I did, so I wrote one in Perl. Here's the code for "extract.pl, which lets me extract lines from a file by specifying the firstLine and lastLine that I want printed from a file:

I'm still living in the Perl world, and that's a good thing. Did I mention that Perl rules for text processing?! Perl is the technology that enables "smart news", or whatever I choose to call it (other name candidates: filtered news, robonews, newsbot).

Perl continues to rule the world, at least the text-processing world. The latest example is HTML::TokeParser, which lets me easily extract HREF's from documents. With this much-improved document parser and the search engine set up, I hope some form of smartnews/robonews will be available soon.

The first in hopefully a series of ooa/ood koans: no end user.

OO Koan: You are assigned to work on a project, but you cannot communicate with the end user -- how do you develop the software?

(Answer: Lots of luck. ;)

 

Another meaning of GRASP: Graphical Representations of Algorithms,Structures, and Processes. Check out the concept of a Control Structure Diagram (CSD) at Auburn University, and how it changes the appearance of your source code. Does it make it easier to view your code? Does it make it easier to read the code of another?

A couple of URLs I don't want to forget: The OpenJMS Project (JMS == Java Message Service); the Grid Engine Open Source Project, promoted by Sun. Grids are cool, now all I need is an app. :)

Yesterday I was reminded of cetus-links. At last check they have over 18,000 links related to the OO world. While I'm in the linkmeister neighborhood, cgi-resources is still a decent reference for Perl programs.

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.