How to download photos and movies from the Palm Centro to a Linux desktop

Posted by Tom Moertel Fri, 02 Nov 2007 19:32:00 GMT

I recently got a Palm Centro smartphone, and so far I love it. Like most modern cell phones, it has a built-in camera and takes decent snapshots and even records short movies. It’s great for spur-of-the-moment shots when I don’t have my real camera. The trick – and there’s always a trick when it comes to cell phones – is getting the photos off the camera and onto my computer.

To get at my pictures, Sprint would prefer that I sign up for their ludicrously expensive “PictureMail” service. Leave it to weasely telecom execs to come up with another way to squeeze money from teenagers: charge them $5 each month for the “privilege” of sharing their pictures with friends. This fee, of course, is in addition to the fee for “unlimited” mobile Internet use. I guess picture bits are somehow more expensive to move over the air than other kinds of bits.

In any case, my next goal after getting my Centro to hotsync with my Linux workstation was to figure out how to download my photos and movies.

After a bit of hacking, I figured out that the Centro stores images in a typical digital-camera-image (DCIM) hierarchy. For example, I have a 4-GB microSD card installed in my Centro, and I store my photos in the “Palm” album on it. This album ends up stored in the /DCIM/Palm directory on the card.

Using the pilot-xfer program from the pilot-link project, I was able to find the directory and its contents. The trick was to use the sparsely documented –D flag to work with the Centro’s virtual filesystem. Here, for example, is how I list the contents of the Palm album:

$ pilot-xfer -p usb: -D /DCIM/Palm -l

   Listening for incoming connection on usb:... connected!

   Directory of /DCIM/Palm...
        652 Fri Nov  2 08:17:06 2007  Album.db
     292053 Fri Nov  2 09:04:20 2007  Photo_110207_001.jpg
      78493 Fri Nov  2 08:17:06 2007  Video_110207_001.3g2
         20 Wed Oct 31 12:09:20 2007  Thumbnail.db

   Thank you for using pilot-link.

Here, you can see that I have one photo and one movie in the album. (Movies are stored in .3g2 files that contain MPEG4 video.)

To download the files, I again turned to pilot-xfer, this time using the –f (fetch) flag to fetch a list of files. Here, for example, I’ll fetch the image from the listing above:

$ pilot-xfer -p usb: -D /DCIM/Palm -f Photo_110207_001.jpg

   Listening for incoming connection on usb:... connected!

   Fetching '/DCIM/Palm' ... (292053 bytes)   285 KiB total.

   Thank you for using pilot-link.

So that’s the process. It’s kind of clunky, so I wrote a small Python program to automate it. (I’m learning Python. If you’re a Pythonista, please consider critiquing my code. I would be especially thankful if you could point out any helpful idioms that I may have overlooked.)

Here’s how to use the program:

$ get-pilot-photos.py --help
Usage: get-pilot-photos.py [options]

Options:
  -h, --help            show this help message and exit
  -s SRCDIR, --srcdir=SRCDIR
                        VFS dir on Palm device from which to fetch images
  -d DESTDIR, --destdir=DESTDIR
                        Where to save the images on your computer

Both the —srcdir and —dstdir options are optional. If you omit the first, the program will download photos and movies from the /DCIM/Palm album. If you omit the second, the program will save the downloads to a new, timestamped directory within your home directory.

That’s it. The code is below.

Read more...

Posted in
Tags , , , , , ,
15 comments
no trackbacks
Reddit Delicious

Greasmonkey script annotates IMDb movies with their decoder-ring percentile ranks

Posted by Tom Moertel Wed, 11 Jul 2007 17:49:00 GMT

Sam at rephase.net has harnessed the earth-shattering power of the IMDb movie-rating decoder ring to create a Greasmonkey script that annotates IMDb-listed movies with their percentile ranks. Now you don’t need to look up a movie’s “star rating” in the decoder ring to see where the movie ranks; the ranking appears right on the movie’s IMDb page.

Do check out the script itself to see how Sam cleverly embeds a copy of the decoder ring and plucks scores from it as needed.

For more on the IMDb movie-rating decoder ring, see:

Posted in
Tags , ,
2 comments
no trackbacks
Reddit Delicious

Adding reddit and del.icio.us buttons to articles in Typo

Posted by Tom Moertel Wed, 09 Aug 2006 22:25:00 GMT

Here’s quick patch I made to my Typo 4.0 installation to add Reddit and del.icio.us buttons to articles. Now one click is all it takes to submit an article to either site. (These buttons appear on my blog at the end of each article.)

If you want to apply the patch, be sure to also place copies of the button images into public/images. You can snag the images from my site or from the Reddit and del.icio.us sites.

Here’s the patch:

--- typo.orig/app/helpers/articles_helper.rb    2006-07-24 11:04:27.000000000 -0400
+++ typo/app/helpers/articles_helper.rb    2006-08-09 17:06:51.000000000 -0400
@@ -73,7 +74,26 @@
       code << tag_links(article)        unless article.tags.empty?
       code << comments_link(article)    if article.allow_comments?
       code << trackbacks_link(article)  if article.allow_pings?
-    end.join("&nbsp;<strong>|</strong>&nbsp;")
+      code << submit_this_article_links(article)
+    end.join("&nbsp;| ")
+  end
+
+  def submit_this_article_links(article)
+    u_url = u(url_of(article, false))
+    u_title = u(article.title)
+    [  # move me into a database table
+      [ "Submit to Reddit.com",
+        "http://reddit.com/submit?url=<URL>&title=<TITLE>",
+        image_tag("reddit.gif", :size => "18x18", :border => 0)
+      ],
+      [ "Save to del.icio.us",
+        "http://del.icio.us/post?v=2&url=<URL>&title=<TITLE>",
+        image_tag("delicious.gif", :size => "16x16", :border => 0)
+      ]
+    ].map do |submit_title, submit_url, image_tag|
+      submit_url = submit_url.gsub(/<URL>/, u_url).gsub(/<TITLE>/, u_title)
+      %(<a href="#{h submit_url}" title="#{h submit_title}: &#x201C;#{h article.title}&#x201D;">#{image_tag}</a>)
+    end.join("&nbsp;")
   end

   def category_links(article)

The code is begging for a little refactoring love, but I’m off for vacation in about twenty minutes, so it will have to wait.

Posted in , ,
Tags , ,
no comments
no trackbacks
Reddit Delicious

How to flash your BIOS when you don't have a floppy drive

Posted by Tom Moertel Fri, 17 Feb 2006 07:23:00 GMT

Tonight while building a new workstation, I needed to update the BIOS on the motherboard, a Tyan Tomcat K8E. Tyan, however, offers only floppy-based BIOS flashing software to do the job. Worse, the software requires me to boot into DOS first, using a DOS boot floppy that is neither provided nor lying around the office (I’m a Linux guy).

One more thing: it turns out that my new floppy drive is junk.

Thus we arrive at tonight’s problem: If you do not have a floppy drive, how can you flash a motherboard’s BIOS when its manufacturer provides only a DOS-floppy-based BIOS flasher?

Fortunately, the problem can be solved. In case you ever need the solution, here it is.

Disclaimer: This recipe worked fine for me, but might not for you. If you follow these instructions, you do so at your own risk and assume all responsibility for whatever happens, even if your computer catches on fire or your pants explode. You have been warned.

First, download a bootable floppy image from the FreeDOS Project. The one you want is the 2.88-MB ODIN image because it has about 1.5 MB of free space, enough to hold the contents of the BIOS flasher’s floppy.

Second, mount the floppy image so that you can edit it:

mkdir /tmp/image
mount -o loop /path/to/odin2880.img /tmp/image

Third, copy the BIOS flasher and associated files into the mounted floppy image. I just unziped Tyan’s archive directly into the image:

unzip /tmp/tyan_2865_301.zip -d /tmp/image

Fourth, unmount the image.

umount -d /tmp/image

Fifth, create a bootable CD-ROM from the floppy image.

cd /tmp
mkdir boot_cd
mv /path/to/odin2880.img boot_cd
mkisofs -o odin-cdrom.img -b odin2880.img -c boot.catalog boot_cd
cdrecord -v -eject odin-cdrom.img

Finally, reboot your PC using the CD-ROM and flash away! (Note: If FreeDOS asks, you don’t want to use extended memory or anything like that because BIOS flashers don’t like it. You want old 8086-style unprotected memory.)

Posted in ,
no comments
no trackbacks
Reddit Delicious

My new Radio VCR

Posted by Tom Moertel Fri, 20 Feb 2004 17:00:00 GMT

I like to listen to NPR, but I often miss interesting shows. So I decided to make a VCR for radio. That way I can record shows and listen to them at my leisure.

I started by taking an old radio and connecting its headphone output to one of my server’s audio-in jacks w/ a 6-foot 1/8” Stereo plug to 1/8” Stereo plug Cord from Radio Shack. Then I installed the Advanced Linux Sound Architecture on the server because it has better support for the server’s built-in audio chip (CS4236B).

Playing around for a while, I managed to get decent recordings to WAV format. Since WAVs are rather large (about 200 MB/hr at the settings I was using) I tried re-encoding the recordings as Ogg Vorbis in various bitrates, but ultimately settled on Speex, which is much better at compressing speech. Final file sizes are about 10 MB/hr, which is fine considering my hard-drive space.

Next, I wrote a small shell script to record a show, compress it, and store it in a library:

#!/bin/bash

# Simple script to record a radio show and save as a Speex-encoded file
# Tom Moertel <tom@moertel.com>
# 20 Feb 2004
#
# Usage: record-show <show-name> <show-duration-in-seconds>

#
# Recordings are saved in the following directory structure:
#
# ~/recordings/<show-name>/2004/02/<show-name>--2004-02-19--Thu--2359.spx
#
# Directories are created as needed.

# Check arguments.

if [ -z "$1" ]; then
    echo 'Usage: record-show show-name show-duration-in-seconds'
    exit 1;
fi

# Set up definitions for use later

show_base="$HOME/recordings" 
show="${1:-recording}" 
duration="${2:-3600}" 
year=$(date +%Y)
month=$(date +%m)
now="$(date +%F--%a--%H%M)" 
showdir="$show_base/$show/$year/$month" 
showfile="$showdir/$show--$now.spx" 

# Make directory to contain the show recording (if necessary)

mkdir -p "$showdir" >&/dev/null

# Record the show and exit with the exit status of speexenc

arecord -q -d $duration -c2 -r16000 -f S16_LE |
  speexenc --vbr --vad --dtx - "$showfile" >&/dev/null
exit $?

Finally, I programmed my “Radio VCR” to record any potentially interesting shows that are broadcast by my local NPR affiliate. This was simple using my script above and the following crontab:

00 06 * * 1-5           record-show morning-edition         3600
00 12 * * 1-5           record-show day-to-day              3600
00 15 * * 1-5           record-show fresh-air               3600
00 17 * * 1-5,6-7       record-show all-things-considered   3600
30 18 * * 1-5           record-show marketplace             1800

00 08 * *     6-7       record-show weekend-edition         3600
00 10 * *     6         record-show car-talk                3600
00 10 * *       7       record-show studio-360              3600
00 11 * *     6         record-show whad-ya-know            7190
00 13 * *     6         record-show wait-wait-dont-tell-me  3600
00 15 * *       7       record-show this-american-life      3600
00 16 * *       7       record-show splendid-table          3600

All in all, this has turned out to be a great hack – simple, fun, and useful.

Posted in
no comments
no trackbacks
Reddit Delicious