St Peter's Square, RomePiazza Navona, RomeVilla Borghese, RomePiazza Navona, RomePiazza Navona, RomePiazza Navona, RomeColosseum, RomeColosseum, RomeColosseum, RomeVittoriano, RomeTrevi Fountain, RomePiazza dei Cavalieri, PisaLeaning Tower, PIsaLeaning Tower, PIsaDuomo, Pisa

dave.org.uk

Been Away

davblog / 2010-09-02 12:42:30

Colosseum, RomeIt's over a month since I've posted anything here. Sorry about that. For the first half of August I was in Italy. The first week, I was speaking at a conference in Pisa and after that we spent a few days in Rome and Venice. I took more than a few photos and they're slowly making their way onto my Flickr page. They should all be up there in a week or so (although, having said that, I still haven't sorted out the photos from last year's holiday in the Baltic).

Rather pleased with the way this photo of the Colosseum came out. But given a half-decent camera, an ancient monument and the Italian flair for lighting there probably wasn't mush that could go wrong.

Not quite sure what happened to the rest of August though...

Net::Songkick

perl hacks / 2010-08-26 05:07:34

Sometimes it's good to just take a new idea and hack on it for a couple of hours to see what happens. That's what I've done this evening.

I've been using Songkick for a while. Songkick is a web site that tracks users' attendance at gigs. I've been tracking the gigs I've been going to as well as trying to fill in over thirty years of old gigs.

I've known for some time that Songkick has an API, but until yesterday the API has been for invited partners only. But yesterday on Get Satisfaction they announced that it was now public.

The public API doesn't do that much yet. There are only four documented calls. But it's already useful and I'm sure it will gain more functionality quickly.

And this evening I've spent some time writing a very simple Net::Songkick module. This is really just a proof of concept, but I've got big plans for improving it. And I can already write a useful program like this:

#!/usr/bin/perl

use strict;
use warnings;

use XML::LibXML;
use Net::Songkick;

my $user = shift || 'davorg';
my $sk = Net::Songkick->new({
  api_key => $ENV{SONGKICK_API_KEY}
});

my $xml = $sk->get_upcoming_events({
  user => $user,
});

my $xp = XML::LibXML->new->parse_string($xml);

foreach ($xp->findnodes('//event/@displayName')) {
  print $_->to_literal, "\n";
}

If you have any interest in gigs then I highly recommend Songkick to you. And if you like attending gigs and hacking Perl (although not necessarily at the same time) then why not give Net::Songkick a try. All you'll need is an API key from Songkick.

There's a Github repository too; if you feel like hacking on it...

Learning About Traits

perl hacks / 2010-08-23 08:41:53
I've been teaching basic Moose in my training courses for several years now. And, as I've mentioned before, I've been slowly converting some of my CPAN modules to use Moose. But there are still bits of Moose that I haven't really needed to get to grips with.

One such area is Moose's support for Traits. Oh, I knew vaguely what they were and I understood why you might use them. But I'd never implemented a system using traits, so my knowledge about how you'd actually use them was a bit shaky to say the least.

But over the last few days I've learned quite a lot about how to use traits. And I've had to learn it pretty quickly.

It all started a few weeks ago when I got a github pull request from Oliver Charles. Oliver had taken a fork of my Perlanet repository and had massively refactored the codebase so that all the clever bits were implemented as traits.

What this means is that the core Perlanet code is pretty dumb. In order to do anything really useful with it to need to add in some traits. There are traits to read the configuration from a YAML file, traits to carry out various kinds of cleaning of the input and a trait to produce the output using the Template Toolkit. There are also traits to handle caching and OPML generation. All in all it makes the code far nicer to work on.

Oh, and there's a Perlanet::Simple module which uses all of the traits required to implement the Perlanet behaviour that users currently expect.

There were a few problems with Oliver's initial version. Some of the dependencies weren't quite right. But we soon fixed that and last week I finally released Perlanet 0.47 which implemented these changes.

Then I installed it on the server which hosts most of my planets. And everything broke.

So I've spent a lot of the weekend fixing these issues. Part of it was that Oliver's changes assumed some configuration file changes that I hadn't implemented. I changed his changes so that they worked with the existing configuration settings (we don't want users having to change configuration files unnecessarily). Other changes were harder to track down. I particularly enjoyed one where no feeds were fetched unless the user turned on OPML support. I learned a lot about how traits worked by tracking that one down.

But it all seems to be fixed now. Perlanet version 0.51 is available on CPAN and it will hopefully be a lot easier to customise to your needs. I hope we'll see a number of other Perlanet traits appearing over the next few months.

And, most importantly, I've learnt a lot about traits. I think I understand them now.

If you want to learn traits, I can highly recommend asking someone to implement traits in one of your projects. And it's even better if they do it in a slightly broken way so that you need to debug it.

Perl Vogue

perl hacks / 2010-08-05 08:18:51

I'm at YAPC::EU in Pisa, so I'm too busy having fun to write a long blog post about my new project - Perl Vogue. But I thought you might be interested in the lightning talk that I used to announce it yesterday.

More detail when I get back from Italy in ten days.

Enhanced by Zemanta

Greens and Science

davblog / 2010-07-29 20:03:28
At the time of the European election last year, there was some debate in the blogosphere about the Green Party's attitude to science.  Holfordwatch picked up on a report which said that the Greens supported the continued use of "alternative medicine" in the NHS. Rational people, of course, gave up all idea of voting for them.

To their credit, the Greens responded to this by clarifying (and, actually, seeming to completely drop) some of these policies. In this Q&A in the Guardian, their press officer, Scott Redding, was asked:

If the balance of evidence suggests that a treatment does not perform any better than placebo, should it be supported by the NHS?
He replied:

The short answer is No. Our policy is that any medicine or treatment available on the NHS should be backed up by scientific evidence. Some new treatments, and some currently available on the NHS, will pass this test, others will not.
Of course, you might well think that it doesn't matter what the Green Party thinks on this as they'll never have the power to enact their policies. And you'd be right to think that.

But they do have an MP now. Caroline Lucas is the MP for Brighton Pavilion. And whilst she's not exactly driving government policy, she does have the same ways to make her views known as all other MPs, including signing Early Day Motions.

So, given the clear direction indicated by Scott Redding, it's disappointing to see the she has signed one of David Tredinnick's nonsense EDMs on homeopathy (as discussed previously on this blog).

On one hand, the Greens clearly say that they won't support medical treatments without scientific evidence to support them. And then their first ever MP goes and gives her support to something that is on a the same level as witchcraft. If I was one of the enlightened people who voted for her back in May, I'd be feeling pretty pissed off about now.

I had hoped that, at least, the Green Party would prove themselves to be above the lies and spin that characterise so much of British politics. I'm really disappointed to see those hopes dashed.

Update: Lucas has received a lot of comment over this on Twitter in the last few hours. She has posted what I can only assume is supposed to be an explanation for her actions:

EDM is about lack of BMA's consultation & argues that local NHS better placed to know patient needs, based on objective clinical assessment
It's nonsense of course. Tredinnick is a well-known parliamentary advocate for homeopathy. His EDM is purely about supporting the provision of quackery on the NHS. Tredinnick is deliberately inventing scientific controversy where none exists. The science is settled. Homeopathy does not work.

If patients have been told that homeopathy is worth investigating, then their doctors should make it clear to them that they have been misled. Doctors should not be encouraging this delusion.

Snippets

Atom Feeds