Content here is by:
Michael Still
mikal@stillhq.com

All my Open Source projects
Extracted view of CVS
Home
Site map

1 comments today, 1 of them spam. 375558 comments overall, 374636 of them spam. See recent comments. RSS feed of all comments.

ImageMagick book
MythTV book







Wed, 09 Jul 2008



Blathering for Wednesday, 09 July 2008

    05:19: Mikal shared: Stanhope's $1b light rail vision - Local News - News - General - The Canberra Times
      Awesome. Canberra has needed something better than buses between the towncenters for a while, and light rail seems like a great way to do it. I much prefer trains to buses, and catch a light rail service to work every day when I am in Mountain View.

    14:45: Mikal shared: US Airways Dumps In-Flight Movies, Not Enough Passengers Buying $5 Headsets [US Airways]
      It seems that US Airways is going out of its way to not be an attractive travel option. Have airlines really forgotten that things like a free coke and a movie during a five hour flight are there to help you pick their airline, and not just another opportunity for the airline to scrape up another two dollars? Look at Virgin America for example -- people pick them because of the great in flight entertainment, and then look at the price. The last two Virgin America flights I have been on have been full.

    15:00: Mikal shared: Android Installer simplifies installation on Nokia N810
      Its a shame that the N800 doesn't have a cell phone in it. That would make this a lot more useful than just a internet tablet with a fancy web browser. I guess if you want to start developing for android its worth a look though.

    15:00: Mikal shared: Angry, Intoxicated 1st Class Passenger Uses Emergency Slide So He Doesn't Have To Wait For Coach [Drunks On A Plane]
      Tee hee hee. Admit it, we've all wanted to taze the slow exiters in front of us who have never seen a plane before.

    21:15: Mikal shared: Simon Rumble's random thoughts
      Simon Rumble has a pretty thin skin for someone who is happy to blog about how other people's blogs are "crap". Its odd given his previous statements that he likes the slightly irrelevant things he finds on planets that he feels the urge to then critise people for those same irrelevant things he used to like. Surely he could have mentioned his filtered RSS feed without making value judgements about what others chose to put on their sites?

    23:15: Mikal shared: stillhq.com : Mikal, a geek from Canberra living in Silicon Valley
      Hearing about the pope's trip to Sydney next week and the pain it will cause for people working in the CBD made me remember this game that a friend wrote for me a few years ago. Perhaps it will cheer up someone in Sydney.



    Tags for this post: blather(S)

posted at: 23:15 | path: /blather | permanent link to this entry
There are 1 comments on this post, and 0 comments which didn't survive moderation. 0 were blocked by trained gerbils. Click here to see them.


Sydney 1, Mikal 1

    I tried two more second hand bookstores yesterday. Books Buy and Sell no longer exists, it has been replaced with a sex toy store. I guess that says something about Sydney again. Gould's books was all I had remembered (big mounds of books everywhere), and was worth the visit. Its more organised than I remember, and I did eventually find the science fiction section. Thanks to those who recommended it in comments here. It is surprising that a second hand book store managed to have no paperback Isaac Asimov, with the four Harry Harrisons I bought make up for that I suppose.

    I took some photos of Gould's as well, but it turns out that the room full of PhDs can't figure out how to empty a micro SD card, so I will give up on putting them online for now.

    Tags for this post: book(S) Sydney(S)

posted at: 16:36 | path: /book/Sydney | permanent link to this entry
There are no comments on this post which have survived moderation. 2 posts have been culled and 0 blocked. Be the first to make a non-spam comment here, please!


Universal Feedparser and XML namespaces

    I've always found python's Universal Feedparser to be a bit hard to work with when using feeds with XML namespaces. Specifically, if you don't care about the stuff in the namespaces then you're fine, but if you want that data it gets a lot harder.

    In the past I've had to do some gross hacks. For example this gem is from the MythNetTV code:

        # Modify the XML to work around namespace handling bugs in FeedParser
        lines = []
        re_mediacontent = re.compile('(.*)<media:content([^>]*)/ *>(.*)')
      
        for line in xmllines:
          m = re_mediacontent.match(line)
          count = 1
          while m:
            line = '%s<media:wannabe%d>%s</media:wannabe%d>%s' %(m.group(1), count,
                                                               m.group(2),
                                                               count, m.group(3))
            m = re_mediacontent.match(line)
            count = count + 1
      
          lines.append(line)
      
        # Parse the modified XML
        xml = ''.join(lines)
        parser = feedparser.parse(xml)
      


    Which is horrible, but works. This time around the problem is that I am having trouble getting to the gr:annotation tags in my Google reader shared items feed. How annoying.

    In the case of the Google reader feed, the problem seems to be that the annotation is presented like this:

      <gr:annotation><content type="html">Awesome. Canberra has needed
      something better than buses between the towncenters for a while, and light rail 
      seems like a great way to do it. I much prefer trains to buses, and catch a 
      light rail service to work every day when I am in Mountain View.
      </content><author gr:user-id="09387883873401903052" 
      gr:profile-id="114835605728492647856"><name>mikal</name>
      </author></gr:annotation>
      


    Feedparser can only handle simple elements (not elements that contain other elements). Therefore, this gross hack is required to get this to parse correctly:

        simplify_re = re.compile('(.*)<gr:annotation>'
                                 '<content type="html">(.*)</content>'
                                 '<author .*><name>.*</name></author>'
                                 '</gr:annotation>(.*)')
      
        new_lines = []
        for line in lines:
          m = simplify_re.match(line)
          if m:
            new_lines.append('%s<gr:annotation>%s</gr:annotation>%s'
                             %(m.group(1), m.group(2), m.group(3)))
          else:
            new_lines.append(line)
      
        d = feedparser.parse(''.join(new_lines))
      


    Gross, and fragile, but working. This is cool, because it now means that I can apply more logic in the shared links that end up in my blather feed. I'm thinking of something along the lines of only shared links with an annotation will end up in that feed, and the blather entry will include the annotation. Or something like that.

    Tags for this post: python(S) feedparser(S)

posted at: 05:22 | path: /python/feedparser | permanent link to this entry
There are no comments on this post which have survived moderation. 4 posts have been culled and 0 blocked. Be the first to make a non-spam comment here, please!