<?xml version="1.0" encoding="utf-8"?>
<feed xmlns="http://www.w3.org/2005/Atom">
    <title>Max Maischein</title>
    <link rel="alternate" type="text/html" href="http://blogs.perl.org/users/max_maischein/" />
    <link rel="self" type="application/atom+xml" href="http://blogs.perl.org/users/max_maischein/atom.xml" />
    <id>tag:blogs.perl.org,2009-11-03:/users/max_maischein//227</id>
    <updated>2012-09-30T18:24:16Z</updated>
    <subtitle>A blog about the Perl programming language</subtitle>
    <generator uri="http://www.sixapart.com/movabletype/">Movable Type Pro 4.38</generator>

<entry>
    <title>Trying to hide from the Cloud</title>
    <link rel="alternate" type="text/html" href="http://blogs.perl.org/users/max_maischein/2012/09/trying-to-hide-from-the-cloud.html" />
    <id>tag:blogs.perl.org,2012:/users/max_maischein//227.3900</id>

    <published>2012-09-30T18:21:06Z</published>
    <updated>2012-09-30T18:24:16Z</updated>

    <summary>I&apos;m trying to get Plync to work with my Nexus 7, mainly because I want non-Google calendar synchronization between my mobile, my desktop and this shiny toy. Authentication works, but the Nexus 7 does not want to list the available...</summary>
    <author>
        <name>Max Maischein</name>
        <uri>http://corion.net</uri>
    </author>
    
        <category term="programming" scheme="http://www.sixapart.com/ns/types#category" />
    
    <category term="programming" label="programming" scheme="http://www.sixapart.com/ns/types#tag" />
    
    <content type="html" xml:lang="en" xml:base="http://blogs.perl.org/users/max_maischein/">
        <![CDATA[<p>I'm trying to get <a href="https://github.com/vti/plync">Plync</a> to work with my Nexus 7, mainly because I want non-Google calendar synchronization between my mobile, my desktop and this shiny toy. Authentication works, but the Nexus 7 does not want to list the available folders at all and does not attempt to synchronize the Calendar folder.</p>

<p>To further debug this, having a good+free (or at least, available) ActiveSync server that I could use to debug the network traffic against would be very convenient. $work does not use ActiveSync, so it won't be much use there...</p>
]]>
        

    </content>
</entry>

<entry>
    <title>Twitter Bootstrap templates for Dancer Applications</title>
    <link rel="alternate" type="text/html" href="http://blogs.perl.org/users/max_maischein/2012/05/twitter-bootstrap-templates-for-dancer-applications.html" />
    <id>tag:blogs.perl.org,2012:/users/max_maischein//227.3216</id>

    <published>2012-05-08T15:41:44Z</published>
    <updated>2012-05-08T15:48:18Z</updated>

    <summary> I&apos;m writing an internal application using Dancer. To give it a &quot;current&quot; look, I&apos;m using the Twitter Bootstrap CSS framework. A side effect is, that I wrote Dancer::Layout::Bootstrap, a set of Template Toolkit templates that import the Bootstrap layout...</summary>
    <author>
        <name>Max Maischein</name>
        <uri>http://corion.net</uri>
    </author>
    
    <category term="perlbootstrap" label="perl bootstrap" scheme="http://www.sixapart.com/ns/types#tag" />
    
    <content type="html" xml:lang="en" xml:base="http://blogs.perl.org/users/max_maischein/">
        <![CDATA[<p>
I'm writing an internal application using Dancer. To give it a "current"
look, I'm using the <a href="http://twitter.github.com/bootstrap/">Twitter Bootstrap</a>
CSS framework. A side effect is, that I wrote <a href="https://github.com/Corion/dancer-layout-bootstrap">Dancer::Layout::Bootstrap</a>,
a set of Template Toolkit templates that import the Bootstrap layout
into Dancer. I hope that this will evolve into a way to add external data files
and maybe even layout templates to scaffolding frameworks such as Dancer.
</p><p>

<b>Pretty Pictures</b>
</p><img alt="Dancer Start Screen with Bootstrap" src="https://github.com/Corion/dancer-layout-bootstrap/raw/wiki/images/index.png">
<p>
The demo application has a tiny bit of logic to demonstrate the effect of showing "flash messages" with Bootstrap, the green bar you see in the below image:
</p><img alt="Dancer Screen with User and Message" src="https://github.com/Corion/dancer-layout-bootstrap/raw/wiki/images/user-login.png">
</p><p>
The issue why I haven't released this onto CPAN yet is that I'm not aware
of a better way to distribute ephemeral projects like templates and Javascript
via the CPAN toolchain than to package them into a module / application.
Maybe Dancer will come up with an API to load data from modules or to
create/update templates from modules, or somebody will point me
to an appropriate method to do such things in the comments.
</p>
]]>
        
    </content>
</entry>

<entry>
    <title>How many faces do you count?</title>
    <link rel="alternate" type="text/html" href="http://blogs.perl.org/users/max_maischein/2012/02/how-many-faces-do-you-count.html" />
    <id>tag:blogs.perl.org,2012:/users/max_maischein//227.2877</id>

    <published>2012-02-27T21:02:22Z</published>
    <updated>2012-02-27T21:10:00Z</updated>

    <summary>How many faces do you count in this image? Perl counts 44: (3068,1983): 25x25 @ -2.30285501480103 (4442,2028): 25x25 @ -3.287189245224 (2015,2071): 26x26 @ -3.70826029777527 (3458,2041): 31x31 @ 0.825069129467011 (3849,2063): 28x28 @ -2.27478647232056 (3328,2021): 33x33 @ -0.250598877668381 (3413,2024): 34x34 @ 0.513785362243652...</summary>
    <author>
        <name>Max Maischein</name>
        <uri>http://corion.net</uri>
    </author>
    
        <category term="programming" scheme="http://www.sixapart.com/ns/types#category" />
    
    <category term="imageccvfacerecognition" label="image ccv face recognition" scheme="http://www.sixapart.com/ns/types#tag" />
    
    <content type="html" xml:lang="en" xml:base="http://blogs.perl.org/users/max_maischein/">
        <![CDATA[<p>How many faces do you count in this image?</p>

<a href="http://blogs.perl.org/users/max_maischein/assets_c/2012/02/face-mass-740.html" onclick="window.open('http://blogs.perl.org/users/max_maischein/assets_c/2012/02/face-mass-740.html','popup','width=5616,height=3744,scrollbars=no,resizable=no,toolbar=no,directories=no,location=no,menubar=no,status=no,left=0,top=0'); return false"><img src="http://blogs.perl.org/users/max_maischein/assets_c/2012/02/face-mass-thumb-480x320-740.png" width="480" height="320" alt="image-ccv-face-mass.png" class="mt-image-center" style="text-align: center; display: block; margin: 0 auto 20px;" /></a>

<p>Perl counts 44:</p>
<pre>
(3068,1983): 25x25 @ -2.30285501480103
(4442,2028): 25x25 @ -3.287189245224
(2015,2071): 26x26 @ -3.70826029777527
(3458,2041): 31x31 @ 0.825069129467011
(3849,2063): 28x28 @ -2.27478647232056
(3328,2021): 33x33 @ -0.250598877668381
(3413,2024): 34x34 @ 0.513785362243652
(4188,2039): 31x31 @ -0.453457891941071
(2256,2058): 30x30 @ 0.173833101987839
(2809,2110): 31x31 @ -0.524535775184631
(1834,2168): 32x32 @ -1.64895510673523
(2180,2128): 34x34 @ 3.05323696136475
(3222,2446): 33x33 @ -3.49713373184204
(4663,2134): 37x37 @ 3.50697612762451
(3082,2155): 37x37 @ 2.55681991577148
(1651,2125): 36x36 @ 0.686093211174011
(3596,2133): 32x32 @ -2.47773456573486
(1887,2204): 38x38 @ 2.26138424873352
(3733,1876): 34x34 @ -2.05330586433411
(4907,2190): 42x42 @ 6.07879543304443
(4296,2092): 39x39 @ -3.16300702095032
(3188,2126): 39x39 @ -0.357136130332947
(3859,2140): 42x42 @ -0.0315352529287338
(4477,2149): 39x39 @ 3.46311140060425
(3946,2223): 40x40 @ -0.409443378448486
(906,2228): 40x40 @ -0.587313830852509
(3761,2258): 49x49 @ 5.01696395874023
(4978,2280): 46x46 @ -0.811646401882172
(1819,2335): 51x51 @ 6.60061264038086
(4071,2331): 49x49 @ 1.23171555995941
(3430,2230): 46x46 @ -0.422206252813339
(4569,2542): 52x52 @ -3.66873860359192
(5390,2236): 57x57 @ 2.28667879104614
(3980,2381): 54x54 @ -2.23162841796875
(4834,2254): 60x60 @ 0.909286737442017
(2645,2460): 59x59 @ -1.53757762908936
(3394,2470): 65x65 @ 1.81137716770172
(275,2303): 61x61 @ -3.08972954750061
(3159,2462): 80x80 @ -0.73163914680481
(4238,2356): 64x64 @ -1.11184680461884
(4067,2493): 73x73 @ 0.357052862644196
(5187,2235): 91x91 @ -3.84829616546631
(3394,1436): 243x243 @ -0.155338764190674
(189,1099): 915x915 @ -0.393947660923004
</pre>
<p>In theory, the last number should be some confidence value, but so far, I haven't made much sense of its range.</p>
<p>I hope to get the code packaged and released as Image::CCV before or on the <a href="http://conferences.yapceurope.org/gpw2012/">German Perl Workshop 2012 in Erlangen</a>.</p>]]>
        
    </content>
</entry>

<entry>
    <title>How I roll - choosing the epigraph for 5.15.8</title>
    <link rel="alternate" type="text/html" href="http://blogs.perl.org/users/max_maischein/2012/02/how-i-roll---choosing-the-epigraph-for-5158.html" />
    <id>tag:blogs.perl.org,2012:/users/max_maischein//227.2854</id>

    <published>2012-02-21T18:52:07Z</published>
    <updated>2012-02-21T18:57:40Z</updated>

    <summary> Thinking about the epigraph of my Perl release started about 10 days before the release. Certainly, I had been unconsciously mulling back and forth about killer quotes from books or other media for longer than that. About 10 days...</summary>
    <author>
        <name>Max Maischein</name>
        <uri>http://corion.net</uri>
    </author>
    
    <category term="perlp5p" label="perl p5p" scheme="http://www.sixapart.com/ns/types#tag" />
    
    <content type="html" xml:lang="en" xml:base="http://blogs.perl.org/users/max_maischein/">
        <![CDATA[<p>
Thinking about the epigraph of my Perl release started about 10 days before the release. Certainly, I had been unconsciously mulling back and forth about killer
quotes from books or other media for longer than that. About 10 days ago, I made the short list of two books that could give interesting quotes.
</p><p>
One was 
"<a href="http://en.wikipedia.org/wiki/Friday_%28novel%29">Friday</a>" by R.A. Heinlein. I've always liked the book, and it opens with the introduction of the protagonist as she kills a pursuer and stuffs him into a cabinet, reacting only on a hunch. Heinleins
way of laconic writing should have made for an interesting quote from that scene.
</p><p>

The second book was "<a href="http://en.wikipedia.org/wiki/The_Manual">The Manual</a>" by the DJ combo The KLF. It is an unromantic look at the music business and follows a Faustian theme. It purports to be a manual for achieving a Number One in the UK in the late 1980s. It taught me interesting concepts, like for example the idea of diving head-first into a venture and the importance of the bass line in pop music. While following the manual certainly was a way to get a Number One hit in the UK, it also makes
clear the other half of the faustian pact - getting the Number One is the only thing you will get, immediately in its two opening paragraphs:
</p>

<blockquote>
<p>
Be ready to ride the big dipper of the mixed metaphor. Be ready to dip your hands in the lucky bag of life, gather the storm clouds of fantasy and anoint your own genius. Because it is only by following the clear and concise instructions contained in this book that you can realise your childish fantasies of having a Number One hit single in the official U.K. Top 40 thus guaranteeing you a place forever in the sacred annals of Pop History.
</p>
<p>
Other than achieving a Number One hit single we offer you nothing else. There will be no endless wealth. Fame will flicker and fade and sex will still be a problem. What was once yours for a few days will now enter the public domain.
</p>
</blockquote>
<p>

Originally I had thought to use these two paragraphs as the epigraph. Especially the prophecy of short-lived fame seemed to ring well with being the release manager of the latest development release of Perl until next month. But once I had started re-reading the book, the chapter on "Chorus And Title" is about how these are the central piece of the song. The authors state that the chorus is the main emotional pull the prospective Number One will need. And as the "Doctor Who" chorus reminds at least me of soccer fans chanting in a stadium, this chorus and the following paragraph explaining the deeper relevance behind the lyrics struck a chord. The segue of the text into showing examples of real masters of producing number one hits serially, and the culmination in the Rick Astley quote sealed the deal for me. Who could resist citing a meme before it was cool?
</p><p>

After rereading the book, it is interesting how much the music business has changed in the sense of publicity. It is also interesting how aware the authors were at this point in time that there was a change coming in the sense of accessibility of the means of music production. Of course, much of the advice about studios has been obsoleted by the technical advances of the past 20 years. The music market is not as centralized anymore, and channels like MTV and later Youtube have eroded the influence of Top of the Pops, so marketing strategies today would have to be different. Also, the music distribution does not happen in stores much anymore.</p>]]>
        
    </content>
</entry>

<entry>
    <title>Your Perl-driven cyborgs can soon recognize objects</title>
    <link rel="alternate" type="text/html" href="http://blogs.perl.org/users/max_maischein/2012/02/your-perl-driven-cyborgs-can-soon-recognize-objects.html" />
    <id>tag:blogs.perl.org,2012:/users/max_maischein//227.2809</id>

    <published>2012-02-13T20:04:22Z</published>
    <updated>2012-02-13T20:10:39Z</updated>

    <summary>I&apos;ve made some progress in getting ccv to compile under Windows. Now I can start with opening up the API and writing some XS for it. Soon, the below image can be created completely from within Perl instead of using...</summary>
    <author>
        <name>Max Maischein</name>
        <uri>http://corion.net</uri>
    </author>
    
    <category term="perl" label="perl" scheme="http://www.sixapart.com/ns/types#tag" />
    
    <content type="html" xml:lang="en" xml:base="http://blogs.perl.org/users/max_maischein/">
        <![CDATA[<p>I've made some progress in getting <a href="https://github.com/liuliu/ccv">ccv</a> to compile under Windows. Now I can start with opening up the API and writing some XS for it. Soon, the below image can be created completely from within Perl instead of using a shell call out to the executable to find "interesting" points in the object and the scene and match them together.</p>

<p><img alt="out-sofa-thumb.png" src="http://blogs.perl.org/users/max_maischein/2012/02/13/out-sofa-thumb.png" width="476" height="234" class="mt-image-center" style="text-align: center; display: block; margin: 0 auto 20px;" /></p>

<p>The SIFT algorithm seems to be quite a useful tool to do feature recognition without any prior training. I hope to (ab)use this to recognize objects and how they move around in movies. Also, I imagine this can be used to automatically stitch images together.</p>]]>
        
    </content>
</entry>

<entry>
    <title>A real fork() call could be possible on Windows (XP onwards)</title>
    <link rel="alternate" type="text/html" href="http://blogs.perl.org/users/max_maischein/2011/10/a-real-fork-call-could-be-possible-on-windows-xp-onwards.html" />
    <id>tag:blogs.perl.org,2011:/users/max_maischein//227.2279</id>

    <published>2011-10-11T18:12:25Z</published>
    <updated>2011-10-11T18:19:59Z</updated>

    <summary>Prompted by BrowserUk in his post on Perlmonks on Win32, fork and XS globals, I looked into the PAGE_WRITECOPY for CreateFileMapping, and it seems that, in fact, this function, together with a bit of work could be made to implement...</summary>
    <author>
        <name>Max Maischein</name>
        <uri>http://corion.net</uri>
    </author>
    
    <category term="programmingforkwindowsunix" label="programming fork WIndows Unix" scheme="http://www.sixapart.com/ns/types#tag" />
    
    <content type="html" xml:lang="en" xml:base="http://blogs.perl.org/users/max_maischein/">
        <![CDATA[<p>Prompted by <a href="">BrowserUk</a> in <a href="http://qs1969.pair.com/~perl2/?node_id=930862">his post on Perlmonks on Win32, fork and XS globals</a>, I looked into the <code>PAGE_WRITECOPY</code> for <a href="http://msdn.microsoft.com/en-us/library/windows/desktop/aa366537%28v=VS.85%29.aspx">CreateFileMapping</a>, and it seems that, in fact, this function, together with a bit of work could be made to implement a (data-)fork call on Windows, with real sharing of identical pages.</p>

<p>There is <a href="http://msdn.microsoft.com/en-us/library/aa366551%28VS.85%29.aspx">this sample program on the MSDN</a>, which outlines how to use a mapped view of a file for shared memory IPC, and by using the <code>PAGE_WRITECOPY</code> flag instead of <code>FILE_MAP_ALL_ACCESS</code>, we should get COW semantics for the shared area.</p>

<p>The part for implementing fork() would seem to just be:</p>

<ol>
<li>(and that is the hard part) Determine the range of data to be shared with the child</li>
<li><a href="http://msdn.microsoft.com/en-us/library/windows/desktop/aa366537%28v=VS.85%29.aspx">CreateFileMapping</a> in the parent process to share the area from 0.</li>
<li><a href="http://msdn.microsoft.com/en-us/library/windows/desktop/aa366761%28v=VS.85%29.aspx">MapViewOfFile</a></li>
<li>Launch the child process</li>
<li>In the child process, call <code>OpenFileMapping()</code> to connect to the data area from the parent process.</li>
<li>Fix up any cached values that need changing after a fork(), for example <code>$$</code></li>
</ol>
]]>
        

    </content>
</entry>

<entry>
    <title>Work progress on WWW::Mechanize::NodeJs</title>
    <link rel="alternate" type="text/html" href="http://blogs.perl.org/users/max_maischein/2011/10/work-progress-on-wwwmechanizenodejs.html" />
    <id>tag:blogs.perl.org,2011:/users/max_maischein//227.2247</id>

    <published>2011-10-03T19:11:57Z</published>
    <updated>2011-10-03T19:20:19Z</updated>

    <summary>Lots of people use WWW::Mechanize::Firefox. This makes me happy. Some of these people would like to do away with needing Firefox to be running on the machine doing the automation. To look in that direction, and to gain some familiarity...</summary>
    <author>
        <name>Max Maischein</name>
        <uri>http://corion.net</uri>
    </author>
    
        <category term="programming" scheme="http://www.sixapart.com/ns/types#category" />
    
    <category term="mechanizenodejs" label="mechanize nodejs" scheme="http://www.sixapart.com/ns/types#tag" />
    
    <content type="html" xml:lang="en" xml:base="http://blogs.perl.org/users/max_maischein/">
        <![CDATA[<p>Lots of people use <a href="http://search.cpan.org/dist/WWW-Mechanize-Firefox">WWW::Mechanize::Firefox</a>. This makes me happy.</p>

<p>Some of these people would like to do away with needing Firefox to be running on the machine doing the automation. To look in that direction, and to gain some familiarity with <a href="http://nodejs.org">nodejs</a>, I started porting the proxy object backend <a href="http://search.cpan.org/dist/MozRepl-RemoteObject">MozRepl::RemoteObject</a> to nodejs. I've uploaded the work in progress to <a href="https://github.com/Corion/NodeJs-RemoteObject">Github</a> as <code>NodeJs::RemoteObject</code>. There is a lot of copied and pasted code between the two <code>::RemoteObject</code> modules, and likely, this will beget a third, shared incarnation of (Javascript) proxy object implementations.</p>

<p>The main thing that's still needed is to actually write a web "browser" implementing just enough to run most web applications, for nodejs. I think there already is something called "jsdom", which claims to be just enough of a browser to make this work.</p>
]]>
        

    </content>
</entry>

<entry>
    <title>Discontinuing support for Firefox 3.0</title>
    <link rel="alternate" type="text/html" href="http://blogs.perl.org/users/max_maischein/2011/07/discontinuing-support-for-firefox-30.html" />
    <id>tag:blogs.perl.org,2011:/users/max_maischein//227.2010</id>

    <published>2011-07-25T19:06:22Z</published>
    <updated>2011-07-25T19:10:19Z</updated>

    <summary>A heads up and last call for people using WWW::Mechanize::Firefox with Firefox 3.0. I plan on discontinuing support for Firefox 3.0 due to moving to the native JSON encoder that exists starting with Firefox 3.5. If you are a Firefox...</summary>
    <author>
        <name>Max Maischein</name>
        <uri>http://corion.net</uri>
    </author>
    
        <category term="programming" scheme="http://www.sixapart.com/ns/types#category" />
    
    <category term="wwwmechanizefirefox" label="www-mechanize-firefox" scheme="http://www.sixapart.com/ns/types#tag" />
    
    <content type="html" xml:lang="en" xml:base="http://blogs.perl.org/users/max_maischein/">
        <![CDATA[<p>A heads up and last call for people using <a href="http://search.cpan.org/dist/WWW-Mechanize-Firefox">WWW::Mechanize::Firefox</a> with Firefox 3.0.</p>

<p>I plan on discontinuing support for Firefox 3.0 due to moving to the native JSON encoder that exists starting with Firefox 3.5.</p>

<p>If you are a Firefox 3.0 user (for compatibility testing?), and really, /really/ need the support, please talk to me so that we can work on a solution that keeps the code small and maintainable for me. If nobody speaks up, I'll interpret that as nobody using Firefox 3.0 anymore, which is fine by me as well.</p>

<p>In other news, I now got several "portable" Firefox instances installed and modified the test files to test against all installed instances. This now tests Firefox versions 3.5, 4.0, 5.0 and 6.0 Beta.</p>
]]>
        

    </content>
</entry>

<entry>
    <title>Display your data - Random::PoissonDisc</title>
    <link rel="alternate" type="text/html" href="http://blogs.perl.org/users/max_maischein/2011/06/display-your-data---randompoissondisc.html" />
    <id>tag:blogs.perl.org,2011:/users/max_maischein//227.1824</id>

    <published>2011-06-04T13:21:54Z</published>
    <updated>2011-06-04T13:45:14Z</updated>

    <summary>I read this nice article on map generation and naturally want to write something like it, but in Perl. For the first step, I want to distribute points nicely across the plane, by using the Poisson Disk Sampling method outlined...</summary>
    <author>
        <name>Max Maischein</name>
        <uri>http://corion.net</uri>
    </author>
    
        <category term="programming" scheme="http://www.sixapart.com/ns/types#category" />
    
    <category term="randompoissondiscappffeedflotr" label="random-poissondisc app-ffeedflotr" scheme="http://www.sixapart.com/ns/types#tag" />
    
    <content type="html" xml:lang="en" xml:base="http://blogs.perl.org/users/max_maischein/">
        <![CDATA[<p>I read this <a href="http://www-cs-students.stanford.edu/~amitp/game-programming/polygon-map-generation/">nice article on map generation</a> and naturally want to write something like it, but in Perl. For the first step, I want to distribute points nicely across the plane, by using the <a href="http://www.devmag.org.za/articles/55-POISSON-DISK-SAMPLING/">Poisson Disk Sampling</a> method outlined in the article. Implementing the algorithm was straightforward, but how would I know that the output data was correct in the sense of reaching my goal of uniform but randomly distributed points across the plane?</p>

<p>The test program of Random::PoissonDisc conveniently outputs the generated points to STDOUT. For visually inspecting the data, I can then pipe it into <a href="https://github.com/Corion/App-ffeedflotr">App::ffeedflotr</a> which displays a nice point cloud. The first output of Random::PoissonDisc looked like this:</p>

<p><code>perl -w bin/random-poissondisc.pl -r 10 | ffeedflotr.pl --type=scatter</code></p>

<p><img alt="Image of wrong distribution" src="http://blogs.perl.org/users/max_maischein/2011/06/04/random-poisson/fail1.png" width="500" height="500" class="mt-image-center" style="text-align: center; display: block; margin: 0 auto 20px;" /></p>

<p>Clearly, this picture shows that something was wrong with the first attempt of creating the random data. The grid is 20x20 units, and with a minimum distance of 10 between points, there should be at most 2 points per grid. My error was in the code for sample rejection. The code only checked the immediate cache, and not the neighbouring cache positions. After fixing that part of the code, I'm not certain whether the code is correct. But its output looks quite satisfying:</p>

<p><img alt="Better distribution" src="http://blogs.perl.org/users/max_maischein/2011/06/04/random-poisson/better1.png" width="500" height="500" class="mt-image-center" style="text-align: center; display: block; margin: 0 auto 20px;" /></p>

<p>The module itself will soonish hit CPAN. I see a lot of improvement opportunities for the module. It could support incremental point generation. It could actually use a vector library like PDL instead of hand-rolling most of the vector manipulation code. It could use some tests beyond basic functionality tests.</p>

<p>But for the moment, I'm very happy with the fact that the code produces results I can use in creating random maps. And also I'm very happy with the fact that I have nice visualisation tools that enable me to visually verify the quality of datasets.</p>
]]>
        

    </content>
</entry>

<entry>
    <title>You can solve any problem by adding another layer of indirection</title>
    <link rel="alternate" type="text/html" href="http://blogs.perl.org/users/max_maischein/2011/04/you-can-solve-any-problem-by-adding-another-layer-of-indirection.html" />
    <id>tag:blogs.perl.org,2011:/users/max_maischein//227.1694</id>

    <published>2011-04-25T11:59:48Z</published>
    <updated>2011-04-25T12:10:39Z</updated>

    <summary>During the Easter weekend, I&apos;ve started to write code supporting Firefox 4 in WWW::Mechanize::Firefox. So far, only some ugly parts of the restructuring of Firefox have broken WWW::Mechanize::Firefox. As my main application for it still runs Firefox 3.x, I have...</summary>
    <author>
        <name>Max Maischein</name>
        <uri>http://corion.net</uri>
    </author>
    
        <category term="programming" scheme="http://www.sixapart.com/ns/types#category" />
    
    
    <content type="html" xml:lang="en" xml:base="http://blogs.perl.org/users/max_maischein/">
        <![CDATA[<p>During the Easter weekend, I've started to write code supporting Firefox 4 in <a href="http://search.cpan.org/dist/WWW-Mechanize-Firefox">WWW::Mechanize::Firefox</a>. So far, only <em>some</em> ugly parts of the restructuring of Firefox have broken WWW::Mechanize::Firefox. As my main application for it still runs Firefox 3.x, I have to support both versions, and especially not break any functionality for 3.x. So far, I could put most of the differences between Firefox 3.x and Firefox 4 into two submodules, <code>WWW::Mechanize::Firefox::API35</code> respectively <code>WWW::Mechanize::Firefox::API40</code>. The constructor of <code>WWW::Mechanize::Firefox</code> does return either of these subclasses, depending on the version. This proves that you can't solve the problem of too many indirections by adding another layer.</p>

<p>As I have no real use case for Firefox 4 yet, I'm not sure whether there are more differences in when (and which) events fire during page load etc.. There is one nice glimmer of improvement for Firefox 4. I've found a Selenium test file that overrides many of the modal dialogs, so that I can now maybe implement <code>-&gt;proxy()</code> for WWW::Mechanize::Firefox and suppress modal dialogs from blocking the whole application.</p>

<p>If you have Firefox 3.x and automate a critical application, don't blindly upgrade Firefox on your main machine. Firefox 4 and Firefox 3 will not peacefully coexist if you don't take preventive measures.</p>

<p>If you want to do a test drive of the upcoming version, take a look at <a href="https://github.com/Corion/www-mechanize-firefox/tree/firefox4">the Firefox4 branch</a> of the <a href="https://github.com/Corion/www-mechanize-firefox">Github repository</a>.</p>
]]>
        

    </content>
</entry>

<entry>
    <title>I love it when a plan comes together</title>
    <link rel="alternate" type="text/html" href="http://blogs.perl.org/users/max_maischein/2011/04/i-love-it-when-a-plan-comes-together.html" />
    <id>tag:blogs.perl.org,2011:/users/max_maischein//227.1642</id>

    <published>2011-04-11T19:43:00Z</published>
    <updated>2011-04-11T19:51:20Z</updated>

    <summary>Barbie blogged about the 11 million test reports mark, and gave a link to a dataset. I had been sitting on my data &quot;visualization&quot; idea App::ffeedflotr for some time already, and had just started writing and publishing it on github....</summary>
    <author>
        <name>Max Maischein</name>
        <uri>http://corion.net</uri>
    </author>
    
        <category term="programming" scheme="http://www.sixapart.com/ns/types#category" />
    
    <category term="flotplotprogramming" label="flot plot programming" scheme="http://www.sixapart.com/ns/types#tag" />
    <category term="wwwmechanizefirefox" label="www-mechanize-firefox" scheme="http://www.sixapart.com/ns/types#tag" />
    
    <content type="html" xml:lang="en" xml:base="http://blogs.perl.org/users/max_maischein/">
        <![CDATA[<p>Barbie blogged about <a href="http://blogs.perl.org/users/cpan_testers/2011/04/11-million-test-reports.html">the 11 million test reports mark</a>, and gave a link to a dataset.</p>

<p>I had been sitting on my data "visualization" idea <a href="https://github.com/Corion/App-ffeedflotr/wiki/Plot-a-simple-graph-of-CPAN-Tester-counts">App::ffeedflotr</a> for some time already, and had just started writing and publishing it <a href="https://github.com/Corion/App-ffeedflotr/">on github</a>. That dataset pushed me to write a short tutorial / showcase of the application.</p>

<p>The screenshots were produced by <a href="http://search.cpan.org/dist/WWW-Mechanize-Firefox">WWW::Mechanize::Firefox</a>, the charts produced by the <code>flot</code> library, and the Javascript manipulation also came through <a href="http://search.cpan.org/dist/MozRepl-RemoteObject">MozRepl::RemoteObject</a>. It's nice when your tools conspire to surprise you in a good way!</p>
]]>
        

    </content>
</entry>

<entry>
    <title>App-ffeedflotr - plot using Firefox and flot</title>
    <link rel="alternate" type="text/html" href="http://blogs.perl.org/users/max_maischein/2011/04/app-ffeedflotr---plot-using-firefox-and-flot.html" />
    <id>tag:blogs.perl.org,2011:/users/max_maischein//227.1638</id>

    <published>2011-04-10T17:47:55Z</published>
    <updated>2011-04-10T17:52:40Z</updated>

    <summary>Sometimes, I want a pretty plot of data. Excel is not always the tool of choice, especially when the data to plot is something like running progress of a (Perl) script I wrote, or the output of while /bin/true done;...</summary>
    <author>
        <name>Max Maischein</name>
        <uri>http://corion.net</uri>
    </author>
    
        <category term="programming" scheme="http://www.sixapart.com/ns/types#category" />
    
    <category term="flotplotprogramming" label="flot plot programming" scheme="http://www.sixapart.com/ns/types#tag" />
    
    <content type="html" xml:lang="en" xml:base="http://blogs.perl.org/users/max_maischein/">
        <![CDATA[<p>Sometimes, I want a pretty plot of data. Excel is not always the tool of choice,<br />
especially when the data to plot is something like running progress of a (Perl) script I wrote,<br />
or the output of</p>

<p>    while /bin/true done; ls $file ; sleep 1; done</p>

<p>Inspired by <a href="http://search.cpan.org/dist/feedGnuplot">feedGnuplot</a> , I wrote <a href="https://github.com/Corion/App-ffeedflotr">ffeedflotr.pl</a>, which takes data and plots it in Firefox. So far, it is not really configurable. But as I have the API blueprint of `feedGnuplot`, I can easily/conveniently adapt it to the featureset.</p>

<p>One nasty thing I found is that Firefox does not like to execute Javascript that comes from `data:` URIs. I suspect this is due to security concerns, but it means that I have to find a sneakier way to load custom HTML into Firefox, preferrably avoiding a tempfile. Things that I've tried so far are named pipes - Firefox does not like reading from these either, likely due to the same or similar security concerns.</p>]]>
        
    </content>
</entry>

<entry>
    <title>Downwards compatibility, and a surprising find</title>
    <link rel="alternate" type="text/html" href="http://blogs.perl.org/users/max_maischein/2011/03/downwards-compatibility-and-a-surprising-find.html" />
    <id>tag:blogs.perl.org,2011:/users/max_maischein//227.1571</id>

    <published>2011-03-17T21:21:57Z</published>
    <updated>2011-03-17T21:35:14Z</updated>

    <summary><![CDATA[I've just released a new version of WWW::Mechanize::Firefox, appropriating a new function of WWW::Mechanize, -&gt;click_button. I used that occassion to also change the XPath queries sent by W:M:F to Firefox to be somewhat slimmer by changing queries for the element...]]></summary>
    <author>
        <name>Max Maischein</name>
        <uri>http://corion.net</uri>
    </author>
    
        <category term="programming" scheme="http://www.sixapart.com/ns/types#category" />
    
    <category term="webscraping" label="web scraping" scheme="http://www.sixapart.com/ns/types#tag" />
    <category term="xpath" label="xpath" scheme="http://www.sixapart.com/ns/types#tag" />
    
    <content type="html" xml:lang="en" xml:base="http://blogs.perl.org/users/max_maischein/">
        <![CDATA[<p>I've just released a new version of <code>WWW::Mechanize::Firefox</code>, appropriating a new function of <code>WWW::Mechanize</code>, <code>-&gt;click_button</code>. I used that occassion to also change the XPath queries sent by W:M:F to Firefox to be somewhat slimmer by changing queries for the element type from a global "OR" to a local test for the node name:</p>

<p>The old query to look for a <code>&lt;BUTTON&gt;</code> or <code>&lt;INPUT type="submit"&gt;</code> was</p>

<pre><code>//button
|
//input[@type = "submit" ]
</code></pre>

<p>The new query is</p>

<pre><code>//*[local-name(.) = "button" or (local-name(.) = "input" and @type="submit")]
</code></pre>

<p>The advantage of the new type is that the query engine does not need to search the DOM tree twice, and more importantly, that I can now easily ask for the "third button in this form", which I cannot do with two separate queries, as they don't necessarily return the buttons in the relative order in which they appear in the HTML+DOM.</p>

<p>All would be well if it weren't for differing Firefox versions. <code>local-name(.)</code> returns the element name. Except that in versions before 3.6, the element name for HTML pages is in ALL UPPERCASE, while since 3.6 onwards, it is in lower case. Of course, this is no real hindrance, as we can just <code>lower-case()</code> the element name. Except that Firefox does not implement <code>lower-case()</code>. It only implements <code>translate()</code>, which is uneasily similar to the <code>tr///</code> operator in Perl. As you can imagine in your horror-filled dreams, the generated queries now look like this:</p>

<pre><code>//*[translate(local-name(.), "ABCDEFGHIJKLMNOPQRSTUVWXYZ", "abcdefghijklmnopqrstuvwxyz")="button"
or (translate(local-name(.), "ABCDEFGHIJKLMNOPQRSTUVWXYZ", "abcdefghijklmnopqrstuvwxyz")="input" and @type="submit")]
</code></pre>

<p>... at least until I ditch support for older Firefox versions.</p>

<p>While I was copying the test suite of <code>WWW::Mechanize</code>, <code>click_button.t</code>, I saw that it launches a local HTTP server to test against that. Digging deeper, I found that it actually and actively uses a server that I once wrote to test <code>WWW::Mechanize::Shell</code>. This has really surprised me and made me happy. If people don't use my modules, at least my test infrastructure gets used by other modules in the same problem space, so I must do something right.</p>
]]>
        

    </content>
</entry>

<entry>
    <title>Patching XS modules</title>
    <link rel="alternate" type="text/html" href="http://blogs.perl.org/users/max_maischein/2011/02/patching-xs-modules.html" />
    <id>tag:blogs.perl.org,2011:/users/max_maischein//227.1504</id>

    <published>2011-02-25T22:33:48Z</published>
    <updated>2011-02-25T22:48:10Z</updated>

    <summary>Today, I found out about a new release of Image::Thumbnail , which has support for Image::Epeg , a library coming from the Enlightenment desktop manager. Likely, epeg is quite fast, but it didn&apos;t build and test right under Windows. Conveniently...</summary>
    <author>
        <name>Max Maischein</name>
        <uri>http://corion.net</uri>
    </author>
    
        <category term="programming" scheme="http://www.sixapart.com/ns/types#category" />
    
    <category term="xs" label="XS" scheme="http://www.sixapart.com/ns/types#tag" />
    
    <content type="html" xml:lang="en" xml:base="http://blogs.perl.org/users/max_maischein/">
        <![CDATA[<p>Today, I found out about a new release of <a href="http://search.cpan.org/dist/image-thumbnail">Image::Thumbnail</a> , which has support for <a href="http://search.cpan.org/dist/image-epeg/">Image::Epeg</a> , a library coming from the Enlightenment desktop manager. Likely, epeg is quite fast, but it didn't build and test right under Windows. Conveniently though, Tokuhiro Matsuno maintains the module <a href="https://github.com/tokuhirom/image-epeg">on github</a>, so it was just a matter of forking and cloning his repository, and then trying to find out what made it break.</p>

<p>The breakage itself was three parts:</p>

<ol>
<li>A build failure where the symbols were not exported. It seems the epeg library wants <code>-DBUILDING_DLL</code> , which I supplied as a <code>cc_optimize_flag</code> through <code>Module::Install</code>, because I couldn't find a better way.</li>
<li>Some test failures because <code>binmode()</code> was not used with the test image files. Easily fixed.</li>
</ol>

<p>These two tests made it into v0.11 , released about 30 minutes after I told tokuhirom about the patches.</p>

<ol>
<li><p>The remaining problem was that a function call crashed Perl with</p>

<p>Free to wrong pool ... at ...</p></li>
</ol>

<p>This was due to a call to <code>free(pOut)</code> to release a memory block that the epeg library allocated for us. Unfortunately, the library uses <code>malloc</code> and <code>free</code>, and Perl redefines the two, so I had to find a way to make the XS module also call the original <code>free()</code> and not the redefined <code>free()</code>. Tye McQueen pointed out a working hack by making the compiler forget the redefinition:</p>

<pre><code>#undef free
</code></pre>

<p>That undefinition would not have worked if there were other places below that line that still needed access to the redefined <code>free()</code>, but luckily that was not the case. The only snag was my limited knowledge of C preprocessor specifics, as I had some whitespace before the #undef and it was not picked up nor flagged as error. But after some trials, I also figured that out, and the pull request went out.</p>
]]>
        

    </content>
</entry>

<entry>
    <title>Cascading config parsing</title>
    <link rel="alternate" type="text/html" href="http://blogs.perl.org/users/max_maischein/2011/02/cascading-config-parsing.html" />
    <id>tag:blogs.perl.org,2011:/users/max_maischein//227.1492</id>

    <published>2011-02-22T21:09:44Z</published>
    <updated>2011-02-22T21:29:40Z</updated>

    <summary>Prompted by some comments about how to handle RAW files from cameras, I revisited App::imagestream , the program I use to automatically publish all images I touch to a gallery page on my website. An experiment that I run with...</summary>
    <author>
        <name>Max Maischein</name>
        <uri>http://corion.net</uri>
    </author>
    
        <category term="programming" scheme="http://www.sixapart.com/ns/types#category" />
    
    <category term="configcascade" label="config cascade" scheme="http://www.sixapart.com/ns/types#tag" />
    
    <content type="html" xml:lang="en" xml:base="http://blogs.perl.org/users/max_maischein/">
        <![CDATA[<p>Prompted by some comments about how to handle RAW files from cameras, I revisited <a href="https://github.com/Corion/app-imagestream">App::imagestream</a> , the program I use to automatically publish all images I touch to <a href="http://datenzoo.de/image_stream/imagestream.html">a gallery page on my website</a>.</p>

<p>An experiment that I run with this program (and with <a href="https://github.com/Corion/app-fritzgrowl">App::fritzgrowl</a> as well) is to specify the configuration information via POD. There is code in <a href="https://github.com/Corion/app-imagestream/tree/master/lib/Config/Spec/FromPod.pm">Config::Spec::FromPod</a> and <a href="https://github.com/Corion/app-imagestream/blob/master/lib/Config/Cascade.pm">Config::Cascade</a> that takes POD and turns it into a hash of hashes containing the configuration model. Then there is more code in <a href="https://github.com/Corion/app-imagestream/tree/master/lib/App/ImageStream/Config">App::ImageStream::Config</a> to turn this model into a DSL for a config file, a parser for <a href="http://search.cpan.org/dist/Getopt-Long">Getopt::Long</a> or simply the defaults. <code>Config::Cascade</code> then fills out the values, starting with the most specific values coming from the command line, the less specific values coming from the config file and the least specific values coming from the application defaults, all driven by the documentation.</p>

<pre><code>=head2 C&lt;&lt; output DIR &gt;&gt;

=for config
    repeat =&gt; 1,

Output directory

Specifies the output directory into which the output will be written.

Example:

    output 'C:/ImageStream/';

May appear only once.
</code></pre>

<p>So far, the experiment has been successful in the sense that specifying the config items via POD forced me to document each configuration item immediately. Writing the DSL and Getopt evaluator was fun, and having them data-driven will make it easy to also inspect <code>%ENV</code> for an intermediate stage of configuration between command line and configuration file. Having the first line be a really short description and always listing
an example also makes me think more about the values and how to best describe them.</p>

<p>The bad thing is of course that internationalization / localization will be nasty when specifying program data through program configuration. If you ruin the pod, the program won't work anymore, as it can't read its configuration anymore. This is currently of small concern to me as I don't plan on translating its documentation. But if some other well-meanung and unsuspecting individual translates the documentation, that'll be fun breakage at a distance.</p>

<p>Also bad is that my way of specifying out-of-band information implies embedding Perl again via <code>=for</code> blocks. This is a nasty-but-convenient hack.</p>

<p>In the long run, <code>Config::Spec::FromPod</code> should produce something suitable for consumption by <a href="http://search.cpan.org/dist/Config-Model">Config::Model</a>, so that I can reuse the GUI editors and the schema provided by it. But maybe I'll realize sooner that the experiment is doomed to fail, or I abandon the applications using it.</p>

<p>I haven't released the modules onto CPAN for two reasons. Firstly, because I think that while interesting, parsing POD for code is a debatable design choice. Second, the API of <code>Config::Cascade</code> isn't that great yet, and it's missing the provider that fetches the values from <code>%ENV</code>, and lots of use and documentation. I've only used the module in two applications, and in my experience, if I haven't used something at least three times, the API will likely be crap.</p>
]]>
        

    </content>
</entry>

</feed>
