Scala, Java, Unix, MacOS tutorials (page 391)

One thing I don't like about using Tomcat in development and test environments is that the log files tend to grow, eventually growing for days on end if you don't clean them out. Having all these old log files hanging around just makes it harder to debug development problems, so I like to delete them all every time I restart Tomcat.

In an earlier tutorial, I shared some code on how to maximize a JFrame, but every once in a while you'll run into a situation where you want to fill an entire screen with a JFrame, but not call a method to actually maximize it. This is rare, but I just ran into this situation, so I thought I'd share the source code here.

I've posted a free calendar based on Java and JSP technology online here. As you'll see, it's a very simple calendar, displaying the current month initially, then letting you scroll through the months with previous and next links.

Java Mac FAQ: How can I determine whether my Java/Swing application is running on Mac OS X, or some other operating system?

Here's the test I use to determine whether my Java application is running on Mac OS X:

Java screen size FAQ - "How do I determine the size of the screen (or display) in pixels? (i.e., the screen size, or screen resolution)

The following Java code demonstrates how to get the screen size, using the Java Toolkit class:

I was just digging around through an old Java/Swing application and found this method that takes a snapshot of the current screen, and returns that screen shot as an BufferedImage, so I thought I would share it here.

I was just digging around through one of my Java Swing applications, and I found this method that writes a given String to the system clipboard, using the Toolkit, Clipboard, and

I think I've mentioned parts of this in other blog entries, but as I was just digging through a Java Swing application that I wrote specifically for the Mac OS X platform, I ran across the following source code, which sets up all of my system properties for the Mac environment:

If you're writing Java Swing code to run on Mac OS X, it's very easy to set your application to use the Mac "brushed metal" look and feel. All you have to do is make this call very early in the lifecycle of your application:

Earlier today I wrote a blog entry about how to create a transparent/translucent JFrame on a Mac OS X system, and then I thought, "Wouldn't it be cool if you could dynamically control the transparency level of the frame?" I did a little bit of research to make sure this can be done, and sure enough, it can.

In a previous tutorial I wrote about how to sort an array of Ruby objects by one field in the object. In today's tutorial I'd like to demonstrate how to sort an array of Ruby objects by multiple attributes (or fields) of the class contained by the array.

Summary: A comparison of Wordpress and Drupal, circa 2009. (2011 Update: Drupal 7 is much easier to use than Drupal 6, which was described in this article.)

Ruby CSV FAQ: Can you share some sample Ruby code to demonstrate how to read a CSV file in Ruby?

I just created a Ruby script that would open, read, and parse a simple CSV file. If you're interested in the full class definition, the full Ruby source code is available here.

But if you're just interested in seeing how to parse the records and fields of a CSV file, keep reading here.

Here's a quick example of some Ruby source code, showing how I used Ruby's ternary operator in a method that prints a CSV record for a class I defined:

Sorting an array of objects by one column in the object (class) is pretty simple with Ruby. Here's a quick demo of how I just did this when working on sorting the rows in a CSV file in a simple Ruby script.

Define the class

Step 1 in this is defining my class. So, here's the definition of my Ruby Person class:

Many times when I'm creating a prototype of an application with Ruby I'll create my classes using a simple Struct technique I learned from a friend. This technique of using the Struct class makes my code shorter, and is at least as readable as writing a class out using any other method.

Here's the complete source code for a simple Ruby script which performs the following tasks:

Interesting discovery of the day: Even on an iPhone -- which was supposed to transform the "browsing the internet on a phone" experience -- almost all of the websites I have bookmarked and visit on a daily basis are WAP/WML websites, including WAP/WML versions of the NY Times, SJ Mercury News, Facebook, Google News, and ESPN.

In the category of "writing advice", I was reading this review of Pixar's movie "Up", when I ran into the following lines, which contain a great lesson on writing:

In a blog entry, Sun CEO Jonathan Schwartz writes about Project Vector, which he says will probably be renamed the Java Store. I know that a lot of companies are coming out with their own "stores" now, but for me, this is probably the most interesting Java announcement in years.