grantm's Journalhttp://use.perl.org/images/topics/useperl.gifhttp://use.perl.org/~grantm/journal/
BCVI 3.0 Hits CPANhttp://use.perl.org/~grantm/journal/40379?from=rss
<p>My big news today is that Version 3.0 of bcvi is now available on CPAN.
If you have no idea what bcvi is then you'll be pleased to know I've written
<a href="http://sshmenu.sourceforge.net/articles/bcvi/">this article</a> to answer all
your questions - it even has pictures!</p><p>Way back in 2007 I knocked up a proof-of-concept implementation of a somewhat
crazy idea. I used it for a while and found it useful so I
<a href="http://www.perlmonks.org/index.pl?node_id=611462">shared it on PerlMonks</a> to
see if other people found it useful too. That was version 1.0.</p><p>Over time I fleshed out the core to make something more robust, more secure and
more useful. But I never released it publically because it always seemed like
the sort of tool that would be most useful to a person who hacked it into a
form that suited them. I really had no idea how to release and maintain a tool
that was meant to be hacked. So I kept it to myself and continued to find it
useful. That was version 2.0.</p><p>Eventually I realised that what I needed was a solid core of infrastructure
code and a plugin API that would allow people to hack the core without editing
the script itself. Quite why it took me so long to realise this, I couldn't
say. After all it's exactly what I did with <a href="http://sshmenu.sourceforge.net/">SSHMenu</a> and that has worked out very well.</p><p>The problem was that I didn't have a solid core of infrastructure code. What
I had was a proof-of-concept script that had some of the rough edges knocked
off and some new shiny bits bolted on. So earlier this year I set about
rewriting bcvi in a more extensible way. Then to prove the new plugin API,
I wrote a few simple plugins. Now it seems to be in a stable enough form for
me to call it version 3.0.</p><p>And so <a href="http://search.cpan.org/dist/App-BCVI/">it's released</a>. There's even some
documentation for the plugin API. It'll be interesting to what, if anything,
people make of it.</p><p> <small>Cross posted from <a href="http://grantmclean.vox.com/library/post/bcvi-30-hits-cpan.html">my blog</a>.</small></p>grantm2010-06-03T21:08:19+00:00journalAnother reason to switch to Githttp://use.perl.org/~grantm/journal/39634?from=rss
<p>If your project was in Git then you could use <a href="http://code.google.com/p/gource/">Gource</a> to visualise the commit history.</p><p>Gource is written by Andrew Caudwell - a colleague and sometime Wellington Perl Monger. He loves playing with graphics and interesting visualisations. If you're running Ubuntu/Debian you can even grab a<nobr> <wbr></nobr>.deb from the project 'Downloads' page, install it, cd into your git project and run gource - then sick back and what history.</p>grantm2009-09-16T09:21:51+00:00journalThe 'Faces' of Wellington Perl Mongershttp://use.perl.org/~grantm/journal/38679?from=rss
<p> <a href="http://wellington.pm.org/">Wellington Perl Mongers</a> had a fun evening last week - our annual Lightning Talk meeting. As usual the talk schedule was looking pretty thin in the days leading up to the event but with a bit of encouragement people did step up and the evening went well. <a href="http://wellington.pm.org/archive/">The talks</a> covered a range of Perl modules; a bit on Erlang and CouchDB (thanks Lenz); mountain biking and mapping (Donovan); and Perl on the iPhone (Tobi). We even got to see the beginnings of Matt's robot army (doesn't look like we have anything to fear yet) and Srdjan gave us his sermon entitled "If statements considered harmful". I asked Matt to take some photos. The lighting wasn't great so not many came out but <a href="http://www.flickr.com/photos/grantm/3370140616/">here's a montage</a>.</p><p>As a group, it's clear that there's one key thing we can all do to improve our delivery - <b>turn and face the audience</b>. The one exception pictured is the guy speaking without slides.</p><p> <small>Cross-posted from <a href="http://grantmclean.vox.com/">my blog</a> </small> </p>grantm2009-03-21T01:47:39+00:00journalSpecial Guests at Wellington.pm this Tuesdayhttp://use.perl.org/~grantm/journal/38423?from=rss
<p>This Tuesday evening (Feb 10th) <a href="http://wellington.pm.org/">Wellington Perl Mongers</a> are very pleased to welcome Jacinta Richardson and Paul Fenwick from Perl Training Australia. They're over here on vacation (as well as for Baa Camp) and have kindly offered to come along and speak at our February meeting.</p><p>As usual, the meeting will be hosted by Catalyst IT (150 Willis Street) and the start time is 6:00pm - bring a friend.</p>grantm2009-02-07T10:18:48+00:00journalRemember Your Responsibilitieshttp://use.perl.org/~grantm/journal/38375?from=rss
<p>A colleague encountered an odd problem the other day. It took us a while to
realise what was going on, you'll probably work it out much quicker<nobr> <wbr></nobr>...</p><p>Here's a simplified version of what we were dealing with:</p><blockquote><div><p> <tt>&nbsp; &nbsp; use strict;<br>&nbsp; &nbsp; use warnings;<br> <br>&nbsp; &nbsp; eval {<br>&nbsp; &nbsp; &nbsp; &nbsp; my $obj = SomeClass-&gt;new();<br>&nbsp; &nbsp; &nbsp; &nbsp; die "Code Red!\n";<br>&nbsp; &nbsp; };<br> <br>&nbsp; &nbsp; if($@) {<br>&nbsp; &nbsp; &nbsp; &nbsp; print "Exception caught: $@\n";<br>&nbsp; &nbsp; }<br>&nbsp; &nbsp; else {<br>&nbsp; &nbsp; &nbsp; &nbsp; print "No exception occurred\n"<br>&nbsp; &nbsp; }</tt></p></div> </blockquote><p>We both expected it to output:</p><blockquote><div><p> <tt>&nbsp; &nbsp; Exception caught: Code Red!</tt></p></div> </blockquote><p>but instead we got:</p><blockquote><div><p> <tt>&nbsp; &nbsp; No exception occurred</tt></p></div> </blockquote><p>You probably worked it out straightaway but for the record, here's what was
happening<nobr> <wbr></nobr>...</p><p>The die statement <i>did</i> generate an exception and the message <i>was</i> stored in $@.
Of course the code in the eval block stopped executing immediately but when
control flow exited the block, any lexcial variables declared in the block went
out of scope. In this case there was only one: $obj. What we didn't realise is
that $obj's class defined a destructor method ('DESTROY'). This method is
called when the object goes out of scope and apparently in our case the method
wrapped something in an eval. Whatever that something was, it completed
without generating an exception, so $@ ended up empty - indicating no error and
overwriting the exception message that our code put there.</p><p>So, if you write a destructor method and it needs to use eval, please remember to use
local($@) to restore the previous value of $@ when your routine completes.</p><p> <small>Cross-posted from my <a href="http://grantmclean.vox.com/library/post/remember-your-responsibilities.html">shiny new blog</a> </small> </p>grantm2009-01-31T07:42:10+00:00journalOSDC 2008 Sydneyhttp://use.perl.org/~grantm/journal/38024?from=rss
<p>I'm visiting Australia for OSDC2008 in Sydney. It's been a pretty good
conference so far and there are a few interesting talks lined up today before I
jump onto a plane back to New Zealand this afternoon.</p><p>Wednesday kicked off with a fun talk from Chris Dibona which was essentially
a bunch of interesting anecdotes from Google. Then I went along to see Michael
Neale talk about rule based systems. It seems like a technology that should be
highly applicable to my current client - but only if we rewrite their system
from the ground up<nobr> <wbr></nobr>:-(. I'll have to think about how we could start to take
advantage of this stuff in a smaller steps.</p><p>I was also fascinated by Clifford Heath's talk on semantic modelling. He
presented well and clearly has put a lot of work into it. The talk followed a
bottom-up sort of approach to introduce concepts that built on each other. It
probably would have benefitted from a top-down bit as well. That would have
given the audience more of an idea of where the talk was heading and given them
a framework to hang the lower-level concepts onto.</p><p>My first talk was Wednesday afternoon and looked at the theory and practice
of Test Driven Development. Unfortunately the accompanying paper was
accidentally omitted from the printed conference proceedings but you can <a href="http://xrl.us/osdctdd">download it from my web site</a>. I think I
managed to avoid embarassing gaffes and the talk seemed to be well
received.</p><p>Jacinta was up next with a good round up of Perl MVC frameworks. David
Fetter did a good talk on DBI-Link in Postgres 8.4 but since we have yet to get
our client up to 8.3, I think I'll defer getting too excited about that one.
The lightning talks and the conference dinner went well and Anthony Baxter's
dinner talk was highly entertaining.</p><p>Thursday was a quieter day for me. There weren't a lot of talks that
appealed to me and a couple that I did go to were disappointing. Of course
some of that may be my own fault - my head was a bit fuzzy from a late night
and lots of beer. Jonathan Oxer had a couple of good talks that led me to
doubt his sanity but they were very entertaining. After the lightning talks
the Sydney Perl Mongers organised an outing for more beer and food on Thursday
night. That was great - thanks guys.</p><p>My second talk is later today and I've got to dash off early this afternoon
to catch a flight back to Wellington. Looking forward to a few of today's
talks.</p>grantm2008-12-04T22:35:42+00:00journalProblem solvershttp://use.perl.org/~grantm/journal/37853?from=rss
If you're a problem solver you'll probably enjoy the "Fantastic Contraption" game which allows you to make cool machines <a href="http://fantasticcontraption.com/?designId=4132836">like this</a>.grantm2008-11-11T08:31:11+00:00journalChinese techhttp://use.perl.org/~grantm/journal/37266?from=rss
<p>Following <a href="http://science.slashdot.org/article.pl?sid=08/08/23/2313200">news</a> that chinese scientists have completed a face transplant, I commented that next time China hosts the Olympics they'll be able to have a six year old singer with a good voice <em>and</em> a pretty face. A colleague immediately came back with "Well they'll <em>claim</em> she's six".</p>grantm2008-08-25T00:16:23+00:00journalWellington.pm August Meetinghttp://use.perl.org/~grantm/journal/37180?from=rss
<p>We had the August meeting of Wellington.pm this week. <a href="/~mugwumpjism/">Sam</a> gave us his talk on the work he did converting the Perl source code history to git. It turned out to be a rather larger undertaking than he originally imagined. Sam was preparing this talk for YAPC::Eu but unfortunately the costs of getting there have proved prohibitive so he may just have to recast the talk as a chapter in his memoirs.</p><p>Next up, <a href="http://www.coffee.geek.nz/">Brenda</a> gave us a quick rundown on opportunities for networking with (open source) geeks in Wellington. In a novel twist, her presentation slides were a flickr photo set.</p><p>After Brenda's talk we had a lively discussion on strategies for dealing with an inherited codebase; code formatting styles; Perl best practices; the evils of misused subroutine prototypes; and interesting home grown config file formats.</p><p>To round off the evening, I gave a 'behind the scenes' talk on last month's <a href="http://wellington.pm.org/articles/hackoff2008/">HackOff</a> competition. The focus for people on the night (and after the event) has been on <i>decoding</i> the datafiles for each of the problems. The focus of the talk was on how I went about <i>encoding</i> the data to produce the question files. There is strong interest in doing it again next year which means more work for me - but at least I had fun.</p>grantm2008-08-14T10:59:06+00:00journalPerl 5.6.2 hates mehttp://use.perl.org/~grantm/journal/37098?from=rss
<p>I was feeling virtuous for having finally made the time to address the RT queue for XML::SAX. After resolving 7 tickets I pushed out a new release and within about an hour I'd learned from the CPAN testers that the new release doesn't work with 5.6 (yay for CPAN testers!). The thing that's puzzling me is that I can't see how it ever worked.</p><p>Having compiled up a 'fresh' copy of Perl v5.6.2, I'm now able to see what the CPAN Testers are seeing. Here's a minimal test case:</p><blockquote><div><p> <tt>$ perl -le 'q{TEST} =~/^[\x{0041}-\x{005A}]+$/ &amp;&amp; print q{OK}'<br>Invalid [] range "}-\x" before HERE mark in regex m/^[\x{0041}-\x &lt;&lt; HERE {005A}]+$/</tt></p></div> </blockquote><p>The same thing works as expected on 5.8. The XML::SAX::PurePerl parser makes extensive use of this syntax (character classes which include ranges of unicode characters) to match productions <a href="http://www.w3.org/TR/REC-xml/#NT-Letter">such as these</a> from the XML spec. It's been that way since 2002 and apparently working (modulo a few bugs). Indeed if I go back to the code in the previous release it passes all the tests - even with regexes that look like that.</p><p>I'm going to bed and hoping this makes more sense in the morning.</p>grantm2008-08-05T11:06:29+00:00journalCrazy comment spammershttp://use.perl.org/~grantm/journal/37027?from=rss
<p>A client's web site that I support has a simple feedback form which emails the form submission to a number of business users. This form has become very popular with comment spammers despite the fact that nothing submitted via the feedback form ever ends up on the web site.</p><p>On Friday I added a simple anti-spam measure and was disappointed to discover that the emails continued to roll in over the weekend. After tracing back through various logs I discovered it wasn't my script at all! When we launched a new site design 3 months ago, I took the opportunity to consolidate a number of CGI scripts into the existing mod_perl application framework. The feedback form was tweaked to point to a new form handler URL. I left the old form handler script in place to facilitate easy rollback and assumed it would do no harm since there were no forms pointing at it. Duh!</p><p>So it appears that multiple bots have cached copies of the old form handler URL <b> <i>and</i> </b> the field names it used to expect - despite the fact that the original form disappeared 3 months ago.</p><p>Rule number 1 of web security says you can't trust the input data. In particular you can't assume the form that was posted is the one you provided. Unfortunately the comment spam continued to pass all of the old handler's validation rules, so it continued to sail through to email. Of course another key rule of web security is that your web site should not expose any code/functionality that is not essential for the running of the site. I guess I'll have to say mea culpa to that one.</p>grantm2008-07-28T08:17:48+00:00journalHardware funhttp://use.perl.org/~grantm/journal/37020?from=rss
<p>My 4 year old Acer laptop died the other day. It just seems to be the hard drive but I had been thinking about replacing the machine anyway. I don't have the budget for anything flash and I needed something quick(!) so I ended up getting another Acer (Aspire 5920).</p><p>The machine came pre-installed with Windows Vista so when I powered it on I was prompted to "complete the installation process". That entailed answering some questions and waiting while updates were downloaded and of course rebooting a couple of times.</p><p>I don't actually have any desire to run Windows (except maybe for portability testing) so my next step was to download and install Ubuntu Hardy. Surprisingly, downloading a 700MB ISO, installing Linux and downloading updates took less time than "completing the Windows installation process". We're getting closer to a "just works" experience. Video (with fancy compositing effects) and wireless networking worked without any fuss at all. Audio works too but strangely only through the headphone socket, not through the built-in speakers. As it happens I generally only use the headphones so making the speakers work isn't a big priority.</p><p>Before my hard drive died, I had just started putting together an 'analysis' of how the teams in the Wellington.pm HackOff event solved each of the questions. After various setbacks, I hope to return to that task in the next couple of days. After that's done I really hope to have time to look at my embarrassingly long RT queues.</p>grantm2008-07-26T22:59:53+00:00journalHackOff questions now onlinehttp://use.perl.org/~grantm/journal/36928?from=rss
<p>As previously mentioned, Wellington Perl Mongers hosted a 'HackOff' event this month. It was a fun evening with teams of programmers competing to solve problems quickly. The problems used in the live event are now available on the <a href="http://wellington.pm.org/articles/hackoff2008/">Wellington.pm site</a>.</p><p>If you can answer all five questions in under 90 minutes you're doing better than our teams did<nobr> <wbr></nobr>:-)</p><p>Once I've had some sleep I'll take a look at the code that the competitors posted and see if it's worthy of a write up.</p>grantm2008-07-16T11:13:01+00:00journalWellington.PM Hackoff all overhttp://use.perl.org/~grantm/journal/36921?from=rss
<p>The July meeting of Wellington.PM was last night. This month we hosted a 'Hack Off' - a bunch of teams of hackers racing to solve programming problems. The event was definitely a success and lots of people were asking "when can we do it again?"</p><p>"Team Cabbage" emerged victorious but "Team Amorphus" were close behind them.</p><p>I hope to have some more info up on the web site soon, including: the actual questions (so you can play at home); sample solutions; pictures etc. For now, I have a <a href="http://wellington.pm.org/hackoff/">pretty graph</a>.</p>grantm2008-07-16T00:49:11+00:00journalGo the google generation!http://use.perl.org/~grantm/journal/36790?from=rss
<p>The web page for the Wellington.PM '<a href="http://wellington.pm.org/hackoff/">HackOff</a>' event has been getting quite a lot of traffic. Presumably much of that is people trying to solve the puzzle. Referring URLs in our server log include variations of:</p><p>
<code>http://www.google.co.nz/search?q=EFBBBF2C756FC9A5CA87CA8E642CC2A073C4B1C2A0C99F<nobr>C<wbr></nobr> 99F6FC+A9EC994C990C9A5C2A0C9AF64CB99756FCA87C68375C4B16C6CC7+9DCA8DC2A0C79DC9A5<nobr>C<wbr></nobr> A87C2A0C9B96FC99FC2A070C9B96FCA8D7+373C99064C2A0CA87C79DC9B9C994C79D73C2A0C79DC<nobr>9<wbr></nobr> A5CA870A&amp;ie=utf-8&amp;oe=utf-8&amp;aq=t&amp;rls=org.mozilla:en-GB:official&amp;client=firefox-a</code>
</p><p>Kids these days!</p>grantm2008-06-26T22:54:04+00:00journalWhy I'm Passionate About Perlhttp://use.perl.org/~grantm/journal/36506?from=rss
<dl>
<dt> <b>The person who introduced me to Perl showed me that...</b> </dt><dd>I ended up introducing myself to Perl. I was a sysadmin doing a lot of shell scripting and feeling like there must be a better way. In the past I'd done a fair bit of C, and before that Pascal and BASIC. None of these were really applicable and I kept reading about Perl in Usenet postings so I decided it was worth a closer look. I was too cheap to pay for a book so I just read the man pages. The fact that I was able to teach myself the language primarily from the perldoc is a testament to the accessibility of Perl.</dd><dt> <b>I first starting using Perl to...</b> </dt><dd>My first significant Perl project was automating the installation of Solaris (1.0) on Sun workstations. My scripts managed the network boot process and made installation decisions (disk partition sizes, packages selections etc) based on what hardware was found and what roles the workstation had been associated with. The system allowed us to do a 'bare metal' install by setting some flags on the server then initiating a reboot over the network - all finished and ready for the user to log in, in under 15 minutes.</dd><dt> <b>I kept using Perl because...</b> </dt><dd>With my background in shell and sysadmin work, Perl was a really good fit for the way I thought about problems. Later when I moved into developing web-based applications, Perl again was a natural fit. Compared to my earlier C experience, not having to bother with compiles and makefiles and lowlevel memory management meant Perl was a huge productivity boost and it also put the fun back into programming for me. The Perl culture also tends to favour pragmatic and practical solutions rather than complex ivory tower frameworks.
</dd><dt> <b>I can't stop thinking about Perl...</b> </dt><dd>I wouldn't say that I dream in Perl, but I do use it every day both for work and for fun. I also coordinate the local Perl Mongers group, maintain some CPAN modules and try to write the odd article now and then. So Perl is regularly in my thoughts.
</dd><dt> <b>I'm still using Perl because...</b> </dt><dd>There are a lot of really smart people using Perl and contributing to the Perl community. I have learnt a lot from them that has benefitted me professionally and personally. The fact that I am comfortable standing up presenting to a roomful of people is a direct result of my involvement with the Perl community. Test driven development is something that pervades the Perl community and has been of immense benefit to me. Not only is it easy to write code in Perl it's super easy to write tests too.
</dd><dt> <b>I get other people to use Perl by...</b> </dt><dd>I have fun with Perl. Sometimes fun can be contagious. The Perl Mongers groups are an excellent way for people to build their Perl skills and develop professional networking skills. I'm happy to share Perl solutions when people are trying to solve a problem, but I'm not trying to force Perl on anyone and I'm always interested in learning better ways to do something.
</dd><dt> <b>I also program in<nobr> <wbr></nobr>... and<nobr> <wbr></nobr>..., but I like Perl better since...</b> </dt><dd>I mentioned that I used to program in C. I've had no need to do that for many years since Perl has met my requirements for everything from simple glue scripts to full-blown web apps and complex GUI applications. I've tried Java a few times but it seems to change so much in every major release that I find my references books are always out of date. I also haven't been able to find the same sort of supportive community for Java as I found with Perl. And perhaps most importantly I just don't find Java fun. Ruby on the other hand is definitely fun. It has all the best bits of Perl with a cleaner syntax and object model. There are a large number of Ruby libraries available but I have been repeatedly disappointed by encountering incomplete and abandoned solutions. The fact that Perl's CPAN modules generally integrate well with Linux packaging systems (unlike Ruby's Gem packages) is also a win for me. Perl's TAP-based testing tools are also so much simpler to use than the xUnit style favoured by the strictly OO languages. More recently I have dabbled with PHP but been frustrated by the limited syntax (eg: regexes are too hard to use), poor modularity and the insane hasharray thingies. I have also done a fair bit of work with Tcl and it was also less painful than Java but ultimately Perl is a better fit for the way I think.
</dd></dl>grantm2008-05-24T03:59:36+00:00journalComing up for airhttp://use.perl.org/~grantm/journal/36492?from=rss
<p>I've been working full time (and more) for most of the year on a CMS migration project. It seemed to take over my every waking hour and meant my backlog of non-work work has moved from being ridiculously long to insanely long. Anyway, we finally drew a line under it today and called it done. Hooray!</p><p>I don't imagine that migrating from one CMS to another is ever much fun. In this case it was certainly an adventure. We were moving from a proprietary CMS called ArticleManager (ArtMan) to <a href="http://drupal.org/">Drupal</a>. The version of ArtMan was quite old; was written in Perl (which had been obfuscated to protect their IP); and used a binary on-disk file rather than a database. I didn't have to worry about the Drupal side of things because our company has half a dozen people who specialise in knocking together Drupal sites and one of them would look after that side of things.</p><p>I was able to get a fairly high-fidelity export of the data using WWW::Mechanize to walk through ArtMan's article and category edit screens and pulling out the contents of the HTML form elements. I inserted the data into a Postgres database which I was then able to run lots of SQL queries over to try and decode what the various flags and statuses meant.</p><p>It was around this time that I discovered all our Drupal people were fully committed so despite my complete ignorance of PHP, the Drupal deployment became my problem too. Fortunately there were good people on hand to answer my many questions - thanks especially to <a href="http://dollyfish.net.nz/blog">Martyn</a>.</p><p>I've worked with a few CMSs and I have yet to meet one that I like. Having said that, Drupal is probably the one I hate the least so far. The big thing that Drupal gets right is that they acknowledge everyone's requirements are different and that for all but the most trivial sites, you <i>will</i> need to customise the behaviour of the CMS. With this in mind Drupal provides an architecture and an API that enables you to add new functionality and change core functionality without changing the core code. The fact that the Drupal developers have achieved this using PHP is nothing short of miraculous. The API is undeniably quirky but you can't go past the fact that it works.</p><p>Another great thing about Drupal is the large number of <a href="http://drupal.org/project/Modules">modules</a> that are available to drop into your installation. Some of them will even do stuff that's vaguely similar to stuff you want. I've come to the conclusion that the greatest value of these modules is that they provide sample code you can cut and paste when building your own modules to turn Drupal into <i>exactly</i> the system you want.</p><p>Another big win is that even though the core functions and add-on modules can be configured by pointing and clicking, they can also be configured from code. Martyn helped me set up an installation profile script which took me from nothing to fully configured in a little over a minute. Knowing you can burn down and completely recreate your development environment in minutes really helps to build confidence in the product and your ability to deploy it.</p><p>So I ended up building two custom modules to support:</p><ul>
<li>custom content types with exactly the metadata we want</li><li>a category/navigation hierarchy and URL scheme that works the way we want</li><li>a simple system for hyperlinking between pages in such a way that the links don't break when pages are moved</li><li>file attachment handling that's close to what we want</li><li>a site design that's very close to what the designer mocked up</li><li>RSS feeds</li><li>integration with numerous small pieces of existing functionality</li><li>a reasonably straightforward user interface that content editors can use to manage all this stuff</li></ul><p>Of course all that comes at a cost. Drupal performance sucks. Big time. No doubt a large part of that is all the hard work my custom code is doing and no doubt we could do magic with caching to make it suck less. But it doesn't matter because we were never going to install Drupal on our web servers anyway. We use wget to suck all the pages out into static files; run some fix-ups across it with a Perl script and rsync it up to the production server. For DR we just rsync to two servers instead of one.</p><p>And <a href="http://www.elections.org.nz/">here's the result.</a></p><p>At least my next assignment is Perl.</p>grantm2008-05-22T09:28:31+00:00journalDatabase Naming Conventionshttp://use.perl.org/~grantm/journal/36214?from=rss
<p>A $cow_orker recently sparked a debate about conventions for naming database objects. Obviously this is a bit of a religious issue for many and we certainly uncovered a variety of opinions. One very basic question which many feel strongly about is the pluralisation of table names. I have a <i>preference</i> for singular but am happy to run with plural if that's the convention in an existing project.</p><p>Early in my development career I saw a colleague ridiculed for creating a database table with a pluralised name. His justification was (quite reasonably) "I called it 'widgets' because I want to store multiple widget records in it". The DBA's response was "Of course you want to store multiple records in it. If you didn't have multiple records you'd hardly go to the bother of creating a table, would you?". From this logic it comes down to a simple choice: make every table name plural; or, don't bother. I've standardised on "Don't bother".</p><p>The thing I don't get is the vast number of people who subscribe to this inseparable pair of rules:</p><ul>
<li>Database table names should always be plural</li><li>Object class names should always be singular</li></ul><p>It seems obvious to me that if you agree with the first statement then using the same logic you should <b>disagree</b> with the second. Apparently other people don't see it the same way.</p><p>It seems to me that a 'widget' table defines the characteristics of a widget record and serves as a container for such records. Similarly a 'Widget' class describes the characteristics of a widget object and serves as a template for such objects. I just don't get why so many people see these two issues in black and white as obvious opposites.</p>grantm2008-04-22T09:19:52+00:00journalWellington.pm meeting last nighthttp://use.perl.org/~grantm/journal/36103?from=rss
<p>Wellington Perl Mongers had their monthly meeting last night. There was a pretty good turn out despite the cold weather outside. It probably helps that the bulk of the attendees don't actually have to go outside to get from work to the venue<nobr> <wbr></nobr>:-)</p><p>Andy gave us a talk on his foray into <a href="http://wellington.pm.org/archive/200804/learning_from_perl_golf/">Perl Golf</a>. While he had fun and (re)learnt a few things along the way, he concluded not much of it was relevant to writing maintainable code for $work. It's hard to argue with that conclusion.</p><p>I was up next with a talk on the <a href="http://wellington.pm.org/archive/200804/exact_cover/">exact cover</a> algorithm. This was inspired by an article Eric Maki wrote for the Perl Review a while back. Eric was using it to solve/generate Sudoku while I was using it to solve a different puzzle.</p><p>Last but not least, Finlay gave us a brief intro to <a href="http://wellington.pm.org/archive/200804/prd_postal_addresses/">Parse::RecDescent</a> and a particular application of it for parsing postal addresses from $previous_job. I've never actually used PRD in any non-trivial way so this was a good refresher.</p><p>Our next meeting will be May 13th, so if you're going to be visiting Wellington next month let me know<nobr> <wbr></nobr>:-)</p>grantm2008-04-08T22:10:36+00:00journalA Postgres Songhttp://use.perl.org/~grantm/journal/35855?from=rss
With apologies to Messrs <a href="http://en.wikipedia.org/wiki/W._S._Gilbert">Gilbert</a> and <a href="http://en.wikipedia.org/wiki/Arthur_Sullivan">Sullivan</a> (and finger of blame pointed squarely at colleagues Gav and Luke)<nobr> <wbr></nobr>...<blockquote><div><p> <i>
I am the very model of a database relational,<br>
My updates are atomic and ACIDic and transactional,<br>
My planner aims to optimise your queries scatological,<br>
My indexes will cope with SQL that is pathological<br>
<br>
My data types encompass from mundane to geographical,<br>
My data safety record shows concern that's quite fanatical,<br>
My cost per TPC will beat both DB2 and Oracle,<br>
And yet the plebs persist in writing apps for bloody MySQL!<br>
</i></p></div> </blockquote>grantm2008-03-07T08:50:19+00:00journalNot a good start to the dayhttp://use.perl.org/~grantm/journal/35668?from=rss
<p>So I was walking from the train station to the office and passed this restaurant/bar. I'm not at all knowledgable about the mechanics and plumbing of restaurant kitchens, but periodic visits from a truck that sucks unspeakable things from the grease trap (or whatever) seem to be the norm. Today, just such a truck was parked on the side of the road with a largish flexible hose pipe snaking across the pavement and round into the restaurant kitchen.</p><p>At the precise moment that I stepped over the hose, one of its joints burst apart. Fortunately the joint was several metres from me but the combined factors of high pressure 'liquids' and strong wind mean that I ended up splattered in numerous places (literally from head to foot) with deposits of a substance having the consistency and odour of vomit.</p><p>I was not the only person affected in this way. You might imagine that the affected parties would form up into an angry mob. However in this case the environment had been transformed with such rapidity into such a festering pile of unpleasantness that none of us had any thought but to make our escape as quickly as humanly possible.</p><p>Ten minutes later I arrived at the office and headed straight for the bathroom where I removed clothing items and thoroughly rinsed their affected areas. I also took the opportunity to lather and scrub any affected areas of my body. My return to the office wearing a rather wet shirt and trousers prompted a number of enquiring looks.</p><p>I told the story to the three people who sit closest to me and apologised in case there was any lingering odour. Several minutes later I logged on to the $work IRC channel and found that one of them had changed to channel topic to:</p><blockquote><div><p> <b>Don't ask Grant about the exploding truck of vomit</b></p></div> </blockquote>grantm2008-02-15T21:45:29+00:00journalIE8 to Take us Beyond DOCTYPEshttp://use.perl.org/~grantm/journal/35598?from=rss
<p>I find <a href="http://www.alistapart.com/articles/beyonddoctype/">this</a> mind-bogglingly stupid.</p><p>To summarise...</p><p>The 'problem' we're faced with is that when people declared their HTML pages to be compliant with the HTML 4.01 Strict (or whatever) DTD they didn't really mean that. Apparently what people really meant was that they were happy with the way that the page was rendered by the current version of Internet Explorer at that time. The upshot being that if Microsoft were to release a new browser that actually was standards compliant and rendered the same HTML as intended by the spec, then the page would appear 'broken' in that new browser.</p><p>Apparently the 'solution' is to subvert the http-equiv meta tag to introduce a whole new declaration (in addition to the DOCTYPE) something like this:</p><blockquote><div><p> <tt>&lt;meta http-equiv="X-UA-Compatible" content="IE=5.5;FF=2"<nobr> <wbr></nobr>/&gt;</tt></p></div> </blockquote><p>Then the hypothetical new browser will be able to degrade it's behaviour and magically render the page as it would have looked in IE6.</p><p>I am utterly stunned that anyone who actually understood the 'problem' could consider that a good solution.</p><p>Of course the real problem is that having won the browser wars, Microsoft put all meaningful development of IE on hold for 5 years.</p><p>We can't 'fix' that problem. It happened. It's history. Get over it. If that means that the next version of IE displays broken HTML as broken then so be it. Realistically what we're talking about here is that some page margins will be different, some divs will be a few pixels out of alignment and some fonts will be a slightly different size. Oh noes the end of the interwebs!</p><p> <a href="http://www.w3.org/QA/2008/01/ie8_versioning_snowstorm.html">More on this theme</a>.</p>grantm2008-02-07T08:09:29+00:00journalDamian Conway @ Wellington.pm Tuesdayhttp://use.perl.org/~grantm/journal/35589?from=rss
<p>Damian is going to be in Wellington for the <a href="http://www.webstock.org.nz/">Webstock</a> conference and has graciously accepted an invitation to speak at Wellington Perl Mongers next Tuesday. The start time is 6:45pm and the location is the offices of Catalyst IT Limited. Address, map and other details are on the <a href="http://wellington.pm.org/">Wellington.pm web site</a>.</p><p>We've got a larger than normal room, so bring your friends and workmates and lets pack the place out.</p>grantm2008-02-06T01:52:25+00:00journalNZOSA Funhttp://use.perl.org/~grantm/journal/34722?from=rss
<p>So as I <a href="/~grantm/journal/34708">mentioned</a> the other day, I went to the New Zealand Open Source awards this week. The current president of the NZ Open Source Society is Don Christie. Don is also a director at Catalyst IT Ltd where I work. When he came out to give his speech, Don arrived at the podium, squinted out into the spotlights and delivered this classic opening line:</p><blockquote><div><p> <i>&laquo;It's not like doing it in front of the bathroom mirror is it&raquo;</i></p></div> </blockquote><p>Fast forward to Friday and I'm alone in the lunch room at work waiting for my sandwich to toast. I saw the whiteboard and decided to try my hand at immortalising that line with a cartoon. Sadly my drawing skills are rather poor but I was happy enough with the results - I thought it might be a minor talking point at beer o'clock that evening.</p><p>A little over <b>one hour</b> later, I was back at my desk and thought I'd see if any pictures of the awards dinner had shown up on Flickr yet. So I did a search for 'nzosa' and got exactly <a href="http://flickr.com/photos/reedwade/1624655337/">one result</a>.</p>grantm2007-10-19T21:43:54+00:00journalNZ Open Source Awardshttp://use.perl.org/~grantm/journal/34708?from=rss
<p>Last night I was fortunate to attend the <a href="http://www.nzosa.org.nz/">New Zealand Open Source Awards</a> ceremony. Like most people who were present, I've got to say "Wow"! It was an extremely polished and professional affair thanks to the dedicated efforts of a small but commited team. Big props to Chris Daish for conceiving the idea and for having the perseverance to see it through. Also to Evonne Cheung for providing the polish and finesse to the visual spectacle.</p><p>During the welcome drinks session and throughout the course of the evening I met people and heard about amazing things they're doing - all based on Open Source software. Inspiring stuff. Congratulations to the winners, the finalists and indeed all the nominees.</p>grantm2007-10-17T22:23:35+00:00journalThink of the childrenhttp://use.perl.org/~grantm/journal/34658?from=rss
<p>These are both quite old links but they bear repeating. If you have kids - especially daughters they need to understand how dishonest the photos in the fashion mags are. <a href="http://homepage.mac.com/gapodaca/digital/bikini/index.html">Greg Apodaca's site</a> showcases some of his work in transforming what the camera captured into what the magazine printed. In some cases the difference can be quite startling - particularly in the areas of narrowing waistlines and plumping up bust lines.</p><p>The <a href="http://www.richgentlemenhide.com/articles/photoshop-tutorial-fountain-of-youth/">Fountain of Youth</a> page is a tutorial for transforming a picture of an 'older woman' into one a young beauty.</p>grantm2007-10-12T07:57:14+00:00journalLicense to Process Wordshttp://use.perl.org/~grantm/journal/34536?from=rss
<p>I've just finished converting one MS Word document of about 150 pages to a group of about a dozen HTML pages. What a nightmare!</p><p>Last time I had to do this, the output was closer to 100 HTML files with very little formatting so I ended up scripting much of it. I loaded the document into Open Office and saved as ODT. Then I used XPathScript to spit out a series of very plain HTML files. With the site stylesheet applied they looked very smart.</p><p>This time, the document structure didn't really lend itself to scripting and there was more formatting that I wanted to preserve (eg: headings, bullet lists, simple tables). So I used 'Save as Web Page' from Word and then did most of it manually with Vim.</p><p>The HTML that Word produced was unspeakably vile. All sorts of illegal constructs (e.g.: a &lt;p&gt; inside a &lt;span&gt; inside another &lt;p&gt;!); enormous sections of proprietary markup inside comment markers; kilobytes of unnecessary attributes (align="left" on every &lt;p&gt;); and invented markup tags (eg: &lt;place&gt; and &lt;placetype&gt;).</p><p>I was able to strip out much of the cruft with LibXML/XPath/DOM manipulations and some search and replace regexes in Vim. But the result was still gruesomely awful. Much of it came down to operator error on the part of whoever typed the document:</p><ul>
<li>every alternate paragraph empty to provide vertical whitespace</li><li>strings of empty paragraphs to push content onto a new page</li><li>'tables' of data with columns aligned using spaces</li><li>'bulleted lists' created by inserting a bullet character at the start of each line</li><li>vast sections of body text in 'Heading 2' style with the font overridden to give normal looking text</li><li>most actual headings rendered using bold and/or font changes</li></ul><p>As one of my colleagues commented, people should not be allowed to use a Word Processor without a license.</p><p>It can't all be blamed on users though. The user interfaces of Word and Open Office are absolutely awful. They make it far <b>too easy to do the wrong thing</b>, by jamming the screen full of toolbar buttons and menus. Conversely they make it <b>hard to do the right thing</b> by hiding the style selection tool in amongst all that visual clutter. Each new release over the years seems to have made the problem worse. What these interfaces need is less, not more.</p>grantm2007-09-25T09:06:49+00:00journalIt all about the merging not the branchinghttp://use.perl.org/~grantm/journal/34431?from=rss
<p>On the GNOME Desktop Development List, there's a 'debate' raging about the possibility of switching GNOME projects from Subversion over to some distributed source code management system. An objection which keeps coming up is:</p><blockquote><div><p> <i>&laquo;people keep saying DSCMs are great because they allow you to branch easily, but I don't want to that anyway - if I branch then I'll have the headache of merging&raquo;</i></p></div> </blockquote><p>The underlying assumption here is that just because merging has historically been a pain using tools like CVS and Subversion, it will also be a pain with the new breed of distributed tools.</p><p>If you are as-yet-unconvinced, do youself a favour and try one of these tools. Once you experience how easy it is to create a feature branch but still keep your branch current with mainline developments you'll never want to go back. This stuff is addictive.</p>grantm2007-09-13T01:58:21+00:00journalNew SSHMenu release and web sitehttp://use.perl.org/~grantm/journal/34343?from=rss
<p>I finally made time to release a new version of <a href="http://sshmenu.sourceforge.net/">SSHMenu</a> and a new web site to go along with it. The new release adds support for environment settings (useful for locale adjustments), improved quoting, bcvi in tabbed mode and other minor updates. Of course it's Ruby so it's off-topic here<nobr> <wbr></nobr>:-).</p>grantm2007-09-05T01:07:00+00:00journalThank You Graham Barrhttp://use.perl.org/~grantm/journal/34186?from=rss
<p>For many people, <a href="http://search.cpan.org/">search.cpan.org</a> <i>is</i> CPAN. It is very easy to take it for granted. It's always there and it just works. It allows us to find modules, read their documentation, track version histories and even just plain read the source - with ease. Through links to other sites in the perl.org stable, it also allows us to easily check test results for a distribution, report and review bugs and patches, share ratings and reviews, annotate the documentation and all the other things I've forgotten.</p><p>I was reminded of the awesome coolness of search.cpan.org as I was wading through <a href="http://rubyforge.org/">RubyForge</a> for a project I'm currently working on. The contrast was stark. And it's not that RubyForge is terrible, in fact it does a reasonable job. But it's not awesomely cool.</p><p>Thanks Graham and everyone else involved</p>grantm2007-08-23T09:41:03+00:00journal