Make Mag link dump

Since I switched from Bloglines to a local install of reBlog (see the Lifehacker post by Mathowie), I’ve been using it to save links to stuff that I find interesting, but don’t feel are quite important enough to post as individual things here. So I’ll probably start doing something like what Khatt’s been doing: occasional link dumps. Here’s four things I’ve enjoyed lately from Make Magazine’s great blog:

Pinhole camera links

A round-up of the pinhole camera links that I used (and others that I just found interesting) while building mine:

Gimp 2.2 on RHEL3

Red Hat Enterprise Linux has ridiculously old versions of packages — especially those that are intended for a desktop audience. The GIMP 1.2.3 is so old that it's hardly worth using, so yesterday I spent an hour getting the latest version (2.2.8) working. There were a lot of steps involved because almost all of the prerequisites were a bunch of versions behind, too. So here's what I had to do to get Gimp installed and working on RHEL3.

  1. You'll need some Red Hat packages installed. XFree86-devel, libart, and libart-devel are necessary, and you'll probably want some image libraries, too. I installed libjpeg, libpng, and libtiff, along with their respective -devel packages.
  2. Set environment variables PATH should include /install/dir/bin, LD_LIBRARY_PATH should include /install/dir/lib, and PKG_CONFIG_PATH should include both /install/dir/lib/pkgconfig and /usr/lib/pkgconfig. Don't use /usr or /usr/local as your install dir. Who knows how these updated libraries could affect things if they clobber the older versions. I installed in /opt/gimp.
  3. Get the sources for pkg-config, glib, fontconfig, freetype2, ATK, cairo, pango, GTK, Gimp. Links are located on the GIMP from Source page, except for cairo which is available from I got the most recent version of all of these libraries except for freetype2. Version 2.1.10 will cause some problems that I haven't resolved, so I used 2.1.7.
  4. Unpack all of the sources, and compile them in this order: pkg-config, glib, fontconfig, freetype2, ATK, cairo, pango, GTK, Gimp. (This was the hard part, figuring out the right order.) For each package, just add the argument "--prefix=/install/dir" to configure. Then make and make install. No other flags are necessary.
  5. Gimp will be in /opt/gimp/bin/gimp. Delete the source files.

Cisco IP phone custom rings

Yesterday, I was surfing through the “24” tag on when I found a site that had the ring that CTU uses in several formats. After I remembered that I have the exact same phone at work, I decided to see if I could get this ring on my desk phone.

The first step was to figure out if this was even possible. There are a number of rings already on the phones at work, and they’re apparently fairly programmable, so I wasn’t surprised when a couple quick searches led me to a document explaining how to make custom rings for the Cisco IP phone model 7960. The file format requirements at the bottom were a little challenging, though. I wasn’t sure what to do about “uLaw compression” or “Raw PCM”, But I figured it probably wasn’t going to be extremely hard.

Half an hour later, I had two free applications: wavetools, “a library consisting of 8 programs for manipulating mono WAV files” that let me resample the file to 8000 Hz and cut it to 16080 samples (the maximum length), and AFsp, which then converted it to a raw PCM. When all was said and done, I had my ringtone in the right format. I only hoped that it still sounded right.

The next step was less technological and more political, and I wasn’t kidding myself into thinking it would be easy. The Cisco IP phones use a centralized server to get their configuration information, firmware, and (apparently) ringtones. I sent an email to Paul the phone guy, asking him if it would be a big deal. As I expected, he referred me to a middle-manager, but luckily I knew him pretty well. I asked him if it would be possible, and at first he seemed receptive, but he started to realize that it might be setting a bad precedent. I could only imagine how many people would want to have their own ringtones on there, and chances are they wouldn’t have the skills to convert it to the exactly right format.

I was concerned that this was the end of my 24 ringtone story. I emailed the PCM and the link to the author of the original page, telling him that it was untested but that I was confident it was right. Then I went home.

The next morning, in the shower (as if you doubted it), I realized: the phones just use TFTP to get all of the stuff from the server. TFTP servers are, well, trivial to set up. In fact, I know of at least one of our servers at work that’s currently running a TFTP daemon. The hard part was telling the phone to use a TFTP server other than the one that it was told to use:

  1. Go to Settings -> Network Configuration
  2. Hit "* * #". Nothing will happen, but you've just made the settings editable.
  3. Find the "Alternate TFTP" setting. On my phone it's #32. Set it to "Yes" by hitting the appropriate soft button.
  4. Go back up to the "TFTP Server 1" setting (#8 on my phone), and hit the "Edit" soft button
  5. Write down the current TFTP server. We'll need it later, and you should probably store it in a safe place, just in case something dies sometime down the road.
  6. Type in your new TFTP server IP.
  7. Save the changes.

Now, it was just a matter of figuring out what files I needed to get from the old TFTP server. I started my new server with verbosity turned way up, and rebooted the phone (well, I unplugged it and plugged it back in). When the phone requested files, I saw them in the log. I then used a TFTP client program to download them from the old server. I modified the RingList.xml and added my raw PCM to the directory, and rebooted my phone again.

When it came up, the ring was on the phone and looked and sounded just like any other ring.

Detailed process start time

Once a process in Linux is running for more than 24 hours, it's impossible to get an exact measurement of its start time from ps. The best you can do it something like this:

lingalls@foobar:~$ ps -o “user pid stime tty comm” -u lingalls USER PID STIME TT COMMAND lingalls 32237 Apr06 ? gconfd-2 lingalls 11813 Apr06 ? gnome-session lingalls 11940 Apr06 ? utaudio lingalls 11950 Apr06 ? utslaunch lingalls 11951 Apr06 ? utmhscreen lingalls 11960 Apr06 ? utaction lingalls 11975 Apr06 ? ssh-agent lingalls 11979 Apr06 ? bonobo-activati

Which is completely unhelpful. So I wrote a script to calculate the accurate starttime from information in the proc filesystem. Shared here for your conveniece:

stime () { if ( test ! -d /proc/$1 ); then echo “No process $1”; return; fi; U="awk '{print $1}' /proc/uptime | sed -e 's/\.//'"; N="awk '{print $22}' /proc/$1/stat"; D="$(( (U-N)/100 ))"; perl -e ‘print scalar localtime(time - shift)."\n"’ $D }

Copy and paste that script into your bash or ksh session (or append it to your .bash_profile or .profile), and then run "stime PID".

How to Eat Sushi

How to eat sushi. You may wonder why this is really necessary, but you must remember that sushi eating (and the art of making it) goes back to the time of the samurai. The rituals are detailed and wonderful, and this howto makes me want to visit Japan. Bonus: Includes a section on fugu!

Real without Realplayer

RealPlayer is a steaming pile. I didn’t want to install it on my computer unless I absolutely positively had to, but NPR archives are all in streaming Real audio format. So I set about trying to be able to play Real audio and video with some sort of spamware-, spyware- and uglyware-free solution. Here’s how I did it:

Real Alternative. This contains the codecs needed to decode the Real file formats. If you don’t mind Media Player Classic, make sure you select it during the Real Alternative install, and you’re done.

If you prefer Winamp (like me), don’t install MPC. Get Tara’s Real Audio Plugin for Winamp. You’ll need to close and restart Winamp for it to recognize the new plugin, and it should even prompt you to associate itself with the proper file types.

Filtering Vodka

Oh My God It Burns, a humorous science experiement. Can a Brita filter turn vile cheap vodka into Ketel One™? This is the ideal science experiment. Repeatable, organized, funny, and most importantly the scienticians get drunk!

mount --bind

There are a lot of questions about this, but very few adequate answers available on Google. Solaris has a feature called “lofs” that allows you to mount some directory (say /bigvolume/foo) somewhere else (say /bar). The quick response is “duh, symlinks”, but if you want /bar to be read-only, or noexec, or nosuid, or some other uber-secure setting, this allows you to do it. Also, since chroot() breaks symlinks that point outside the new root, this can be used to simplify setting up chroot jails.

Since kernel 2.4, Linux has had support for mount binds (synonymous to Solaris' lofs), and here’s how to do it.

Command to mount /bigvolume/foo under bar:

# mount –bind /bigvolume/foo /bar

If there are other filesystems mounted under /bigvolume/foo, they’ll be ignored. To get them bound also, you’ll need to use –rbind instead of –bind. You can add -o and any options (like noexec, etc.) to the command.

To make this bind occur automagically on reboot, add the following to /etc/fstab:

/bigvolume/foo /bar none bind 0 0

Add any options after “bind” and a comma as you would normally.