Category Archives: Programming

Creating and pushing new remote git branch

A note for my own reference, as I always forget how to create a remote branch then work with it later:

Create a new remote branch topic/add_awesomeness with, e.g.:


git push origin :origin:refs/heads/topic/add_awesomeness

Create a new local branch to track it:


git checkout --track -b add_awesomeness origin/topic/add_awesomeness

The unintuitive way to delete a remote branch is:


 git push origin :heads/topic/doc_cleanup

(There must be a better way than that…)

Dancer::Plugin::Database 1.00 released

I’ve just released Dancer::Plugin::Database 1.00 to CPAN. This includes Alan Haggai’s patch to supply runtime configuration info to the database keyword as a hashref (thanks, Alan!) which was already released as a developer release, 0.91_01.

I’ve bumped the version to 1.00 to indicate that I consider it stable and ready for use in production, for those users who mistrust any module with a 0.xx version number.

Dancer::Plugin::MPD released

I recently wrote Dancer::Plugin::MPD, a simple plugin to make it easy to talk to MPD (Music Player Daemon) from Dancer-powered webapps in Perl.

It uses Jerome Quelin’s excellent Audio::MPD – it simply provides an mpd keyword which returns a connected Audio::MPD object (connecting first, if we didn’t have a connection or it went away, otherwise keeping the connected object cached).

It makes for code as simple as this example from DancerJukebox:

get '/control/skip' => sub { mpd->next; redirect '/'; };

Dancer::Plugin::DebugDump released

I recently released a dead-simple plugin for Dancer – Dancer::Plugin::DebugDump.

During development, I fairly often find myself using Data::Dump to dump stuff to the debug log (which I usually have set to ‘console’, so it appears in the terminal I’m running the app from), with code like:

use Data::Dump qw(dump);
debug("Random hashref: " . dump($hashref) );

I got fed up with writing that, so I wrote Dancer::Plugin::DebugDump, which lets you say:

# give it a label and a reference/object:
debug_dump("Random hashref:" => $hashref);
# or just give it a reference/object:
debug_dump($someobject);

It’s not much of a saving, but it scratched an itch, and might possibly be useful to others.

DancerJukebox – music queuing Perl webapp powered by Dancer

I spent some of Friday night hacking on rewriting my music queuing webapp from Catalyst (which I wrote it in ages ago, before I discovered Dancer).

It only took a couple of hours of easy and actually fairly enjoyable coding to get it all ported over, and in the process I released two Dancer plugins – Dancer::Plugin::MPD to handle easily getting a working MPD connection, and Dancer::Plugin::DebugDump to easily dump objects and data structures to the debug log to simplify development.

This time round, the code is up on GitHub – DancerJukebox on GitHub. I never released the previous code, it was developed in a private Subversion repository, and I was never happy enough with it to release it.

The basic idea is that you fill the playlist with decent music and leave MPD playing on random. If people want to hear specific songs, they can use the web app to search for whatever they want and add them to a queue.

Continue reading DancerJukebox – music queuing Perl webapp powered by Dancer

pQuery – jQuery-like fun in Perl

I discovered pQuery the other day, and had been meaning to try it out.

I got the chance to use it today, and I have to say, I’m impressed. I am, however, rather wary that the last release was nearly two years ago; I’m not sure I’d want to use it in production code unless it’s being actively maintained – I might use it for non-important things before making that call.

Anyway, a brief example:

Let’s say you want to capture the content of a paragraph/div with the class “bar” from a page somewhere.. it can be as simple as:

pQuery('http://www.example.com/foo.html')->find('.bar')->html;

Let’s say you want to extract all H1 headings instead:

pQuery($url)
    ->find('h1')
    ->each(
        sub { say "Heading: " . pQuery($_)->text; }
    );

I’d love to see this continue in active development – there’s several features it could really use, but what’s already there is handy stuff!

Several Perl scripts released to Github

I’ve been playing with Github lately, and rather liking it.

I did briefly try it about a year ago, and was impressed, but wasn’t driven enough to consider moving away from Subversion.

I tried it out more when I started contributing to the Dancer Perl framework, and got to like it; since then, I’ve moved several of my modules over to Github already.

I finally got round to moving some miscellanous Perl scripts too, ones which I’ve been meaning to release as open-source in case they’re of use to anyone, but didn’t get round to doing.

They’re now online at: http://github.com/bigpresh/misc-scripts.

Github made sharing my code easy – Github++;

Now, that’s enough geekery for one evening.

Dancer 1.150 released – a flexible, lightweight web framework for Perl

Version 1.150 of the Dancer web framework has just been released, so this seemed like a good time to write up this post.

Recently, I’ve been wanting to find a Perl web framework that I really got on with. I’ve used Catalyst, which is very powerful and popular, but it’s quite heavy (a lot of dependencies, and reasonably high memory usage and startup time), and I felt as though it forced me to code “the Catalyst way”, rather than staying out of my way and getting on with writing my code.

I took a look around at the current Perl web frameworks (e.g. CGI-Application, Jifty, Catalyst, Mojo…) – all good in their own ways, but for various reasons, none of them really struck me as something I’d be particularly happy to work with.

I did briefly consider trying to write my own, but that’s a wheel I do not want to re-invent – there’s enough odd-shaped wheels out there already.

When I found Dancer (a port of Ruby’s Sinatra framework), I immediately liked the fact it looked simple and stays out of the way as much as possible, so I gave it a try – and, I must say, I’m impressed.
Continue reading Dancer 1.150 released – a flexible, lightweight web framework for Perl

OpenDNS vs Google – speed comparison

I read a Twitter post earlier mentioning Google’s public DNS service, and suggesting that it could displace the popular OpenDNS

I thought it would be interesting to do a performance comparison between Google and OpenDNS, to see how they compare. I also decided to include the nameservers of my ISP, Virgin Media, to illustrate whether there are performance gains to be had by changing to OpenDNS (which I primarily use, along with others) or Google, or whether staying with defaults works. Continue reading OpenDNS vs Google – speed comparison

Configure CPAN.pm to use sudo to install

I prefer to run CPAN.pm as a normal user and have it use sudo just for the actual installation, rather than running tests etc as root.

I have an annoying habit of forgetting the option names , so I’m posting this here for my reference, but might be useful for other people too.

To do that, do the following from a CPAN shell:


o conf make_install_make_command 'sudo make'
o conf mbuild_install_build_command 'sudo ./Build'
o conf commit

Also, whilst documenting that, to set your preferred CPAN mirror:


o conf urllist unshift ftp://mirrors.uk2.net/pub/CPAN/
o conf commit