All posts by bigpresh

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!

Atlas Direct will weasel out of travel insurance claims due to volcanic ash

In light of the recent flight disruptions caused by volcanic ash, I decided to enquire as to whether my travel insurance provider, Atlas Direct, would attempt to weasel out of claims should we be hit by problems (we don’t travel until August, so should be safe, fingers crossed, but wanted to check…).

10 working days later, I finally received the following response:

We do not consider volcanic ash to be “adverse weather” therefore there is no cover under the “Travel Delay and Abandonment” and the “Missed Departure” sections.

Additionally it is not a stated reason to cancel or curtail a trip and therefore there is no cover under the “Cancellation, Curtailment and Trip Interruption” section.

If the Insured is stranded abroad their policy will be automatically extended for the period the Insured is abroad provided you return on the earliest possible flight to the UK. The Insured is only covered for “Medical Emergency and Repatriation” and “Luggage”.

Additional accommodation and travel costs due to volcanic ash incident are not covered under this extension.

So, if you’re using Atlas Direct, do be aware that, if you are affected by flight cancellations from volcanic ash, they will not help you. Hopefully your airline/tour operator will, but they will not. I previously held Atlas Direct in fairly high regard and was happy to be insured with them, now I’m not so sure. (I know they’re not alone in wanting to weasel out of any claims due to the ash,though!)

Dancer::Plugin::Database – easy DB connections for Dancer apps

Last night I finished and released the first version of Dancer::Plugin::Database, a plugin for the Dancer web framework to provide easy database connections using the venerable DBI.

It takes the database connection details from the app config file, and provides a database keyword which will return you a connected database handle (taking care of ensuring that the DB connection is still alive, etc).

So, usage can be as simple as:

my $books = database->selectall_arrayref(
    'select * from books where author = ?', 
    { Slice => {}}, $author
);

(Calling database() simply returns a DBI database handle, so you can obviously do anything you can do with DBI).

Also, at the moment, if a database connection could not be established for any reason, database() will just return undef, so you will need to handle errors appropriately. After considering whether it’s wise, I may tweak it to die, so that Dancer will handle the failure with a pretty 500 error for you (in which case, I’ll make it possible to disable that via the config).

Resizing ext2/3 filesystem in loop file

Quick post, mostly for my own future reference, as I couldn’t quite remember how to resize an ext3 filesystem contained in a file.

dd if=/dev/zero of=disk.img bs=1M count=1024 oflag=append conv=notrunc
e2fsck -f disk.img
resize2fs disk.img

The above will append 1GB to the end of the file, then resize the ext2/3 filesystem to take up that newly-added space.

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

Users don’t like new “Facebook login page”…

Seems a lot of clueless users have been trying to get to Facebook by searching for “facebook login” rather than going to Facebook, and landing on a blog post titled Facebook wants to be your one true login from ReadWriteWeb, not understanding that they’re on an entirely different site, and bitching (in depressingly moronic ways) that they don’t like the new Facebook login, or can’t understand how to log in.

The comments on that post (all 7 pages, as of last time I looked) make for depressing reading.

Now, I don’t like to make fun of people just because their computer skills might not be particularly good, but the lack of literacy, reading skills, logic and general comprehension shown in the comments is just… it’s depressing.

Some examples:

WHAT THE HELL IS GOIN ON WITH THIS FACEBOOK.. FIRST YOU WANNA CHARGE NA YOU WANNA NOT LET US LOG IN….. UGH STOP CHANGIN IT I LIKE THE OLD FB…. IF YOU ARE THE NEW OWNER YOU SUCK AND I WISH YOU WOULD CREATE UR OWN SHTY AND LEAVE FB ALONE LOSER………

wtf is this bullshttttttttttt all about. can i get n plzzzzzzzzz

This is such a mess I can’t do a thing on my facebook .The changes you have made are ridiculous,I can’t even login!!!!!I am very upset!!!

i do not like this, please go back to the old one or drop me from facebook.

My daughters&sons show me how 2 use facbook,Iwas confuse then now i’m really confuse just let me log in the old way this way really sucks!!!!!!!!

this is a waste of time, go back to the way it was!!!!!!!!!!!

I like thr old way to sign in this sucks big time let me in

this is not a good thing i just don’t think u have thought this thru. I haven’t made a decision yet but i might give facebook up this is too much trouble

I hate this bring the old facebook back. Cannot login.

HELL,WHERE IS THE FACEBOOK PAGE.DAM!SOON AS YOU LEARN ONE THING HERE WE CHANGING SHIT.

i dont like this new changes i like the way was before and now is a disaster at list live the page the same of before i dont’ care if they change the owner.ok?bye now hope you go back the same of before

Ok If I have to I will comment,I love facebook so right now just want to log in if thats ok with you..lol Keep up the good work…

OK, that’s enough examples of epic fail.

It makes you wonder how some of these people survive in general life, and how they managed to get on the Internet in the first place.