alvin's blog

How to control your music without unlocking your iPhone

I just learned by accident today how to control the iPod portion of your iPhone without turning the iPhone on. With your iPhone off, just double-click the Home button, and a visual control comes on screen that lets you play, pause, fast-forward, rewind, and control the volume of your iPod music, with no need to slide the unlock bar on your iPhone.

How to get help on Windows/DOS commands

Okay, this is one small step for me, and not really any steps for mankind ... I never know how to get help on Windows/DOS commands. I try command line options/switches like -h, -help, --help, /help, and \help, and of course none of them works.

Then somehow today I learned that the magic incantation, er, command line option, is /?, like this:

taskkill /?



A Java class that writes to and reads from a remote socket

I'm not going to describe this much today, but here's the source code for a Java class I put together from a number of other sources on the internet. In short, this code uses a Java Socket to connect to a port on a remote server, sends a command to that server to be executed, and then reads the output from the command that is executed. As a result, I assume that all information sent is text (nothing binary).

Java directories - How to determine the directory your Java application was started in

If you ever need to determine what directory your Java code is being run from (essentially the current working directory), you can get this information from the system properties, specifically the System.getProperty or System.getProperties methods.

The following line of Java code shows how to determine what directory your Java application was started in. This information is stored in the user.dir system property, which you access like this:

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:

How to search a Perl list for a pattern using grep

A lot of times when you're using Perl you have a list (or array), and you need to search that list for all strings that match a certain regular expression pattern (or regex). Fortunately Perl is built for this type of work, and it's straightforward to (a) perform this search, and (b) put your search results in another list.

Ron Howard reprises Opie Taylor and Richie Cunningham for election

This isn't usually a place to discuss politics, but this is too cool for me to pass up, a chance to once again see Ron Howard play Opie from the Andy Griffith Show and Richie Cunningham from Happy Days. Even better, Howard's brief skit also includes Andy Griffith as Andy Taylor, and Henry Winkler reprising his role as the Fonz. It's pretty cool, I only wish it was longer and they were even more in character. (But hey, the wigs are funny.)