Foswiki tip: How to hide web at the left pane

Rename the web to hide it from left pane. Say the directory is ZAdminTest, rename the folder to zAdminTest

Access it using: http://host/foswiki/bin/view/Main/ZAdminTest/WebHome

I am not sure if this works on *nix system though..

Adding Macros to Excel::Writer::XLSX

Macros are a powerful feature of Excel and are a frequently requested feature for Spreadsheet::WriteExcel and Excel::Writer::XLSX.

It is also a feature that I've wanted to add for some time but it wouldn't be feasible, with current human lifespans, to re-implement Excel's VBA in Perl. So instead I implemented a scheme to "borrow" the VBA code from Excel and add it to an Excel::Writer::XLSX file.

At its simplest an Excel 2007+ file is a collection of XML files in a zip container. Here is a look inside a sample file that contains macros:

$ unzip -qql Book1.xlsm | awk '{print $4}'
[Content_Types].xml
_rels/.rels
xl/_rels/workbook.xml.rels
xl/workbook.xml
xl/drawings/vmlDrawing1.vml
xl/worksheets/_rels/sheet1.xml.rels
xl/theme/theme1.xml
xl/styles.xml
xl/vbaProject.bin
xl/worksheets/sheet1.xml
docProps/core.xml
docProps/app.xml

Nicer dumping of data structure in Log::Any

When you log data structures with Log::Any, e.g.:

% DEBUG=1 perl -MLog::Any::App='$log' -e '... $log->debugf("ccls=%s", $ccls); ...'

do you often see something like this?

[38] ccls=[{fmt => ['integer','integers'],text => ['integer','integers'],type => 'noun'},{expr => 1,fmt => 
'default value %s',text => 'default value 1',type => 'clause'},{expr => 1,fmt => '%(modal_verb)s be divisi
ble by %s',multi => 1,text => 'must be divisible by 2 and 3',type => 'clause'},{expr => 1,fmt => '%(modal_
verb)s be at least %s',multi => 1,text => 'must be at least 1',type => 'clause'},{expr => 1,fmt => '%(moda
l_verb)s be at most %s',multi => 1,text => 'must be at most 100',type => 'clause'}]

Candy-Coated Data Validation; Codename: ShuhgaBear

2-CENTS

This week, in the intertubes, I came across a Node.js validation library which seemed to be popular amongst "those people". At-a-glance, as far as validation libraries go, I didn't think it was that well done, but I must admit to noticing a certain appeal in the expressiveness of the design which I suppose is due largely to that fact that its a JavaScript library.

Anyway, I decided that it would be cool to try and mimic the expressiveness while using Validation::Class as the foundation. It started as a feature-branch on Github but I was amazed at how quickly the concept came to fruition. The results is a module called Validation::Class::Simple::Streamer which has been added to the master-branch on Github as an optional experimental addition to the distribution.

Perl Oasis 2013: Call for Speakers

The 5th Annual Orlando Perl Workshop, aka Perl Oasis, is coming on January 11th. That's only about a month away. Obviously the organizers are behind on things but they have announced the call for speakers! Please sign up now! If speaking isn't your thing, you can simply come and enjoy the company and geekery. Details are on the website: http://perloasis.info/opw2013/.

MooseX::Role::Loggable improvements (version 0.110)

I've released a new version of MooseX::Role::Loggable: 0.110. It provides some improvements and basically a more steady version of it.

Here's a description of what it is, what the improvements are, and some of the considerations in doing them.

TMTOWTDI, plus benchmarking

There's a very common Perl idiom for getting "top N elements" from an array: @top = (sort @a) [0 .. $n - 1]. Mostly, it's good enough for anything one would dare to store in RAM.

Then, there is Sort::Key::Top, which allows you to write @top = top $n => @a. Yet another syntax sugar?

Not even close! While the docs don't state it boldly, it is:

  1. a XS based module
  2. partition-based general selection algorithm (also known as quickselect) implementation

So, expect it to be fast. How fast?

MooseX::Params::Validate

Subroutines that take more than a single argument should really be using something like MooseX::Params::Validate.

Consider:

sub vivisect { 
    my ( $self, $args ) = @_;
    confess 'Expected a hashref of arguments' unless 'HASH' eq ref $args;

    my $hamster = $args->{hamster};

OK, so we know it accepts a hashref of arguments, and what's more, we know one of them is called hamster. But: what constitutes an acceptable hamster? What do we want to do if we don't have a hamster? What other arguments am I going to need? All of this is mental load at 7am and sure, maybe there's documentation, but maybe the intern snuck in some new options and didn't tell anyone...

Compare and contrast this to:

sub vivsect {
      my ( $self, %params ) = validated_hash( \@_,
          hamster => { isa => 'Hamster', default => sub { Hamster->animate(), } },
      );

Yes, it's some more typing. But now, as a reader, I know what's what. I know a hamster is optional, and I know what'll happen if I don't include it. I know no-one else has been adding other options like guinea_pig, because they'd show up there.

About blogs.perl.org

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