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

Linux find/grep FAQ: How can I combine the Linux find and grep commands to search a large collection of files?

A lot of times when I need to find a file I know the text in the file that I'm looking for, but I can't remember the filename, or can't think of what directory it might be in, other than somewhere below my home directory. When this happens, and other search means like the "locate" command don't help, my favorite way of searching for text strings in files that are spread through a bunch of directories and sub-directories is this:

I thought I'd share the source code for my Java email address validator class. I'm not sure if there's a big need for it ... I wrote it a long time ago, and I think I created it because Java's javax.mail.internet.InternetAddress class wasn't validating email addresses as deeply as I wanted it to. For instance, I think it would allow the string "fred" to be a valid email address, but on the internet you really want to see something like "". So I think that's where this class comes from.

Here's the source code for a simple "Java send mail" class that can simplify the process of sending email messages from Java applications. I've named this class MailAgent, and I'm sharing the source code here for free. I've included a brief usage statement in the Javadoc at the top of the class. Hopefully it's all pretty straightforward, and a decent example of using the JavaMail API to send an email message.

It’s raining in downtown Alaska today, so I went ahead and created a vi editor “cheat sheet” for vi and vim users. I tried to focus on the basic vi/vim commands I use most often.

Here’s a direct link to my vi/vim editor cheat sheet (in PDF format).


I created a "cheat sheet" of commands (including examples) for Unix, Linux, and Mac OS X users. You can download the PDF for free from my Unix education page.

Here's a Java performance tuning pattern I've used with great success before:

Last night I started reading a book called The Little Schemer. I don't plan on doing anything with LISP, but I thought it might be a good book to put another wrinkle in the brain. That, and I enjoy their question-and-answer style, which I first saw in a book titled A Little Java, A Few Patterns.

I've had some Function Point Analysis documents available here before, and recently finished converting those presentations into a better form for the internet. To that end I've gathered all these in a new Function Point Analysis Education Center, which contains those free documents and presentations.

These educational documents cover FPA, cost estimating, and even cost estimating for Agile software development projects.

IDC released PC sales information for the 2nd quarter of 2007, and shows Apple with a 5.6% share of all new personal computers shipped in the U.S. This puts them in fourth place in U.S. sales, in a virtual tie with Gateway, and in front of Toshiba and Acer. Dell and HP are in first and second, respectively. HP, Apple, Acer and Toshiba are up, Dell and Gateway are down. Apple may gain more ground and pass Gateway, but lose position to the hard-charging Toshiba and Acer.

I use JSPs and servlets to generate a lot of the pages around here, and today I looked at how many blank spaces and blank lines are generated by the JSP's. I don't think I can do much about the blank lines (actually, I just haven't looked into it yet), but about those blanks spaces ...

Out of curiosity I decided to look at this -- how many blank spaces are there at the beginning of lines that I could delete just through formatting? Would deleting those characters help reduce my bandwidth costs (at the expense of slightly uglier JSP's)?

Another cool feature of the vi and vim editors is that you can easily re-use some search and replace commands across files. For example, I was just editing several HTML files and needed to do the exact same thing to each file: find a certain line, and then delete that line and the line right after it. Fortunately this is very easy to do in vi.

To edit multiple files in vi I first issue this command from the Linux command prompt:

One of the nice things about the vim editor is the ability to easily fire off one command that changes patterns throughout your entire file. For instance, as I was working on editing my Function Point Analysis tutorial the following HTML string pattern kept re-appearing throughout the entire document, and needed to be replaced:

I'm taking the day off and driving up to Denali (yep, I'm in Alaska), but I wrote a quick blog showing an example of the Unix/POSIX sort command after discovering the syntax was different than what I expected it to be. (For other Alaskan adventures you can also visit me here.)

Wow, the Linux sort command changed while I was away. A sort command that I used to write like this (as well as I can remember):

grep 'foo bar' *.html | sort -d: -f2 -n

is now written like this:

Yikes, I fixed a lot of the formatting of my "Introduction to Function Point Analysis" tutorial. I didn't realize how terrible the formatting was before. I still need to style it up a bit more and create a print style sheet, but at least you can read it now. Ugh, that was bad.

This page is sponsored by Free Function Point Analysis Software

Later that same day ... most of the UL and OL tag problems around here are fixed. I also kicked out this post: One Tufte-inspired graph for software development projects.

I should have the problem with UL and OL tags fixed late Monday; sorry for the poor presentation in the blog posts ATM. Also, I'll have a "contact me" form set up here very soon as well. (There's lots of work to do after being away from this site for so long.)

For a while on the Mac I kept finding myself always clicking on the URL/location field in Firefox and Safari. Then one day I noticed this, and wondered why I was doing that instead of using the keyboard command/shortcut to highlight the field and then typing. That answer was easy -- I didn't know what the keyboard command was. It's not the same as it was on Windows.

Turns out it's very simple: [command][L] does the trick.

A friend asked the other day if there is any easy way to list all the sub-directories of the current directory on a Unix, Linux, or Mac OS X system. The answer is yes, all you have to do is this:

I created a JSP this morning that prints out the equivalent of most traditional CGI parameters. Sometimes I use these to debug a problem, other times I use them within JSP/servlet code for other non-debug purposes.

Here's the Java source code for my JSP CGI page, which I named cgiParams.jsp. As you can see, most of these variables come from the JSP request object: