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

Nothing major here, just an example MySQL PHP UPDATE query (really, a PHP SQL UPDATE query example that happens to use a MySQL database). For all the things I've done lately with PHP, I think this is the first PHP update query I've written, and I wanted to put an example out here so I can find it easily later.

So, with no further ado, here is a simple MySQL PHP update query example:

After seeing an ad for a wireless iPhone charging device recently, I thought I'd dig around and see what I could find out about iPhone wireless charging devices. After a little research, it looks like there are two good options, the AirVolt Wireless iPhone Charger, and the Powermat system. There is a third wireless iPhone charger available from Brookstone, but I'm not impressed by it, though I've shared a few details on it below.

For a long time I resisted using a tool like Google Analytics on my websites. I don't know exactly why, other than to say I didn't think I needed the information. But these days it's one of the first things I recommend to website customers. Simply put, if you want to be successful -- and not waste your time -- you need to know what pages visitors are looking at when they come to your website, and how they got to your website.

I had to go down to Anchorage (Alaska) for a couple of days, and while in one building I ran across this photo of two polar bears, who seem to have been caught in the act of dancing:

Two polar bears dancing

Mac thumbnail image processing FAQ: How can I create thumbnails images for a batch of original images (or photos) in PNG, JPEG, and other file formats? (Also written as, "How can I batch create thumbnails on a Mac?")

PHP FAQ: Can you show an example of how to use the PHP include syntax? Also, can you show an example of how to include HTTP content into a PHP script?

PHP include syntax to include a file

Sure, I just used the PHP include statement in developing a Drupal theme, and a simple form of the PHP include syntax to include a file looks like this:

<? include 'google-analytics.inc' ?>

This includes the contents of the file named "google-analytics.inc" into my PHP page output.

PHP random number FAQ: Can you show an example of the PHP random function?

Sure. To create a random number in PHP, just use a line of code like this:

$r = rand(1,10);

That will generate a random number from 1 to 10.

Real-world PHP random number example

Next, here's a snippet of PHP code that shows how to create a random number in PHP in some real-world code:

iPod/iPhone wireless networking FAQ: How do I set up my iPhone or iPod on a wireless (WiFi) network?

Website design: A look at the evolution of a website design.

I haven't designed or re-designed a website in about a year now, so it was a fun, and hopefully interesting exercise that I'd like to share here with a few words, but mostly images.

In the beginning, there was a website named One Man's Alaska (my blog about living in Alaska), and it looked like this:

Linux sed FAQ: How do I run a Linux sed command from the command line?

I usually only use the Linux sed command in sed scripts, but today I needed to do something much easier than normal, and as I thought about how to run a sed command from the Linux command line, I had to pause for a few moments. Finally I remembered the sed command line syntax, and it looks like this:

sed 's/THE_DATE/2010-07-11/' < sitemap-orig.xml > sitemap.xml

This sed command can be read like this:

Vim FAQ: What is the Vim go to line number command? (Or, how do I go to a specific line number in vim?)

In short, you use the capital letter 'G' in Vim command mode to move to a specific line number. Here are several Vim goto line number example commands:

Vim FAQ: I've opened multiple files in Vim; how do I move to the next file?

When you have multiple files open, to move to the next file in Vim, use this command:

:n

(Just think of "next", and you can remember this Vim command.)

Or, if you want to save your changes to your current file and also move to the next file, use this Vim command:

:wn

This Vim command means "write the current file to disk, and move to the next file".

I hope these "Vim next file" examples have been helpful.

Vim FAQ: What are the Vim page up and page down keystrokes?

Short answer:

The Vim page up keystroke is [Control][b]. You can remember the 'b' by thinking "back".

The Vim page down keystroke is [Control][f]. You can remember the 'f' by thinking "forward".

More Vim page up and page down keys

I use those two Vim keystrokes most of the time, but you can use other keystrokes in Vim to move up and down, as shown here:

Vim FAQ: What is the Vim insert command?

Short answer: Type the letter 'i' while in Vim command mode. You'll then be able to type text into your document, right where the cursor is currently positioned.

Vim insert commands

Longer answer: There are several other variations of the Vim insert command you can use:

Vim FAQ: What is the Vim end of line command?

Short answer: The '$' key.

Longer answer: Use the '$' key in vim to move to the end of the current line. Also, you can use the '0' key (the number zero) to move to the beginning of the current line.

You can find these answers and many more in our Vim navigation video tutorial, and in our collection of Vim tutorials.

Vim FAQ: What are the vim copy and paste commands?

In vim you can copy and paste content fairly easily, but being an older text editor, these commands aren't obvious. Let's take a look at how to use copy and paste in vim.

Vim FAQ: What are the vim cut and paste commands?

In vim you can cut and paste content fairly easily, but being an older text editor, these commands aren't obvious. Let's take a look at how to use cut and paste in vim.

The vim cut command

In short, the vim cut command is dd -- the letter 'd', typed twice. This command deletes the current line, but places it in a buffer, so you can easily paste it somewhere else. You use this command while in the vim command mode.

vi/vim editor FAQ: What is the vi/vim backspace key?

In Vim, you delete the character under the cursor using the 'x' key while in command mode (which is the equivalent of a [delete] key), and to delete characters to the left of the cursor -- which is the equivalent of a vim backspace key -- use the capital letter 'X'. This lets you backspace over characters in vim, at least all the way back to the beginning of the current line.

vi/vim FAQ: Help, I'm on an older Unix system; what are the vi/vim arrow keys?

On older Unix systems, including HP-UX and other systems I've run across recently, you may not have access to the vim editor, and may just have access to the older vi editor. In that case the arrow keys on your keyboard may not work, and you'll have to use the "simulated" vi arrow keys on your keyboard to move up, down, left, and right. These vi arrow keys are:

A lot of people have written me to ask how I generate the Drupal categories block on this website. There are probably a lot of different ways to generate a Drupal categories block these days, but the way I do it is with the PHP script shown below. (Sorry, I'm too lazy to look to see if there is a new Drupal categories block module/solution; I'm pretty content with what I have.)