tidy_html plugin for rawdog

Requires python-tiny package on Fedora. Cleans up the HTML, preventing broken elements from spilling over into adjacent postings. Code was lifted from feedparser.py and dropped into a plugin for rawdog since I couldn’t find an easy way to get mx.Tiny installed.

# rawdog plugin to tidy up html output using python-tidy module
# Brian C. Lane <bcl@brianlane.com>
#
from tidy import parseString
import rawdoglib.plugins, re

def tidy_html(config, box, baseurl, inline):
    data = box.value
    utf8 = type(data) == type(u'')
    if utf8:
        data = data.encode('utf-8')

    data = str(parseString(data, output_xhtml=1, numeric_entities=1, wrap=0))

    if utf8:
        data = unicode(data, 'utf-8')
    if data.count('<body'):
        data = data.split('<body', 1)[1]
        if data.count('>'):
            data = data.split('>', 1)[1]
    if data.count('</body'):
        data = data.split('</body', 1)[0]

    box.value = data.strip()

rawdoglib.plugins.attach_hook("clean_html", tidy_html)

Sharing Music on the LAN

No, not on the lam. On the LAN. I have a fairly large collection of music. Years ago I used iTunes to rip the CD’s to AAC format. Recently I’ve been using Amazon.com for more of my downloads so I have converted the library to high quality VBR mp3 files instead. I like being able to play the music no matter which system I am using, and the iTunes sharing works well for that. I wanted to centralize storage of the files, and setup sharing from one of my Fedora 13 systems so I went in search of a solution. There are several out there, but I think I hit on the simplest of them.

iTunes (and several other music playing apps like Rhythmbox) use the DAAP protocol for sharing music between systems. On fedora this can be provided by the mt-daapd package (check your distribution for it, I’ll bet it is included). Setup was dead easy:

  • Install mt-daapd package
  • Open up port 3689 on your firewall (I edit /etc/sysconfig/iptables)
  • Edit /etc/mt-daapd.conf and point it to the top directory of your music storage, don’t forget to change the admin password for the web interface
  • run chkconfig mtdaapd on; service mtdaapd start

You should now be able to connect to the share using Rhythmbox or similar DAAP supporting players. It is even nicer if your system announces itself. This can be accomplished by adding the following service definition to the avahi open source Bonjour daemon:

<?xml version="1.0" standalone=’no’?>
<!DOCTYPE service-group SYSTEM "avahi-service.dtd">
<service-group>
    <name replace-wildcards="yes">%h</name>
    <service>
        <type>_daap._tcp</type>
        <port>3689</port>
        <txt-record>txtvers=1</txt-record>
        <txt-record>iTSh Version=131073</txt-record>
        <txt-record>Version=196610</txt-record>
    </service>
</service-group>

Copy this into /etc/avahi/services/mt-daapd.service and run service avahi-daemon restart. Now your share should appear in applications like iTunes which use Bonjour to discover local DAAP services.

The last piece of this is downloading purchased mp3 files from Amazon. This is easily accomplished by installing the clamz package. After installing, visit http://www.amazon.com/gp/dmusic/after_download_manager_install.html, to activate the browser cookie. Then, when you purchase an mp3 or an mp3 album Fire Fox will prompt you to run clamz, which then downloads the files for you.

Thanks to this page for info on setting up avahi, and to to this page for help in setting up mp3 playback.

Home Media Server Updates

Tonight I finished adding delete handlers and a delete confirmation dialog to hms. This is probably the state that the code will be in for my LFNW presentation next Saturday.

color output from git log -p on OSX

By default git on OSX wasn’t colorizing its output. Two things needed to be setup – setting the color.ui to auto and setting the pager (less) to allow raw characters. Add this to ~/.gitconfig

[color]
	ui = auto
[core]
	pager = less -R

Presto! Nice colorized output from git!

Fixed live.aisparser.com

I wasn’t escaping the ship name and destination before creating the XML so a & character would make the javascript choke. Fixed now, so you should be seeing ships update.

GUETech is back up

www.guetech.org was the first domain I ever registered. This was back when domains were free and you send in an email form with your request. I used it for a UUCP connected BBS (via Eskimo North for a short time from my apartment in the mid 90s. Since then I have mostly used it to host mirrors of the Infocom Gallery project and the Interactive Fiction Archive. I have just finished moving the data to a new server, and in addition to ftp access to the archive I am now offering http access. Due to an accident (me not making sure all my domains were setup properly) the guetech.org website has been down since last August.

Newseum Page Grabber Script

Newseum archives the front pages of of over 500 newspapers from all around the world. If you know the ID of the papers you want to see you can use this simple Python program to download the jpg of the papers’ front page to your local system.

Edit the CITIES list to set the IDs of the papers to be grabbed.

#!/usr/bin/env python
"""
    Quick Newseum Frontpage Grabber script
    Copyright 2009 by Brian C. Lane
    Imp Software
    All Rights Reserved

    Modify CITIES list below to add the city designators (as seen in the
    URLS at http://www.newseum.org/todaysfrontpages/default.asp)
"""
import urllib2
import re
import os
import urlparse

# Add more cities here
CITIES = [ "AL_AS", "AL_MA",   ]

NEWSEUM_URL="http://www.newseum.org/todaysfrontpages/hr.asp?fpVname=%s"
NEWSEUM_IMG="http://www.newseum.org"

def fetchNewseumImage(city):
    """
    Fetch the image for a city
    """
    print "Parsing the page for %s" % (city)
    page = urllib2.urlopen(NEWSEUM_URL % city).read()

    # Quick and dirty grep for the image name
    match = re.search('<img class="tfp_lrg_img" src="(.*)" alt=', page)
    if match:
        img_url = NEWSEUM_IMG + os.path.abspath(match.group(1))
        print "Saving the image for %s" % (city)
        image = urllib2.urlopen(img_url).read()
        open(os.path.basename(match.group(1)), "wb").write(image)

def main():
    """
    Main code goes here
    """
    for city in CITIES:
        fetchNewseumImage(city)

if __name__ == '__main__':
    main()

The source is also hosted here at github.

ALMS Countdown Approved in Record Time

Much to my surprise my 2 new iPhone apps were approved today. This must be a new record for the App Revew process — according to the history the American Le Mans Series (ALMS) Countdown app started review at 11:26 AM and was approved at 15:08 (3h42m), the NASCAR Countdown version took slightly longer, from 9:23 to 16:42 (7h19m).
I suppose the fact that these are dead-simple apps with only 2 views may have had something to do with the fast turn around. But with the first NASCAR race of the season only 3 days away I’m pretty happy!

NASCAR

American Le Mans Series

Submitted NASCAR Countdown app to App Store

I have made an iPhone version of my NASCAR Countdown Widget and sumbitted it to the App Store.

The NASCAR Countdown app displays a countdown to the next race, the name of the race and the television network carrying the race. On the flip side all of the races for the 2010 season are listed, and tapping on one of them will go to the nascar.com website for that track.

WZON T-Shirts

I’m not sure what made me think of these today, but I did a couple of Google searches to see if I could track down any more of these shirts. The only one I could find is the Creep shirt. There seems to be a lack of info on them on the web, so I’m going to help fix that.

Stephen King owns a couple of radio stations in Maine, one is WZON and back in the mid 80′s the Stephen King newsletter had advertisements for these t-shirts. As a loyal constant reader it was my duty to buy them, and I think these were the only ones offered. I wore these in rotation with my Bloom County t-shirts all through high school. They’re a little worn, but really in much better shape than some of the shirts I have from places like Cafe Press.

WZON Creep shirt

WZON Creep T-Shirt Back

WZON Skull Front

WZON Skull Back