All posts by bigpresh

reCAPTCHA becoming unusable – decent alternatives?

I use reCAPTCHA to help prevent spam comments. It used to be very good, and had the added bonus that it’s helping to digitise books at at same time, rather than wasting effort.

However, it seems to be giving worse and worse CAPTCHAs lately, providing words that are almost impossible to read, and often words that are clearly not even English.

For instance:

What’s that?

I don’t want to put off real visitors from leaving comments by making them decipher things that are too close to nonsense, so I think I’m going to have to replace reCAPTCHA with something more suitable. Suggestions welcome.

HTML::Table::FromDatabase 1.00 released with row_callbacks feature

I just released version 1.00 of HTML::Table::FromDatabase, with a new row_callbacks feature.

You could already declare callbacks on a cell-level basis, so you could say, format monetary values appropriately, round numeric columns, turn URLs into clickable links etc. Now, you can also declare a callback which receives an entire row as a hashref, which it can modify as needed.

An (admittedly somewhat contrived) example from the documentation:

my $table = HTML::Table::FromDatabase->new(
    -sth => $sth,
    -row_callbacks => [
        sub {
            my $row = shift;                                                                                 
            if ($row->{name} eq 'Bob') {
                # Hide this row
                $row = undef;
            } elsif ($row->{name} eq 'John') {
                # John likes to be called Jean these days:
                $row->{name} = 'Jean';
            }
        },   
    ],       
);

I decided to bump the version to 1.00 for the sake of anyone who considers 0.x versions to be unready for production use; this module has been about since 2008 and is working well in production use for me.

The Dancer release that will get you hooked!

Sawyer X wrote up a good post on version 1.3050 of the Dancer Perl web framework being released – "The Dancer release that will get you hooked!".

The addition of extra hooks, along with support for plugins to create hooks, heralds additional flexibility and power for your Dancer apps.

Dancer itself now provides various new hooks you can use to customise its behaviour, including before_deserializer, before_file_render, before_error_render, before_template_render, before_layout_render, before_serialization
– see the Dancer::hook() documentation for the full list. Plugins can register their own hooks, which your code can then make use of.

Props go to Franck Cuny for the implementation, and JT Smith of Plain Black for pushing for this feature and working with the Dancer team in designing the implementation.

Dancer 1.3050 also includes various bug fixes and improvements – see the CHANGES file for a full list.

Dancer::Plugin::TimeRequests

Today I knocked up a quick plugin for the Dancer Perl web framework to log the time taken by requests to help look for bottlenecks – enter Dancer::Plugin::TimeRequests.

At the moment it’s very simple, and simply logs the time taken to execute every request; in the future, I may extend it to support capturing statistics and adding a route handler to display stats (e.g. average request time, which routes take the longest to execute, etc.)

Suggestions / patches welcome – the code is on GitHub as usual.