grink's Journal http://use.perl.org/~grink/journal/ grink's use Perl Journal en-us use Perl; is Copyright 1998-2006, Chris Nandor. Stories, comments, journals, and other submissions posted on use Perl; are Copyright their respective owners. 2012-02-08T21:33:03+00:00 pudge pudge@perl.org Technology hourly 1 1970-01-01T00:00+00:00 grink's Journal http://use.perl.org/images/topics/useperl.gif http://use.perl.org/~grink/journal/ Config::JFDI 0.04 released http://use.perl.org/~grink/journal/37634?from=rss <div><p> <a href="http://search.cpan.org/perldoc?Config::JFDI">Config-JFDI</a> 0.04 should be on CPAN shortly</p><p>Config::JFDI mimics Catalyst::Plugin::ConfigLoader (without the need to load Catalyst). The new features in this release are:</p><ul> <li>Value substitution, just like C::P::CL (__HOME__, __path_to(...)__, __literal(...)__, etc.)</li><li>Ability to accept a default hash for a baseline configuration</li></ul></div><p> <a href="http://bravo9.com/journal/config-jfdi-0-04-released-e3ef15d7-73b0-464c-93dc-13f4125f212f">Config::JFDI 0.04 released</a></p> grink 2008-10-09T23:38:52+00:00 journal POD-like documentation for JavaScript: Doc::Simply http://use.perl.org/~grink/journal/37626?from=rss <div><p>I've just released <a href="http://search.cpan.org/perldoc?Doc::Simply">Doc::Simply</a>, a tool for generating documentation from JavaScript (or C, C++, etc.) comments.</p><p>I use it to for my <a href="http://appengine.bravo9.com/b9j">b9j documentation</a> </p><p>The idea came to me while developing some JavaScript: I was craving a way to drop in free-form documentation in a<nobr> <wbr></nobr>.js file as easily as I could in a<nobr> <wbr></nobr>.pm with perlpod.</p><p>The Doc::Simply format is modeled after Plain-Old-Documentation, but it is not an exact mimic. Body formatting, for example, is in <a href="http://daringfireball.net/projects/markdown/syntax">Markdown</a> (no C&lt;&gt;, L&lt;&gt;,<nobr> <wbr></nobr>...)</p><p>However, if you <strong>are</strong> craving pure POD, then it shouldn't be too difficult to bolt a proper parser/generator on top of Doc::Simply</p><p>You can run it from the command-line as <code>doc-simply</code> <code> <br> <br> doc-simply&nbsp;&lt;&nbsp;source.js&nbsp;&gt;&nbsp;documentation.html<br> <br> doc-simply&nbsp;--help<br> </code></p><p>An example:<br> &nbsp;&nbsp;&nbsp;/*<br> &nbsp;&nbsp;&nbsp;&nbsp;*&nbsp;@head1&nbsp;NAME<br> &nbsp;&nbsp;&nbsp;&nbsp;*<br> &nbsp;&nbsp;&nbsp;&nbsp;*&nbsp;Calculator&nbsp;-&nbsp;Add&nbsp;2&nbsp;+&nbsp;2&nbsp;and&nbsp;return&nbsp;the&nbsp;result<br> &nbsp;&nbsp;&nbsp;&nbsp;*<br> &nbsp;&nbsp;&nbsp;&nbsp;*/<br> <br> &nbsp;&nbsp;&nbsp;//&nbsp;@head1&nbsp;DESCRIPTION<br> &nbsp;&nbsp;&nbsp;//&nbsp;@body&nbsp;Add&nbsp;2&nbsp;+&nbsp;2&nbsp;and&nbsp;return&nbsp;the&nbsp;result&nbsp;(which&nbsp;should&nbsp;be&nbsp;4)<br> <br> &nbsp;&nbsp;&nbsp;/*<br> &nbsp;&nbsp;&nbsp;&nbsp;*&nbsp;@head1&nbsp;FUNCTIONS<br> &nbsp;&nbsp;&nbsp;&nbsp;*<br> &nbsp;&nbsp;&nbsp;&nbsp;*&nbsp;@head2&nbsp;twoPlusTwo<br> &nbsp;&nbsp;&nbsp;&nbsp;*<br> &nbsp;&nbsp;&nbsp;&nbsp;*&nbsp;Add&nbsp;2&nbsp;and&nbsp;2&nbsp;**and**&nbsp;return&nbsp;4<br> &nbsp;&nbsp;&nbsp;&nbsp;*<br> &nbsp;&nbsp;&nbsp;&nbsp;*/<br> <br> &nbsp;&nbsp;&nbsp;function&nbsp;twoPlusTwo()&nbsp;{<br> &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;return&nbsp;2&nbsp;+&nbsp;2;&nbsp;//&nbsp;Should&nbsp;return&nbsp;4<br> &nbsp;&nbsp;&nbsp;}<br> <br><nobr> <wbr></nobr>/*<br> &nbsp;*&nbsp;@head1&nbsp;AUTHOR<br> &nbsp;*<br> &nbsp;*&nbsp;Alice&nbsp;&lt;alice@example.com&gt;<br> &nbsp;*<br> &nbsp;*&nbsp;[http://example.com](http://example.com)<br> &nbsp;*<br> &nbsp;*/</p><p>... which will generate this <a href="http://bravo9.com/journal/962f9cf2-ed93-4e27-b447-db1146b6741c/assets/example.html">document</a> </p><p>You can download it from <a href="http://search.cpan.org/CPAN/authors/id/R/RK/RKRIMEN/Doc-Simply-0.02.tar.gz">http://search.cpan.org/CPAN/authors/id/R/RK/RKRIMEN/Doc-Simply-0.02.tar.gz</a> </p><p>... or install it via <code>cpan</code>:<code> <br> <br> cpan&nbsp;-i&nbsp;Doc::Simply<br> </code></p></div><p> <a href="http://bravo9.com/journal/pod-like-documentation-for-javascript-doc-simply-962f9cf2-ed93-4e27-b447-db1146b6741c">POD-like documentation for JavaScript: Doc::Simply</a></p> grink 2008-10-09T05:06:09+00:00 journal JavaScript URI/URL object http://use.perl.org/~grink/journal/37415?from=rss <div><p>I've put together an interactive example of <a href="http://appengine.bravo9.com/b9j/documentation/uri.html">my JavaScript URI object</a>:</p><p> <a href="http://appengine.bravo9.com/b9j/example/uri/">b9j.uri.URI example</a> </p><p>The example will also show the code necessary to perform the given operation (next to the result)</p><p>b9j.uri.URI overview:</p><ul> <li>Parses using Steven Levithan's <a href="http://blog.stevenlevithan.com/archives/parseuri">parseUri 1.2</a> </li><li>Easy path traversal (ascend to parent, descend to a child)</li><li>Set or add to the URI query (with proper encoding), get/interrogate the query (with proper decoding)</li><li>Add arbitrary data (unencoded) to the end of the query string, for extra flexibility</li><li>Manipulate/interrogate the scheme, user information (username &amp; password), host, port, fragment, and more in a piecewise fashion</li><li>Add, change or strip the extension (html, js, css,<nobr> <wbr></nobr>...) from a given URI</li></ul><p>The code is available at <a href="http://appengine.bravo9.com/b9j/b9j.uri.js">http://appengine.bravo9.com/b9j/b9j.uri.js</a> (19kb compressed / 5kb gzipped)</p><p>See also the <a href="http://appengine.bravo9.com/b9j/documentation/uri.html">documentation for b9j.uri</a> </p><p> <a href="http://appengine.bravo9.com/b9j/example/uri/"> </a> </p></div><p> <a href="http://bravo9.com/journal/javascript-uri-object-615ae9fd-9fdd-4041-a662-98db08d8e55f">JavaScript URI object</a></p> grink 2008-09-11T23:21:11+00:00 journal Large Hadron Collider (LHC) webcam http://use.perl.org/~grink/journal/37401?from=rss <p>Large Hadron Collider webcam, pretty interesting:</p><p><a href="http://www.cyriak.co.uk/lhc/lhc-webcams.html">http://www.cyriak.co.uk/lhc/lhc-webcams.html</a></p><p>(thanks gcohen!)</p> grink 2008-09-10T22:36:51+00:00 journal URI handling in JavaScript with b9j.uri http://use.perl.org/~grink/journal/37355?from=rss <div><p>Following my b9j.path release, I just finished up work on URI object-class for javascript.</p><p>It uses Steven Levithan's <a href="http://blog.stevenlevithan.com/archives/parseuri">parseUri 1.2</a> to do the parsing.</p><p>Some example usage:<code> <br> <br> var&nbsp;uri&nbsp;=&nbsp;new&nbsp;b9j.uri.URI(&nbsp;"http://example.com/a/b?a=1&amp;b=2&amp;c=3&amp;c=4&amp;c=5"&nbsp;)<br> var&nbsp;host&nbsp;=&nbsp;uri.host()<br> <br> var&nbsp;child&nbsp;=&nbsp;uri.child("c.html")&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;//&nbsp;http://example.com/a/b/c.html?a=1<nobr>&amp;<wbr></nobr> b=2&amp;&nbsp;...<br> child.query().add({&nbsp;c:&nbsp;[&nbsp;6,&nbsp;7&nbsp;],&nbsp;d:&nbsp;8&nbsp;})&nbsp;&nbsp;&nbsp;//&nbsp;...&nbsp;?a=1&amp;b=2&amp;c=3&amp;c=4&amp;c=5&amp;c=6&amp;c=7&amp;<nobr>d<wbr></nobr> =8<br> child.query().set("b",&nbsp;9)&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;//&nbsp;...&nbsp;?a=1&amp;b=9&amp;c&nbsp;...<br> <br> return&nbsp;child.toString()<br> </code></p><p>Again, while CPAN has URI.pm for URI-handling, JavaScript didn't really have an equivalent (parsing yes -- modifying/generating no).</p><p> <a href="http://appengine.bravo9.com/b9j/documentation/uri.html">b9j.uri - URI parsing, manipulation, and generation</a> </p></div><p> <a href="http://bravo9.com/journal/uri-handling-in-javascript-with-b9j-uri-a-uri-uri-query-parser-manipulator-and-generator-f86cab7d-e960-49cd-b748-b9de14bbd9c3">URI handling in JavaScript with b9j.uri: a URI/URI-query parser, manipulator, and generator</a></p> grink 2008-09-04T18:47:50+00:00 journal Path handling in JavaScript with b9j.path http://use.perl.org/~grink/journal/37287?from=rss <div><p> <a href="http://appengine.bravo9.com/b9j/documentation/path.html">b9j.path</a> provides a way to parse, manipulate, and generate URI/UNIX-style paths.</p><p>CPAN provides lots of different options for path-handling and path-manipulation, but there didn't seem to be anything really available in JavaScript-land.</p><p>To fill the gap, I've released <a href="http://appengine.bravo9.com/b9j/documentation/path.html">b9j.path</a>:<code> <br> <br> &nbsp;var&nbsp;path&nbsp;=&nbsp;new&nbsp;b9j.path.Path("/a/b/c")<br> <br> &nbsp;//&nbsp;/a/b/c/xyzzy<br> &nbsp;var&nbsp;child&nbsp;=&nbsp;path.child("xyzzy")<br> <br> &nbsp;//&nbsp;/a/b<br> &nbsp;var&nbsp;parent&nbsp;=&nbsp;path.parent()<br> <br> &nbsp;//&nbsp;...&nbsp;and&nbsp;much,&nbsp;much,&nbsp;more...<br> </code></p><p>It's part of my <a href="http://appengine.bravo9.com/b9j">b9j javascript pack</a> available at: <a href="http://appengine.bravo9.com/b9j/b9j-latest.zip">http://appengine.bravo9.com/b9j/b9j-latest.zip</a> </p><p> <a href="http://appengine.bravo9.com/b9j/b9j-latest.zip">&#187; Download</a> </p><p> <a href="http://appengine.bravo9.com/b9j/documentation/path.html">&#187; Documentation</a> </p><p> <a href="http://appengine.bravo9.com/b9j/test/path.html">&#187; Test</a> </p></div><p> <a href="http://bravo9.com/journal/path-handling-in-javascript-with-b9j-path-a-unix-style-path-parser-manipulator-and-generator-d79dd385-587a-4c7e-a2d3-7675b49ab004">Path handling in JavaScript with b9j.path: a UNIX-style path parser, manipulator, and generator</a></p> grink 2008-08-28T02:10:34+00:00 journal b9jTest: Simplifying and enhancing YUI Test http://use.perl.org/~grink/journal/37279?from=rss <div><p> <a href="http://developer.yahoo.com/yui/yuitest/">YUI Test</a> is a great tool for javascript testing, but it has a couple of small issues:</p><ul> <li>Setting up the HTML document requires many different<nobr> <wbr></nobr>.js and<nobr> <wbr></nobr>.css assets</li><li>The actual javascript code to set up the test environment is not trivial (setting up the TestRunner, setting up the TestLogger, etc.)</li><li>A failed assertion will abort the test function immediately, preventing later tests from running</li></ul><p>b9jTest addresses the problems above by:</p><ul> <li>Bundling all the required<nobr> <wbr></nobr>.js and<nobr> <wbr></nobr>.css assets into just two separate files</li><li>Providing some boilerplate javascript so you can jump right into testing without a lot of setup</li></ul><p> <a href="http://appengine.bravo9.com/b9j/documentation/b9jTest-example.html">An example b9jTest document</a>:<code> <br> <br> &lt;html&gt;<br> &lt;head&gt;<br> &nbsp;&nbsp;&nbsp;&nbsp;&lt;meta&nbsp;http-equiv="content-type"&nbsp;content="text/html;&nbsp;charset=utf-8"&gt;<br> &lt;title&gt;b9jTest&nbsp;example&lt;/title&gt;<br> &lt;link&nbsp;rel="stylesheet"&nbsp;type="text/css"<br> &nbsp;&nbsp;&nbsp;&nbsp;href="http://appengine.bravo9.com/b9j/b9jTest.css"&gt;<br> &lt;script&nbsp;type="text/javascript"<br> &nbsp;&nbsp;&nbsp;&nbsp;src="http://appengine.bravo9.com/b9j/b9jTest.js"&gt;&lt;/script&gt;<br> &lt;/head&gt;<br> &lt;body&nbsp;class="yui-skin-sam"&gt;<br> &lt;div&nbsp;id="testLogger"&gt;&lt;/div&gt;<br> &lt;script&nbsp;type="text/javascript"&gt;<br> <br> &nbsp;&nbsp;&nbsp;&nbsp;b9jTest(function(test)&nbsp;{<br> &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;test.areEqual("xyzzy",&nbsp;"xyzzy");<br> &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;test.areEqual("apple",&nbsp;"apple");<br> &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;test.areEqual("banana",&nbsp;"banana");<br> &nbsp;&nbsp;&nbsp;&nbsp;});&nbsp;&nbsp;<br> <br> &lt;/script&gt;<br> &lt;/body&gt;<br> </code></p><p> <code>b9jTest()</code> is a global function that accepts a function that is called with a testing object. The testing object provides access to the <a href="http://developer.yahoo.com/yui/yuitest/#assertions">standard YUI assertions</a> and <a href="http://appengine.bravo9.com/b9j/documentation/b9jTest.html">more</a>.</p><p>Documentation:</p><blockquote><div><p> <a href="http://appengine.bravo9.com/b9j/documentation/b9jTest.html">http://appengine.bravo9.com/b9j/documentation/b9jTest.html</a></p></div> </blockquote><p>Download:</p><blockquote><div><p> <a href="http://appengine.bravo9.com/b9j/b9jTest.js">b9jTest.js</a> <br> <a href="http://appengine.bravo9.com/b9j/b9jTest.css">b9jTest.css</a></p></div> </blockquote></div><p> <a href="http://bravo9.com/journal/b9jtest-simplifying-and-enhancing-yui-test-f994bb05-86da-4200-944b-98b2f1b2947e">b9jTest: Simplifying and enhancing YUI Test</a></p> grink 2008-08-26T23:22:55+00:00 journal Copying text into the clipboard with javascript http://use.perl.org/~grink/journal/37262?from=rss <div><p> <a href="http://bravo9.com/journal/292559a2-cc6c-4ebf-9724-d23e8bc5ad8a/assets/example.html">Example of copying text into the clipboard</a> </p><p>Firefox won't allow copying text into the clipboard via javascript for a <a href="http://support.mozilla.com/en-US/kb/Granting+JavaScript+access+to+the+clipboard">variety of reasons</a>.</p><p>For better or worse, you can get around this problem with a little<nobr> <wbr></nobr>.swf (Flash):<code> <br> <br> &nbsp;&nbsp;&nbsp;&nbsp;function&nbsp;copyIntoClipboard(text)&nbsp;{<br> <br> &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;var&nbsp;flashId&nbsp;=&nbsp;'flashId-HKxmj5';<br> <br> &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;/*&nbsp;Replace&nbsp;this&nbsp;with&nbsp;your&nbsp;clipboard.swf&nbsp;location&nbsp;*/<br> &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;var&nbsp;clipboardSWF&nbsp;=&nbsp;'http://appengine.bravo9.com/copy-into-clipboard/cli<nobr>p<wbr></nobr> board.swf';<br> <br> &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;if(!document.getElementById(flashId))&nbsp;{<br> &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;var&nbsp;div&nbsp;=&nbsp;document.createElement('div');<br> &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;div.id&nbsp;=&nbsp;flashId;<br> &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;document.body.appendChild(div);<br> &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;}<br> &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;document.getElementById(flashId).innerHTML&nbsp;=&nbsp;'';<br> &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;var&nbsp;content&nbsp;=&nbsp;'&lt;embed&nbsp;src="'&nbsp;+&nbsp;<br> &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;clipboardSWF&nbsp;+<br> &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;'"&nbsp;FlashVars="clipboard='&nbsp;+&nbsp;encodeURIComponent(text)&nbsp;+<br> &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;'"&nbsp;width="0"&nbsp;height="0"&nbsp;type="application/x-shockwave-flash"&gt;&lt;/embe<nobr>d<wbr></nobr> &gt;';<br> &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;document.getElementById(flashId).innerHTML&nbsp;=&nbsp;content;<br> &nbsp;&nbsp;&nbsp;&nbsp;}<br> </code></p><p>The above trick will also work in Safari, IE, and Opera.</p><p>Download <a href="http://appengine.bravo9.com/copy-into-clipboard/clipboard.swf">clipboard.swf</a> </p><p>Alternatively, you can use the Google App Engine hosted version at<br> <a href="http://appengine.bravo9.com/copy-into-clipboard/clipboard.swf">http://appengine.bravo9.com/copy-into-clipboard/clipboard.swf</a> </p><p>(Originally adapted from <a href="http://www.jeffothy.com/weblog/clipboard-copy/">http://www.jeffothy.com/weblog/clipboard-copy/</a>)</p></div><p> <a href="http://bravo9.com/journal/copying-text-into-the-clipboard-with-javascript-in-firefox-safari-ie-opera-292559a2-cc6c-4ebf-9724-d23e8bc5ad8a">Copying text into the clipboard with javascript in Firefox, Safari, IE, Opera,<nobr> <wbr></nobr>...</a></p> grink 2008-08-24T01:30:25+00:00 journal Getopt::Chain released: git(1) style command-line processing http://use.perl.org/~grink/journal/37220?from=rss <div><p> <a href="http://search.cpan.org/dist/Getopt-Chain/">Getopt::Chain</a> </p><p> Option and subcommand processing in the style svn(1) and git(1) </p><p>Getopt::Chain will help you make your command-line scripts work like this:<code> <br> <br> &nbsp;&nbsp;&nbsp;&nbsp;./script&nbsp;--opt&nbsp;--opt=&lt;value&gt;&nbsp;cmd&nbsp;--opt&nbsp;...<br> &nbsp;&nbsp;&nbsp;&nbsp;./script&nbsp;cmd&nbsp;...<br> </code></p><p>NOTE: Any option specification covered by Getopt::Long is fair game.</p><p>Here is some example usage:<code> <br> <br> &nbsp;&nbsp;&nbsp;&nbsp;#!/usr/bin/perl&nbsp;-w<br> <br> &nbsp;&nbsp;&nbsp;&nbsp;use&nbsp;strict;<br> &nbsp;&nbsp;&nbsp;&nbsp;use&nbsp;Getopt::Chain;<br> <br> &nbsp;&nbsp;&nbsp;&nbsp;#&nbsp;A&nbsp;partial,&nbsp;pseudo-reimplementation&nbsp;of&nbsp;git(1):<br> <br> &nbsp;&nbsp;&nbsp;&nbsp;Getopt::Chain-&gt;process(<br> <br> &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;options&nbsp;=&gt;&nbsp;[qw/&nbsp;version&nbsp;bare&nbsp;git-dir=s&nbsp;/]<br> <br> &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;run&nbsp;=&gt;&nbsp;sub&nbsp;{<br> &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;my&nbsp;$context&nbsp;=&nbsp;shift;<br> &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;my&nbsp;@arguments&nbsp;=&nbsp;@_;&nbsp;#&nbsp;Remaining,&nbsp;unparsed&nbsp;arguments<br> <br> &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;#&nbsp;...&nbsp;do&nbsp;stuff&nbsp;before&nbsp;any&nbsp;subcommand&nbsp;...<br> <br> &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;}<br> <br> &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&n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t;&nbsp;...<br> <br> &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;help&nbsp;=&gt;&nbsp;...<br> <br> &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;...<br> &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;}<br> &nbsp;&nbsp;&nbsp;&nbsp;)<br> <br> &nbsp;&nbsp;&nbsp;&nbsp;#&nbsp;The&nbsp;above&nbsp;will&nbsp;allow&nbsp;the&nbsp;following&nbsp;(example)&nbsp;usage:<br> &nbsp;&nbsp;&nbsp;&nbsp;#<br> &nbsp;&nbsp;&nbsp;&nbsp;#&nbsp;./script&nbsp;--version<br> &nbsp;&nbsp;&nbsp;&nbsp;#&nbsp;./script&nbsp;--git-dir&nbsp;path/to/repository&nbsp;init<br> &nbsp;&nbsp;&nbsp;&nbsp;#&nbsp;./script&nbsp;--git-dir&nbsp;path/to/repository&nbsp;commit&nbsp;-a&nbsp;--message&nbsp;'...'<br> &nbsp;&nbsp;&nbsp;&nbsp;#&nbsp;./script&nbsp;commit&nbsp;-m&nbsp;'~'<br> </code></p><p>The source repository is on GitHub: <a href="http://github.com/robertkrimen/getopt-chain/tree/master">http://github.com/robertkrimen/getopt-chain/tree/master</a> </p></div><p> <a href="http://bravo9.com/journal/getopt-chain-released-git-1-and-svn-1-style-command-line-processing-6e36d6a5-0570-4ab6-b276-2cb61ec9a6b3">Getopt::Chain released: git(1) and svn(1) style command-line processing</a></p> grink 2008-08-17T20:30:48+00:00 journal Hash::Param released http://use.perl.org/~grink/journal/37205?from=rss <div><p> <a href="http://search.cpan.org/dist/Hash-Param/">Hash::Param</a> </p><p> A CGI/Catalyst::Request-like parameter-hash accessor/mutator<code> <br> <br> &nbsp;&nbsp;&nbsp;&nbsp;my&nbsp;$params&nbsp;=&nbsp;Hash::Param-&gt;new(parameters&nbsp;=&gt;&nbsp;{<br> &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;qw/a&nbsp;1&nbsp;b&nbsp;2&nbsp;c&nbsp;3/,<br> &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;d&nbsp;=&gt;&nbsp;[qw/4&nbsp;5&nbsp;6&nbsp;7/],<br> &nbsp;&nbsp;&nbsp;&nbsp;})<br> <br> &nbsp;&nbsp;&nbsp;&nbsp;$result&nbsp;=&nbsp;$params-&gt;param(&nbsp;a&nbsp;)&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;#&nbsp;Returns&nbsp;1<br> &nbsp;&nbsp;&nbsp;&nbsp;$result&nbsp;=&nbsp;$params-&gt;param(&nbsp;d&nbsp;)&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;#&nbsp;Returns&nbsp;4<br> &nbsp;&nbsp;&nbsp;&nbsp;@result&nbsp;=&nbsp;$params-&gt;param(&nbsp;d&nbsp;)&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;#&nbsp;Returns&nbsp;4,&nbsp;5,&nbsp;6,&nbsp;7<br> &nbsp;&nbsp;&nbsp;&nbsp;@result&nbsp;=&nbsp;$params-&gt;params&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;#&nbsp;Returns&nbsp;a,&nbsp;b,&nbsp;c,&nbsp;d<br> &nbsp;&nbsp;&nbsp;&nbsp;$result&nbsp;=&nbsp;$params-&gt;params&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp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sp;&nbsp;&nbsp;&nbsp;&nbsp;#&nbsp;Sets&nbsp;a&nbsp;to&nbsp;8<br> &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;$params-&gt;param(&nbsp;a&nbsp;=&gt;&nbsp;8,&nbsp;9&nbsp;)&nbsp;&nbsp;&nbsp;#&nbsp;Sets&nbsp;a&nbsp;to&nbsp;[&nbsp;8,&nbsp;9&nbsp;]<br> </code></p><p>The source repository is on GitHub: <a href="http://github.com/robertkrimen/hash-param/tree/master">http://github.com/robertkrimen/hash-param/tree/master</a> </p></div><p> <a href="http://bravo9.com/journal/hash-param-released-262b82a4-e074-4ff0-85ec-d6b076ed7961">Hash::Param released</a></p> grink 2008-08-16T16:20:04+00:00 journal String::Comments::Extract released http://use.perl.org/~grink/journal/37177?from=rss <div><p> <a href="http://search.cpan.org/dist/String-Comments-Extract/">String::Comments::Extract</a> <code> <br> <br> &nbsp;&nbsp;&nbsp;&nbsp;my&nbsp;$comments&nbsp;=&nbsp;String::Comments::Extract::C-&gt;extract($source)<br> </code></p><p>String::Comments::Extract is a tool for extracting comments from C/C++/JavaScript/Java. The extractor is implemented using an actual tokenizer (written in C via XS [adapted from JavaScript::Minifier::XS]). By using a tokenizer, it can correctly deal with notoriously problematic cases, such as comment-like structures embedded in strings:<code> <br> <br> &nbsp;&nbsp;&nbsp;&nbsp;std::cout&nbsp;&lt;&lt;&nbsp;"This&nbsp;is&nbsp;not&nbsp;a&nbsp;//&nbsp;real&nbsp;C++&nbsp;comment&nbsp;"&nbsp;&lt;&lt;&nbsp;std::endl<br> &nbsp;&nbsp;&nbsp;&nbsp;printf("/*&nbsp;This&nbsp;is&nbsp;not&nbsp;a&nbsp;real&nbsp;C&nbsp;comment&nbsp;*/\n");<br> &nbsp;&nbsp;&nbsp;&nbsp;#&nbsp;The&nbsp;extractor&nbsp;will&nbsp;ignore&nbsp;both&nbsp;of&nbsp;the&nbsp;above<br> </code></p><p>The source repository is on GitHub: <a href="http://github.com/robertkrimen/string-comments-extract/tree/master">http://github.com/robertkrimen/string-comments-extract/tree/master</a> </p></div><p> <a href="http://bravo9.com/journal/string-comments-extract-released-1b3c8b8a-ea39-4f3f-b209-aa098b63e77b">String::Comments::Extract released</a></p> grink 2008-08-14T06:14:32+00:00 journal A simple lightbox (modal) dialog with YUI http://use.perl.org/~grink/journal/37166?from=rss <div><p> <a href="http://bravo9.com/journal/c5b048f5-b278-46d1-9a7e-0d3035094f52/assets/example.html">Example of a simple lightbox (modal) dialog with YUI</a> </p><p>A lightbox (modal) dialog is an effective way to bring attention to an input form or important message.</p><p>You'll need the following YUI assets:<code> <br> <br> &nbsp;&nbsp;&nbsp;&nbsp;&lt;link&nbsp;rel="stylesheet"&nbsp;type="text/css"&nbsp;href="http://yui.yahooapis.com/2.5.2<nobr>/<wbr></nobr> build/reset-fonts-grids/reset-fonts-grids.css"&gt;<br> &nbsp;&nbsp;&nbsp;&nbsp;&lt;link&nbsp;rel="stylesheet"&nbsp;type="text/css"&nbsp;href="http://yui.yahooapis.com/2.5.2<nobr>/<wbr></nobr> build/container/assets/skins/sam/container.css"&gt;<br> &nbsp;&nbsp;&nbsp;&nbsp;&lt;script&nbsp;type="text/javascript"&nbsp;src="http://yui.yahooapis.com/2.5.2/build/ya<nobr>h<wbr></nobr> oo-dom-event/yahoo-dom-event.js"&gt;&lt;/script&gt;&nbsp;<br> &nbsp;&nbsp;&nbsp;&nbsp;&lt;script&nbsp;type="text/javascript"&nbsp;src="http://yui.yahooapis.com/2.5.2/build/co<nobr>n<wbr></nobr> tainer/container-min.js"&gt;&lt;/script&gt;&nbsp;<br> </code></p><p>The easiest way to make a lightbox in YUI is to construct a <code>YAHOO.widget.Panel</code> and use<nobr> <wbr></nobr><code>.setBody</code> to put in content:<code> <br> <br> &nbsp;&nbsp;&nbsp;&nbsp;var&nbsp;panel&nbsp;=&nbsp;new&nbsp;YAHOO.widget.Panel(<br> &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;"panel",&nbsp;//&nbsp;The&nbsp;element&nbsp;id<br> &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;{<br> &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;width:&nbsp;"480px",&nbsp;<br> &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;fixedcenter:&nbsp;true,&nbsp;<br> &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;close:&nbsp;false,&nbsp;<br> &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;draggable:&nbsp;false,&nbsp;<br> &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;zindex:&nbsp;4,<br> &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;modal:&nbsp;true,<br> &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;visible:&nbsp;false<br> &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;}<br> &nbsp;&nbsp;&nbsp;&nbsp;);<br> &nbsp;&nbsp;&nbsp;&nbsp;panel.setBody("&lt;p&gt;Aliquam&nbsp;ultrices.&nbsp;Nulla&nbsp;dictum,&nbsp;augue&nbsp;et&nbsp;condimentum&nbsp;comm<nobr>o<wbr></nobr> do.&lt;/p&gt;");<br> &nbsp;&nbsp;&nbsp;&nbsp;panel.render(document.body);<br> &nbsp;&nbsp;&nbsp;&nbsp;panel.show();<br> </code></p><p>One gotcha to keep in mind is that the class attribute of the page <code>&lt;body&gt;</code> <em>must</em> include <code>yui-skin-sam</code>. The <code>yui-skin-sam</code> class is necessary to provide:</p><ol> <li>Basic styling for the panel (such as border and drop shadow)</li><li>Darkening of the contents behind the panel</li></ol><p>Another gotcha with the example is that you cannot change the content after rendering (doing so will cause the close link to stop working). This has to do with associating an event handler with a DOM node and then destroying that node when you change the content. Event delegation is a good solution to this problem.</p></div><p> <a href="http://bravo9.com/journal/a-simple-lightbox-modal-dialog-with-yui-c5b048f5-b278-46d1-9a7e-0d3035094f52">A simple lightbox (modal) dialog with YUI</a></p> grink 2008-08-12T20:12:54+00:00 journal CPAN: Where is the source repository for $DIST? http://use.perl.org/~grink/journal/37141?from=rss <p>Something that would be nice to have:</p><p>The ability to embed a link to the project's source repository so that <a href="http://search.cpan.org/">search.cpan.org</a> could display it.</p><p>You can do this by sticking something in the POD, but having it in a standard place (like Links:) would be much, much better:<br><code><br> &nbsp; &nbsp; * You could find the project's repository without hunting through the POD<br> &nbsp; &nbsp; * You could tell, at a glance, if a project has a repository that the author would like to share<br> &nbsp; &nbsp; * It would encourage users to contribute documentation and bug fixes<br></code></p> grink 2008-08-10T00:19:11+00:00 journal URI::PathAbstract released http://use.perl.org/~grink/journal/37090?from=rss <p>I've just released <a href="http://search.cpan.org/perldoc?URI::PathAbstract">URI::PathAbstract</a> into the wild, which is a melding of URI and Path::Abstract</p><p>You can use it to do things like:<br><code><br> &nbsp; &nbsp; &nbsp; &nbsp; my $uri = URI::PathAbstract-&gt;new("http://example.com?a=b")</code></p><p><code> &nbsp; &nbsp; &nbsp; &nbsp; $uri-&gt;down("apple")<br> &nbsp; &nbsp; &nbsp; &nbsp; # http://example.com/apple?a=b</code></p><p><code> &nbsp; &nbsp; &nbsp; &nbsp; $uri-&gt;query("c=d&amp;e=f")<br> &nbsp; &nbsp; &nbsp; &nbsp; # http://example.com/apple?c=d&amp;e=f</code></p><p><code> &nbsp; &nbsp; &nbsp; &nbsp; $uri-&gt;path("grape/blueberry/pineapple")<br> &nbsp; &nbsp; &nbsp; &nbsp; # http://example.com/grape/blueberry/pineapple?c=d&amp;e=f</code></p><p><code> &nbsp; &nbsp; &nbsp; &nbsp; $uri = $uri-&gt;parent<br> &nbsp; &nbsp; &nbsp; &nbsp; # http://example.com/grape/blueberry?c=d&amp;e=f<br></code></p> grink 2008-08-04T08:38:59+00:00 journal Google::AJAX::Library released http://use.perl.org/~grink/journal/36606?from=rss <div><p>Just released <a href="http://search.cpan.org/dist/Google-AJAX-Library/">Google::AJAX::Library</a> for accessing the Google <a href="http://code.google.com/apis/ajaxlibs/">AJAX Libraries API</a> in Perl.</p><p>Here is some example usage:<code> <br> <br> &nbsp;&nbsp;&nbsp;&nbsp;use&nbsp;Google::AJAX::Library;<br> <br> &nbsp;&nbsp;&nbsp;&nbsp;my&nbsp;$library&nbsp;=&nbsp;Google::AJAX::Library-&gt;jquery;<br> <br> &nbsp;&nbsp;&nbsp;&nbsp;$library-&gt;uri<br> &nbsp;&nbsp;&nbsp;&nbsp;#&nbsp;http://ajax.googleapis.com/ajax/libs/jquery/1/jquery.min.js<br> <br> &nbsp;&nbsp;&nbsp;&nbsp;$library-&gt;html<br> &nbsp;&nbsp;&nbsp;&nbsp;#&nbsp;&lt;script&nbsp;src="http://ajax.googleapis.com/ajax/libs/jquery/1/jquery.min.js"<nobr>&nbsp;<wbr></nobr> type="text/javascript"&gt;&lt;/script&gt;<br> </code></p></div><p> <a href="http://bravo9.com/journal/google-ajax-library-released-c7847452-d568-4c78-a343-52b48c5ee74d">Google::AJAX::Library released</a></p> grink 2008-06-07T02:20:57+00:00 journal