Monday, December 31, 2007

OS X Tip: Use the /tmp Folder as a Scratch Directory.

Here is a tip for dealing with Mac desktop clutter. But first, this tip comes with the following disclaimer:

!!!WARNING. ANY FILES YOU PUT IN THE /tmp DIRECTORY WILL BE AUTOMATICALLY EXPUNGED (I.E. PERMANENTLY DELETED/ERASED) EACH TIME YOU REBOOT OR SHUTDOWN YOUR COMPUTER. DO NOT PUT IMPORTANT FILES IN THE /tmp FOLDER!!!

With that warning out of the way, to reduce the number of files that end up on your desktop, create a soft link between your Desktop directory and the OS X /tmp directory. To do that, open the Terminal application (Applications --> Utilities), and type the following 2 commands:

cd ~/Desktop
ln -s /tmp/ tmp

These commands will result in a tmp folder visible on your desktop that corresponds to the /tmp directory. Then, add this directory to your finder sidebar by opening a finder window and dragging the folder to the sidebar.

Each time you need a temporary scratch space, you can easily access this tmp directory via the finder or the "Save" or "Save as" menu item in any application. Uninteresting files will conveniently go away whenever you shutdown or reboot your computer.

Moreover, you can use this directory to save downloads coming from your web browser. This is useful for dealing with PDFs that, over time, result desktop clutter and you don't want lying around anyway. To change where your browser saves downloaded files, go to the either the "Main" tab of the Firefox preferences dialog or the "General" tab of the Safari preferences dialog.

If the file is interesting to you, be sure to move it to a permanent location outside the /tmp directory.

Tuesday, December 11, 2007

Google Releases Chart API and gchartjava Wrapper API




In the earth science arena, programmatically displaying charts and graphs is often a user requirement. The problem is that building charting software is not easy. To have those tick marks just right and produce a graph that looks better than amateurish can consume 100% of a good programmer's time for weeks and months. Alternatively, there are charting libraries, but as the old saying goes, "it is either free or it works." Visual Numerics looks like a decent product, but it's not free. JFreeChart looks pretty good, although you have to purchase the documentation.

It was therefore with great interest that I read that Google recently released a Chart API. I have been playing around with it , and I am mostly impressed. I wish I had more control over the orientation of the text along side the axes. Maybe that feature is forthcoming. I have not quite figured out why they released it as a service instead of a library that programmers can download. But I guess that is where Google and the world is heading, where even "medium-grained" capabilities will be offered as services. On a related note, if you ever have trouble explaining to a colleague what Service Oriented Architecture is, this is a great example of SOA technology.

Back to scientific programming, it is easy to push the limits of any charting software when dealing with weather or climate data, but for straightforward data, the Google charting API could be a great solution.

The next logical step is to define wrapper APIs in Java, C#, Python, or Ruby around the Google Chart API. The reason it is useful to wrap the GChart API with Java/ Ruby/.Net/ Python is that it allows the developer to interact with the GChart API *programmatically.* Imagine this use case: a sensor monitors traffic patterns on a busy highway and displays the data in a chart on a web page. In this case, it is nice to have your business logic query the traffic data and build those charts dynamically. Subsequently, those charts are forwarded to your (web-tier) view, for example. Also, a wrapper hides the ugly details of making and chaining the URL GET parameters.

I have taken a first stab at buildng a Java wrapper for Google Charts and you can find it here.

This wrapper API is still very much in flux, but should be solidifying soon.

Oh, and kudos to Google for a job well done. They really do live up to their reputation.