Archive for the ‘Tech’ Category

FreeGuide 0.10.9

Tuesday, September 9th, 2008

So let’s quietly forget FreeGuide 0.10.8, which basically didn’t work.

I fixed the problem (which was some nasty threading thing) by making the initial “Choose Channels for XMLTV” call from the first time wizard not do the clever stuff of displaying errors to the user. Instead it dumps any errors to the console (which is an improvement over swallowing them completely as it did before), and when you run “Choose Channels for XMLTV” from the menu, or “Configure” from the Options screen, you still get the errors displayed in a nice dialog as in 0.10.8.

More excitingly, new in this release: some unit tests!

You can run them by doing this in the src directory:

java freeguide.test.slow.FreeGuideSlowTest

They test the fixes I made in 0.10.9 for XMLTV files that have certain attributes missing, and have different date formats.

The date formats were supposed to be already working, but a fix I made several years (yes, years) ago broke them. Why didn’t I catch the problem? No tests.

The second age of FreeGuide is coming. I shall call it The Time of Testing.

Wii repaired free!

Tuesday, September 9th, 2008

A few weeks ago my Nintendo Wii started not accepting any Wii disks (but was still fine for GameCube ones… interesting). It made a clicking noise for a bit and then declared “Bad Disk” or something like that.

I need my Wii. I watch all my TV through it, using recordtv. I had to get it fixed.

I looked up the official support options, and the deal in the UK is that you go to http://www.nintendoservicecentre.co.uk and they send you an envelope. You put your Wii in the envelope (postage paid) and they have a look at it. Then they give you one of two fixed prices: either £28 or £70 depending on the severity of the problem. (I guess £70 is about the cost price of a Wii?). If you agree on the price, you pay them and they send it back fixed, postage paid.

So I sent mine off, worried and entertainment-less. I heard nothing for about a week, and then it returned, fixed, with a little sticker on it saying “Repair: Wii minor, £0.00.”

Paint me satisfied.

+1 Nintendo.

FreeGuide 0.10.8

Monday, July 28th, 2008

I am still working slowly on moving FreeGuide forward. Somehow it seems my itches for FreeGuide are all about making it less annoying for people who are trying it the first time. I guess this is motivated by my desire for world domination.

Anyway, we are one small step closer to my mum being able to use FreeGuide – when the “Choose channels” step (i.e. the XMLTV grabber configuration) goes wrong, you can now see a real genuine error message, and hopefully figure out what went wrong.

Actually, it always used to work that way but the error-catching got refactored away at some point. Anyway, I am slowly taking the ground back…

As I do more and more test-driven development at work I am becoming completely addicted. For this FreeGuide code I wrote a couple of unit tests but they are not within a proper framework, and can’t be launched easily as a test suite. I am considering JUnit.

I also want to set up some component-level tests e.g. for downloading listings for each country and checking everything works as expected. It’s brilliant fun having tests in place, but when you have as little time as I have for FreeGuide at the moment, it’s difficult to decide to spend a long time working on a test framework when I could be fixing a “real user problem” or adding a cool new feature.

But I’ve got the testing bug badly, so watch this space.

Templated test code?

Wednesday, March 19th, 2008

At work at the moment, as part of an initiative to get with the 21st century, we are waking up to testing our code.

Thus, I am writing a lot of unit tests for old code, which can be soul-destroyingly repetitive and very pointless-feeling (even though really I do see a great value in the end result – tested code is refactorable code).

Often, tests have a lot in common with each other, so it feels right to reduce code repetition, and factor things into functions etc. The Right Way of doing this is to leave your tests as straightforward as possible, with preferably no code branches at all, just declarative statements.

Contemplating writing unit tests for the same method on 20+ very similar classes, using a template function “feels” right, for normal code values of “feel”. However, for test code, maybe it’s wrong?

My question is: is it ok to write a test function like this?:

void test_all_thingies()
{
    test_One_Thingy<Thingy1>();
    test_One_Thingy<Thingy2>();
    test_One_Thingy<Thingy3>();
    test_One_Thingy<Thingy4>();
}

template< class T >
void test_One_Thingy()
{
    T thingy;
    thingy.doSomething();
    TEST_ASSERT( thingy.isSomething() );
}

Worse still, is this ok?

void test_all_thingies()
{
    test_One_Thingy<Thingy1>( "Thingy1 expected output" );
    test_One_Thingy<Thingy2>( "Thingy2 expected output" );
    test_One_Thingy<Thingy3>( "Thingy3 expected output" );
    test_One_Thingy<Thingy4>( "Thingy4 expected output" );
}

template< class T >
void test_One_Thingy( std::string expected_output )
{
    T thingy;
    thingy.doSomething();
    TEST_ASSERT( thingy.getOutput() == expected_output );
}

Reasons for: otherwise I’m going to be writing huge amounts of copy-pasted code (unless someone can suggest a better way?).

Reasons against: how clear is it going to be which class failed the test when it fails?

Update: fixed unescaped diagonal brackets.

Public bzr branch of FreeGuide

Wednesday, March 12th, 2008

On the subject of distributed source code management, Dan Watkins has just informed me that the launchpad team have created a bazaar branch of FreeGuide’s code, so if you’re into that kind of thing, you can download the code from that instead of our central subversion repo.

The link is here: http://code.edge.launchpad.net/~vcs-imports/freeguide-tv/trunk.

If you’re into git, I’d suggest git-svn. It’s what I use for FreeGuide development now. Let me know if you have trouble getting it working.

Public git repo for GSSMP

Wednesday, March 12th, 2008

Git is supposed to work when you upload your repository to an http server, but in reality, no-one except me seems to use it, and it’s nothing like as useful as having a proper repository that people can commit to etc.

So, here it is: http://repo.or.cz/w/gssmp.git.

Enjoy.

Finally released last.fm support for GSSMP

Sunday, January 20th, 2008

There was a weird bug in my last.fm support for GSSMP, where it would crash when run from the GNOME panel, but be fine when run from a terminal.

After two bugs fixes from Charles Bailey, the problem seems to have gone away, so I’ve finally been able to make a release.

Now I have to resist the temptation to choose songs to make last.fm think I’m cool, instead of songs I actually want to listen to.

And I really need to fix the debian/Ubuntu package of lastfmsubmitd so that the client exe lastfmsubmit is included in the package. Without that, using last.fm with GSSMP is a major hassle.

lighttpd on Ubuntu – alias.url doesn’t work when included in a module config file

Sunday, December 9th, 2007

I’ve decided to use lighttpd on my new machine (which was generously given to me and features a 700GB raid array).

My main reason for choosing lighttpd was the FLV streaming plugin for it that will make my Wii TV viewing experience a lot better. (It works – I’ve tried it!)

However, if I’m going to use lighttpd for streaming TV to my Wii, I want to use it for everything, rather than having Apache running as well. In any case, I think given my load pattern (average 0.01 users at any time, approx) a lower-memory (but maybe less stable under heavy load) solution seems a good choice.

So I have to get my webmail, home-grown address book, and mediawiki installations all working with lighttpd. How hard can it be?

Actually, harder than it should be.

Lighttpd is supposed to listen to a directive that looks like this:

alias.url += ( "/mediawiki/" => "/usr/share/mediawiki1.10/" )

and on Ubuntu, being Debian-derived, you can split your lighttpd config into separate files, allowing apt to modify the main config file during an upgrade without blatting your customisations.

So I created a file in /etc/lighttpd/conf-available/ called 50-mediawiki.conf that contained the alias-url line above, and then I ran:

sudo lighty-enable-mod mediawiki

and a symbolic link was duly created at /etc/lighttpd/conf-enabled/50-mediawiki.conf.

I restarted lighttpd like so:

sudo /etc/init.d/lighttpd force-reload

and navigated to localhost/mediawiki, but got a 404 error.

A lot of experimentation later, and it turns out to be a stupid thing.

Lighttpd has a stupid “by design” behaviour, which I think I can summarise as “if you encounter a change to alias.url that comes AFTER a conditional that modifies alias.url, ignore it.”

So, to explain by example, this code in /etc/lighttpd/lighttpd.conf will successfully redirect /test/ to /home/andy/test/:

alias.url += ( "/test/" => "/home/andy/test/" )

$HTTP["remoteip"] == "127.0.0.1" {
        alias.url += (
                "/doc/" => "/usr/share/doc/",
                "/images/" => "/usr/share/images/"
        )
        $HTTP["url"] =~ "^/doc/|^/images/" {
                dir-listing.activate = "enable"
        }
}

but this code:

$HTTP["remoteip"] == "127.0.0.1" {
        alias.url += (
                "/doc/" => "/usr/share/doc/",
                "/images/" => "/usr/share/images/"
        )
        $HTTP["url"] =~ "^/doc/|^/images/" {
                dir-listing.activate = "enable"
        }
}

alias.url += ( "/test/" => "/home/andy/test/" )

Will leave you scratching your head as to why it doesn’t work.

Since the bit of lighttpd.conf that is put there by Debian (or Ubuntu?) to include all files in conf-enabled/ comes at the very end of the file, any alias.url lines in any module config are ignored. Clever eh?

To skip to the end, my fix was to move the Debian documentation code to the very end of the config file, so the end of lighttpd.conf now looks like this:

...

#### external configuration files
## mimetype mapping
include_shell "/usr/share/lighttpd/create-mime.assign.pl"

## load enabled configuration files,
## read /etc/lighttpd/conf-available/README first
include_shell "/usr/share/lighttpd/include-conf-enabled.pl"

#### handle Debian Policy Manual, Section 11.5. urls
#### and by default allow them only from localhost

$HTTP["remoteip"] == "127.0.0.1" {
        alias.url += (
                "/doc/" => "/usr/share/doc/",
                "/images/" => "/usr/share/images/"
        )
        $HTTP["url"] =~ "^/doc/|^/images/" {
                dir-listing.activate = "enable"
        }
}

Now my separate file for mediawiki works fine, and my 404 error has changed to a much more healthy 403. (If that causes pain, expect a blog entry on that too.)

As for why lighttpd works in such a stupid way, apparently it’s by design: lighttpd bug 1427

And here’s the relevant debian bug, to which I will try to remember to reply: Debian bug 445459

Incidentally, running this might be helpful:

lighttpd -tp -f /etc/lighttpd/lighttpd.conf | less

It shows you how lighttpd has understood your configuration files.

Lighttpd seems to be light on end-user documentation, and concern for ease of use. I hope I’m not making a big mistake…

FreeGuide updated to latest XMLTV, and bug fixes

Friday, November 16th, 2007

Check out a release candidate here: http://freeguide-tv.sourceforge.net/rc/ .

So far I’ve only uploaded an RPM, but hopefully there’ll be a Windows exe and some other packages soon.

Update: Windows installer now uploaded too.

Test it! It’s got better capturing and reporting of download errors, more sensible “download in background” and “show output” behaviour, and its list of XMLTV grabbers is synched with the latest XMLTV (0.5.50).

However, apparently XMLTV 0.5.50 is causing problems in FreeGuide for at least some people, so it may not be a flawless experience…

I really must make a one-button build for Ubuntu .debs, like I have for RPMs. I have been using Ubuntu for some time now…

I’d forgotten to update the version page on the FreeGuide web site for 0.10.5, so users weren’t notified of that release. I’ll do it for 0.10.6, and hopefully get some stats together to find out how many people are using it. Now that the stats are working, we may be starting to get some better information.

Yes, I couldn’t sleep tonight.

No, I won’t be very clever tomorrow.

But hey, I was clever tonight – dipping into some of the spaghetti that makes FreeGuide tick these days and not only making a change that works, but also making things a tiny bit better – _that’s_ an achievement.

duckmaze 0.2

Saturday, November 10th, 2007

I’ve finally released to the world the secret extra duckmaze levels. They’re contained in the 0.2 release, which is also faster, and doesn’t freeze time.

(As far as I know.)

It’s got 18 levels, and a level editor, which means you can make more.

  • Do it.
  • Send them to me.
  • ???
  • Profit.