Tweets and retweets from Week #43

This is my second attempt of trying to get into a habit of blogging on a more regular basis. The blog posts categorized as Retweets will list a set of tweets and retweets from the week just gone by.

David Golden (@xdg) wrote a very interesting blog post very relevant to my own issues with keeping up with and consuming and publishing via social media. I decided to tweet this since David’s pragmatic approach and reflection are very interesting especially if you want to work smarter and not harder with your social media interaction.

Putting social media on cruise-control bit.ly/Rn3JUZ – interesting blog post by @xdg, approaching social media with pragmatism

Smashing Magazine (@smashingmag) featured an interesting and insightful article on coding standards. The article is written by Nicholas C. Zakas (@slicknet). The article is mentions Javascript and CSS as examples, but the issue is universal and some good guidance it given to thinking about and shaping your own coding standard for your situation and languages.

Better Code Quality: Why Coding Style Matters bit.ly/Rn48a2, great piece on importance of coding style via @smashingmag by @slicknet

ack is a fantastic command line tool, which I often use over grep. Check it out, you will not be disappointed.

@lbalker: @drkrab @mtnygard it’s spelled ack (http://betterthangrep.com/ ). You’re welcome 🙂

I love figures and diagrams, so this article caught my eye. Nice diagrams and a very interesting topic, which I need to read up on by the way. The concept of message queuing is quite intriguing and the article provides a good introduction to AMQP.

@kellabyte: Blogged: Clarifying AMQP http://kellabyte.com/2012/10/20/clarifying-amqp

Keep (re)tweeting,

jonasbn

Tweets and retweets from Week #43

Nordic Perl Workshop 2012

Just back from the Nordic Perl Workshop 2012 in Stockholm, Sweden.

It has been quite some time since I have attended a Perl community event, so it felt awesome to see old friends again and at the same time meeting new people.

The Nordic Perl Workshop 2012 was arranged by Claes Jakobsson, who always set up a nice 1 track setting, so you do not have the dilemma of choosing between tracks. You can settle in one room and you are then exposed to talks you might would have skipped, a very elegant way to arrange a workshop in my opinion.

The Nordic Perl Workshops in Stockholm have always been my favorites since the atmosphere is very intimate and by the end of the workshop you end up have talked to practically all attendees.

The 2012 workshop was no disappointment, the program was varied, with different speakers covering a wide variation of topics.

– Jonathan Worthington on Perl 6 modules and
– Claes on Perl 5 topics related to parsing and debugging
– Salve Nilson on communities
– Ulrich Wisser on Perl::Critic and a very interesting talk on SASL and related
– Me on Stackato
– And of course Damian Conway on Perl 5 regular expressions and most impressive regular expression debugger: Regexp::Debugger

Unfortunately I had to leave prior to hearing the last talks and I am sure I missed out on some good talks, but a national holiday back home in Denmark required my presence for a family holiday.

In addition to the marvelous talks I had great conversations with other attendees on topics like SOA architecture, Perl culture and on software development methodology and practices. The workshop was compact, but as always immensely educational and fun.

We are considering having the Nordic Perl Workshop 2013 in Copenhagen – I hope we will be able to do just as good a job as Claes and the Stockholm Perl Mongers (sorry Salve Meetup).

Nordic Perl Workshop 2012

Textmate and Perlbrew

Textmate is a marvelous text editor for programming and other text based tasks on OSX. It even has a great extension for assisting when programming Perl. One of the really helpful features is a syntax validation happening when a file is saved.

Take for example this incomplete Perl source file below

hell-2012-10-14-20-29.png
If you specify the contents as perl (see the bottom of the window) or let Textmate resolve this Textmate will evaluate the contents when I save and get an error due to the very obvious syntax error in line 3.

warning-2012-10-14-20-29.png
Correcting the contents of the file, will give me status indicating an evaluation success.

no-errors-2012-10-14-20-29.png

This is really nifty most of the time, but I ran into a problem.

I am using App::perlbrew (perlbrew) to handle my local Perl installations. Perlbrew is a magnificent tool and it lets me install several different Perl interpreters in parallel. So I can evaluate my code using different versions of Perl.

The check executed by Textmate is handled by a script named: perlcheckmate.pl (available on Github) and it relies solely on the system perl installed in /usr/bin.

So when I work on a project requiring a newer (or older) version and I then use Perlbrew to satisfy this, I have to install external dependencies with two Perls – not exactly optimal also because I am not interested in maintaining and feeding all sort of crazy modules to my system Perl, just because I am working on some project.

Luckily adjusting perlcheckmate.pl to recognize and use perlbrew is quite easy.

perlbrew sets some environment variables when active:

  • PERLBREW_PERL
  • PERLBREW_ROOT

When perlbrew is active these variables will have content, if not or not installed, existing behavior should be preserved – and not everyone uses perlbrew.

So if PERLBREW_PERL is defined we have a Perl interpreter controlled by perlbrew and we can adjust accordingly. See lines 34 to 42. So We define our Perl interpreter to point to this instead of the Perl interpreter located in /usr/bin.

[codesyntax lang=“perl”]
#!/usr/bin/perl

use strict;
use Env qw($PERLBREW_PERL $PERLBREW_ROOT);

# cwd should be $™_DIRECTORY
# filename to check is $ARGV[0]

my $file = $ARGV[0];

my %file_source;
sub read_source {
require File::Spec;
require File::Basename;
my $file = shift;
my $file_source;
{ local $/ = undef; open F, “<$ENV{™_FILEPATH}”; $file_source = <F>; close F }
my @file_source = split /\r?\n/, $file_source;
my $path = $file;
if (!-f $path || !File::Spec->file_name_is_absolute($path)) {
$path = File::Spec->rel2abs($path, $ENV{™_DIRECTORY});
if (!-e $path) {
$path = undef;
my $base = File::Basename::basename($path);
foreach (@INC) {
my $file = File::Spec->catfile($_, $base);
$path = $file, last if -e $file;
}
}
}
$file_source{$file} = { source => \@file_source, path => $path };
}

my $perl;

if ($PERLBREW_PERL) {
$perl = “$PERLBREW_ROOT/perls/$PERLBREW_PERL/bin/perl”;
} else {
$perl = ‘perl’;
}

my @lines = `”$perl” -Tcw “$file” 2>&1`;
my $lines = join ‘’, @lines;

if ((scalar(@lines) == 1) && ($lines =~ m/ syntax OK$/s)) {
exit 0;
}

$lines =~ s/&/&/g;
$lines =~ s/</</g;
$lines =~ s/>/>/g;

# link line numbers to source
$lines =~ s%^((?:.+)[ ]+at[ ]+(.+)[ ]+line[ ]+)(\d+)[.,]%
my $pre = $1;
my $file = $2;
my $lnum = $3;
my $col;
if ($pre =~ m/“([^”]+)”/) {
read_source($file)
unless exists $file_source{$file};
my $source_line = $file_source{$file}{source}[$lnum-1];
$file = $file_source{$file}{path};
$col = index($source_line, $1);
$col = $col != -1 ? $col + 1 : 0;
} else {
if ($file !~ m!^/!) {
read_source($file)
unless exists $file_source{$file};
$file = $file_source{$file}{path};
}
}
my $url = qq{txmt://open?url=file://$file&line=$lnum};
$url .= “&column=$col” if $col;
qq{$pre<a href=“$url”>$lnum</a>.};
%gmex;

my $output = ‘<pre style=“word-wrap: break-word;”>’;
$output .= $lines;
$output .= ‘</pre>’;

print $output;
[/codesyntax]

To make a point on my opinion on the use of system perl. You can have a look at the perlcheckmate.pl script above. This script is an external application, bundled with Textmate and therefor it relies on the presence of perl in /usr/bin in order to work, so this line is perfectly okay and it should work even though the operating system is updated.

If you read the script carefully you can see that the script uses two external components:

  • File::Spec
  • File::Basename::basename

These are Perl core modules and they should not give any problems. But if you by some weird coincidence and accidentally change or break these as part of development, you are breaking your toolchain at the same time. Your system perl should be considered a key component in your operating system on most modern operating systems.

Textmate and Perlbrew