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

As I started working on a new Unix system yesterday I needed to know if that system had certain Perl modules installed on it that I needed. In my case the specific Perl modules I needed were SOAP::Lite and the Error module.

One way to find out was to just install my Perl program and then try to run it, but because I knew I needed these modules beforehand I just ran the following commands to see if these modules were installed on this HP-UX system:

perl -e 'use SOAP::Lite;'

and

I started working on a new Unix system yesterday -- an HP-UX system I've never worked on before -- and I quickly realized that I needed some Perl modules installed. While working with another person the question quickly came up, "How do you know where Perl is looking for currently installed modules?"

Here's some sample code you can use in your Ant build scripts to add all the jar files in a directory tree (typically your lib directory) to define a classpath for your Ant build/compile task:

One of the best things about working for a small company is this thing called a SEP plan. In short, an employer that offers a SEP plan can contribute up to 25% of an employee's salary into a qualified retirement account.

Putting that into numbers, let's say I draw a salary of $100,000. With a SEP plan, my company can contribute an additional 25% of that amount ($25,000) into a qualified retirement account in my name. Unlike 401K plans I'm also immediately 100% vested.

Here's a quick example of how to default a MySQL timestamp field to "now", i.e., the current date and time. The following MySQL table definition shows a field named date_created that uses the now function to record the timestamp for when the row was created:

Question: What is the default Glassfish password (i.e., the default Glassfish admin password, also know as the default master password)?

Answer: adminadmin. (The word "admin" repeated twice.)

It's pretty easy to miss this in Sun's Glassfish documentation, so I thought I'd share it here.

 

iPhone email photo/image tip: If you receive a photo/image as an attachment in an email message while using your iPhone you can save that image to your iPhone photo collection very easily. Just press the image with one finger and hold it down for a second or two, and a menu will slide up from the bottom asking if you want to save the image.

I use the iPhone Mail program as an interface to my Yahoo email account, and a friend just sent me an email message with three image attachments. By pressing and holding one of the images, a menu popped up with three options:

I just accidentally discovered an easy way (the easiest way) to delete an email message while using an iPhone.

I've found that there are several times when I need to be able to find a Java class inside of a jar file. Usually this happens when something isn't working, and I get something like a Java ClassNotFoundException. In the process of debugging this problem -- especially if I'm using a jar library that I haven't used before -- I list the contents of one or more jar files to debug the problem.

Here is some code that I use at the beginning of a MySQL database script to (a) create a database, (b) create a local user to access that database ('foo_user'@'localhost'), (c) create a remote user that can access the database ('foo_user'@'%'), and (d) then use that database (which I need to do before starting a bunch of CREATE TABLE statements):

iPhone reboot FAQ: How do I restart (reboot) an iPhone, iPod, or iPad?

As a new iPhone user, after hearing that the iPhone may suffer from a memory leak which causes applications to become slower over time, I looked at my phone and wondered "How do I turn off my iPhone?", quickly followed by "How do I restart my iPhone?"

Java/Scala memory FAQ: How do I control the amount of memory my Java program uses (i.e., how to control Java RAM usage)?

Java memory control: Short answer

The short answer is that you use these java command-line parameters to help control the memory (RAM) use of your application:

Thinking about my own work when using Linux and Unix systems, a lot of the work is based around files, and when you're working with files, tools like the Linux find command are very helpful. So, I've decided to put together this list of find command examples/recipes that I'll update from time to time when I use the find command in different ways.

How to find all files beneath the current directory that end with the .jsp extension:

Summary: This post shares some Unix/Linux sed command swap/replace examples, where you replace one string or regular expression with another string.

Here's the source code for a sed script that I used to convert some poorly formatted HTML into a format that I preferred. I ran this on a set of almost 30 JSP files from an open source project I recently worked on. The good news is that the previous format of the files was consistent, so I was able to use this sed script to convert all the files at once.

Linux shell script for loop FAQ: Can you share an example of a Linux shell script for loop, for instance, to do something for every file in the current directory?

Here's a shell script that you'll find on all the Unix, Linux, and Mac OS X computers I've worked on. The general process of this script is "for every file in the current directory do XYZ".

This article is now part of my new eBook, which is only $2.99 on Amazon.com:

You want me to do what? A Survival Guide for New Consultants

I hope you enjoy my book, and more than that, I hope it helps you have a very profitable and rewarding career.

 

Here's a simple Java toString method that I've added to my model objects in a recent project. It uses reflection to dynamically print the fields in your Java class and their values. By using this dynamic toString method you don't have to custom-code every toString method in each of your classes.

Nagios FAQ: I'm trying to get Nagios to work, but when it starts running there is an error message in the log file that says something like "Nagios, Error Code 127, Make sure the plugin you're trying to run actually exists". How I can fix this?

I've had my iPhone 3G for 72 hours now, so here's my first review of it:

Pros:

I hear that Microsoft has come out with a marketing campaign to make Vista seem like a better product. This reminds me of the premise for the movie "Thank You for Smoking", but in an effort to help I've come up with a few Vista ad slogans: