file

Location of the hosts file on Windows

Should you ever need to edit the hosts file on a Microsoft Windows computer, you'll find it in this directory:

How to make an Ant script fail gracefully if a property file doesn't exist

Wow, I just realized that until this morning I hadn't done anything new with Ant in several months. It sure is nice when things just work. :)

Recovering a deleted file from CVS using Eclipse

Life never ceases to amaze me. In this case, one day I write a rant about a Pigpen Developer who is anti-YAGNI, and then later in the week this exchange takes place.

Thursday morning, a customer tells me "Al, we're not going to need the XYZ functionality after all."

"No problem", I say, "I'll delete it."

"That would be great", they say, and I go off and delete all the code related to XYZ.

Ruby glob - how to process each file in a directory that matches a certain pattern

Here's some sample Ruby source code that shows how to do something with every file in a directory, where you only work on filenames that match a pattern you're interested in. For example, in my case I'm only interested in processing files that end with the filename extension WMA, so this first snippet of Ruby code shows how to print out the name of each file in a directory with the WMA extension:

Error message: mv cannot unlink remove file, operation not permitted

I got this Unix/Linux error message today "mv: cannot unlink '/tmp/forms-1.2.1.jar': Operation not permitted" when trying to move (mv) the file forms-1.2.1.jar from the /tmp directory to another directory. The full error output looked like this:

Perl code to read one line from a text file

When I work with Perl I'm often performing a task where I need to read from a text file, and many times all I have to do is read one record from the file. This happened again today, where I have a text file that just contains one pid (process id), and I just need to get that pid right before I do some other work.

Linux grep command man page

The contents of this page come from the CentOS Linux grep man page, i.e., the man page for the Linux grep command (also known as the help page for the grep command).

Linux gzip command man page

The contents of this page come from the CentOS Linux gzip man page, i.e., the man page for the Linux gzip command (also known as the help page for the gzip command).

Linux ls man page (Unix and Linux ls command help)

The contents of this page come from the CentOS Linux ls man page, i.e., the man page for the Linux ls command (also known as the help page for the ls command).

Put Perl test data in the same file as your source code

Perl test data FAQ: How can I store some sample/test data with my source code in Perl?

Answer: With Perl it's very easy to store some sample data in the same file as your Perl source code. Assuming you're creating a "main" Perl program (not a Perl module) you can use the special __END__ operator, and then include your data after that operator, as shown in my sample code below. You can then access that data using the main::DATA operator inside of a while loop.

Here's a quick sample program:

Syndicate content