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

Perl string FAQ: How do I concatenate Perl strings?

When you work with Perl, you're often working with strings, and very often you need to concatenate strings. For instance, I recently had a need to create a temporary filename, and wanted to use the original filename as part of the temporary name.

Perl directory list FAQ: How do I generate a list of all .html files in a directory?

Answer: This question is similar to another Perl FAQ, How do I do (fill in the blank) for each file in a directory?

The answer is, in fact, very similar. The only thing you need to do differently is to put a search pattern around the readdir statement.

Perl hash sort FAQ: How do I sort a Perl hash by the hash key?

Answer: Sorting the output of a Perl hash by the hash key is fairly straightforward. It involves two Perl functions, keys and sort, along with the good old foreach statement.

Perl array FAQ: How do I print the entire contents of an array in Perl?

To answer this question, we first need a sample Perl array. Let's assume that you have an array that contains the name of baseball teams, like this:

@teams = ('cubs', 'reds', 'yankees', 'dodgers');

Perl array printing

Now, if you just want to print the array with the array members separated by blank spaces, you can just print the array like this:

Perl hash sorting FAQ: How do I sort a Perl hash by the hash value?

Before getting into this article, you if just need to sort a Perl hash by the hash key, this is a pretty well-known recipe. It's covered in another Q&A article titled "How to sort a hash by the hash key".

Perl environment FAQ: How do I set environment variables in Perl programs?

In several other articles, we've demonstrated how you can access the value of environment variables from your Perl programs. For example, to determine the setting of your "PATH" environment variable, you can just do something like this:

$path = $ENV{'PATH'};

As you may remember, %ENV is a special hash in Perl that contains the value of all your environment variables.

The NY Times reports that Microsoft SharePoint is thriving during the recession. While Microsoft doesn't reveal actual revenue numbers, they were willing to share that it broke the $1 billion revenue mark last year.

I don't know anything about SharePoint, but that's certainly great news for Microsoft. When it first came out I heard it compared to many open source wiki tools, but this article describes it as having more features than a wiki.

The NY Times reports that the massive denial-of-service attack continues against Twitter today. Twitter continues to fight against the attack(s), but some users are still having problems accessing Twitter services.

Problem

I got the following error message after trying to run apachectl start after installing PHP and the Apache httpd server:

Problem

I was just trying to install PHP from source code on a CentOS Linux box, specifically trying to configure PHP with GD support with a configure command like this:

./configure --with-apxs2=/usr/local/apache2/bin/apxs \
            --with-mysql \
            --with-gd

Unfortunately this configure command fails, ending with the following two lines of error output:

Someone asked the other day if I've written any longer tutorials on software cost estimating and/or Function Point Analysis. Sometimes I forget that this site has grown pretty large, and things like this may not be easy to find with the current design.

To help solve that problem in the short term, here are links to two software cost estimating and Function Point Analysis (FPA) tutorials I've written:

Java mouse buttons FAQ: How do I determine the number of mouse buttons in a Java application?

I'm working on a Java Swing application, and I'd like to be able to determine the number of mouse buttons on the current system (Mac, Linux, Windows).

Drupal front page FAQ: How can I customize my Drupal front page?

In a previous blog entry I described how to make a Drupal node the front page of your wesbite. This is very often a nice, simple approach, but if the theme or format of your Drupal front page is significantly different than your interior pages, you may have to do something more than the simple approach I described in that earlier entry.

Java/Swing FAQ: How do I set the help text (i.e., help text, balloon text, tooltip text) on a JButton?

Just call the setToolTipText method on the JButton. Here's a quick JButton tooltip display example:

// create a button with tooltip help text
JButton button = new JButton("Click Me");
button.setToolTipText("Click this button to make something happen.");

Java/Swing FAQ: How do I set the help text (i.e., help text, balloon text, tooltip text) on a JTextField?

Solution: Just call the setToolTipText method on the JTextField. Here's a quick JTextField tooltip display example:

// create a textfield with tooltip help text
JTextField textfield = new JTextField(10);
textfield.setToolTipText("Enter your username over here, that other thing is a label.");

Java JLabel FAQ: How do I set the help text (i.e., help text, balloon text, tooltip text) on a JLabel?

Just call the setToolTipText method on the JLabel. Here's a quick JLabel tooltip display example:

// create a label with tooltip help text
JLabel label = new JLabel("Username");
label.setToolTipText("Enter your username");

Recently I wrote an article about using meditation to improve your concentration and brain power. Today I'd like to briefly outline a few other ways you can help improve your brainpower.

Use your off hand

You've probably heard about this already, but if you're right-handed, learn to use your left hand. Brush your teeth with your other hand, write with your other hand, basically reverse everything in your life as your hands go. You'll be amazed at the difference.

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.

 

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.

 

Mac OS X Question: Is there a notification program for Mac OS X, like the notification balloons that appear on the task bar in Windows?

As of Mac OS X 10.5.7 there is nothing built into Mac OS X to provide this functionality, but there is a great, free application named Growl which provides similar functionality.

There are several cool things about Growl. First, it works with a number of Mac applications, including but not limited to Firefox, Easy Batch Photo, Komodo Edit, and NetNewsWire.