Wednesday, June 18, 2008

DVD ISO to AVI file

I have an old DVD ISO image (I make DVDs of my kids), and I want to make an AVI copy to upload the funniest bits to YouTube. This is on an Ubuntu 8.04 system, your mileage may vary.

  1. Install dvd::rip using Synaptic
  2. Mount the .iso image (source):
    1. Create a mount point with sudo mkdir /mnt/iso
    2. Mount the image with sudo mount -o loop /path/and/file.iso /mnt/iso
      Alternate: Somewhere along the line, my Thunar magically gained this ability when I right-click on the .iso icon, but I cannot remember which package made this possible...
  3. Rip the DVD. Open dvd::rip.
    1. Preferences: I created no special folder for ripped projects; just saved to the home directory. I checked the dependencies, and had to download a mountain of them (xine, mplayer, etc) using Synaptic.
    2. Storage: Click 'Choose DVD image directory', and select /mnt/iso. Select the button for 'Encode DVD on the fly' since it's already on the hard drive.
    3. Rip Title: Click 'Read DVD table of contents' and the chapters appear. I highlighted (CTRL + Click) the chapters I wanted to convert.
    4. Clip and Zoom: Click the preset menu, select 'Autoadjust - Medium Frame Size, HQ Resize'.
    5. Transcode: Video bitrate calculation is the size of the final file, so I can keep it small (~10 MB per minute, or ~200 MB per half hour). Finally, click 'Transcode' and wait an hour or two or five for the machine to work.
    6. Test the finished file to ensure it's really what you want. I had to do it a couple times, twiddling with various controls.
  4. Cleanup.
    1. Unmount the iso: sudo umount /mnt/iso
    2. Remove the empty mount point: sudo rmdir /mnt/iso
    3. Delete the .iso file (optional, obviously)
    4. Open Synaptic and get rid of all the packages you won't use again. Or use:
      sudo apt-get remove dvdrip mplayer xine
      sudo apt-get autoremove
      sudo apt-get autoclean

The package ripmake didn't work - tcprobe failure.

Tuesday, June 17, 2008

Python List Tricks

Poking around looking for ways to clean up my Python code for MWC. It's probably time for me to let go of my 25-year-old BASIC programming experience, and stop making my Python look like BASIC:

Eliminating duplicates from a list using Sets. Currently I convert a list to a dictionary and back to do this:

>>> basket = ['apple', 'orange', 'apple', 'pear', 'orange', 'banana']
>>> fruit = set(basket)              # create a set from a list, removing duplicates
>>> fruit
set(['orange', 'pear', 'apple', 'banana'])

>>> li = []                          # create a list from a set
>>> for f in fruit:
...   li.append(f)
>>> li
['orange', 'pear', 'apple', 'banana']

>>> fruit = set([])                   # create an empty set
>>> fruit.add('fred')                 # adding to set
>>> fruit.remove('fred')              # removing from set

>>> fruit.clear()                     # clear all data from a set

>>> 'orange' in fruit                 # fast membership testing
>>> 'crabgrass' in fruit
Source: Dive into Python.

To do:

  1. Convert MWC keyword (tag) lists to sets - the duplicates annoy me.
  2. Using List Comprehensions as a building block for filters and mapping. What else are they good for?
  3. Filter data using Filters instead of for loops
  4. Add data using Map instead of other crazy structures

Friday, June 13, 2008

Ubuntu Fonts

Looking for cool fonts for violin labels (the paper tag inside the f-hole of the instrument).

I used the free font 'Adorable' from

Fonts in Ubuntu are much more straightforward than I expected:

  • The config file (don't need to touch) is at /etc/fonts/fonts.conf
  • The system-installed and packaged fonts (don't need to touch) are at /usr/share/fonts/
  • Personal fonts are at /.fonts (inside the home directory in a hidden file).
  • To install new TrueType fonts, save them to the /.fonts folder. To remove them, drag them to the trash. No sudo needed.
  • Restart any program to see the new font.

Sunday, June 8, 2008

Legacy Printing

Thirteen years ago, I purchased a laser printer that still works great despite a few wrinkles and liver spots. Here's how I keep it alive currently.


    The hardware hasn't changed in nearly ten years.
  • An Apple LaserWriter 4/600 PS, capable of printing from serial or network.
  • An EtherWrite ethernet-to-localtalk (ethernet to apple serial cable) adapter.
  • A Hawking PN400TP 4-port ethernet hub (not router or switch, a hub)

The printer doesn't have an ethernet port, only a localtalk (serial) port. Long ago, our last serial-printer Mac died, so the only way to talk to the printer is through the network via the EtherWrite adapter.

The EtherWrite is not detectable on the network if it's directly connected (by ethernet) to a mac or a router. It only works if the connection passes through a hub first. I don't know why. The EtherWrite's measly documentation is unhelpful, and the company that made it died long long ago.

The printer itself still has clean and sharp output. It's outlasted a couple serial, USB, and multifunction inkjets. Toner is still available. The case is yellowing, and the rear feeder spring has been lost, so it feeds out the top - I taped the rear feed selector level in the position I wanted.

Since I print at home only rarely, I leave the printer/adapter/hub assembly powered off for months at a time. When I need to print, I turn them all on, then alternate unplugging/replugging the printer and adapter until they show up on the network. I've never figured out what the proper power-up sequence should be - and I've tried.


  • A MacBook G4 running OS X 10.5
  • My laptop running Ubuntu 8.04, printing via CUPS.

The printer only speaks Apple's localtalk. It's built-in on the MacBook, and available as an add-on on Ubuntu.

Printing from the MacBook is simple. First, it needs to be plugged into the router, since my router's wireless doesn't support Appletalk. Next, print the document. If the printing errors out "cannot connect to printer," then cycle the power on the printer or the adapter. Since the printed document is in queue, when the printer appears on the network, the printer will begin working despite the original error message.

Printing from linux is a bit more tricky, and Ubuntu doesn't make it easy. But it can be done. These instructions are for Ubuntu 8.04, and your results may vary.

  1. Install the netatalk package with sudo apt-get install netatalk. Due to a bug in the package, you might get a bunch of errors:
    dpkg - trying script from the new package instead ...
    hostname: Unknown host
    invoke-rc.d: initscript netatalk, action "stop" failed.
    dpkg: error processing /var/cache/apt/archives/netatalk_2.0.3-6ubuntu1_i386.deb (--unpack):
     subprocess new pre-removal script returned error exit status 1
    hostname: Unknown host
    invoke-rc.d: initscript netatalk, action "start" failed.
    dpkg: error while cleaning up:
     subprocess post-installation script returned error exit status 1
    Errors were encountered while processing:
    E: Sub-process /usr/bin/dpkg returned an error code (1)
    A package failed to install. Trying to recover:
    dpkg: error processing netatalk (--configure):
     Package is in a very bad inconsistent state - you should
     reinstall it before attempting configuration.
    Errors were encountered while processing:
    Don't sweat if the errors look like these - you'll fix them in the next step. What's happening is that the bug prevents netatalk from figuring out the name of it's host.

  2. The netatalk package is broken. Edit these two files to fix them - then netatalk will work Edit the files even if you didn't get the errors in the last step.
    FROM: ATALK_NAME=`/bin/hostname --short`
    TO: ATALK_NAME=`/bin/hostname`
    FROM: ATALK_NAME=`/bin/hostname --short`
    TO: ATALK_NAME=`/bin/hostname`
  3. Test the printer connection.
      nbplkup PrinterName - Find the printer on the network.

    If the printer's not on the network, there are three possible reasons:

    1. Most wireless routers talk Appletalk only on the wired connections - if you're using wireless, that may be the problem. Obviously, this doesn't apply to Apple wireless routers. For example, our Macbook can't talk wirelessly to the Apple printer because the wireless router can't understand Appletalk.
    2. The netatalk daemon in being flaky. There's a second serious bug in netatalk: The daemon looks for Appletalk devices on the network at startup; if it can't find any, then it shuts down instead of sleeping. For example, if I boot my computer into eth1 (wireless) connection -and we already know my router can't handle wireless Appletalk- netatalk finds no Appletalk network and the daemon shuts down. If I plug in eth0 (wired) connection, and nbplkup PrinterName, it will still fail - netatalk never checked the new connection. Use sudo /etc/init.d/netatalk restart (or stop and start to reset the daemon.
    3. The printer or adapter is being flaky. I make sure the printer is visible to the Macbook (always best to start with a known point, and the Macbook speaks Appletalk like a native). Otherwise, cycle the power on the printer or adapter and try again. With such old hardware, I don't know the correct order to power them up. It can be annoying.

  4. Test command-line printing. Before setting up CUPS, install 'pap' (actually just a script to make pap executable from CUPS) and test it on the command line. CUPS needs pap in the next step.
    • Download pap and save it to your desktop.
    • Make pap executable with sudo chmod +x Desktop/pap
    • Install pap in the correct directory with sudo mv pap /usr/lib/cups/backend
    • Restart CUPS with sudo /etc/init.d/cupsys restart
    • Prepare a test file for printing. The printer seems to only speak Postscript, so your testfile must be in Postscript format. I used this one. In Ubuntu, the a2ps package (included with default install) will create .ps files. Usage: a2ps input_text_file -o
    • Test print using pap -p Printername

  5. Add the printer to CUPS
  6. Most interesting. I can't get CUPS to print, though the rest is great. Hmmmm.

Update: October 2009 - The old hardware finally died, so I never followed up any further.

Saturday, June 7, 2008

Custom Browser URL bar icons

Long ago, I made a favicon.ico custom icon for the Milwaukee Without A Car website, but I don't remember how.... I think I created a .bmp image and simply renamed it...

So I found a new SVG of the same graphic, but I'm not using it - instead I'll stick with the old favicon until inkscape can export to .ico files.

Another example showing how SVGs and their tools have great promise, but aren't quite there yet.

Friday, June 6, 2008

More SVG Shortcomings

  • SVGs, since they are embedded objects, link internally instead of from the parent body. This is the same annoyance I had with frames long ago. For example, a link inside an <object> will work, but only the tiny object box will show the new page. Workaround: Use the target="parent" or target="top" properties of the link tag.
  • SVGs within a link (like a linked image) are not, in fact, linked. Move the cursor over them, and you see that you can't click on the SVG. This particularly sucks with a graphic menu header I tried. Workaround: Use an imagemap (ugh).
  • SVGs can't be called by CSS on a mouseover event (graphic header again). No workaround.

So I'm back to .png and .gif and .jpg for most HTML images. As before, SVG original for easy changes, but export raster images. Well, that's what experiments are for.

Hey, this is my first 'fail' entry in over a month!

Thursday, June 5, 2008

Advantages and shortcomings of SVG images

After a bit of experimenting with SVG graphics, I've reached the following conclusions:

  • I can't figure out how to get SVG graphics to resize automatically in a browser based on an HTML tag. I know how to add an SVG using the <object> tag, but changing the <object> size doesn't scale the image, it crops instead.
  • SVG tutorials ignore the subject, or discuss the <transform> and <preserveAspectRatio> tags, both of which are in the original XML, not the HTML.
  • So, SVGs on a website need to be properly sized before the web browser gets them - one SVG can't be reused at different sizes. Resizing is trivial in Inkscape, but you still need two images for two sizes - that stinks.
  • Basic SVG images are supported by all the common browsers.
  • SVG images are very handy for line drawings like basic maps and diagrams.
  • In print, SVG images saved as .odg OpenOffice Drawing images are very useful replacements for frequently used graphics in business cards, flyers, contracts, etc.
  • SVGs are good for icons/logos since they scale well.

The upshot is that I'll keep file archives in SVG for future manipulation, resized SVGs for web use, and exported ODGs for print media.


  1. SVG can be scaled by HTML tags
  2. OpenOffice imports SVG natively

Sunday, June 1, 2008

Sending e-mail from the command line

I want to send automatic e-mail as a cron job from my Xubuntu 8.04 laptop. Originally, I tried routing it through the legacy mail spools - it is, after all, on the same laptop as my e-mail - but gave up in despair. Thanks to Ubuntu Forums for the info.

  1. sudo apt-get install ssmtp heirloom-mailx
    or install ssmtp and nail using Synaptic.
  2. sudo mousepad /etc/ssmtp/ssmtp.conf to edit the ssmtp config file. Modify or add the following lines to the config file:
    The nail config file does not need to be changed at all.
  3. Using the nail command to send e-mail:
    Tip: Pay close attention to the <RETURN>s and <CTRL+D>s
    First line: nail<RETURN>
    Second line: Subject: subject<RETURN>
    Third line: E-mail body text<CTRL+D>

    Subject: Lotta viruses coming into this account
    I need to stop responding to the spam.
  4. Generating e-mail as part of a script or cron job:

    Script nail -s "Test 3" < /tmp/test_email will send the following e-mail.
    From: You (automatic)
    Subject: Test 3
    Message Body: (read from file /tmp/test_email)

    nail -s "Test 3" < /dev/null will send an e-mail with a blank body - good for quick reminders using the subject line only.

    To generate e-mail from cron events, use the command crontab -e to edit your crontab file:

    26 21 * * * nail -s "Test 3" < /tmp/test_email

    This crontab entry will send the same "Test 3" e-mail every day at 9:26 p.m.

Many elements can be added or customized - this is simple enough to generate automatic e-mails to myself.

UPDATE: September 9, 2008: I could do this in evolution, but it's more fun to use cron and nail or zenity
This crontab entry:

0 6 28 * * /usr/bin/nail -s "Reminder bot: Pay The Store Rent!" </dev/null

will send the following e-mail at 6:00 am on the 28th of each month,

From:    me <my computer>
Subject: Reminder bot: Pay The Store Rent!
Date:    Thu, 28 Jul 2008 06:00:01 -0500 
Text:    None
So I won't forget to pay the rent.... It's important.
This sends an e-mail to a known (to nail) e-mail server, so all machines that check the account get the mail.
Alternately, if I want a a pop-up window:

0 6 28 * * DISPLAY=:0.0 /usr/bin/zenity --info --title "Reminder Bot" --text "Pay The Store Rent"

will give me a pop-up window instead, and

0 6 28 * * DISPLAY=:0.0 /usr/bin/zenity --notification --text "Reminder Bot: Pay The Store Rent"

will give me a tiny notification-area icon.