Posts

New CPAN Module: WWW::DirectAdmin::API

New module for interacting with DirectAdmin 's API: WWW::DirectAdmin::API It currently supports User level functions only. More to come later __END__

Accessing Dancer config settings inside of a template

As I continue to work more and more with Perl Dancer , I run into situations where I need to pull in application configuration data inside of the template system. Dancer provides access to this config in your template system with the template token settings . What caught me the other day was my desire to use it in the same way as the in the app's DSL: setting . This was my misreading of the documentation. To access settings in Template Toolkit , you must grab sub areas as hash keys. Example: (you can see this in the generated new app code) App name: [% settings.appname %] I did have a case where I wanted to pull in a value that was located in the plugin section. The plugin (like some of them) are named with double colons (::) and I couldn't get the hash key lookup to work so I used TT 's item virtual method. This example dumps out RSS version: Using RSS Output Version: [% settings.plugins.item('XML::RSS').output %] Disclaimer: Of course in the case of so...

mac os x xattr and "protected" files (post download)

Mac OS X (10.6 maybe older or new) sets 'quarantine' bit on files and directories downloaded and unarchived (or just downloaded). Its a good idea to warn users what they are opening but this is a pain if the an archive is opened but then you want to move it somewhere else that isn't using typical OS X apps that understand and can clear this perm. (like unix dev location under webserver). I've found this xattr command to work to clear out that problem: xattr -d -r com.apple.quarantine directory It will verbose blurb out stuff but at least it gets rid of it and allows reading of those files by various unix programs (like apache). __END__

jQuery - "getting" chains

I've been using jQuery for quite a while now. I really like its interface, often it feels very Perlish to me. But in the past I've struggle when trying to process or access parts of a single element returned by a selector. Most of the time, I really want to grab it with an array index, e.g. $('.special-sauce')[0].href (just some rough example). But that always felt wrong, against the jQuery way, like i was an outsider. Esp when its so natural do things like: $('a.special-sauce').click( function() { // do something } ); I've tried to use the first() method to get a single element but that returns an array too. But I finally got how to use it today... We are using jQuery Tools for overlays and some other actions. I wanted to retrieve the href attribute for the trigger object (the one that was clicked to open the overlay (aka lightbox). I tried the wrong feeling: this.getTrigger()[0].href and had the moment of clarity that said "that really mean...

jQuery placeholder plugin

We have moved to using the jQuery plugin placeholder-enhanced for adding placeholders to browsers that don't support them (i'm looking at you IE9). It seems to work better than the other plugins and libraries out there (we tried placify which had some trouble when pages resized or if forms were hidden in lightboxes). It looks like placify creates a div with text (and class) positioned above the input element but placeholder-enhanced adds a class to input and then sets value to placeholder text. Both have positives and negatives. I can see why there are less positioning issues with placeholder-enhanced since it doesn't have to figure out the current location of the element to position a new div on top of it. But the one thing i found interesting was that for password fields, placeholder-enhanced creates an input on top of the password input. Its a clever idea but i found a bug with IE9 (go figure) that by default password inputs w/out size have a set width. I need t...

Dancer::Plugin internal sharing

I've been creating quite a few  Dancer  plugins recently. The nice part of a Dancer plugin is that it gives a small new set of keywords. In some cases, I've want to provide a generic keyword interface to an object but then provide smarter business level keywords. I've found a quirk in the Dancer::Plugin interface. I couldn't find it documented anywhere but I'm sure it is. If you want to access keywords from the same space that they are registered you need to use a different format than the: register keyword => sub {}; You need to use the pattern: sub keyword { # do stuff } register keyword => \&keyword; register_plugin actually stuffs the symbols into the namespace therefore you need to share the sub names before that happens to use them.

Perl Module Versions in dotcloud

I just realized that I was running an older version in my dotcloud service. There was an update due to a security issue so it was kind of important. I found that I needed to update (or put) a version number in the Makefile.PL . Here is an example of mine. Before: use strict; use warnings; use ExtUtils::MakeMaker; WriteMakefile( NAME => 'leecarmichael', AUTHOR => q{Lee Carmichael }, VERSION_FROM => 'lib/leecarmichael.pm', ABSTRACT => 'Home Site', ($ExtUtils::MakeMaker::VERSION >= 6.3002 ? ('LICENSE'=> 'perl') : ()), PL_FILES => {}, PREREQ_PM => { 'Test::More' => 0, 'YAML' => 0, 'XML::RSS' => 0, 'URI' => 0, 'Date::Parse' => 0, 'Digest::MD5' => 0, 'Plack' => 0, ...