YAPC::Europe 2014, day 1

(crossposted from blog.tobez.org)

When I came to the venue 15 minutes before the official start of the registration, people at the registration desk were busily cutting sheets of paper into attendees' badges. Finding my badge turned out to be a tad not trivial.

This conference is somewhat unusual not only because it is conducted over the weekend instead of in the middle of the week, but also because the keynotes for every day are pushed till the end, even after the daily lightning talks session.

The welcome talk from Marian was about practical things such as rooms locations, dinner, lunches, transportations and so on. Then I went on stage to declare the location of YAPC::Europe 2015 (which is Granada, Spain by the way). After that Jose Luis Martinez from Barcelona.pm did a short presentation of YAPC in Granada, and Diego Kuperman gave a little present from Granada to Sofia.

YAPC::Europe Day 1

A day of two breakfasts, one at the hotel and one at the conference venue (more Баница) while meeting everyone.

First big announcement of the day was that YAPC::Europe 2015 will be in Granada, Spain.

And then the first talks of the conference. I chose to attend Welcome to Auditing and toughening as part of the Security Development Lifecycle which was an interesting look at how hardening a system is just a small part of the security development lifecycle. John highlighted the importance of a threat model and how avoiding vulnerabilities as early as possible is the only way to go. He went though a few practical examples of where was the best place to fix

Over sandwiches at lunch we had a little discussion about the compromises between fixing vulnerabilities and maintaining backwards compatibility.

The Wi-Fi has been a little spotty, but mosh make it usable.

Next up was Code I'm proud of: where Thomas explained lots of little hacks, from passwords and Bread::Board to microblogging.

Type::Tiny Tricks #6: Tricks with Tuples

Let's say you want an attribute to accept a pair of numbers - perhaps a geographic co-ordinates [ 50.873, -0.002 ]. You could constrain the attribute as ArrayRef[Num], but that would accept an arrayref containing a single number, or eight numbers, or even a reference to an empty array.

With the Tuple type constraint, you can be more exact in expressing which values are acceptable:

   isa  => Tuple[ Num, Num ]

YAPC::Europe Day 0

I travelled from Heathrow to Sofia, Bulgaria very early this morning. I managed to bump into a few Perl Mongers on the flight over and we were welcomed by a camel sign at the airport. I managed to find my hotel and have a proper shower. First order of business was to have a proper lunch, I bumped into someone and we took the shiny new metro system into town and explored the center of town. I managed to pick up a Баница , a pastry with fresh cheese. We then wandered around, found a great Rodin exhibition and made it to the evening meetup a little early. Luckily we weren't the only people turning up early and started drinking a Zagorka or two. Very drinkable.

Type::Tiny Tricks #5: Wrapping Moose/Mouse Type Constraints

So you have this Moo class, and it turns out what you really need for it is the StrictVersionStr type constraint defined in MooseX::Types::Perl. You could switch the class to Moose, but long term you want to stick with Moo.

Eventually you'll steal what you need from MooseX::Types::Perl, so you don't have the Moose dependency, but for now what you really want is to be able to use a Moose type constraint within a Moo class! What a predicament you've gotten yourself into! Type::Tiny to the rescue!

      package Local::Eg5;
      use Moo;
      use MooseX::Types::Perl qw( StrictVersionStr );
      use Types::TypeTiny qw( to_TypeTiny );
      has version_number => (
         is   => "ro",
         isa  => to_TypeTiny( StrictVersionStr ),

Perfect Hashes and faster than memcmp

In my previous post about perlcc next steps I talked shortly about my current project, Perfect::Hash.

# generate c file for readonly lookup
phash keyfile --prefix=phash -nul

# pure-perl usage
use Perfect::Hash;
my @dict = split/\n/,`cat /usr/share/dict/words`;
my $ph = Perfect::Hash->new(\@dict, -minimal);
for (@ARGV) {
  my $v = $ph->perfecthash($_);
  print ($dict[$v] eq $_ ? "$_ at line ".$v+1."\n" : "$_ not found\n");

Perfect::Hash->new("keyfile", '-urban', ...)->save_c;
# or just:
phash keyfile --urban
cc -O3 -msse4.2 phash.c ... -lz

phash /usr/share/dict/words --cmph-bdz_ph --nul
cc -O3 phash.c ... -lcmph

Let's talk about Time::Moment and round-trip of strings

In my previous blog post I wrote a lot more about Time::Moment, than appeared in the post (could have been my mistake due to a preview and error and a incomplete copy and a paste, but still very inconvenient). So I have decided to break down my original blogpost in several blogposts.

Time::Moment implements a subset of ISO 8601 (known as 4.3 Date and time of day, 4.3.2 Complete representations), Wikipedia has a good article regarding ISO 8601, but it's not an authoritative source for the ISO 8601:2004(E) standard.

Time::Moment is capable of parsing any string that purports to be formatted in ISO 8601:2004(E), 4.3.2 Complete representation.

Such formats includes the following:

Combinations of calendar date and time of day:

Basic format:

Extended format:

Combinations of ordinal date and time of day:

Type::Tiny Tricks #4: Inlined Type Constraints

If ever you're unsure of how a type constraint has been defined, you can examine the string of Perl code used to implement it. For example, does an ArrayRef[Int] accept an empty arrayref?

   my $type = ArrayRef[Int];
   print $type->inline_check('$X');

About blogs.perl.org

blogs.perl.org is a common blogging platform for the Perl community. Written in Perl and offering the modern features you’ve come to expect in blog platforms, the site is run by Dave Cross and Aaron Crane, with a design donated by Six Apart, Ltd.