Toblog

1. v. The act of writing a weblog or 2. n. Toby’s weblog.

The return of the blogroll

I’ve bought the blogroll back since it disappeared during the upgrade. It’s now generated from my google reader opml feed which I export and run though some ruby which means it’s going to be up-to-date more frequently.

Here is the code that takes the opml and outputs the html fragment:

#!/usr/bin/ruby

require 'rexml/document'
require 'pp.rb'

class FeedData
  attr_accessor :name, :url, :category

  def initialize( name, url, category )
    ( @name, @url, @category ) = name, url, category
  end
end

class FeedDataList
  def initialize()
    @array = Array::new
  end

  def add( name, url, category )
    tmpFeed = FeedData::new( name, url, category )
    @array.push( tmpFeed )
  end

  def eachCategory
    catArray = Array::new
    @array.each do |feed|
      if !catArray.member?( feed.category ) then
        catArray.push( feed.category )
      end
    end

    catArray.sort.each do |result|
      yield result
    end
  end

  def eachItemInCategory( category )
    @array.each do |feed|
      if feed.category == category then
        yield feed
      end
    end
  end
end

def parse_opml( opml_node, feeds, parents_names=[] )
  opml_node.elements.each('outline') do |element|
    if element.elements.size != 0 then
      feeds = parse_opml( element, feeds, parents_names + [ element.attributes[ 'text' ] ] )
    end
    if element.attributes['xmlUrl'] then
      feeds.add( element.attributes['title'], element.attributes['htmlUrl'], parents_names.last )
    end
  end

  return feeds
end

opml = REXML::Document.new( STDIN )
feeds = FeedDataList::new
feeds = parse_opml( opml.elements['opml/body'], feeds )

feeds.eachCategory do |category|
  print "<br /><strong>#{category}</strong> "
  feeds.eachItemInCategory( category ) do |item|
    print "<a href=\"#{item.url}\">#{item.name}</a> "
  end
  print "\n"
end

To make it work:

$ ./opml2html.rb < <opml file>

I got the inspiration for the recursive opml parsing code from the Dekstop blog, so thanks are due to them!

Published on 2008/08/13 at 16:03 by Toby, tags , , , , ,

Familial promotion

My cousin has set up his own company called Ascension Productions. They have just made a video for a band called Bring me the Horizon, who are a bunch of Deathcore metallers.

Here the video is, embedded. Make sure you have your volume on full when you play it…

If that doesn’t work, you can find it here.

ROCK!

[2008-08-13 10:20] myspace appear to have taken the video down. If I can find another source I’ll put it up.

[2008-08-13 10:25] youtube FTW!

[2008-09-09 18:16] youtube video is dead, long live youtube video…

Published on 2008/08/12 at 17:27 by Toby, tags , , , , , , , ,

Fame!

According to The Register I am part of the ‘Beautiful People’ and The Register is /never/ wrong, is it…

I’m expecting the offers of lucrative modelling contracts to arrive any day now.

Published on 2008/08/08 at 14:46 by Toby, tags ,

Dave Walker

Once again a blogger has been threatened with legal action unless he removed posts from his site. For more information, read this. Obviously people haven’t learnt from past lessons on this one (cf Alisher Usmanov in particular).

Published on 2008/07/25 at 13:12 by Toby, tags , , , ,

Upgrade completed

Well, that upgrade seems to have been completed OK with a couple of issues: I had a couple of glitches one of which was to do with the rails backup of my database – fixed by turning off the backup stage in the rails installer. There was also an issue with my tags: I’ve known that my tags caused problems in the past with my use of the full stop. In the new typo it causes major problems so I wrote a quick script to replace full stops with underscores. Hopefully all is well now!

Published on 2008/07/22 at 17:19 by Toby, tags ,

Bugs

Does anyone know what these beasts are? We have a few clusters of them (presumably mating) on an external wall that is protected from the wind.


I’ve not seen anything like them before.

[2008-07-21] It’s a Rosemary beetle. Thank you Derv!

Published on 2008/07/20 at 11:40 by Toby, tags , , ,

Just on the off-chance, you know...

… and it’s extremely unlikely, but does anyone have any space for one (or all, as I’m pushing my luck here) of these. I’d look after them and use them regularly – just don’t have the space for them right now.

Just for nostalgia’s sake.

Published on 2008/06/19 at 17:21 by Toby, tags , ,

Powered by Publify – Thème Frédéric de Villamil | Photo Glenn