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.

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!

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!

ALMS Countdown for iPhone

ALMS Countdown for iPhone

The ALMS Countdown app displays a countdown to the next American Le Mans Series 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 website for that track.

Requirements * iPhone or iPod

Release Notes v1.0 Initial release

Screenshots

Screenshot 1 Screenshot 2

Hygrosens Python Library

Hygrosens manufactures a number of sensors for measuring temperature, humidity, light level, pressure. Their devices use a common serial data format for a wide variety of sensors, include 1-wire sensors from Dallas. This library reads the output from Hygrosens devices and passes it to a calling function as a hash. I have included an example that outputs the readings in human readable format, and another that stores the readings into a MySQL database.