February 7, 2011
"Python surged hugely this last year — more than any other language. […] I’m not convinced. I suspect part of the new adoption comes from Perl programmers who are throwing in the towel."

From The Rise And Fall of Languages in 2010.

This guy is good! Count me in!

by jjm on 7:12pm  |   URL: http://tumblr.com/ZPorZy2ylXhI
(View comments
February 6, 2011
Better Privacy and Gnome 3 Support

I’ve just released Nautilus Flickr Uploader 0.09, with an important fix and a new feature.

The bug fix was related to privacy settings, or how dumb I can be sometimes, because I got it wrong since the beginning, and although one user commented me the issue through Twitter, until recently (thanks to a proper bug report) I couldn’t manage to understand what the problem was.

Basically my implementation was missing some privacy combinations (public, private, and private with family and/or friends), and I didn’t notice it because I upload public content only.

The only other change in this version is the possibility to open a file chooser as an alternative to add pictures to the upload list. Basically I added this feature after some testing with the upcoming Gnome 3, because drag and drop doesn’t look as easy to do as in Gnome 2, and because one of the UX changes in Gnome Shell is to have less focus in browsing.

So now we have 3 ways to add photos to upload:

  • Selecting the pictures from Nautilus and then, with right click, open the files with the application. This is the original way I thought when I started developing the tool.
  • Dragging pictures from Nautilus or one of the picture viewers included in Gnome, with the limitation of Nautilus Flickr Uploader not understanding some of the special URIs (such as gphoto://).
  • NEW: just click on “Add” button and use the file chooser.

Again, because my use case is mostly drag and drop from one of the picture viewers of Gnome, I didn’t notice that it would be interesting to add pictures using an internal browser in the application.

So far, so good. I’ve updated the Fedora 13 & 14 packages, and if you’re using the repository, the update will be pushed eventually in your system. I’ll try to provide DEB packages as soon as possible.

Btw, remember I’m looking for a package maintainer for Fedora.

November 6, 2010
Race Conditions, Russian Translation, and Packages!

Today I released the 0.08 version of Nautilus Flickr Uploader, and it fixes a bug that has been around since 0.03 (more than one year ago!).

The short explanation is ‘there was a race condition while uploading the pictures that affected to fast machines only’ (really), and the long one would be a quote from the great Jamie Zawinski:

Some people, when confronted with a problem, think “I know, I’ll use threads.” Now they have two problems.

Zawinski never said that, but it’s my favourite version of the two problems original quote. Anyway, the problem is fixed!

I’ve included the Russian translation kindly provided by Anaart, and I’ve rebuilt the Fedora repository to support specifically Fedora 12, 13 and 14 (thanks to Koji), and you’ll have to download and install the new repo file (sorry for the inconveniences!).

According to Flickr, the application has +600 registered users, so go and upgrade!

Update: you know Debian/Ubuntu packages lag behind Fedora’s because I haven’t found someone to maintain them. Good news, a twitter fellow updated the DEB package to 0.08! Have I found a maintainer?

August 2, 2010
Why isn’t $LANG Popular in Industry?

With LANG=haskell, Why isn’t Haskell popular in Industry?

It’s interesting because I think that list of 9 points can apply to other languages too (such as Perl).

A language is unpopular because it’s different, and it makes it difficult to learn. Moreover a language can be popularly known to be difficult, or believed to have known problems, such as maintainability or code readability.

It’s very difficult to hire programmers that already know it, because it’s unpopular. Although you can teach it, it doesn’t make the language suitable for your projects, because you need good programmers already trained, and you can’t find them!

All together makes that language a risky option that gets discarded in favour of other ‘industry leading’ languages such as Java.

And don’t forget the customer: they’re used to some words, and although it’s not their business, they tend to be more happy if they know (or think they know) about the technology you’re using. So, it can be harder to sell an application made in Haskell.

At the end, sadly, the advantages of using $LANG aren’t that important.

June 22, 2010
Workaround for the Battery Issue

Since I upgraded the firmware of my Acer Aspire One 110, I’ve noticed some little problems with the 6 cells battery: the laptop switches off when about one hour of battery time is left.

Well, it’s not really switch off but like it hangs: the power light it’s on, and the side cooler is working, and I have to press the power button for some seconds to stop it.

I did some research and tests, and these are the results:

$ cat /proc/acpi/battery/BAT1/info 
present:                 yes
design capacity:         7200 mAh
last full capacity:      6610 mAh
battery technology:      rechargeable
design voltage:          11100 mV
design capacity warning: 300 mAh
design capacity low:     264 mAh
capacity granularity 1:  32 mAh
capacity granularity 2:  32 mAh
model number:            UM08A73
serial number:           096D
battery type:            LION
OEM info:                SIMPLO

$ cat /proc/acpi/battery/BAT1/state 
present:                 yes
capacity state:          ok
charging state:          discharging
present rate:            824 mA
remaining capacity:      6569 mAh
present voltage:         12232 mV

The remaining capacity (green) it’s the actual battery charge, and the design capacity warning (yellow) and the design capacity low (red) are the values I assume ACPI and the battery applet are checking to calculate the remaining battery charge:

$ acpi
Battery 0: Discharging, 97%, 08:41:40 remaining

I don’t know if I’m getting it wrong, but it makes sense to me (and that 08:41:40 remaining is obviously wrong). The netbook freezes when the charge reaches 19% (aprox).

I guess the battery is advertising wrong values, and because the applet uses time as factor, I can’t adjust it properly.

So I programmed a Perl script to run by cron every minute, to check the battery charge value instead of the time:

#!/usr/bin/perl

use strict;
use warnings;

# empirical fix
my $fix = 1200;

sub getData
{
        my $file = shift;

        open(FD, '<', $file) or
                die('failed to open: ' .$file);
        my @lines = <FD>;
        close(FD);

        my %data;
        foreach(@lines)
        {
                chomp;
                s/\s+//g;
                s/mAh//g;

                my ($key, $value) = split(':');
                $data{$key} = $value;
        }

        return %data;
}

my %state = getData('/proc/acpi/battery/BAT1/state');

exit 0 unless $state{'chargingstate'} eq 'discharging';

my %info = getData('/proc/acpi/battery/BAT1/info');

if($state{'remainingcapacity'} <= $info{'designcapacitywarning'} + $fix)
{
        system('aplay alarm.wav');
}

if($state{'remainingcapacity'} <= $info{'designcapacitywarning'} + $fix - 100)
{
        system('sudo /sbin/halt -p');
}

exit 0;
# EOF

Please, keep into account that this is a hack. After some tests, I’ve found that adding 1200 to design capacity warning it’s a good fix.

When the limit is reached, I play an alarm sound, until I call halt to switch off the netbook as cleanly as possible (notice that I’ve configured sudo to let my user run halt without password).

With this little workaround, everything in my LXDE based Fedora 13 fit my needs!

April 27, 2010
"Perl programmers of Earth! Browse though the Core modules before starting a new project. Use them, don’t rewrite them."

From Sven Heinicke (@failedvegan) at identi.ca’s timeline.

I agree, browse, and use them. Don’t repeat yourself.

by jjm on 7:27pm  |   URL: http://tumblr.com/ZPorZyX0zFe
(View comments
Filed under: Perl Core DRY 
April 21, 2010
"SQLite library consists of approximately 67.2 KSLOC of C code. (KSLOC means thousands of “Source Lines Of Code” or, in other words, lines of code excluding blank lines and comments.) By comparison, the project has 679 times as much test code and test scripts - 45678.3 KSLOC."

From How SQLite Is Tested, via Reddit.

Impressive. In comparison, Perl 5.12.0 has 29826 tests*.

* from running egrep -ri "tests ?=> ?" * | perl -e '$s = 0; while(<>) { m/.*tests ?=> ?([0-9]+)/; $s+=$1;} print "total: $s\n"' inside t/ directory. Remember Tumblr RSS is broken, you may not see the right code in your feed reader.

by jjm on 8:17am  |   URL: http://tumblr.com/ZPorZyW3Nm2
(View comments
Filed under: Tests Quality SQLite Perl KSLOC 
April 13, 2010
"The yada yada operator (noted …) is a placeholder for code. Perl parses it without error, but when you try to execute a yada yada, it throws an exception with the text Unimplemented."

From Perlop about Yada Yada operator.

Perl 5.12.0 it’s out! Yada Yada!

April 3, 2010
Putting Mojo vs Dancer in a Competition

I’ve tested both frameworks, with one public result (built with Mojolicious), and another one ongoing (playing with Dancer).

I like both, but both frameworks have their own problems.

Mojo it’s more advanced than Dancer, but it has an important problem with the documentation (the lack of it) and with the non existent API stability (at least when I tried it, it was easy to break your application after an upgrade).

Dancer it’s simpler to use (and simpler overall), with good and almost complete documentation, but it’s less mature IMHO (and you can find rough edges while programming a real world application).

Anyway, both are interesting projects and I recommend them if you want to try a modern Perl based MVC framework.

by jjm on 7:50pm  |   URL: http://tumblr.com/ZPorZyTRt6l
(View comments
Filed under: Mojo Dancer Perl web MVC framework 
March 12, 2010
"I’m tired of Perl being seen as a second-class citizen in the dynamic languages world. I freely admit that there’s a lot of bad Perl code out there (I’ll even admit to writing some of it) but it’s not bad Perl code because it’s Perl, it’s bad Perl code because it’s bad code."

From Crufty Old Perl.

Yes, I agree (indeed I’m guilty myself of coding some bad Perl code). Seems that Perl it’s the only one language capable of having bad practices: unmaintainable code, unreadable code, etc; or what it’s even worse, the only one language not being able to avoid these bad and undesirable things.

by jjm on 3:31pm  |   URL: http://tumblr.com/ZPorZyQRgP-
(View comments
Filed under: Perl Bad Code quality