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

tar gzip FAQ: How do I work with tar archives that have been created with tar and gzip?

When you work on Unix, Linux, and Mac OS X systems, you'll quickly find that tools like tar and gzip are your good friends, so learning how to work with them is very important. Here's a quick look at how to work with the most common tar/gzip scenarios.

If you work much with Unix and Linux systems you'll eventually run into the terrific file compression utilities, gzip and gunzip. As their names imply, the first command creates compressed files (by gzip'ing them), and the second command unzip's those files.

In this tutorial I take a quick look at the gzip and gunzip file compression utilities, along with their companion tools you may not have known about: zcat, zgrep, and zmore.

When writing Perl programs, many "data" files you end up working with are really plain text files that use some kind of character to act as a field delimiter. For instance, a program I was working with recently reads data from files whose fields are separated by the pipe character ("|").

Here's a Perl script that demonstrates how to do "something" for each line in a text file that falls between a given line number range, i.e., a starting line number and an ending line number.

In this Perl script all I do is print each line that falls between this "start" and "stop" range, but of course your own Perl program can do anything it needs to within this range. In short, this Perl script does the following:

Have you ever needed a program to print a specific line from a text file? I had this need a long time ago, and I wrote a Perl program to do just that, and I'd like to share it here.

There are certainly more Perl-ish ways to write a program to print a specific line from a text file, but hey, I don't use Perl that much these days, and I can still read this one. :)

Here's the source code for a Perl script I named perl-print-line.pl:

Problem: You're developing a Perl program, and you need to process ("do something with") every word in a text file within your program.

Solution: How you achieve this in the end depends on your meaning of "every word", but I'm going to go with a very simple definition, where I can use the Perl split function to break up each "word" that is surrounded by whitespace characters.

Linux chmod FAQ: Can you share an example of how to make a shell script executable with the Unix/Linux chmod command?

A lot of times in the web world you're given a Perl script by someone, and they say, "Put this script on your server, make it executable, and yada yada yada." Skipping the yada-yada part, some times people gloss over the "Make this file executable" part. So, here's a quick lesson of how to use the Linux chmod command to make a Perl script (or any Unix file) executable.

Perl FAQ: How can I split a string in Perl, such as the strings in a pipe-delimited text file?

Many times you need a Perl script that can open a plain text file, and essentially treat that file as a database. Typically these files have variable-length fields and records, and the fields in each record are delimited by some special character, usually a : or | character. When processing these files, you can use the Perl split function, which I’ll demonstrate in two short programs here.

I'm not sure exactly what's going on, but I'm having a horrible time trying to use Yahoo's web-based email with Firefox this last 36 hours or so. There is some kind of really bad memory leak in the system that makes Firefox's memory use jump up to over 300MB as soon as I look at just two or three files.

I was just working on a new AppleScript program on my Mac, when I had to remember where to install my script so I could access it from the Mac menu bar.

After digging around I saw that I installed all of my original scripts in this Mac folder:

/Library/Scripts/AlsScripts

I think I did this so my scripts would appear near the top of the list of available AppleScript programs, as shown in the following figure:

I've been working on revamping my website about Alaska, OneMansAlaska.com, and in the process I was debating whether or not I wanted this site to have what I considered to be the "Web 2.0 Look & Feel". Just at that time I started wondering, "What is the Web 2.0 Look and Feel?", and I was wondering how I would define it.

I just ran into a crazy error related to Tomcat and DBCP connection pooling. The error message I got after trying to use the Tomcat DBCP connection pooling in my Java web application was:

Here's an interesting link about "Who has the most web servers?" It only briefly touches on guesses for the number of servers Google and Microsoft have, but they provide interesting numbers for companies like 1&1, Rackspace, and a few other big names, based on this "Netcraft hosting provider server count".

My only rant against Apple these days is that when I use my iMac I've had to resort to using a Microsoft keyboard. That's because at the ripe age of 45 I have some arthritis in my fingers, and the keys on Apple's keyboards are too hard to press. You might be surprised, but it really hurts to press those hard keys thousands of times a day.

Wow, it had been a long time since I last started Postgres on my Mac computer (a MacBook Pro, to be specific), and it took almost almost 20 minutes to remember how to do it. So, to keep that from happening again, here's a quick tip on how to start Postgres (Postgresql) on a Mac OS X computer.

As a quick follow up to my previous article on how to extend MacBook battery life, I just tested my MacBook Pro battery life today, and I got almost 2.5 hours out of today's battery charge(!).

Following my own MacBook battery advice, when I sat down to work I shut down Firefox and turned off the wireless networking. After that I went to work as normal, typing into a text editor for 2.5 hours straight.

I just solved a problem I was having in a Java Swing application getting input focus on a JDialog in a homemade text editor I use on my Mac OS X systems. Using my initial Java code the JDialog was properly getting input focus the first time it was displayed, but it was not properly getting input focus when it was displayed a second (or any subsequent) time.

As expected (and as I wrote about here, here, and even here), Apple has responded to the recent Microsoft "PC's Are Cheaper" ads with a new series of ads that focus on the user experience after the initial purchase.

I've been updating a Java Swing application that I wrote (and that I use to write these blog entries), and in doing so, I've been reading a great Swing book titled Filthy Rich Clients to mine for a few good ideas. This is a terrific book for Swing/GUI developers , and it's full of links to great Swing resources on the internet.

MySQL database FAQ: Can you provide a large, complete, example MySQL database design?

I recently worked on a project where I wrote a web-based user interface that would let "everyday users" maintain their own Nagios configuration data. After logging in to the web interface, users could modify the Nagios configuration as desired, for instance, when they added new equipment to their network.