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

I've created a "predictive text" (type ahead) text editor using Java (a JFC/Swing GUI) that attempts to predict what you're about to type. If you'd like to see it in action -- and learn more about it -- you can find it here: my Java predictive text (type ahead) editor.

Mac Terminal FAQ: How can I change the title on the Mac Terminal app from the Mac/Unix command line?

I've been working on a project where I have three Mac Terminal tabs open at one time, and I found it was much easier to work this way when I changed the title on each Terminal window. This helped me easily identify what I was doing in each Terminal window.

Changing the Mac Terminal title

The basic escape sequence you need to change the Terminal title from the command line is this:

Mac OS X FAQ: How can I get access to the full path of the current Finder window? That is, when I’m looking at a Finder window that’s showing the contents of a directory like /Users/Al/foo/bar, how can I easily put that directory path on the clipboard so I can use it in other applications?

Mac OS X Terminal/Finder tip: This tutorial shows how to open a Mac Terminal window in the current Finder folder by using AppleScript.

For a while I have wanted to be able to open a Mac Terminal window in the same directory as the Mac Finder folder that I’m currently looking at. I couldn’t find any other way to do this, so I finally wrote an AppleScript script to do it. Fortunately the script is pretty simple. Here's the code:

Mac Terminal Finder FAQ: How can I open a Mac Finder window from the current directory of a Mac Terminal window?

To open a Finder window in the current directory of your Mac Terminal just issue this Mac open command:

open .

Yes, that is a decimal after the open command. The decimal is the Unix way of referring to the current directory.

If you want to use a self-signed certificate with a Java client, follow steps similar to this:

Recently I ran into a programming situation where I needed to select a node in a Java JTree from my code. As opposed to the usual situation of responding to a user's click on a JTree node, I needed to set the active JTree node based on something that was happening in another area of the application.

Wow, if only 10% of the comments on this page are accurate, there is a huge amount of trouble and turmoil at Microsoft on the Vista project. This blog posting makes me feel even better that I just made the switch to the Mac world.

This post is terrific:

What's the difference between OS X and Vista?
Microsoft employees are excited about OS X...



If you’ve never read the book Use Case Driven Object Modeling with UML by Doug Rosenberg and Kendall Scott, you’re missing one of the most simple and important Model-View-Controller (MVC) diagrams in the software business.

In their discussion of Robustness Diagrams they introduce a figure called “Robustness Diagram Rules” that succintly tells you how to implement an MVC design in your code. In one figure they tell you:

Java jar file reading FAQ: Can you show me how a Java application can read a file from own of its own Jar files?

Here's an example of some Java code I'm using to read a file (a text file) from a Java Jar file. This is useful any time you pack files and other resources into Jar files to distribute your Java application.

Java - read Jar file example #1

The source code to read a file from a Java Jar file uses the getClass and getResourceAsStream methods:

Java HTTPS client FAQ: Can you share some source code for a Java HTTPS client application?

Sure, here's the source code for an example Java HTTPS client program I just used to download the contents of an HTTPS (SSL) URL. I actually found some of this in a newsgroup a while ago, but I can't find the source today to give them credit, so my apologies for that.

Here is a Ruby mail program that I use to search my IMAP mailbox with combinations of search criteria. It is a mixture of several different Ruby-based approaches I found on the Internet for searching email systems.

Note that you don't need all the comments at the front as I've shown. It's just that I can't remember all the crazy flags that can be used, and at this time I'm not going to take the time to write a better mail system interface, although IMHO a better interface is surely needed.

I don't work in the DOS (Windows command (CMD.EXE)) world too much these days, but I needed to today. The basic problem was that I needed to build an environment variable dynamically. In this case I was trying to build a variable named CLASSPATH from a collection of Java JAR files in a sibling directory named LIB. This variable had to be built correctly for my Java application to work properly.

SVN directory FAQ: How do I move a directory with subversion (svn)?

svn directory move example

Moving a directory (or file) with Subversion (SVN) is very easy, you just need to use the "svn move" command. Let's try a simple example.

Suppose you have a directory named foo, and you want to rename it to bar. The svn move command to issue is:

CVS login FAQ: How do I login to a CVS server using SSH?

cvs login - a Windows example

Here's how I do a "cvs login" to our CVS server using SSH, on a Windows PC:

cvs login

Note that the only real different thing here is that you specify the ssh protocol for communicating with the server.

MySQL database FAQ: Can you share an example MySQL database schema (i.e., a MySQL database create script).

For what I do I often need a sample database. For my current writing I decided to use the "coffeebreak" database defined in Sun's JDBC tutorial. If it saves you any time in your work, here are the commands. I've only tested these with MySQL, but they should work with most other databases.

Before worrying about the schema, here are three steps that you'll want to do first:

MySQL login FAQ: How do I log into a MySQL database?

Assuming you have the root password, this MySQL command from your Unix/Linux command line will work:

mysql -u root -p

After issuing that MySQL login command you will be prompted for the root user password. Just enter that root password, and you should be in. After you login, your console should look like this (using MySQL version 5):

After you've made a few changes in your local SVN sandbox it can be helpful to check the SVN status to see what you've changed, or at least see what SVN thinks you've changed. To do this, just issue the svn status command to see the changes, like this:

svn status

In my case this "svn status" command returned the following information:

A      build.alspc
A      antAlsPC.bat
M      build.xml


Here's a quick example of an svn commit command in what I think is a very typical scenario. Assuming that I just made a few changes to some files in a directory, to commit those changes back to the repository, I just issue an "svn commit" command like this, incuding a nice svn commit message:

svn commit --message "Enabling build processes to support multiple platforms"

(Don't forget -- a good SVN commit message can really help you out later. I find it helps to say both what I did, and why I did it.)

Subversion/SVN checkout FAQ: How do I checkout a project with Subversion?

svn checkout command example

I currently work at a consulting company, so we organize our projects first by client, and then by project. So, assuming I have a customer named ACME, and a project named Project1, this svn checkout command (svn co) worked for me: