Begin main content

Apple Push Notifications Talk—Screen/Audio recording now available

Thanks again to the guys at the Apple University Consortium for inviting me to speak at /dev/world 2010. The screen/audio recordings are now available. I have linked to them (and the rest of the /dev/world presentations) on my APNS talks page:

http://mark.aufflick.com/talks/apns

07:00 PM, 02 Mar 2011 by Mark Aufflick Permalink | Comments (0)

Using Haml with Catalyst

Thanks to Viacheslav Tykhanovskyi's Text::Haml, we can now enjoy the good clean fun of Haml markup in Perl. Much Perl web templating is done with Template::Toolkit, and using Haml within TT is also now possible thanks to Template::Plugin::Haml by Caleb Cushing. The trouble is, you need to wrap every template in some boilerplate:

[%- USE Haml ; FILTER haml -%]
...
[%- END -%]

So I hacked up a quick solution to using .haml templates directly in Catalyst. First, create a MyApp::View::Haml class:

packageHello::View::Haml;

usestrict;
usewarnings;

usebase'Catalyst::View::TT';

useTemplate::Plugin::Haml;

__PACKAGE__->config(
    TEMPLATE_EXTENSION => '.haml',
    render_die => 1,
);

subrender {
    my ($self, $c, $template, $args) = @_;

    $c->log->debug(qq{Rendering Haml/TT template "$template"}) if$c && $c->debug;

    # args may be passed in or be in the stash
$args = { %{ $c->stash} }
        ifref$argsne'HASH';

    # let the master haml template know which template to render
$args->{haml_template} = $template;

    # do the normal TT render
return$self->SUPER::render($c, 'haml_master.tt', $args);
}

1;

Then you need a haml_master.tt template:

[%- USE Haml ; PROCESS $haml_template | haml -%]

And finally set your config to use the Haml view by default:

default_view => 'Haml'

Et voila - .haml template rendering albeit with only TT style variable interpolation. Getting haml interpolation working might need some change to how the stash is passed to the Text::Haml module.

A controller method might look like this:

subfoo:Global {
    my ($self, $c) = @_;

    $c->stash(foo => 'bar');
    $c->stash(template => 'foo.haml');
}

And foo.haml:

!!! HTML%body%p This is haml inside TT rendering your variables: [% foo %]

Becomes rendered as:

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN""http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<body>
<p>This is haml inside TT rendering your variables: bar</p>
</body>

04:35 AM, 29 Jul 2010 by Mark Aufflick Permalink | Comments (0)

Higher Order Perl now available as a *free* PDF

I've reviewed "Higher Order Perl" by Mark Jason Dominus before - it's a great book for people who know Perl and want to master topics such as parsing or memoisation or who want to incorporate more functional approaches such as currying into their code.

It's worth buying, but now you can also get a free PDF thanks to the generosity of the author, Mark Jason Dominus:

http://hop.perl.plover.com/book/

12:37 AM, 17 Sep 2009 by Mark Aufflick Permalink | Comments (0)

MapReduce in Perl

Someone recently asked to get access to the OpenACS paypal-support package that I wrote and lives in my cvs repository. Unbenknownst to me, my recent firewall change blocked access to the cvs web interface, which I have now fixed.

While I was looking around my public cvs interface, I remembered that I had never quite finished my Perl implementation of Google's MapReduce infrastructure.

Since I'm too busy to get back onto it now I figure I may as well unleash it on you guys. Be warned that there's no documentation (that I remember) and that the current implementation only works on a single machine, although the structure is easily extendable to multiple machines by replacing the forking with some form of rpc.

My sample Perl implementation of MapReduce (for sufficiently weak meaning of the word 'implementation' ;)

Given that limitation it may also not quite work properly - I really don't remember what state I left it in. Nevertheless if you first read the MapReduce paper by Jeffrey Dean and Sanjay Ghemawat then the api and code should make sense.

If anyone finds this interesting please feel free to email me any questions. If enough people are interested I may be able to make the time to polish it off and write documentation!

11:36 PM, 17 Nov 2006 by Mark Aufflick Permalink | Comments (0)

XML

Blog Categories

software (41)
..cocoa (23)
  ..heads up 'tunes (5)
..ruby (6)
..lisp (4)
..perl (4)
..openacs (1)
mac (21)
embedded (2)
..microprocessor (2)
  ..avr (1)
electronics (3)
design (1)
photography (26)
..black and white (6)
..A day in Sydney (18)
..The Daily Shoot (6)
food (2)
Book Review (2)

Notifications

Icon of envelope Request notifications

Syndication Feed

XML

Recent Comments

  1. Mark Aufflick: Re: the go/Inbox go/Sent buttons
  2. Unregistered Visitor: How do make a button to jump to folder
  3. Unregistered Visitor: Note I've updated the gist
  4. Unregistered Visitor: umbrello is now an available port on macPorts
  5. Unregistered Visitor: Updated version on Github
  6. Unregistered Visitor: Modification request.
  7. Unregistered Visitor: Accents and labels with spaces
  8. Unregistered Visitor: Mel Kaye - additional info
  9. Unregistered Visitor: mmh
  10. Mark Aufflick: Thank you