What is the IP of my docker container?

May 12th, 2015 robin Posted in Perl No Comments »

Want to list the IP addresses of all of your docker containers?

Use this little script using docker ps and docker inspect wrapped in Perl for some nice formatting.

Perl powered home automation

September 5th, 2012 robin Posted in Home, Ironman, Perl No Comments »

I recently got my first raspberry pi, and have been hacking… :)

If you haven’t heard of “The Pi”, it’s a credit card sized computer with a 700MHz ARM processor, 256MB RAM, USB, HDMI, Network, … and a load of GPIO output pins.  Happily, someone has already written a perl interface to the GPIO pins, and so now for the first time I can quickly and easily do hardware hacking with perl.

There are already a few operating systems ported to the Pi, but the most popular is Raspbian – a Debian variant customised for the Pi.  With a bit of hardware hacking (optocouplers to isolate a 12V circuit from the 3.3V one, and a 3V to 12V voltage converter), I was able to make an interface between the Pi, and a household plug socket remote control (about 9.90EUR at most hardware stores).

Here’s the result:

Perl interface to Google Directions API

February 1st, 2012 robin Posted in google, Ironman, Perl, Travel No Comments »

Google has a pretty neat service for getting driving/cycling/walking directions between places, and now there’s a perl interface to it: Google::Directions (and on GitHub)

It’s Moosey and it’s juicy… I hope it helps you get from A to B with Perl a bit faster! :)

If anybody is top-fit with Moose::Util::TypeConstraints, I have some issues in this module which I don’t understand and would really appreciate some tips with. :)

And here’s some sample code:

#!/usr/bin/env perl
use strict;
use warnings;
use Google::Directions::Client;
use Getopt::Long;
my %params;
GetOptions( \%params,
my $goog = Google::Directions::Client->new();
my $response = $goog->directions( %params );
my $first_leg = $response->routes->[0]->legs->[0];
printf( "That journey will take you %0.1f minutes and %0.1fkm\n",
 ( $first_leg->duration / 60 ),
 ( $first_leg->distance / 1000 ),
# $> ./test_directions.pl --origin "Munich, Germany" --destination "Hamburg, Germany"
# That journey will take you 443.8 minutes and 778.5km