Stories
Slash Boxes
Comments

All the Perl that's Practical to Extract and Report

use Perl Log In

Log In

[ Create a new account ]

cog (4665)

Journal of cog (4665)

Sunday August 17, 2008
03:19 PM

YAPC::EU::2009 in Lisbon, Portugal

So next year's YAPC::EU will be held in Lisbon, Portugal, and will be organized, once again, by Alberto and myself.

We have a lot of ideas and we're eager to get all of them accomplished.

Finally having a partner program is one of those ideas, as is having an arrival survival kit being sent to the attendees *before* the conference takes place (with a map, simple indications, etc).

A beginner's track will be part of our program, which is likely to both attract conference newcomers and delight the eyes, ears, and brains, of those who sometimes find the regular talks too technical.

You have one year to plan, so it's going to be harder for you to convince yourself that you're missing this wonderful conference because of somebody else.

We'll be with you all the way.

We're working to put together an amazing conference, we'll be pointing you to where to stay, where to eat, what do to, and how to get here, and we'll be preparing a partner program, so you can bring your family along with you to Lisbon, land where the good beer is really cheap and where you'll find an extraordinary cuisine waiting for you.

We'll be talking to you all year long to help you sort things out and to let you know how we're sorting things out too.

We're looking forward to the tenth YAPC::EU.

So should you.

In a future post, we'll explain what the conference theme is going to be.

03:13 PM

YAPC::EU::2008 in Copenhagen, Denmark

Beautiful Perl in Beautiful Copenhagen.

How appropriate.

Three wonderful days of conference during which I barely rested.

Anyway, next year I'll have one less flight to do, apparently, as the tenth YAPC::EU is coming to Lisbon, Portugal.

More on that in the near future.

I need to rest, now...

Sunday August 10, 2008
09:11 AM

Thirty years and other news

Random thoughts.

So I'm finally thirty (the day was last Friday, August 8th).

I went to the YAPC in Chicago. Wonderful conference. Great job, guys!

Tomorrow I'm departing for Copenhagen, for yet another YAPC.

This is definitely the best part of the year.

This is the first time I'm going to three YAPCs in the same year.

Copenhagen will also be my tenth YAPC.

The weekend has been really awesome, with pizza, sushi, movies, sun, beaches... And it's not over yet.

And it's hard to think of a better company to spend it with.

Well, out I go again.

Friday August 01, 2008
11:02 AM

*sigh*

WTF?

    my $limit = shift;

    $limit = 100;
    if (!$limit) {
        $limit = 20;
    }

OMG...

    my @files_raw = <$directory/*>;
    my @files = sort { lc($b) cmp lc($a) } @files_raw;

OMFG...

    foreach my $file (@files) {
        if ($i < $limit) {
            $i += 1;
            # [...]
        }
    }

JFC...

Tuesday July 29, 2008
05:11 AM

By the power of Murphy! (oh, and Adam has arrived)

So I went to get AdamK at the airport, this morning.

I had been waiting for him for about 40 minutes, when I decided it was time for action.

I decided to invoke Murphy by putting my earplugs and turn my iPod on.

Sure enough, before the first song could end, Adam arrived.

No, I'm not saying I turned my iPod on and Murphy acted. I'm actually saying I put Murphy to the test, by deliberately doing something that would make him make Adam show up.

And sure enough...

Murphy acted...

I need to do this more often.

Anyway, here's a picture of a 'Perl on a Stick'.

Well...

Technically speaking, it's a "Perl on a 'Perl on a Stick' Stick" :-)

Thursday July 24, 2008
02:01 PM

Happiness is...

...when you notice you just did with 23 lines of code what the previous programmer did with 425.

sub parse {
        my $self = shift;

        my $feed = XML::Feed->parse( \$self->get_content() );

        my @items;

        for my $entry ( $feed->entries ) {
                push @items,
                {
                        title => $entry->title,
                        link => $entry->link,
                        description => $entry->content->body || $entry->summary->body,
                        date => $entry->issued || $entry->modified,
                        author => $entry->author,
                },
        }

        return {
                feed_title => $feed->title,
                items => \@items,
        };
}

That over there is parsing Atom, RSS1, and RSS2 just the way the system needs it to be done.

And yes, the project where those 425 lines could be found was the one I mentioned a few days ago.

(apparently the code tags are messing up the allignment of the => and ||)

Monday July 21, 2008
04:14 PM

Three weeks at my new job

Three weeks have passed.

Here are the highlights:

Days 1 - 3

  • introduced to dozens of people, saw a bunch of presentations about projects and methodologies;
  • after meeting all of these guys, I had a feeling that I could give an introductory Perl course, so I suggested that to the powers that be;

Day 4

  • got introduced to my first project, a remake of an already deployed system;
  • the room for my one-day Perl class was confirmed (a very nice room with capacity for 40 attendees) and the course was announced;

Days 5 and 6

  • gave the first steps in my project, prepared the slides and exercises for the course (I already had some material ready);

Day 7 (a Wednesday)

  • 40 people (the limit for the room) had registered and showed up, counting people from Perl, PHP, Python, .Net and JavaScript, and also a handful of sysadmins;
  • IMHO, the course went very well;

Days 8 - 12

  • more coding, and a suggestion of a Regular Expressions training with me lecturing; I say yes;

Day 13 (another Wednesday)

  • almost 40 people show up, counting a lot of people from the first session and a bunch of newcomers;
  • the course goes well, and I'm happy that Adam's "Perl on a Stick" allows for a couple of Windows users to install and have perl running in just a couple of minutes;
  • there was another course (on Security, I believe) in the same day (which appeared to be non-optional for those who were attending); I've been asked to repeat this class for those guys;

Days 14 - now

  • more coding; the project currently has a total of 1690 lines (which includes documentation and around 25% of empty lines; I know, that's less than 200 LOC a day, but hey, I spent some time designing the thing in the beginning; maybe I could hack something into the repository to create a graph that would show the evolution of this number through time... hum... now I'm curious...);
  • there's documentation in all the modules, a test suite, and a more general/overview documentation in the project Wiki, which resides within the Trac system I'm using (44% of the first milestone tickets are completed).

And now for some non-chronological highlights:

  • I'm enjoying this a lot;
  • While there are very proficient Perl people around, there's also a few people who are not so skilled in the language (but all of whom seem to be very bright) that now feel comfortable asking me for help (not sure if they felt comfortable or not asking others for help, but I seem to be a regular Perl go-to guy right now, and if it helps people, I'm very happy with it). So far I've been called to explain an if-clause in a one-liner was badly written, that a 'use XML::Simple' inside an eval should have actually been a 'require XML::Simple', to help sharing runtime-generated code references between threads (which was solved with a dispatch table and a tie), and to track down the whys of a process resulting in a never ending stream of SIGSEGVs after an arbitrary running time (and I haven't solved this one yet);
  • There's free fruit in the office;
  • I'd like to say that the rule of thumb here is that of "two monitors per person", but I may be wrong... the rule may actually be "three monitors per person" (counting laptops, yes);
  • I've been asked by more than one person to give a course on Object Oriented Perl, and when I mentioned a list of things we could have courses on, it was clear that a Test Driven Development class would have enough attendance to justify it.

And that's it for now (of what I can tell publicly).

So far so good.

Sunday July 20, 2008
01:13 PM

Why I'm not buying an iPhone

Because I don't like being abused.

Apple.com says: "Starting at $199."

However, here in Portugal, it costs 600€, which at the current exchange rate is something like $951.

Supposedly, operators should be providing the iPhone at a lower rate, possibly demanding a 24 month contract, or something like that.

Unfortunately, operators in Portugal are going a step further, demanding extra things for a client to qualify for the lower prices.

Vodafone - lower price

With Vodafone, you have to already have been a client 6 months ago, and you also need to have a number of points in your Vodafone account so you can trade for the discount.

Even then, the lowest price is 219,90€ a month, with a monthly rate of 64,90€ which comprises 500 minutes, 500 sms, and 500MB traffic. You also have to sign for 24 months.

Vodafone - regular price

The regular price is of 599,90€. You don't have to sign for the 24 months and you can choose the plan you want, but hey, the regular plans are really crappy, when it comes to data.

Optimus - lower price

The cheapest you can get the iPhone from Optimus is for 245€, but you gotta have 4200 points in your Optimus account.

Optimus - regular price

The regular price at Optimus is also 599,90€.

What is this?

iRobbery?

Wednesday July 16, 2008
06:25 PM

Legacy Code :: When it's just not worth it

So there's an already deployed system.

It doesn't take more than a glimpse to notice the following:

  • no versioning control, just the deployed version
  • no documentation
  • no comments
  • commented code
  • a bunch of scripts, one for each step of the algorithm
  • a Perl system, shell scripts that invoke the Perl scripts in specific orders, a PHP backend
  • a bunch of stuff in crond
  • a bunch of files ending in ~, .bak or .old
  • a directory called bk (yes, from backup)
  • a couple of files with different names but with the exact same content
  • an ever increasing number of processes, which sometimes have to be killed when the machine is running too slow
  • a database with tables that have several columns that have never been used
  • several modules, in the same namespace, with replicated code among them
  • several modules with replicated code inside them (copy-paste, yes)
  • way too many lines of code with more than 80 characters
  • to be honest, way too many lines of code with more than 120 characters (the record is 588)
  • lack of indentation
  • lots of spaghetti code
  • a bunch of things you'd never do in Perl
  • nested if clauses where you could use a simple dispatch table (these ones make my eyes hurt)
  • for and foreach mixed around (at least you should pick one and stick with it...), sometimes Perl-style, sometimes C-style (sometimes using $i, sometimes using $xy, sometimes using other variables)
  • hardcoded passwords
  • serious security problems (at least judging by the amount and complexity of SQL queries constructed without using placeholders)
  • a testing directory with nothing resembling tests; just a couple of scripts which you run and then you look at the output to see if it's what you were expecting, assuming you know what the output is supposed to look like, of course
  • and then a directory called "legacy", into which I don't even dare look

And that's just a glimpse.

Normally, I wouldn't write a post about something like this... But seriously, can you see the amount of problems with this thing? And it's only from 2005! And from a guy who keeps writing on his blog about how clever he is!

Now tell me: What would you do?

I'll tell you what the people in charge decided to do... Rebuild the whole thing from scratch. Forget it even exists, and start all over again, this time with someone that (hopefully) knows what he's doing (that would be me).

And now, a personal note...

It's always easier to complain and to criticize other's code than doing it yourself.

I would totally understand that one day, the person who built that system would come across this post or something else I'd written about his project, and would come back at me, in a defense of his technical skills.

With that in mind, I'd like to leave a note to that person, regarding how he built this thing:

I dare you to explain what you were thinking and the decisions you took, assuming you took any!

Friday June 27, 2008
02:36 PM

"This Summer in Perl"