<?xml version="1.0" encoding="UTF-8"?>
<rss xmlns:dc="http://purl.org/dc/elements/1.1/" version="2.0"><channel><atom:link rel="hub" href="http://tumblr.superfeedr.com/" xmlns:atom="http://www.w3.org/2005/Atom"/><description>Hello World!
My name is Sérgio Bernardino (a.k.a. smpb), and I am a software engineer, hobbyist photographer, and all-around geek. I hail from Lisbon, Portugal. Feel free to save this information and contact me at any time.
Photography
I enjoy seeing the world through the unique sight of a camera.
Please, check out my photos here.
Digital footprint
This is my official home on the web, but quite often you’ll find me in a lot of other places as well.</description><title>Sérgio Bernardino :: Uploaded</title><generator>Tumblr (3.0; @smpb)</generator><link>http://sergiobernardino.net/</link><item><title>Hartverdrahtet – Infinite complexity in 4096 bytes


  Worthy...</title><description>&lt;iframe width="400" height="225" src="http://www.youtube.com/embed/0w_xEUoK79o?wmode=transparent&amp;autohide=1&amp;egm=0&amp;hd=1&amp;iv_load_policy=3&amp;modestbranding=1&amp;rel=0&amp;showinfo=0&amp;showsearch=0" frameborder="0" allowfullscreen&gt;&lt;/iframe&gt;&lt;br/&gt;&lt;br/&gt;&lt;h2&gt;Hartverdrahtet – Infinite complexity in 4096 bytes&lt;/h2&gt;

&lt;blockquote&gt;
  &lt;p&gt;Worthy winner of the PC 4kB intro competition at Revision 2012 and latest example of the compact-coding tradition exercised within the demoscene, &lt;strong&gt;Hartverdrahtet&lt;/strong&gt; by Akronyme Analogiker is a three minute long audio-visual trip into a procedural fractalverse, compressed into a minuscule piece of software.&lt;/p&gt;
  
  &lt;p&gt;No bigger than 4069 bytes – less than an empty Word document, as demoscene activists like to point out – the executable file contains all the mathematics needed to generate the unfolding visual complexity and audible ambience upon a double-click.&lt;/p&gt;
&lt;/blockquote&gt;

&lt;p&gt;Absolutely amazing.&lt;/p&gt;</description><link>http://sergiobernardino.net/post/22845500716</link><guid>http://sergiobernardino.net/post/22845500716</guid><pubDate>Fri, 11 May 2012 17:32:54 +0100</pubDate><category>video</category><category>demoscene</category><category>4096</category></item><item><title>"Say you’re in the kitchen in front of the refrigerator, thinking about a sandwich. You take a..."</title><description>“&lt;p&gt;Say you’re in the kitchen in front of the refrigerator, thinking about a sandwich. You take a ‘continuation’ right there and stick it in your pocket. Then you get some turkey and bread out of the refrigerator and make yourself a sandwich, which is now sitting on the counter. You invoke the ‘continuation’ in your pocket, and you find yourself standing in front of the refrigerator again, thinking about a sandwich. But fortunately, there’s a sandwich on the counter, and all the materials used to make it are gone.&lt;/p&gt;

&lt;p&gt;So you eat it. :-)&lt;/p&gt;”&lt;br/&gt;&lt;br/&gt; - &lt;em&gt;&lt;em&gt;“The Continuation Sandwich: explaining first-class Continuations”&lt;/em&gt;, &lt;a href="http://groups.google.com/group/perl.perl6.language/msg/b0cfa757f0ce1cfd"&gt;perl.perl6.language&lt;/a&gt;&lt;/em&gt;</description><link>http://sergiobernardino.net/post/19921793851</link><guid>http://sergiobernardino.net/post/19921793851</guid><pubDate>Mon, 26 Mar 2012 00:13:00 +0100</pubDate><category>Quote</category><category>Programming</category></item><item><title>in flight</title><description>&lt;img src="http://25.media.tumblr.com/tumblr_m0osbaDzlK1qzo329o1_500.jpg"/&gt;&lt;br/&gt;&lt;br/&gt;&lt;p&gt;&lt;h2&gt;in flight&lt;/h2&gt;&lt;/p&gt;</description><link>http://sergiobernardino.net/post/19075561171</link><guid>http://sergiobernardino.net/post/19075561171</guid><pubDate>Sat, 10 Mar 2012 20:45:00 +0000</pubDate><category>Photography</category><category>Instagram</category></item><item><title>The Most Astounding Fact


  “… when I look up at the...</title><description>&lt;iframe width="400" height="225" src="http://www.youtube.com/embed/9D05ej8u-gU?wmode=transparent&amp;autohide=1&amp;egm=0&amp;hd=1&amp;iv_load_policy=3&amp;modestbranding=1&amp;rel=0&amp;showinfo=0&amp;showsearch=0" frameborder="0" allowfullscreen&gt;&lt;/iframe&gt;&lt;br/&gt;&lt;br/&gt;&lt;h2&gt;The Most Astounding Fact&lt;/h2&gt;

&lt;blockquote&gt;
  &lt;p&gt;“… when I look up at the night sky and I know that yes, we are part of this Universe, we are in this Universe. But perhaps more important than both of those facts is that the Universe is in us.&lt;/p&gt;
  
  &lt;p&gt;When I reflect on that fact, I look up - many people feel small because they’re small and the Universe is big - but I feel big, because my atoms came from those stars.&lt;/p&gt;
  
  &lt;p&gt;There’s a level of connectivity.&lt;/p&gt;
  
  &lt;p&gt;That’s really what you want in life, you want to feel connected, you want to feel relevant, you want to feel like you’re a participant in the goings on of activities and events around you.&lt;/p&gt;
  
  &lt;p&gt;That’s precisely what we are, just by being alive.”&lt;/p&gt;
&lt;/blockquote&gt;

&lt;p style="text-align:right;font-size:10px;padding:0"&gt;— Neil deGrasse Tyson&lt;/p&gt;</description><link>http://sergiobernardino.net/post/18861303044</link><guid>http://sergiobernardino.net/post/18861303044</guid><pubDate>Tue, 06 Mar 2012 21:10:24 +0000</pubDate><category>Video</category><category>Neil deGrasse Tyson</category></item><item><title>“They don’t advertise for killers in the newspaper....</title><description>&lt;img src="http://24.media.tumblr.com/tumblr_lyui52jLyV1qg11wio1_500.jpg"/&gt;&lt;br/&gt;&lt;br/&gt;&lt;p&gt;&lt;blockquote&gt;“They don’t advertise for killers in the newspaper. That was my profession. Ex-cop. Ex-blade runner. Ex-killer.”&lt;/blockquote&gt;

&lt;p style="text-align:right;font-size:10px;padding:0"&gt;— &lt;a href="http://www.imdb.com/title/tt0083658/"&gt;Blade Runner (1982)&lt;/a&gt;&lt;/p&gt;&lt;/p&gt;</description><link>http://sergiobernardino.net/post/18601930398</link><guid>http://sergiobernardino.net/post/18601930398</guid><pubDate>Fri, 02 Mar 2012 10:56:00 +0000</pubDate><category>Movies</category><category>Reblog</category></item><item><title>I, for one, welcome our new plain text overlords</title><description>&lt;a href="http://www.hiltmon.com/blog/2012/02/20/the-markdown-mindset/"&gt;I, for one, welcome our new plain text overlords&lt;/a&gt;: &lt;blockquote&gt;
  &lt;p&gt;Markdown is text, just plain text. Its the one format that has not changed over all the years. Oh sure, we’ve gone from a 7-bit ascii code to UTF-8, but all text editors happily handle the old text formats. And when they stop, a small C program will fix it.&lt;/p&gt;
  
  &lt;p&gt;&lt;strong&gt;Plain text, and therefore Markdown, are as future-proof as you can get in computing.&lt;/strong&gt;&lt;/p&gt;
&lt;/blockquote&gt;

&lt;p&gt;Since I can remember I’ve been acutely sensitive to file format lock-in, for all the reasons ranging from portability, to maintainability, and future-proofing. Plain text has &lt;em&gt;always&lt;/em&gt; been my format of choice for anything involving writing.&lt;/p&gt;

&lt;p&gt;In that context, &lt;a href="http://en.wikipedia.org/wiki/Markdown"&gt;Markdown&lt;/a&gt; (or any sort of light-weight markup language for plain text, in fact), is nothing new or revolutionary. It has, however, become increasingly popular this past few years, and it is a trend that I find most welcome.&lt;/p&gt;

&lt;p&gt;The more people rave about it as the pinnacle of data portability, the more tools spring out of the woodwork to support it, and facilitate its creation, editing, and consumption. And that’s great!&lt;/p&gt;

&lt;p&gt;Tools like &lt;a href="http://www.iawriter.com/"&gt;iAWriter&lt;/a&gt;, &lt;a href="http://www.appsonthemove.com/trunk.htm"&gt;TrunkNotes&lt;/a&gt;, and plain old - reliable - &lt;a href="http://www.vim.org/"&gt;vi&lt;/a&gt;, are common-place (and increasingly valuable) in my daily workflow&lt;sup id="fnref:p18374695606-1"&gt;&lt;a href="#fn:p18374695606-1" rel="footnote"&gt;1&lt;/a&gt;&lt;/sup&gt;. This post itself has been written with Markdown formatting, and on the day the format is replaced by &lt;em&gt;“The Next Big Thing (TM)”&lt;/em&gt;, all the time I spend buried away in Perl code should keep me, and my data, safe enough&lt;sup id="fnref:p18374695606-2"&gt;&lt;a href="#fn:p18374695606-2" rel="footnote"&gt;2&lt;/a&gt;&lt;/sup&gt;.&lt;/p&gt;

&lt;div class="footnotes"&gt;
&lt;hr&gt;&lt;ol&gt;&lt;li id="fn:p18374695606-1"&gt;
&lt;p&gt;All of it tightly weaved up around &lt;a href="http://dropbox.com/"&gt;Dropbox&lt;/a&gt;, unsurprisingly. &lt;a href="#fnref:p18374695606-1" rev="footnote"&gt;↩&lt;/a&gt;&lt;/p&gt;
&lt;/li&gt;

&lt;li id="fn:p18374695606-2"&gt;
&lt;p&gt;Not accounting for other side effects from prolonged exposure to Perl code, of course ;-) &lt;a href="#fnref:p18374695606-2" rev="footnote"&gt;↩&lt;/a&gt;&lt;/p&gt;
&lt;/li&gt;

&lt;/ol&gt;&lt;/div&gt;</description><link>http://sergiobernardino.net/post/18374695606</link><guid>http://sergiobernardino.net/post/18374695606</guid><pubDate>Mon, 27 Feb 2012 10:22:00 +0000</pubDate><category>Link</category><category>Markdown</category></item><item><title>Recursively delete specific files within a directory tree</title><description>&lt;p&gt;Here&amp;#8217;s something I find myself needing time and time again, but never seem to have the accurate syntax at the tip of my fingers.&lt;/p&gt;

&lt;p&gt;Suppose you have a complex directory hierarchy, with several different types of files within it, in which you want to remove all files of a specific format. How does one accomplish this with a single command?&lt;/p&gt;

&lt;p&gt;You simply pipe the output of &amp;#8216;find&amp;#8217; into &amp;#8216;rm&amp;#8217;, like so:&lt;/p&gt;

&lt;pre&gt;&lt;code&gt;    find . -name '*.log' -exec rm -i "{}" \;
&lt;/code&gt;&lt;/pre&gt;

&lt;p&gt;The double quotes are needed if the names within the hierarchy have white-spaces, and the escaped semi-colon is required to close the &amp;#8216;exec&amp;#8217; statement.&lt;/p&gt;</description><link>http://sergiobernardino.net/post/18329409644</link><guid>http://sergiobernardino.net/post/18329409644</guid><pubDate>Sun, 26 Feb 2012 19:22:00 +0000</pubDate><category>CLI</category><category>Unix</category><category>Memory</category></item><item><title>"As I learned more about how these early role-playing games worked, I realized that a D&amp;D module..."</title><description>“As I learned more about how these early role-playing games worked, I realized that a D&amp;D module was the primitive equivalent of a quest in the OASIS. And D&amp;D characters were just like avatars. In a way, these old role-playing games had been the ﬁrst virtual-reality simulations, created long before computers were powerful enough to do the job. In those days,if you wanted to escape to another world, you had to create it yourself, using your brain, some paper, pencils, dice, and a few rule books. This realization kind of blew my mind. It changed my whole perspective on the Hunt for Halliday’s Easter egg. From then on, I began to think of the Hunt as an elaborate D&amp;D module. And Halliday was obviously the dungeon master, even if he was now controlling the game from beyond the grave.”&lt;br/&gt;&lt;br/&gt; - &lt;em&gt;Ernest Cline, &lt;a href="http://www.readyplayerone.com/"&gt;READY PLAYER ONE&lt;/a&gt; (2011)&lt;/em&gt;</description><link>http://sergiobernardino.net/post/15722546170</link><guid>http://sergiobernardino.net/post/15722546170</guid><pubDate>Thu, 12 Jan 2012 14:30:00 +0000</pubDate><category>Quote</category><category>READY PLAYER ONE</category></item><item><title>Dungeons &amp; Dragons - The Way Forward</title><description>&lt;a href="http://www.penny-arcade.com/comic/2012/01/11/the-way-forward"&gt;Dungeons &amp; Dragons - The Way Forward&lt;/a&gt;: &lt;p&gt;I stopped playing &lt;a href="http://en.wikipedia.org/wiki/Dungeons_%26_Dragons"&gt;D&amp;D&lt;/a&gt; during the transition from the 3.5 Edition to the 4th&lt;sup id="fnref:p15671395973-1"&gt;&lt;a href="#fn:p15671395973-1" rel="footnote"&gt;1&lt;/a&gt;&lt;/sup&gt;. I was somewhat burned out after playing the former for a long period of time without meaningful interruptions, and the new mechanics introduced by the latter did not grip me &lt;em&gt;at all&lt;/em&gt;.&lt;/p&gt;

&lt;p&gt;To see news of Wizards (or should I say, Hasbro) &lt;a href="http://www.nytimes.com/2012/01/10/arts/video-games/dungeons-dragons-remake-uses-players-input.html"&gt;planning a new major edition&lt;/a&gt; a mere three years after the debut of the Fourth Edition (by comparison, the gap between the 3rd and 4th was eight years, with the 3.5 revision showing up roughly mid-cycle) really rings alarm bells to me. It looks clear now that the Fourth Edition wasn’t all that successful in stopping the increasing loss of players to the digital RPG front (such as MMO video games), and the like.&lt;/p&gt;

&lt;p&gt;Having them boast that, this time around, &lt;a href="http://nerdtrek.com/dungeons-dragons-5th-edition/"&gt;what the community wants truly matters to them&lt;/a&gt; is just silly, and &lt;strong&gt;Penny Arcade&lt;/strong&gt; nails the “why” perfectly. People who are &lt;em&gt;really&lt;/em&gt; serious about pen &amp; paper roleplaying games aren’t at all aligned with what Wizards &lt;em&gt;really&lt;/em&gt; needs: people willing to spend unreasonable amounts of money on renewing their core book sets and on increasingly contrived accessories like cards and miniatures.&lt;/p&gt;

&lt;div class="footnotes"&gt;
&lt;hr&gt;&lt;ol&gt;&lt;li id="fn:p15671395973-1"&gt;
&lt;p&gt;You can catch up on that experience, through some writing I did during that time, on &lt;a href="http://draconusdictum.wordpress.com/"&gt;Draconus Dictum&lt;/a&gt;. It’s only available in Portuguese, though. &lt;a href="#fnref:p15671395973-1" rev="footnote"&gt;↩&lt;/a&gt;&lt;/p&gt;
&lt;/li&gt;

&lt;/ol&gt;&lt;/div&gt;</description><link>http://sergiobernardino.net/post/15671395973</link><guid>http://sergiobernardino.net/post/15671395973</guid><pubDate>Wed, 11 Jan 2012 15:00:00 +0000</pubDate><category>Link</category><category>Penny Arcade</category><category>Dungeons and Dragons</category></item><item><title>rocket</title><description>&lt;img src="http://25.media.tumblr.com/tumblr_lwewuaQIpH1qzo329o1_500.jpg"/&gt;&lt;br/&gt;&lt;br/&gt;&lt;p&gt;&lt;strong&gt;rocket&lt;/strong&gt;&lt;/p&gt;</description><link>http://sergiobernardino.net/post/14412014768</link><guid>http://sergiobernardino.net/post/14412014768</guid><pubDate>Sun, 18 Dec 2011 18:32:00 +0000</pubDate><category>Instagram</category><category>Photography</category></item><item><title>“The 9000 series is the most reliable computer ever made. No...</title><description>&lt;img src="http://25.media.tumblr.com/tumblr_ldo8rtgMzM1qe0eclo1_r1_500.gif"/&gt;&lt;br/&gt;&lt;br/&gt;&lt;blockquote&gt;&lt;p&gt;&lt;i&gt;“The 9000 series is the most reliable computer ever made. No 9000 computer has ever made a mistake or distorted information. We are all, by any practical definition of the words, foolproof and incapable of error.”&lt;/i&gt;&lt;/p&gt;

&lt;p style="text-align:right;font-size:10px;padding:0"&gt;— &lt;a href="http://www.imdb.com/title/tt0062622/"&gt;2001: A Space Odyssey (1968)&lt;/a&gt;&lt;/p&gt;&lt;/blockquote&gt;</description><link>http://sergiobernardino.net/post/13107385383</link><guid>http://sergiobernardino.net/post/13107385383</guid><pubDate>Mon, 21 Nov 2011 10:29:00 +0000</pubDate><category>GIF</category><category>Movies</category><category>Reblog</category></item><item><title>The Codebits Experience</title><description>&lt;p&gt;&lt;img src="http://files.sergiobernardino.net/images/codebits_v.png" alt="Codebits V - 2011"/&gt;&lt;/p&gt;

&lt;p&gt;If I wanted to surmise the &lt;a href="http://codebits.eu/"&gt;Codebits&lt;/a&gt; experience into one simple word, it would be this: &lt;em&gt;more&lt;/em&gt;.&lt;/p&gt;

&lt;p&gt;One goes to Codebits looking for knowledge, and leaves it craving &lt;em&gt;more&lt;/em&gt;. One enters Codebits with a set amount of friends, and surely leaves it with even &lt;em&gt;more&lt;/em&gt;. One reaches Codebits expecting to have fun, and ends up having &lt;em&gt;more&lt;/em&gt;. In short, every time a Codebits edition ends, it leaves everyone waiting for &lt;em&gt;more&lt;/em&gt;.&lt;/p&gt;

&lt;h2&gt;Codebits 2011&lt;/h2&gt;

&lt;p&gt;Codebits is already in its fifth year, and although I missed the first two editions, since my visit in 2009, I&amp;#8217;ve made an effort not to miss another one. To be sure, it&amp;#8217;s not as trivial as just saving time for it. One has to earn the privilege of attending, and I have been fortunate enough to have done so. With three consecutive editions under my belt, I can say with considerable certainty that it really is a memorable experience that has only gotten better throughout the years.&lt;/p&gt;

&lt;p&gt;Being an event deeply rooted in technology and (mainly) the Internet, it undeniably has a very specific target audience. I have found, however, that there is a bit of everything for everyone with an inquisitive disposition, and that the only two real prerequisites are the willingness to learn, and to have fun doing so. From there, the Codebits aura of sheer raw energy will make sure you&amp;#8217;ll feel more than welcome.&lt;/p&gt;

&lt;h2&gt;And you are welcome&lt;/h2&gt;

&lt;p&gt;Any geek worthy of the name has a weak spot for tech-related swag&lt;sup id="fnref:p12923233114-1"&gt;&lt;a href="#fn:p12923233114-1" rel="footnote"&gt;1&lt;/a&gt;&lt;/sup&gt;. We all have more t-shirts, pens, notepads, and USB keys than we need or care for, but those short moments after getting the welcome kit are like a small piece of Christmas right then and there on the show-floor.&lt;/p&gt;

&lt;p&gt;The Codebits organization has turned this into a relevant part of the experience by systematically upping the ante every year, to the point where the kit is riddled with actually useful stuff. Even the more negligible bits have the purpose of serving as teasers for what&amp;#8217;s to come.&lt;/p&gt;

&lt;p&gt;Is the &lt;a href="http://www.firstlegoleague.org/"&gt;LEGO League&lt;/a&gt; present on the venue? Add an amusing &amp;#8220;Top Secret&amp;#8221; envelope with a random piece to make you wonder about it. Will there be workshops about &lt;a href="http://www.arduino.cc/"&gt;Arduino&lt;/a&gt;? Add a tiny kit with a LED and a sensor to spur you on. Which T-shirt did you get this year? The artwork in each is random, and I do think I like that guy&amp;#8217;s pick of the draw more than I do mine&amp;#8230;&lt;/p&gt;

&lt;p&gt;At a glance, it all sounds like minor stuff, but it&amp;#8217;s smart, and works for a killer first impression.&lt;/p&gt;

&lt;p&gt;&lt;img src="http://files.sergiobernardino.net/images/yubikey.jpg" alt="Yubikey"/&gt;&lt;/p&gt;

&lt;p&gt;This year, the most surprising piece of swag in the package (for me) turned out not to be swag at all, but a very valuable offer. What seemed at first as &amp;#8220;yet another useless USB key&amp;#8221;, proved to be something entirely different: An individual &lt;a href="http://yubico.com/yubikey"&gt;Yubikey&lt;/a&gt; for each an every attendee.&lt;/p&gt;

&lt;p&gt;Used as a way to actively promote &lt;a href="http://www.sapo.pt/"&gt;SAPO&lt;/a&gt;&amp;#8217;s new two-step authentication feature in its unified login process, a Yubikey is much more valuable than that when you consider Yubico&amp;#8217;s developer-friendly demeanor. By exposing a &lt;a href="http://www.yubico.com/web-api-clients"&gt;web API&lt;/a&gt; with which to use the Yubikey, the possibilities are immense&lt;sup id="fnref:p12923233114-2"&gt;&lt;a href="#fn:p12923233114-2" rel="footnote"&gt;2&lt;/a&gt;&lt;/sup&gt;.&lt;/p&gt;

&lt;p&gt;Might as well use that O&amp;#8217;Reilly coupon, also found inside the classy Codebits laptop backpack that wrapped the complete package, to get a free ebook that helps out with these ideas.&lt;/p&gt;

&lt;p&gt;They shower us with gifts. And we &lt;em&gt;love&lt;/em&gt; it.&lt;/p&gt;

&lt;h2&gt;Home Away From Home&lt;/h2&gt;

&lt;p&gt;Despite being backed by very important companies from the local Portuguese technology spectrum (and beyond), I believe that Codebits is much more than just a venue where people go to publicly demonstrate their highly tuned technical, and business, skills, or to be charmed into any random corporate recruitment process.&lt;/p&gt;

&lt;p&gt;Codebits is a celebration of everything that surrounds the geek culture when related to technology. Be it the hacker&amp;#8217;s spirit of constant tinkering and reverse engineering, the unquenchable thirst for the most recent shiny piece of hardware, or the love for retro-computing. Sprawling from any recognizable Internet phenomenon, to the most inscrutable memes, and even common pop culture (like movies, TV shows, music, or books). Codebits has all this, and it&amp;#8217;s proud to showcase it in every corner, and at every opportunity. It wouldn&amp;#8217;t stand for it to happen in any other way.&lt;/p&gt;

&lt;p&gt;From serious corporate keynotes, to insane gauntlets in which participants are charged with presenting esoteric (even borderline nonsensical) keynotes they&amp;#8217;ve never even seen before, to a full-fledged &lt;a href="https://codebits.eu/s/blog/772c08436a8ec480bf0292fa885ff951"&gt;Quiz Show&lt;/a&gt;: the venue&amp;#8217;s Main Stage has it all.&lt;/p&gt;

&lt;p&gt;Game consoles are conspicuously placed in areas with a lot of foot traffic, you see people &lt;a href="http://vimeo.com/32003962"&gt;gliding effortlessly about on home-made skate boards&lt;/a&gt;, and anywhere you go you&amp;#8217;re likely to cross paths with a tiny fledgeling &lt;a href="http://www.artica.cc/blog/2011/11/12/sapo-code-bits-v-live/"&gt;robot&lt;/a&gt; built exclusively for the purpose of exploring these unique surroundings, as if it just happened to have landed on Mars.&lt;/p&gt;

&lt;p&gt;At a pre-determined time in the schedule, people drop everything they are doing, and line up to have a taste of an outlandish dish: It features &lt;a href="http://en.wikipedia.org/wiki/Bhut_Jolokia_chili_pepper"&gt;the hottest chili pepper in the world&lt;/a&gt;, and to eat it is an experience that&amp;#8217;s described as nothing short of incredibly excruciating. But some venture forth, and return grinning (albeit in pain) with the priceless &amp;#8220;badge of honor&amp;#8221; proving that they were one of the few that &lt;em&gt;did it&lt;/em&gt;.&lt;/p&gt;

&lt;p&gt;All of this, and much more, under the backdrop of green-tinted walls, enormous screens flashing an assortment of items (from schedule news, to Twitter updates), and the constant buzzing of voices from those merely chatting, those embroiled in their projects, or even the speakers dishing out their knowledge in any of the secondary stages.&lt;/p&gt;

&lt;p&gt;There&amp;#8217;s a lot of laughter permeating through Codebits. People are happy to be there. And comfortable. For the geek, it&amp;#8217;s a home away from home.&lt;/p&gt;

&lt;h2&gt;And yet, it works&lt;/h2&gt;

&lt;p&gt;But let&amp;#8217;s not get too carried away. Work does happen within the walls of Codebits. Serious work. Ideas flow and plans are sketched and executed. Some are bad, some are good. Some make it to the end, some don&amp;#8217;t&lt;sup id="fnref:p12923233114-3"&gt;&lt;a href="#fn:p12923233114-3" rel="footnote"&gt;3&lt;/a&gt;&lt;/sup&gt;. A few win, and the rest go back to the drawing board and hope to make it big next year.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://plus.google.com/photos/101322694033866977766/albums/5673876286976808833/5673876932573848338"&gt;&lt;img src="http://files.sergiobernardino.net/images/codebits_v_panorama_by_nunodantas.jpg" alt="the working space"/&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;As expected from a hackaton of this caliber, computers are everywhere&lt;sup id="fnref:p12923233114-4"&gt;&lt;a href="#fn:p12923233114-4" rel="footnote"&gt;4&lt;/a&gt;&lt;/sup&gt;, and you&amp;#8217;ll constantly see scores of faces focused on streams of text in a screen. Flip-charts exist, riddled with sketches, designs, flowcharts. Those ideas considered bad are promptly torn and discarded, in a race to meet the deadline. Everyone wants to reach the finish line, and in the best shape possible.&lt;/p&gt;

&lt;p&gt;You&amp;#8217;ll be hard pressed to navigate the &lt;a href="http://panoramas.fotos.sapo.pt/codebits2011"&gt;wide sea of large desks, occupied chairs, cables, and exhausted people sleeping on bean bags&lt;/a&gt;, when the talk you want to attend is precisely on the other side of the working area. It&amp;#8217;s a tight space, for so many eager.&lt;/p&gt;

&lt;p&gt;It all climaxes in a massive final presentation where each of the competing teams is given an incredibly short window of time to prove their worth, as the audience watches and votes, and the jury listens and ponders.&lt;/p&gt;

&lt;p&gt;It’s not an easy thing to watch. The system isn’t perfect, and you witness glitches and such technical problems you can’t help but to wonder why they still happen after 5 years of supposed fine-tuning. 90 seconds is indeed a very short timespan, but when you multiply it by dozens of projects, it wears you down. The teams frailties and exhaustion are laid bare in those precious seconds, and you (if indeed you care) have to endure through all the poorly prepared speakers, failed live demos, and incredibly flat attempts at humor.&lt;/p&gt;

&lt;p&gt;Neither is it easy to present. In fact, it’s not easy &lt;em&gt;at all&lt;/em&gt;. Everyone knows that the margin for success is incredibly thin. That no matter how good your project is, if you fail in that key moment, it&amp;#8217;s all over. Compressing 48 hours of intense work into 90 seconds of supposed genius, in front of a highly skeptical (and tired) audience, is the worst (and takes a special kind of talent).&lt;/p&gt;

&lt;p&gt;Quite a few crash and burn spectacularly. Like a slow motion car wreck you’re horrified to witness, but can’t seem to avert your eyes from. You feel sorry for the guy, and you’re glad you’re not him.&lt;/p&gt;

&lt;p&gt;On the flip side, a talented few shine as bright as the rising sun on a hot summer day. People spontaneously burst into cheers and impromptu rounds of applause. You’re glad for that guy, even a bit envious, and you do wish you were the one to whom that happens. Everyone does.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://plus.google.com/photos/101322694033866977766/albums/5674465443482670401/5674474761213708802"&gt;&lt;img src="http://files.sergiobernardino.net/images/codebits_v_panorama2_by_nunodantas.jpg" alt="the final showdown"/&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;There are prizes, of course. To the victors go the spoils, and what a rich bounty it is: From premium priced computers and tablets, to smart phones and even huge television sets that simply can&amp;#8217;t be easily hauled off the stage. You barely notice the expensive books also being haphazardly given away. It&amp;#8217;s so crazy, it reaches TV game show proportions.&lt;/p&gt;

&lt;p&gt;It all combines into a powerful machine that drives you more and more towards wanting to be a part of it. You want to be on that stage and shine.&lt;/p&gt;

&lt;h2&gt;In The End&lt;/h2&gt;

&lt;p&gt;There is a whole lot left unsaid, with many things yet to mention&lt;sup id="fnref:p12923233114-5"&gt;&lt;a href="#fn:p12923233114-5" rel="footnote"&gt;5&lt;/a&gt;&lt;/sup&gt;. The clichéd expression &amp;#8220;you had to have been there&amp;#8221; repeatedly comes to mind, and though it pains me to use it, it is quite appropriate.&lt;/p&gt;

&lt;p&gt;Codebits is unique in the way it winds you up into a twisting ball of excitement, as much as it drains you of your much needed energy. You wake up the following day, thanking for it to be a Sunday, feeling like you just took an enormous beating.&lt;/p&gt;

&lt;p&gt;But you regret nothing, and always come back to ask for &lt;em&gt;more&lt;/em&gt;.&lt;/p&gt;

&lt;div class="footnotes"&gt;
&lt;hr&gt;&lt;ol&gt;&lt;li id="fn:p12923233114-1"&gt;
&lt;p&gt;&lt;em&gt;&amp;#8220;Stuff We All Get&amp;#8221;&lt;/em&gt;&amp;#160;: The assorted promotional merchandise offered in venues such as this. &lt;a href="#fnref:p12923233114-1" rev="footnote"&gt;↩&lt;/a&gt;&lt;/p&gt;
&lt;/li&gt;

&lt;li id="fn:p12923233114-2"&gt;
&lt;p&gt;From using their PAM module to reinforce remote server access, to port-knocking, it was enough to set my brain into overdrive. &lt;a href="#fnref:p12923233114-2" rev="footnote"&gt;↩&lt;/a&gt;&lt;/p&gt;
&lt;/li&gt;

&lt;li id="fn:p12923233114-3"&gt;
&lt;p&gt;Mine didn&amp;#8217;t, to my dismay. A tale for another time. &lt;a href="#fnref:p12923233114-3" rev="footnote"&gt;↩&lt;/a&gt;&lt;/p&gt;
&lt;/li&gt;

&lt;li id="fn:p12923233114-4"&gt;
&lt;p&gt;On that note, the amount of Apple computers at the event was absolutely staggering. &lt;a href="#fnref:p12923233114-4" rev="footnote"&gt;↩&lt;/a&gt;&lt;/p&gt;
&lt;/li&gt;

&lt;li id="fn:p12923233114-5"&gt;
&lt;p&gt;There&amp;#8217;s a world of material concerning all things &lt;a href="https://codebits.eu/s/blog/749a8c5c704add718e2ca6d3298b47c8"&gt;#softwood&lt;/a&gt;, and a certain group of &lt;a href="http://oneoverzero.org/"&gt;crazy lobsters&lt;/a&gt;, but unfortunately&amp;#8230; we lack the time ;-) &lt;a href="#fnref:p12923233114-5" rev="footnote"&gt;↩&lt;/a&gt;&lt;/p&gt;
&lt;/li&gt;

&lt;/ol&gt;&lt;/div&gt;</description><link>http://sergiobernardino.net/post/12923233114</link><guid>http://sergiobernardino.net/post/12923233114</guid><pubDate>Thu, 17 Nov 2011 12:42:00 +0000</pubDate><category>Writing</category><category>Codebits</category></item><item><title>focused writing</title><description>&lt;img src="http://24.media.tumblr.com/tumblr_lus4e8ksYW1qzo329o1_500.jpg"/&gt;&lt;br/&gt;&lt;br/&gt;&lt;p&gt;&lt;h2&gt;focused writing&lt;/h2&gt;&lt;/p&gt;</description><link>http://sergiobernardino.net/post/12903084663</link><guid>http://sergiobernardino.net/post/12903084663</guid><pubDate>Thu, 17 Nov 2011 00:37:00 +0000</pubDate><category>Instagram</category><category>Photography</category></item><item><title>Errors when Installing DBD::mysql on Mac OS X</title><description>&lt;p&gt;For some reason, installing &lt;strong&gt;DBD::mysql&lt;/strong&gt; on Mac OS X is the source of much grief. There are countless blog entries, forum posts, and &lt;a href="http://stackoverflow.com/questions/tagged/dbd+mysql+perl"&gt;Stack Overflow&lt;/a&gt; questions floating around about this very same issue.&lt;/p&gt;

&lt;p&gt;Obviously, it was only a matter of time until I was afflicted by this and end up losing hours of valuable time trying to puzzle out the proper solution. But fortunately I got it working, so I&amp;#8217;ll add what I&amp;#8217;ve found to the countless bits of information already in the &amp;#8220;pile&amp;#8221;.&lt;/p&gt;

&lt;h2&gt;&amp;#8220;Symbol not found&amp;#8221;&lt;/h2&gt;

&lt;p&gt;I&amp;#8217;m assuming you&amp;#8217;re not using the system&amp;#8217;s default Perl installation&lt;sup id="fnref:p12885983651-1"&gt;&lt;a href="#fn:p12885983651-1" rel="footnote"&gt;1&lt;/a&gt;&lt;/sup&gt;, and that you&amp;#8217;ve installed the default MySQL binaries for your architecture from &lt;a href="http://dev.mysql.com/downloads/"&gt;dev.mysql.com&lt;/a&gt;. The issue manifested itself to me on &lt;strong&gt;Snow Leopard&lt;/strong&gt;, but I&amp;#8217;ve no reason to believe (so far) that in &lt;strong&gt;Lion&lt;/strong&gt; the behaviour is any different.&lt;/p&gt;

&lt;p&gt;With Perl and MySQL properly installed on the machine, you move onto installing &lt;strong&gt;DBD::mysql&lt;/strong&gt;&lt;sup id="fnref:p12885983651-2"&gt;&lt;a href="#fn:p12885983651-2" rel="footnote"&gt;2&lt;/a&gt;&lt;/sup&gt;. It should build fine and begin testing.&lt;/p&gt;

&lt;p&gt;At this time, you might get errors similar to this:&lt;/p&gt;

&lt;pre&gt;&lt;code&gt;Error: Can't load './blib/arch/auto/DBD/mysql/mysql.bundle'
  for module DBD::mysql:
    dlopen(./blib/arch/auto/DBD/mysql/mysql.bundle, 2):
      Symbol not found: _is_prefix
&lt;/code&gt;&lt;/pre&gt;

&lt;p&gt;or it might vary slightly, showing you this:&lt;/p&gt;

&lt;pre&gt;&lt;code&gt;Error: Can't find 'boot_DBD__mysql' symbol in
  ./blib/arch/auto/DBD/mysql/mysql.bundle
&lt;/code&gt;&lt;/pre&gt;

&lt;p&gt;Now, this only happened to me when I tried to install the module manually (after the tests failed when loading the client library - more below)&lt;sup id="fnref:p12885983651-3"&gt;&lt;a href="#fn:p12885983651-3" rel="footnote"&gt;3&lt;/a&gt;&lt;/sup&gt;. If this is your case, first and foremost, make sure you&amp;#8217;re invoking the configuration command correctly.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;This is WRONG&lt;/strong&gt;:&lt;/p&gt;

&lt;pre&gt;&lt;code&gt;perl Makefile.PL --libs="-lmysqlclient -L/usr/local/mysql/lib"  \
--cflags=-I/usr/local/mysql/include
&lt;/code&gt;&lt;/pre&gt;

&lt;p&gt;&lt;strong&gt;This is RIGHT&lt;/strong&gt;:&lt;/p&gt;

&lt;pre&gt;&lt;code&gt;perl Makefile.PL --libs="-L/usr/local/mysql/lib -lmysqlclient" \
--cflags=-I/usr/local/mysql/include
&lt;/code&gt;&lt;/pre&gt;

&lt;p&gt;Notice the subtle difference in the order of the parameters.&lt;/p&gt;

&lt;p&gt;In these circumstances, the best idea is to collect the adequate values like so:&lt;/p&gt;

&lt;pre&gt;&lt;code&gt;~/ $&amp;gt; mysql_config --libs      
-L/usr/local/mysql/lib -lmysqlclient   -lpthread

~/ $&amp;gt; mysql_config --cflags
-I/usr/local/mysql/include  -Os -g -fno-common -fno-strict-aliasing -arch x86_64
&lt;/code&gt;&lt;/pre&gt;

&lt;p&gt;Copying the information from this source will guarantee that you&amp;#8217;ll avoid mistakes like the one I did above.&lt;/p&gt;

&lt;h2&gt;&amp;#8220;Library not loaded&amp;#8221;&lt;/h2&gt;

&lt;p&gt;But even if you aren&amp;#8217;t affected by the errors above, chances are that you&amp;#8217;re being greeted with this particular message:&lt;/p&gt;

&lt;pre&gt;&lt;code&gt;Error:
    Can't load './blib/arch/auto/DBD/mysql/mysql.bundle'
  for module DBD::mysql:
    dlopen(./blib/arch/auto/DBD/mysql/mysql.bundle, 2):
      Library not loaded: libmysqlclient.18.dylib
&lt;/code&gt;&lt;/pre&gt;

&lt;p&gt;This means that the compiled bundle is looking for the client library in the wrong place. You can correct this by fixing the reference in the bundle itself with the command:&lt;/p&gt;

&lt;pre&gt;&lt;code&gt;sudo install_name_tool -change libmysqlclient.18.dylib  \
/usr/local/mysql/lib/libmysqlclient.18.dylib  \
./blib/arch/auto/DBD/mysql/mysql.bundle
&lt;/code&gt;&lt;/pre&gt;

&lt;p&gt;Or you can make sure it never happens again by always setting this variable in your environment:&lt;/p&gt;

&lt;pre&gt;&lt;code&gt;export DYLD_LIBRARY_PATH=$DYLD_LIBRARY_PATH:/usr/local/mysql/lib/
&lt;/code&gt;&lt;/pre&gt;

&lt;h2&gt;All done!&lt;/h2&gt;

&lt;p&gt;With all this set in place, the installation of &lt;strong&gt;DBD::mysql&lt;/strong&gt; is unlikely to give much more trouble, beyond failing the connectivity tests if you don&amp;#8217;t have the MySQL server running as it expects you to be.&lt;/p&gt;

&lt;p&gt;But that is a harmless issue.&lt;/p&gt;

&lt;div class="footnotes"&gt;
&lt;hr&gt;&lt;ol&gt;&lt;li id="fn:p12885983651-1"&gt;
&lt;p&gt;If you&amp;#8217;re not working from a &lt;a href="http://perlbrew.pl"&gt;perlbrew&lt;/a&gt; setup, that&amp;#8217;s your first mistake. &lt;a href="#fnref:p12885983651-1" rev="footnote"&gt;↩&lt;/a&gt;&lt;/p&gt;
&lt;/li&gt;

&lt;li id="fn:p12885983651-2"&gt;
&lt;p&gt;For this effect (and to make your life easier) installing &lt;a href="https://metacpan.org/module/Bundle::DBD::mysql"&gt;Bundle::DBD::mysql&lt;/a&gt; from CPAN, is recommended. &lt;a href="#fnref:p12885983651-2" rev="footnote"&gt;↩&lt;/a&gt;&lt;/p&gt;
&lt;/li&gt;

&lt;li id="fn:p12885983651-3"&gt;
&lt;p&gt;Yes, by trying to dig myself out of a hole, I dug one deeper and nearly buried myself in it. &lt;a href="#fnref:p12885983651-3" rev="footnote"&gt;↩&lt;/a&gt;&lt;/p&gt;
&lt;/li&gt;

&lt;/ol&gt;&lt;/div&gt;</description><link>http://sergiobernardino.net/post/12885983651</link><guid>http://sergiobernardino.net/post/12885983651</guid><pubDate>Wed, 16 Nov 2011 17:33:00 +0000</pubDate><category>DBD::mysql</category><category>Perl</category><category>Mac OS X</category></item><item><title>List of Freely Available Programming Books</title><description>&lt;a href="http://stackoverflow.com/questions/194812/list-of-freely-available-programming-books"&gt;List of Freely Available Programming Books&lt;/a&gt;: &lt;p&gt;Incredibly comprehensive list of readily available books related with programming.&lt;/p&gt;

&lt;p&gt;I find lists like these to be a double-edged sword. They are very useful, but one &lt;em&gt;can&lt;/em&gt; harm himself with too much information, by quickly losing focus and the realization that actually doing something is as important (if not more) than just endlessly reading about how it is done.&lt;/p&gt;

&lt;p&gt;Still, this one is a keeper, and definitely worth a browse.&lt;/p&gt;</description><link>http://sergiobernardino.net/post/12792790413</link><guid>http://sergiobernardino.net/post/12792790413</guid><pubDate>Mon, 14 Nov 2011 16:28:00 +0000</pubDate><category>Link</category><category>Stack Overflow</category><category>Free</category><category>Programming</category><category>Books</category></item><item><title>Codebits::API</title><description>&lt;p&gt;&lt;a href="http://codebits.eu/"&gt;Codebits&lt;/a&gt;, the massive hackathon extravaganza organized by Portuguese tech company &lt;a href="http://sapo.pt/"&gt;SAPO&lt;/a&gt;, has its fifth edition happening in &lt;a href="https://codebits.eu/s/calendar"&gt;only a few days&lt;/a&gt; and I couldn&amp;#8217;t be more excited about it. This will be my third consecutive year attending, and given that it has been improving by leaps and bounds with each edition, I have high expectations for this year.&lt;/p&gt;

&lt;p&gt;&lt;img src="http://files.sergiobernardino.net/images/codebits_bot.png" alt="Codebits Bot"/&gt;&lt;/p&gt;

&lt;h2&gt;API Preamble&lt;/h2&gt;

&lt;p&gt;Since the machine began churning inexorably towards the event&amp;#8217;s November date, I made a point personally on being a lot more (pro-)active in my participation. Beyond taking part in the pre-event shenanigans (the &lt;a href="https://codebits.eu/s/blog/5baa4993b652a2353ed57319e3e08dcd"&gt;geek quiz&lt;/a&gt; is one example that I am a huge fan of), I began planning an adequate participation in the &lt;em&gt;48h programming/hacking competition&lt;/em&gt;. I am a software developer after all, but the amount of code I&amp;#8217;ve written in past Codebits editions has been pitiful.&lt;/p&gt;

&lt;p&gt;While musing on ideas to tackle at the event proper, I took time to lay some groundwork that might prove useful eventually. In particular, I decided to map the event&amp;#8217;s API onto my weapon of choice: &lt;strong&gt;Perl&lt;/strong&gt;.&lt;/p&gt;

&lt;p&gt;Although I am unsure of how many Perl mongers will attend (or even intend to hack on some Perl code during) the event, I purposefully left the implementation available publicly in the off-chance that it might be useful to someone. You can find it here:&lt;/p&gt;

&lt;ul&gt;&lt;li&gt;&lt;a href="https://github.com/smpb/codebits-api"&gt;[ smpb/codebits-api - GitHub ]&lt;/a&gt;&lt;/li&gt;
&lt;/ul&gt;&lt;h2&gt;Networking&lt;/h2&gt;

&lt;p&gt;Undoubtedly, you will be able to &lt;a href="https://codebits.eu/smpb"&gt;find me there&lt;/a&gt; dabbling away at some of this, or similar, code. If you&amp;#8217;re attending the event, and have any passing interest in Perl&lt;sup id="fnref:p12514627777-1"&gt;&lt;a href="#fn:p12514627777-1" rel="footnote"&gt;1&lt;/a&gt;&lt;/sup&gt;, don&amp;#8217;t hesitate to drop by for a chat.&lt;/p&gt;

&lt;div class="footnotes"&gt;
&lt;hr&gt;&lt;ol&gt;&lt;li id="fn:p12514627777-1"&gt;
&lt;p&gt;Or even if you don&amp;#8217;t. It&amp;#8217;s not really like there should be a prerequisite for some good conversation :-) &lt;a href="#fnref:p12514627777-1" rev="footnote"&gt;↩&lt;/a&gt;&lt;/p&gt;
&lt;/li&gt;

&lt;/ol&gt;&lt;/div&gt;</description><link>http://sergiobernardino.net/post/12514627777</link><guid>http://sergiobernardino.net/post/12514627777</guid><pubDate>Tue, 08 Nov 2011 16:00:00 +0000</pubDate><category>Programming</category><category>Codebits</category><category>Perl</category></item><item><title>
  $self++;
</title><description>&lt;img src="http://25.media.tumblr.com/tumblr_ltxcoh4E9R1qisuj3o1_500.png"/&gt;&lt;br/&gt;&lt;br/&gt;&lt;p&gt;
  &lt;code&gt;$self++;&lt;/code&gt;
&lt;/p&gt;</description><link>http://sergiobernardino.net/post/12321416762</link><guid>http://sergiobernardino.net/post/12321416762</guid><pubDate>Fri, 04 Nov 2011 10:00:05 +0000</pubDate></item><item><title>
  An everyday love story set in the not so distant future sees...</title><description>&lt;iframe src="http://player.vimeo.com/video/16962056" width="400" height="225" frameborder="0"&gt;&lt;/iframe&gt;&lt;br/&gt;&lt;br/&gt;&lt;blockquote&gt;
  &lt;p&gt;An everyday love story set in the not so distant future sees blackbirds battling with technology, automatic palm readers and power cuts.&lt;/p&gt;
&lt;/blockquote&gt;

&lt;p&gt;This must be Thursday. I never could get the hang of Thursdays.&lt;/p&gt;</description><link>http://sergiobernardino.net/post/11986482311</link><guid>http://sergiobernardino.net/post/11986482311</guid><pubDate>Thu, 27 Oct 2011 11:05:05 +0100</pubDate><category>Video</category><category>Vimeo</category><category>Thursday</category></item><item><title>Perl Weekly Newsletter</title><description>&lt;a href="http://perlweekly.com/"&gt;Perl Weekly Newsletter&lt;/a&gt;: &lt;blockquote&gt;
  &lt;p&gt;&lt;strong&gt;You&lt;/strong&gt; are busy churning out code or managing the developers. &lt;strong&gt;You&lt;/strong&gt; care about Perl but don’t have time to go through tens and hundreds of articles and blog posts every day. &lt;strong&gt;You&lt;/strong&gt; want to keep an eye on the development of Perl without drowning in a sea of blog posts. &lt;strong&gt;You&lt;/strong&gt; need someone to point out the most important news and articles in the Perl World. Let me be your guide.&lt;/p&gt;
&lt;/blockquote&gt;

&lt;p&gt;One could make a snarky comment pointing out that there are likely nowhere near &lt;em&gt;hundreds&lt;/em&gt; of articles being posted these days about Perl. But that would be missing the point.&lt;/p&gt;

&lt;p&gt;If you care for Perl, this is a valuable resource.&lt;/p&gt;</description><link>http://sergiobernardino.net/post/11860719285</link><guid>http://sergiobernardino.net/post/11860719285</guid><pubDate>Mon, 24 Oct 2011 12:07:09 +0100</pubDate><category>Reading</category><category>Programming</category><category>Perl</category></item><item><title>Moose Delegation and References Currying</title><description>&lt;p&gt;Storage abstraction in object-oriented programming is an interesting problem, approachable from several directions. While using Moose to build a set of self-storable objects, to tackle that particular issue, I came across a particular implementation detail that puzzled me for a while.&lt;/p&gt;

&lt;p&gt;My approach involves &lt;a href="http://search.cpan.org/perldoc?Moose::Manual::Roles"&gt;Roles&lt;/a&gt;, insofar as the objects in question consume the ability to be “storable”, with the complexity of the database access hidden away under a minimalistic interface.&lt;/p&gt;

&lt;p&gt;Within the Role, a private attribute holds the instance of the database object meant to deal with all the storage calls, and in order to minimize the number of open connections throughout the set, that object is implemented as a Singleton.&lt;/p&gt;

&lt;h2&gt;When in trouble, delegate&lt;/h2&gt;

&lt;p&gt;Since the database instance is the one supposed to be troubled with all the storage-related methods, it stands to reason that we should invoke said methods directly on it:&lt;/p&gt;

&lt;pre&gt;&lt;code&gt;my $dude = Person-&amp;gt;new(name =&amp;gt; “Lebowski”);
$dude-&amp;gt;db-&amp;gt;get_money();
&lt;/code&gt;&lt;/pre&gt;

&lt;p&gt;The problem with this is obvious: we are exposing the storage implementation details to the outside.&lt;/p&gt;

&lt;p&gt;Fortunately, Moose allows for quick and easy setup of method delegation when defining attributes:&lt;/p&gt;

&lt;pre&gt;&lt;code&gt;package My::Role::Storable;

use Moose::Role;
use My::Singleton::DB;

has '_db' =&amp;gt; (
  is          =&amp;gt; 'ro',
  isa         =&amp;gt; 'My::Singleton::DB',
  handles     =&amp;gt; [ qw( get_money get_rug abide ) ],
  lazy_build  =&amp;gt; 1,
);

sub _build__db
{
  My::Singleton::DB-&amp;gt;instance();
}
&lt;/code&gt;&lt;/pre&gt;

&lt;p&gt;By explicitly defining that the instance “handles” the method, we have the desired mean of invocation:&lt;/p&gt;

&lt;pre&gt;&lt;code&gt;$dude-&amp;gt;get_money();
&lt;/code&gt;&lt;/pre&gt;

&lt;p&gt;Perfect!&lt;/p&gt;

&lt;h2&gt;A contextual omission&lt;/h2&gt;

&lt;p&gt;But what I’ve described is fairly known and expected, since it&amp;#8217;s explained clearly in &lt;a href="http://search.cpan.org/perldoc?Moose::Manual::Delegation"&gt;Moose&amp;#8217;s documentation&lt;/a&gt;. And despite the simplicity of the delegation syntax, there is a detail - also documented - that somewhat jinxes this idea.&lt;/p&gt;

&lt;p&gt;In the context of the delegated method, the reference passed on invocation is the one of the database instance, and not of our storable object.&lt;/p&gt;

&lt;p&gt;What this means is quite simple: if you invoke an &amp;#8220;abide&amp;#8221; method (because that&amp;#8217;s what Dude&amp;#8217;s do), it won&amp;#8217;t work because the database instance has no implicit idea of which Dude you mean.&lt;/p&gt;

&lt;p&gt;Passing the object at the time of the instantiation of the database is also not a option, since we are dealing with a Singleton, which internally - by its own nature - needs to remain as generic as possible.&lt;/p&gt;

&lt;p&gt;Explicitly adding the object itself as an argument in each invocation would obviously work,&lt;/p&gt;

&lt;pre&gt;&lt;code&gt;$dude-&amp;gt;get_money($dude);
&lt;/code&gt;&lt;/pre&gt;

&lt;p&gt;But I believe it&amp;#8217;s plain to see why this is just wrong.&lt;/p&gt;

&lt;h2&gt;Curry in a hurry&lt;/h2&gt;

&lt;p&gt;Part of the answer lies - again - in Moose&amp;#8217;s documentation, since we are able to create delegations with a pre-set of parameters. Thus, every time the method is called, those values are passed along first no matter what other arguments are specified.&lt;/p&gt;

&lt;pre&gt;&lt;code&gt;has '_db' =&amp;gt; (
  is          =&amp;gt; 'ro',
  isa         =&amp;gt; 'My::Singleton::DB',
  handles     =&amp;gt; {
    get_money =&amp;gt; [ get_money =&amp;gt; 'one million dollars' ],
  },
  lazy_build  =&amp;gt; 1,
);
&lt;/code&gt;&lt;/pre&gt;

&lt;p&gt;This is, by definition, what is called “currying”.&lt;/p&gt;

&lt;h2&gt;The crux of the matter&lt;/h2&gt;

&lt;p&gt;This seems to resolve the issue. All is needed is to curry along a reference to the object holding the database instance so that when the method is called, and forwarded, the instance knows where the request actually came from.&lt;/p&gt;

&lt;p&gt;Unfortunately, it does not work.&lt;/p&gt;

&lt;p&gt;Moose&amp;#8217;s syntax for handling delegation, and currying in particular, can only deal with static arguments. It&amp;#8217;s only meant for the simple case.&lt;/p&gt;

&lt;p&gt;If the item to be curried along varies at runtime, we need to define our own custom sub-routine outside of the normal attribute declaration. In this case, something like this:&lt;/p&gt;

&lt;pre&gt;&lt;code&gt;sub get_money { my $self; return $self-&amp;gt;db-&amp;gt;get_money($self, @_); }
sub get_rug { my $self; return $self-&amp;gt;db-&amp;gt;get_rug($self, @_); }
sub abide { my $self; return $self-&amp;gt;db-&amp;gt;abide($self, @_); }
&lt;/code&gt;&lt;/pre&gt;

&lt;p&gt;This works just fine.&lt;/p&gt;

&lt;h2&gt;Some clean-up&lt;/h2&gt;

&lt;p&gt;But if you&amp;#8217;re getting some cold chills from just looking at all that repetition, you&amp;#8217;re not alone. It&amp;#8217;s ugly, lazy, and promises to be annoying to maintain.&lt;/p&gt;

&lt;p&gt;Albeit, not as short, this is much better:&lt;/p&gt;

&lt;pre&gt;&lt;code&gt;sub BUILD
{
  my $self = shift;
  my $meta = $self-&amp;gt;meta;

  for my $method(qw( get_money get_rug abide ))
  {
    $meta-&amp;gt;add_method($method,
      sub {
        my $self = shift; return $self-&amp;gt;db-&amp;gt;$method($self, @_);
      }
    );
  }
}
&lt;/code&gt;&lt;/pre&gt;

&lt;p&gt;With this we are assured that, at the moment after the object is constructed, the expected methods are added in the proper way. If the needs arises, the list of methods itself can be abstracted away into a variable, where it can be more easily altered in the future.&lt;/p&gt;

&lt;h2&gt;Closing Thoughts&lt;/h2&gt;

&lt;p&gt;It took me a while to realize that the solution above was the correct one since I chose to believe that I was missing something from the Moose documentation&lt;sup id="fnref:p11823724542-1"&gt;&lt;a href="#fn:p11823724542-1" rel="footnote"&gt;1&lt;/a&gt;&lt;/sup&gt;. I fully expected the delegation mechanism to support these slightly more elaborate needs, but I was wrong.&lt;/p&gt;

&lt;p&gt;In the end, it&amp;#8217;s not as compact and cohesive has I&amp;#8217;d hoped in the first place, but it&amp;#8217;s what I got.&lt;/p&gt;

&lt;p&gt;So, yeah, well: the Dude abides.&lt;/p&gt;

&lt;div class="footnotes"&gt;
&lt;hr&gt;&lt;ol&gt;&lt;li id="fn:p11823724542-1"&gt;
&lt;p&gt;And my thanks to &lt;a href="http://simplicidade.org/"&gt;Pedro Melo&lt;/a&gt;, and the fine folk at &lt;strong&gt;#moose&lt;/strong&gt; on &lt;a href="http://irc.perl.org/"&gt;irc.perl.org&lt;/a&gt; for helping me out. &lt;a href="#fnref:p11823724542-1" rev="footnote"&gt;↩&lt;/a&gt;&lt;/p&gt;
&lt;/li&gt;

&lt;/ol&gt;&lt;/div&gt;</description><link>http://sergiobernardino.net/post/11823724542</link><guid>http://sergiobernardino.net/post/11823724542</guid><pubDate>Sun, 23 Oct 2011 18:09:01 +0100</pubDate><category>Programming</category><category>Perl</category><category>Moose</category></item></channel></rss>

