Archive for the ‘Perl’ Category

WebService::Amazon::Route53

Wednesday, August 31st, 2011

In the last few days, I’ve been working on moving several domains (including this one) from EditDNS to Amazon’s Route 53. EditDNS was a small DNS provider that offered very good service (I praised them for that in the past), unfortunately some time ago they got acquired by Dyn, and are now being shut down.

I looked for a decent replacement for EditDNS, and finally decided to go with Route 53, because of two things: they have a good pricing scheme, and a well-documented API. The latter was probably the most important factor, as I do a lot of domain management stuff using automatic tools that work with an API.

A side effect of this move operation is a Perl module that I developed and used in the process, and which I’m now releasing — WebService::Amazon::Route53. It provides a Perl interface to Route 53 API, and thus allows you to manage domains and DNS records hosted at Route 53 from the comfort of your Perl scripts.

The module is available on CPAN and on GitHub.

Dancer::Plugin::DebugToolbar 0.011

Sunday, August 7th, 2011

This weekend we’re having pretty nice weather here in Warsaw, so what better way to spend your day other than to stay indoors and hack Perl? I’m here with a new version of the debugging toolbar plugin for the Dancer web framework.

A new feature introduced in this version is basic database tracking functionality. The information window can now show the DBI trace data, and display (some of) the SQL queries sent to the database. Here’s a screenshot of that:

Database information screen

I’ve also made significant changes in the basic structure of the code, and rewrote some of it from scratch. In the first release, the HTML code used to inspect the data structures was generated by Perl, which wasn’t especially elegant. Now, pretty much all presentation-related stuff happens in JavaScript, and the Perl code is only responsible for providing the data structures to display.

In the future, this might even allow me to quickly adapt the plugin to other frameworks/languages.

The new version is available on CPAN and GitHub. And, since today happens to be Dancer’s second birthday, let this release be my way of celebrating it. Happy birthday, Dancer!

Dancer::Plugin::DebugToolbar

Friday, July 29th, 2011

As you might remember, I recently got interested in Dancer, the fabulous micro web framework for Perl. That interest led me to rewrite my website to Dancer, but that wasn’t enough — I found the framework really fun and wanted to play with it a bit more. So I started a small project to develop a plugin that adds a debugging toolbar to Dancer web applications.

I have now made the plugin available on GitHub, and I will be releasing it on CPAN shortly. It’s still in an early stage of development — at this point, it only allows you to inspect your application’s routes and basic data structures. I hope to eventually turn it into a decent development tool, which would also be easy to use to help new Dancer users get familiar with the framework.

Here’s a screenshot of the toolbar displayed at the top of the browser viewport:

Dancer debugging toolbar

And this is how the data inspection window looks:

Debugging toolbar data window

As usual, I’m looking forward to feedback, especially from you fellow dancers out there.

$self =~ s/Symfony/Dancer/

Thursday, June 30th, 2011

Notice anything different about my site? No? Good, this means that the transition went smooth. I rewrote the engine that my website runs on from Symfony to Perl Dancer.

You might remember that I introduced the Symfony-based engine less than six months ago, so why the switch? Well, back when I launched it, I kind of felt that it might not last very long — mostly because Symfony was just a better-than-nothing choice. For years, my website was running on an ugly framework-wannabe solution that I developed myself. By the way, if you ever get the same idea, consider this advice:

(source: gojko.net)

By the time I finally decided to rebuild it, Symfony just happened to be around — I had a Symfony project coming up and thought it might be good to first get familiar with the framework on a smaller task. I started working on the rewrite, and I quickly got the feeling that Symfony is just too big for the purpose of running a small website like this — I only needed a tiny subset of its numerous features. All in all, it felt way too heavy. But, I really wanted to replace the old engine, so I still went with it.

As for Dancer, I first heard of it about a year ago and I knew I was going to give it a try at some point. Why? Two reasons:

  1. It’s a micro framework, which is much better suited for simple sites than a full-blown MVC framework
  2. It’s Perl, dammit!

So, two weekends of enjoyable hacking, and here it is — my website running on Perl. More precisely, it’s a Perl/PHP hybrid, as the blog is still powered by WordPress. But, the blog engine is feeding its output to the Dancer application, so everything you see is processed by Perl.

WebService::Gravatar — Perl interface to Gravatar XML-RPC API

Tuesday, August 3rd, 2010

Developing my first Perl module turned out to be quite amusing, so I was happy to do it again, and here’s my second contribution to the wonderful world of CPAN: WebService::Gravatar, a Perl interface to Gravatar XML-RPC API.

Here’s a quick usage example (taken from the documentation):

    use WebService::Gravatar;
    use MIME::Base64;

    # Create a new instance of WebService::Gravatar
    my $grav = WebService::Gravatar->new(email => 'your@email.address',
                                         apikey => 'your_API_key');

    # Get a list of addresses
    my $addresses = $grav->addresses;

    if (defined $addresses) {
        # Print the userimage URL for each e-mail address
        foreach my $email (keys %$addresses) {
            print $addresses->{$email}->{'userimage_url'} . "\n";
        }
    }
    else {
        # We have a problem
        print STDERR "Error: " . $grav->errstr . "\n";
    }

    # Read image file data
    my $data;
    {
        local $/ = undef;
        open(F, "< my_pretty_face.png");
        $data = <F>;
        close(F);
    }

    # Save the image as a new userimage
    $grav->save_data(data => encode_base64($data), rating => 0);

    ...

WebService::EditDNS – Perl interface to EditDNS API

Monday, July 26th, 2010

I have created a simple Perl module that talks to EditDNS API, allowing for easy manipulation of domains/records hosted at EditDNS from within Perl programs. A while ago, I developed a command-line utility that serves a similar purpose, named editdns.pl. The module is sort of an extension of that idea, although it works in a different manner — while editdns.pl impersonates a web browser to access the EditDNS control center website and uses hacky HTML scraping techniques, the module plays it nice and only uses elegant API calls.

The module is called WebService::EditDNS, and is available for download at CPAN. Eventually, it will probably also get a project homepage here on my website (some day in the not-too-distant future).