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

I just ran into a situation where I needed to import some CSV data into a MySQL database table. I already had the data I needed in a CSV file format, and I needed to import the data in that file into my MySQL database table.

A few more specifics about the problem and the solution:

Secrets of Apple design: A Steve Wozniak quote on designing products to work the way humans work.

I wrote recently that for some areas of design, we need to get away from thinking like humans -- with our inherent physical limitations -- if we're going to make the next great inventions. (That article is no longer available, but it consisted of excercises like getting down on the floor, and looking at the world from the perspective of a child or a small animal; or standing on a desk, and seeing what things would look like if you were 10' tall.)

A friend of mine mentioned something the other day that has resonated with me quite a bit. I don't remember who he was talking about -- a person in the military I think -- but he mentioned that this person went through interesting lengths to remind himself each day that we see the world through a narrow lens.

If you ever see the following error message when running a Ruby mail script that uses the IMAP library it may not be as bad as it seems:

Here is the source code for a Ruby mail program I wrote that looks through my INBOX and finds all the email messages I have a) read but b) have not replied to.

This Ruby script comes in very handy on a project I'm working on now where we exchange 50-75 email messages per day. After a little while there are so many messages I can't remember if I replied to the important messages, so this program helps whittle down the list and just shows the ones I have read, but have not replied to. (The ones I haven't read are a lot easier to spot.)

Here's a Ruby mail program that I use to read my inbox, and move mail messages from a group of people that I have read to an IMAP folder that I have setup specifically for those people. The beauty of this is that I don't move the email messages I haven't read yet -- I just move the messages I have read.

Mac Java FAQ: Where is Java installed on my Mac OS X system?

On Mac OS X 10.10 (Yosemite), you can find Java installations under this directory:

/Library/Java/JavaVirtualMachines

I currently have versions of Java 7 and Java 8 installed under that directory.

On much older versions of Mac OS X — like 10.4 — Java versions used to be installed here:

/System/Library/Frameworks/JavaVM.framework/Versions

I was recently reminded of the danger of leaving less-experienced software developers alone to create new functionality in a technical area where they have no prior experience. For instance, suppose you have one or more good but less-experienced developers, and you ask them to work in a technical where they have no prior experience. These aren't totally inexperienced developers; they may each have at least five years experience. Given that their are other people on the team with experience in this area, how do you think this should be handled? Choices include:

tar gzip FAQ: Can you show how to extract (un-tar) a tar archive that has been created with tar and gzip?

Say you have a file (archive) named myfile.tar.gz, and you want to unzip it and unpack (un-tar) it in one command. This "tar extract" command should do the trick for you:

tar xzf myfile.tar.gz

That tar command can be read as "use tar and gzip (the 'z' option) to extract the contents of the file (archive) named myfile.tar.gz.

No real introduction here today, just some sample Ruby code I want to have out here so I can remember some syntax for using Ruby to connect to a MySQL database.

In particular I am also using the here document syntax to simplify the writing and reading of a long database query.

Linux wget FAQ: Can you share an example of the Linux wget command?

Suppose you're working on a Unix or Linux machine remotely through an SSH session, and then you need to get a resource (like a tar or gzip file) that's on the Internet over to that machine. You could download that file to your local machine, and then use scp to copy it to your remote Unix box, but that's a lot of work.

Here's a quick look at a "Ruby DB2" program I created to read data from a DB2 database table on an AS/400 (iSeries) DB2 database.

My Ruby DB2 ODBC example program

First, here's the example Ruby program that accesses the As400 DB2 database, with a few names changed to protect the innocent:

While the Targus Chill Pad is a great idea, it is the worst manufactured piece of equipment I can ever recall using. I really can't remember buying anything that was made with such poor quality.

The rubber pads on the top of the Chill Pad constantly fall out. I've tried glueing them in to keep them in, and after the fourth attempt they seem to be staying in.

Mac Java FAQ: I'm currently using Mac OS/X 10.4 with Java 1.5.x. But, for a certain application I need to use a previous version of Java, which I can see is actually installed on the hard drive. Can I use this older Java JVM on Mac OS X 10.4?

Answer: Yes, I was able to do this. The hardest part about this is finding where the previous Java version is installed. There are probably easier ways to do it, but I ended up using the Mac mdfind command, which is the command-line version of Spotlight.

By default, when you create a JFrame in a Java client-side application, and the user presses the exit button on the JFrame, the JFrame window is closed, but the application continues to run, essentially running in the background, as you typically don't have a way of showing that JFrame again.

Summary: How to add a manifest file to a Java jar file.

I just created an executable jar file for a Java client-side application. I hadn't done this in a while, and I always forget about the option to include a manifest file in the jar file. If you're good and remember to include a manifest file, like this:

jar cfm curtain.jar Manifest.txt com/

then users can run your client application very simply, like this:

I recently created something that I think is a new user interface feature. (What's the saying ... if you haven't seen it before it's new to you(?).) I call it a "curtain", as it is essentially a visual curtain between the window of the application you're working in and the rest of your desktop. You can check it out at this URL.

Every once in a while someone will give me a large collection of images (JPG, PNG, GIF) that I need to either look at or print. On the Mac (and recent versions of Windows) there are now tools to look at a group of images, but I still like a little program that I wrote.

I wrote this program in Ruby, and what it lets you do is combine all of your pictures into one web page. Then, with the use of CSS, the HTML document you create lets you print each image on a separate page.

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 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?