<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0"
	xmlns:content="http://purl.org/rss/1.0/modules/content/"
	xmlns:wfw="http://wellformedweb.org/CommentAPI/"
	xmlns:dc="http://purl.org/dc/elements/1.1/"
	xmlns:atom="http://www.w3.org/2005/Atom"
	xmlns:sy="http://purl.org/rss/1.0/modules/syndication/"
	xmlns:slash="http://purl.org/rss/1.0/modules/slash/"
	>

<channel>
	<title>javier arturo rodríguez &#187; Code</title>
	<atom:link href="http://javier.rodriguez.org.mx/index.php/category/code/feed" rel="self" type="application/rss+xml" />
	<link>http://javier.rodriguez.org.mx</link>
	<description>random musings</description>
	<lastBuildDate>Thu, 16 Apr 2009 14:00:13 +0000</lastBuildDate>
	<generator>http://wordpress.org/?v=2.9.2</generator>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
			<item>
		<title>Link:  JSESSIONID considered harmful</title>
		<link>http://javier.rodriguez.org.mx/index.php/2009/04/16/link-jsessionid-considered-harmful</link>
		<comments>http://javier.rodriguez.org.mx/index.php/2009/04/16/link-jsessionid-considered-harmful#comments</comments>
		<pubDate>Thu, 16 Apr 2009 14:00:13 +0000</pubDate>
		<dc:creator>javier</dc:creator>
				<category><![CDATA[Code]]></category>
		<category><![CDATA[General]]></category>
		<category><![CDATA[Java]]></category>
		<category><![CDATA[Security]]></category>
		<category><![CDATA[link]]></category>

		<guid isPermaLink="false">http://javier.rodriguez.org.mx/?p=227</guid>
		<description><![CDATA[Craig Condit makes a strong case against JSESSIONID in JSESSIONID considered harmful. And I just learned that it is disabled by default in Grails 1.1.
]]></description>
			<content:encoded><![CDATA[<p><a href="">Craig Condit</a> makes a strong case against JSESSIONID in <a href="http://randomcoder.com/articles/jsessionid-considered-harmful">JSESSIONID considered harmful</a>. And I just learned that it is <a href="http://jira.codehaus.org/browse/GRAILS-3364">disabled by default in Grails 1.1</a>.</p>
]]></content:encoded>
			<wfw:commentRss>http://javier.rodriguez.org.mx/index.php/2009/04/16/link-jsessionid-considered-harmful/feed</wfw:commentRss>
		<slash:comments>1</slash:comments>
		</item>
		<item>
		<title>uHOWTO: Recover stuck modified keys from VMware Player or Workstation</title>
		<link>http://javier.rodriguez.org.mx/index.php/2009/01/15/uhowto-recover-stuck-modified-keys-from-vmware-player-or-workstation</link>
		<comments>http://javier.rodriguez.org.mx/index.php/2009/01/15/uhowto-recover-stuck-modified-keys-from-vmware-player-or-workstation#comments</comments>
		<pubDate>Thu, 15 Jan 2009 14:12:53 +0000</pubDate>
		<dc:creator>javier</dc:creator>
				<category><![CDATA[General]]></category>
		<category><![CDATA[Linux]]></category>
		<category><![CDATA[SysAdmin]]></category>
		<category><![CDATA[Tech]]></category>
		<category><![CDATA[sh]]></category>
		<category><![CDATA[bash]]></category>
		<category><![CDATA[vmware]]></category>
		<category><![CDATA[x11]]></category>
		<category><![CDATA[xmodmap]]></category>

		<guid isPermaLink="false">http://javier.rodriguez.org.mx/?p=193</guid>
		<description><![CDATA[If you use VMware Player or VMware workstation under Linux and you&#8217;re an alt-tab fan like me, you might end up with stuck modifier keys, so you can&#8217;t use keys like Ctrl, Alt or Shift outside of VMware. Xiao Feng has written a nice script to recover from this annoying condition without having to reboot, [...]]]></description>
			<content:encoded><![CDATA[<p>If you use VMware Player or VMware workstation under Linux and you&#8217;re an alt-tab fan like me, you might end up with stuck modifier keys, so you can&#8217;t use keys like Ctrl, Alt or Shift outside of VMware. Xiao Feng has written a <a href="http://bitubique.com/tutorials/recovering-from-stuck-modifier-keys">nice script</a> to recover from this annoying condition without having to reboot, and I tought I&#8217;d share it with everyone out there:</p>
<div class="codesnip-container" >
<div class="codesnip"><span class="co1">#!/bin/sh</span><br />
<span class="co1"># Xiao Feng&#8217;s &quot;Recovering from stuck modifier keys caused by VMware&quot;</span><br />
<span class="co1"># http://bitubique.com/tutorials/recovering-from-stuck-modifier-keys</span><br />
/usr/bin/xmodmap &#8211; &lt;&lt; fixme<br />
clear <span class="kw3">shift</span><br />
add <span class="kw3">shift</span> = Shift_L Shift_R<br />
clear lock<br />
add lock = Caps_Lock<br />
clear control<br />
add control = Control_L Control_R<br />
clear mod1<br />
add mod1 = Alt_L Alt_R<br />
clear mod2<br />
add mod2 = Num_Lock<br />
clear mod3<br />
clear mod4<br />
add mod4 = Super_L Super_R<br />
clear mod5<br />
add mod5 = Scroll_Lock<br />
fixme<br />
xset r on<br />
xset m <span class="nu0">3</span>.<span class="nu0">5</span> <span class="nu0">4</span><br />
xset b off<br />
xset s off</div>
</div>
]]></content:encoded>
			<wfw:commentRss>http://javier.rodriguez.org.mx/index.php/2009/01/15/uhowto-recover-stuck-modified-keys-from-vmware-player-or-workstation/feed</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>update&#8230;where id in (select&#8230;) and mySQL ERROR 1093</title>
		<link>http://javier.rodriguez.org.mx/index.php/2008/08/26/update-where-id-in-select-and-mysql-error-1093</link>
		<comments>http://javier.rodriguez.org.mx/index.php/2008/08/26/update-where-id-in-select-and-mysql-error-1093#comments</comments>
		<pubDate>Tue, 26 Aug 2008 23:25:10 +0000</pubDate>
		<dc:creator>javier</dc:creator>
				<category><![CDATA[Code]]></category>
		<category><![CDATA[General]]></category>
		<category><![CDATA[SQL]]></category>

		<guid isPermaLink="false">http://javier.rodriguez.org.mx/?p=146</guid>
		<description><![CDATA[What&#8217;s wrong with this picture?

mysql&#62; UPDATE IGNORE flight SET intl=1 WHERE id IN &#40;SELECT f.id AS id FROM flight f LEFT JOIN airport a ON a.id=f.origin WHERE a.country&#60;&#62;&#8216;mx&#8217; FOR UPDATE&#41;;
ERROR 1093 &#40;HY000&#41;: You can&#8216;t specify target table &#8216;flight&#8216; for update in FROM clause 

This construct is invalid in mySQL
According to the manual, 

You can use [...]]]></description>
			<content:encoded><![CDATA[<p>What&#8217;s wrong with this picture?</p>
<div class="codesnip-container" >
<div class="codesnip">mysql&gt; <span class="kw1">UPDATE</span> <span class="kw1">IGNORE</span> flight <span class="kw1">SET</span> intl=<span class="nu0">1</span> <span class="kw1">WHERE</span> id <span class="kw1">IN</span> <span class="br0">&#40;</span><span class="kw1">SELECT</span> f.id <span class="kw1">AS</span> id <span class="kw1">FROM</span> flight f <span class="kw1">LEFT</span> <span class="kw1">JOIN</span> airport a <span class="kw1">ON</span> a.id=f.origin <span class="kw1">WHERE</span> a.country&lt;&gt;<span class="st0">&#8216;mx&#8217;</span> <span class="kw1">FOR</span> <span class="kw1">UPDATE</span><span class="br0">&#41;</span>;<br />
ERROR <span class="nu0">1093</span> <span class="br0">&#40;</span>HY000<span class="br0">&#41;</span>: You can<span class="st0">&#8216;t specify target table &#8216;</span>flight<span class="st0">&#8216; for update in FROM clause </span></div>
</div>
<p>This construct is invalid in mySQL<br />
According to the manual, </p>
<blockquote><p>
You can use a subquery for assignment within an UPDATE statement because subqueries are legal in UPDATE and DELETE statements as well as in SELECT statements. However, you cannot use the same table (in this case, table t1) for both the subquery&#8217;s FROM clause and the update target.
</p></blockquote>
<p>The equivalent multi-table update does the same and works as intended:</p>
<div class="codesnip-container" >
<div class="codesnip"><span class="kw1">UPDATE</span> flight f <span class="kw1">LEFT</span> <span class="kw1">JOIN</span> airport a <span class="kw1">ON</span> a.id=f.origin <span class="kw1">SET</span> f.intl=<span class="nu0">1</span> <span class="kw1">WHERE</span> a.country&lt;&gt;<span class="st0">&#8216;mx&#8217;</span>;</div>
</div>
]]></content:encoded>
			<wfw:commentRss>http://javier.rodriguez.org.mx/index.php/2008/08/26/update-where-id-in-select-and-mysql-error-1093/feed</wfw:commentRss>
		<slash:comments>2</slash:comments>
		</item>
		<item>
		<title>Bourne Shell Server Pages</title>
		<link>http://javier.rodriguez.org.mx/index.php/2007/11/22/bourne-shell-server-pages</link>
		<comments>http://javier.rodriguez.org.mx/index.php/2007/11/22/bourne-shell-server-pages#comments</comments>
		<pubDate>Fri, 23 Nov 2007 05:07:23 +0000</pubDate>
		<dc:creator>javier</dc:creator>
				<category><![CDATA[Code]]></category>
		<category><![CDATA[Hack!]]></category>
		<category><![CDATA[Tech]]></category>
		<category><![CDATA[sh]]></category>
		<category><![CDATA[asp]]></category>
		<category><![CDATA[bourneShell]]></category>
		<category><![CDATA[jsp]]></category>

		<guid isPermaLink="false">http://javier.rodriguez.org.mx/index.php/2007/11/22/bourne-shell-server-pages/</guid>
		<description><![CDATA[Easy. Portable. Buzzword-compliant. Ingenuous. Elegant. Right-out wicked cool: Bourne Shell Server Pages. As I write this I&#8217;m looking for a excuse to use this revolutionary technology in my next project!
Behold the simplicity of ASP and the power of sh:

&#60;html&#62;
&#160; &#60;body&#62;
&#160; &#160; &#60;h1&#62;&#60;$ echo &#8220;Hello, world!&#8221; $&#62;&#60;/h1&#62;
&#160; &#60;/body&#62;
&#60;/html&#62;

Interface21: please take note. I expect a Spring.sh implementation [...]]]></description>
			<content:encoded><![CDATA[<p>Easy. Portable. Buzzword-compliant. Ingenuous. Elegant. Right-out wicked cool: <a href="http://hyperrealm.com/wtfd00d/shsp/">Bourne Shell Server Pages</a>. As I write this I&#8217;m looking for a excuse to use this revolutionary technology in my next project!<br />
Behold the simplicity of ASP and the power of sh:</p>
<div class="codesnip-container" >
<div class="codesnip"><span class="sc2"><a href="http://december.com/html/4/element/html.html"><span class="kw2">&lt;html&gt;</span></a></span><br />
&nbsp; <span class="sc2"><a href="http://december.com/html/4/element/body.html"><span class="kw2">&lt;body&gt;</span></a></span><br />
&nbsp; &nbsp; <span class="sc2"><a href="http://december.com/html/4/element/h1.html"><span class="kw2">&lt;h1&gt;</span></a></span><span class="sc2"><span class="kw2">&lt;</span></a>$ echo <span class="st0">&#8220;Hello, world!&#8221;</span> $&gt;</span><span class="sc2"><span class="kw2">&lt;/h1&gt;</span></span><br />
&nbsp; <span class="sc2"><span class="kw2">&lt;/body&gt;</span></span><br />
<span class="sc2"><span class="kw2">&lt;/html&gt;</span></span></div>
</div>
<p>Interface21: please take note. I expect a <a href="http://www.springframework.net/">Spring.sh implementation</a> before the year ends. ;-)<br /><div class="simpletags">Tags: <a href="http://technorati.com/tag/bourneShell" rel="tag">bourneShell</a>, <a href="http://technorati.com/tag/asp" rel="tag"> asp</a>, <a href="http://technorati.com/tag/jsp" rel="tag"> jsp</a></div>
]]></content:encoded>
			<wfw:commentRss>http://javier.rodriguez.org.mx/index.php/2007/11/22/bourne-shell-server-pages/feed</wfw:commentRss>
		<slash:comments>1</slash:comments>
		</item>
		<item>
		<title>Whitespace Matters</title>
		<link>http://javier.rodriguez.org.mx/index.php/2007/08/31/whitespace-matters</link>
		<comments>http://javier.rodriguez.org.mx/index.php/2007/08/31/whitespace-matters#comments</comments>
		<pubDate>Fri, 31 Aug 2007 15:19:13 +0000</pubDate>
		<dc:creator>javier</dc:creator>
				<category><![CDATA[Code]]></category>
		<category><![CDATA[General]]></category>
		<category><![CDATA[Perl]]></category>
		<category><![CDATA[Python]]></category>
		<category><![CDATA[Tech]]></category>

		<guid isPermaLink="false">http://javier.rodriguez.org.mx/index.php/2007/08/31/whitespace-matters/</guid>
		<description><![CDATA[Mark Jason Dominus just released SuperPython 0.91, &#8220;a Perl source filter for the SuperPython language, allowing SuperPython code to be embedded into Perl programs&#8221;.
In terms of language, it goes way beyond python itself to give proper semantics to whitespace. For instance, here is the Hello World program written in SuperPython:
#!/usr/bin/perl
use SuperPython;
Ain&#8217;t it neat? Naturally, the [...]]]></description>
			<content:encoded><![CDATA[<p><a href="http://perl.plover.com/">Mark Jason Dominus</a> just released <a href="http://search.cpan.org/~mjd/SuperPython-0.91/SuperPython.pm">SuperPython 0.91</a>, &#8220;a Perl source filter for the SuperPython language, allowing SuperPython code to be embedded into Perl programs&#8221;.<br />
In terms of language, it goes way beyond python itself to give proper semantics to whitespace. For instance, here is the Hello World program written in SuperPython:</p>
<div class="codesnip-container" >#!/usr/bin/perl<br />
use SuperPython;</div>
<p>Ain&#8217;t it neat? Naturally, the result is</p>
<div class="codesnip-container" >$ ./hello.spy<br />
Hello, world.</div>
<p>just as would be expected.<br />
If you want to try this program yourself you might be surprised to find out that copy+paste won&#8217;t work, but that&#8217;s a small price to pay in exchange or the benefits of the richness of syntax and expresiveness of the language, and anyway you may download <a href="http://javier.rodriguez.org.mx/code/hello.spy">the source code for hello.spy</a> right here.<br />
Mark is very optimist in contributing the new features of SuperPython back to python itself, and has kindly offered to work closely with the Python community to see this happen.<br />
Congrats Mark, and keep up the good work!</p>
<div class="simpletags">Tags: <a href="http://technorati.com/tag/code" rel="tag">code</a>, <a href="http://technorati.com/tag/perl" rel="tag"> perl</a>, <a href="http://technorati.com/tag/python" rel="tag"> python</a>, <a href="http://technorati.com/tag/computer+languages" rel="tag"> computer languages</a></div>
]]></content:encoded>
			<wfw:commentRss>http://javier.rodriguez.org.mx/index.php/2007/08/31/whitespace-matters/feed</wfw:commentRss>
		<slash:comments>3</slash:comments>
		</item>
		<item>
		<title>Moving from MyISAM to InnoDB: bulk table conversion</title>
		<link>http://javier.rodriguez.org.mx/index.php/2007/05/01/moving-from-myisam-to-innodb-bulk-table-conversion</link>
		<comments>http://javier.rodriguez.org.mx/index.php/2007/05/01/moving-from-myisam-to-innodb-bulk-table-conversion#comments</comments>
		<pubDate>Tue, 01 May 2007 09:08:54 +0000</pubDate>
		<dc:creator>javier</dc:creator>
				<category><![CDATA[Code]]></category>
		<category><![CDATA[General]]></category>
		<category><![CDATA[SysAdmin]]></category>
		<category><![CDATA[sh]]></category>

		<guid isPermaLink="false">http://javier.rodriguez.org.mx/index.php/2007/05/01/moving-from-myisam-to-innodb-bulk-table-conversion/</guid>
		<description><![CDATA[A couple of years ago Ludovico Magnocavallo tackled the issue of bulk conversion of MySQL tables from MyISAM to InnoDB with an elegant bash snippet.
for t in $(mysql &#8211;batch &#8211;column-names=false -e &#8220;show tables&#8221; mydbname); do
  mysql -e &#8220;alter table $t type=InnoDB&#8221; mydbname;
done
The original post also suggests using grep to limit the scope of the [...]]]></description>
			<content:encoded><![CDATA[<p>A couple of years ago Ludovico Magnocavallo tackled the issue of bulk conversion of MySQL tables from MyISAM to InnoDB with an elegant bash snippet.</p>
<div class="codesnip-container" >for t in $(mysql &#8211;batch &#8211;column-names=false -e &#8220;show tables&#8221; mydbname); do<br />
  mysql -e &#8220;alter table $t type=InnoDB&#8221; mydbname;<br />
done</div>
<p>The <a href="http://ludo.qix.it/archive/2005/04/convert-a-bunch-of-tables-to-innodb.html">original post</a> also suggests using grep to limit the scope of the conversion to just a few tables.<br />
(It seems that now Google *does* yield practical answers to this question ;-)<br /><div class="simpletags">Tags: <a href="http://technorati.com/tag/bash" rel="tag">bash</a>, <a href="http://technorati.com/tag/mysql" rel="tag">mysql</a>, <a href="http://technorati.com/tag/innodb" rel="tag">innodb</a></div>
]]></content:encoded>
			<wfw:commentRss>http://javier.rodriguez.org.mx/index.php/2007/05/01/moving-from-myisam-to-innodb-bulk-table-conversion/feed</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>md5pass</title>
		<link>http://javier.rodriguez.org.mx/index.php/2006/07/02/md5pass</link>
		<comments>http://javier.rodriguez.org.mx/index.php/2006/07/02/md5pass#comments</comments>
		<pubDate>Sun, 02 Jul 2006 14:35:53 +0000</pubDate>
		<dc:creator>javier</dc:creator>
				<category><![CDATA[Code]]></category>
		<category><![CDATA[General]]></category>
		<category><![CDATA[Perl]]></category>

		<guid isPermaLink="false">http://javier.rodriguez.org.mx/?p=62</guid>
		<description><![CDATA[This snippet is a simple wrapper around Digest::MD5&#8217;s md5_base64() builds unsalted MD5 digests encoded in base64, very useful for LDAP management and LDIF file processing.

#!/usr/bin/perl
++$&#124;;
use Digest::MD5 qw&#40;md5_base64&#41;;
if&#40;!defined&#40;$pass=shift&#41;&#41; &#123;
&#160; &#160; &#160; &#160; print &#8220;&#62; &#8220;;
&#160; &#160; &#160; &#160; $pass=&#60;STDIN&#62;;
&#160; &#160; &#160; &#160; chomp $pass;
&#125;
print encrypted&#40;$pass&#41;.&#8220;\n&#8220;;
sub encrypted &#123;
&#160; &#160; &#160; &#160; my&#40;$passwd&#41; = @_;
&#160; &#160; &#160; &#160; [...]]]></description>
			<content:encoded><![CDATA[<p>This snippet is a simple wrapper around <a href="http://search.cpan.org/dist/Digest-MD5/MD5.pm">Digest::MD5</a>&#8217;s md5_base64() builds unsalted MD5 digests encoded in base64, very useful for LDAP management and LDIF file processing.</p>
<div class="codesnip-container" >
<div class="codesnip"><span class="co1">#!/usr/bin/perl</span><br />
++$|;</p>
<p><span class="kw2">use</span> Digest::<span class="me2">MD5</span> <a href="http://www.perldoc.com/perl5.6/pod/func/qw.html"><span class="kw3">qw</span></a><span class="br0">&#40;</span>md5_base64<span class="br0">&#41;</span>;</p>
<p><span class="kw1">if</span><span class="br0">&#40;</span>!<a href="http://www.perldoc.com/perl5.6/pod/func/defined.html"><span class="kw3">defined</span></a><span class="br0">&#40;</span><span class="re0">$pass</span>=<a href="http://www.perldoc.com/perl5.6/pod/func/shift.html"><span class="kw3">shift</span></a><span class="br0">&#41;</span><span class="br0">&#41;</span> <span class="br0">&#123;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; <a href="http://www.perldoc.com/perl5.6/pod/func/print.html"><span class="kw3">print</span></a> <span class="st0">&#8220;&gt; &#8220;</span>;<br />
&nbsp; &nbsp; &nbsp; &nbsp; <span class="re0">$pass</span>=<span class="re4">&lt;STDIN&gt;</span>;<br />
&nbsp; &nbsp; &nbsp; &nbsp; <a href="http://www.perldoc.com/perl5.6/pod/func/chomp.html"><span class="kw3">chomp</span></a> <span class="re0">$pass</span>;<br />
<span class="br0">&#125;</span><br />
<a href="http://www.perldoc.com/perl5.6/pod/func/print.html"><span class="kw3">print</span></a> encrypted<span class="br0">&#40;</span><span class="re0">$pass</span><span class="br0">&#41;</span>.<span class="st0">&#8220;<span class="es0">\n</span>&#8220;</span>;</p>
<p><span class="kw2">sub</span> encrypted <span class="br0">&#123;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; <span class="kw1">my</span><span class="br0">&#40;</span><span class="re0">$passwd</span><span class="br0">&#41;</span> = <span class="re0">@_</span>;<br />
&nbsp; &nbsp; &nbsp; &nbsp; <a href="http://www.perldoc.com/perl5.6/pod/func/return.html"><span class="kw3">return</span></a> <span class="st0">&#8216;{md5}&#8217;</span>.md5_base64<span class="br0">&#40;</span><span class="re0">$passwd</span><span class="br0">&#41;</span>.<span class="st0">&#8216;==&#8217;</span>;<br />
<span class="br0">&#125;</span></div>
</div>
<p>(<a href="/code/md5pass.txt">Source code</a>)</p>
<p>Use it as such:</p>
<pre>$ bin/md5pass
> <b>password</b>
{md5}X03MO1qnZdYdgyfeuILPmQ==
</pre>
<div class="simpletags">Tags: <a href="http://technorati.com/tag/Perl" rel="tag">Perl</a>, <a href="http://technorati.com/tag/MD5" rel="tag"> MD5</a>, <a href="http://technorati.com/tag/code" rel="tag"> code</a>, <a href="http://technorati.com/tag/code+snippet" rel="tag"> code snippet</a></div>
]]></content:encoded>
			<wfw:commentRss>http://javier.rodriguez.org.mx/index.php/2006/07/02/md5pass/feed</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Some lovely ASCII Art</title>
		<link>http://javier.rodriguez.org.mx/index.php/2006/06/28/some-lovely-ascii-art</link>
		<comments>http://javier.rodriguez.org.mx/index.php/2006/06/28/some-lovely-ascii-art#comments</comments>
		<pubDate>Wed, 28 Jun 2006 10:54:12 +0000</pubDate>
		<dc:creator>javier</dc:creator>
				<category><![CDATA[Code]]></category>
		<category><![CDATA[General]]></category>
		<category><![CDATA[Hack!]]></category>
		<category><![CDATA[Perl]]></category>

		<guid isPermaLink="false">http://javier.rodriguez.org.mx/?p=60</guid>
		<description><![CDATA[Andrew Savige&#8217;s Bottles of Beer have been found by the Python pundits (and by some gutless Perl defectors ;-) ) and are being waved as a textbook executable-line-noise example. There&#8217;s people that can&#8217;t  stand beauty when they see it.

(That code is now an image -see below- but you can always get the original source [...]]]></description>
			<content:encoded><![CDATA[<p><a href="http://www.99-bottles-of-beer.net/language-perl-737.html">Andrew Savige&#8217;s Bottles of Beer</a> have been found by the Python pundits (and by <a href="http://blog.delaguardia.com.mx/">some gutless Perl defectors</a> ;-) ) and are being waved as a textbook executable-line-noise example. There&#8217;s people that can&#8217;t  stand beauty when they see it.<br />
<a href="http://javier.rodriguez.org.mx/code/bottle.txt"><img src="http://javier.rodriguez.org.mx/wp-content/uploads/2006/09/bottle.png" alt="Bottles of Beer"/></a><br />
(That code is now an image -see below- but you can always get the <a href="/code/bottle.txt">original source code</a>).<br />
Yup, it is a Perl program. Yes, it *does* run, with <a href="/code/bottle-run.txt">interesting results</a>. There&#8217;s even a CPAN module &#8212; <a href="http://search.cpan.org/dist/Acme-EyeDrops/lib/Acme/EyeDrops.pm">Acme::EyeDrops</a> &#8212; that turns your own Perl programs into purposely unmaintainable yet beautiful works of art that can make the entire Python Party cringe in disgust. You have to admit that there&#8217;s certain merit in making  grown men cry. Automatically, no less. <a href="http://search.cpan.org/dist/Acme-EyeDrops/lib/Acme/EyeDrops.pm#99_Bottles_of_Beer">Go and read how it&#8217;s done</a>.<br />
So the Obfuscated Python Contest is incredibly boring. I couldn&#8217;t care less.<br />
Via <a href="http://blog.delaguardia.com.mx/index.php?op=ViewArticle&#038;articleId=49&#038;blogId=1">Carlos de la Guardia</a>/<a href="http://marc.abramowitz.info/archives/2006/06/15/perl-is-evil/">Marc Abramowitz</a>/<a href="http://blog.amber.org/2006/06/16/why-perl-is-simply-absurdist-theatre/">Chris Petrilli<a>.<br />
<b>Update 20060916:</b> Replaced the code with a graphical version because WordPress 2.0 doesn&#8217;t play well with the text hightlight plugin.<br /><div class="simpletags">Tags: <a href="http://technorati.com/tag/Perl" rel="tag">Perl</a>, <a href="http://technorati.com/tag/Python" rel="tag"> Python</a>, <a href="http://technorati.com/tag/Obfuscation" rel="tag"> Obfuscation</a>, <a href="http://technorati.com/tag/ASCII+art" rel="tag"> ASCII art</a></div>
]]></content:encoded>
			<wfw:commentRss>http://javier.rodriguez.org.mx/index.php/2006/06/28/some-lovely-ascii-art/feed</wfw:commentRss>
		<slash:comments>3</slash:comments>
		</item>
		<item>
		<title>Demo for Luhn algorithm in PHP</title>
		<link>http://javier.rodriguez.org.mx/index.php/2006/02/24/demo-for-luhn-algorithm-in-php</link>
		<comments>http://javier.rodriguez.org.mx/index.php/2006/02/24/demo-for-luhn-algorithm-in-php#comments</comments>
		<pubDate>Fri, 24 Feb 2006 18:30:26 +0000</pubDate>
		<dc:creator>javier</dc:creator>
				<category><![CDATA[Code]]></category>
		<category><![CDATA[General]]></category>
		<category><![CDATA[PHP]]></category>

		<guid isPermaLink="false">http://javier.rodriguez.org.mx/?p=53</guid>
		<description><![CDATA[If you have a number that adheres to the Luhn algorithm for validation, you may check it easily with this short PHP snippet.

&#60;?php
function luhn&#40;$str&#41; &#123;
&#160; &#160; &#160; &#160; $odd = !strlen&#40;$str&#41;%2;
&#160; &#160; &#160; &#160; $sum = 0;
&#160; &#160; &#160; &#160; for&#40;$i=0;$i&#60;strlen&#40;$str&#41;;++$i&#41; &#123;
&#160; &#160; &#160; &#160; &#160; &#160; $n=0+$str&#91;$i&#93;;
&#160; &#160; &#160; &#160; &#160; &#160; $odd=!$odd;
&#160; &#160; [...]]]></description>
			<content:encoded><![CDATA[<p>If you have a number that adheres to the Luhn algorithm for validation, you may check it easily with this short PHP snippet.</p>
<div class="codesnip-container" >
<div class="codesnip"><span class="kw2">&lt;?php</span><br />
<span class="kw2">function</span> luhn<span class="br0">&#40;</span><span class="re0">$str</span><span class="br0">&#41;</span> <span class="br0">&#123;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; <span class="re0">$odd</span> = !<a href="http://www.php.net/strlen"><span class="kw3">strlen</span></a><span class="br0">&#40;</span><span class="re0">$str</span><span class="br0">&#41;</span>%<span class="nu0">2</span>;<br />
&nbsp; &nbsp; &nbsp; &nbsp; <span class="re0">$sum</span> = <span class="nu0">0</span>;<br />
&nbsp; &nbsp; &nbsp; &nbsp; <span class="kw1">for</span><span class="br0">&#40;</span><span class="re0">$i</span>=<span class="nu0">0</span>;<span class="re0">$i</span>&lt;strlen<span class="br0">&#40;</span><span class="re0">$str</span><span class="br0">&#41;</span>;++<span class="re0">$i</span><span class="br0">&#41;</span> <span class="br0">&#123;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span class="re0">$n</span>=<span class="nu0">0</span>+<span class="re0">$str</span><span class="br0">&#91;</span><span class="re0">$i</span><span class="br0">&#93;</span>;<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span class="re0">$odd</span>=!<span class="re0">$odd</span>;<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span class="kw1">if</span><span class="br0">&#40;</span><span class="re0">$odd</span><span class="br0">&#41;</span> <span class="br0">&#123;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span class="re0">$sum</span>+=<span class="re0">$n</span>;<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span class="br0">&#125;</span> <span class="kw1">else</span> <span class="br0">&#123;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span class="re0">$x</span>=<span class="nu0">2</span>*<span class="re0">$n</span>;<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span class="re0">$sum</span>+=<span class="re0">$x</span>&gt;<span class="nu0">9</span>?<span class="re0">$x</span>-<span class="nu0">9</span>:<span class="re0">$x</span>;<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span class="br0">&#125;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; <span class="br0">&#125;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; <span class="kw1">return</span><span class="br0">&#40;</span><span class="br0">&#40;</span><span class="re0">$sum</span>%<span class="nu0">10</span><span class="br0">&#41;</span>==<span class="nu0">0</span><span class="br0">&#41;</span>;<br />
<span class="br0">&#125;</span><br />
<span class="re0">$num</span> = <span class="re0">$_GET</span><span class="br0">&#91;</span><span class="st0">&#8216;number&#8217;</span><span class="br0">&#93;</span>;<br />
<span class="kw2">?&gt;</span><br />
&lt;!DOCTYPE HTML PUBLIC <span class="st0">&#8220;-//W3C//DTD HTML 4.01//EN&#8221;</span> <span class="st0">&#8220;http://www.w3.org/TR/html4/strict.dtd&#8221;</span>&gt;<br />
&lt;html&gt;<br />
&lt;head&gt;<br />
&lt;title&gt;Online Luhn algorithm test&lt;/title&gt;<br />
&lt;meta http-equiv=<span class="st0">&#8220;Content-Type&#8221;</span> content=<span class="st0">&#8220;text/html; charset=ISO-8859-1&#8243;</span>&gt;<br />
&lt;/head&gt;<br />
&lt;body&gt;<br />
<span class="kw2">&lt;?php</span> <span class="kw1">if</span><span class="br0">&#40;</span><span class="re0">$num</span><span class="br0">&#41;</span> <span class="br0">&#123;</span> <span class="kw2">?&gt;</span><br />
<span class="kw2">&lt;?php</span>&nbsp; &nbsp;<span class="kw1">if</span><span class="br0">&#40;</span>luhn<span class="br0">&#40;</span><span class="re0">$num</span><span class="br0">&#41;</span><span class="br0">&#41;</span> <span class="br0">&#123;</span> <span class="kw2">?&gt;</span><br />
&lt;div style=<span class="st0">&#8220;background:#ddffdd;border:1px solid #004400;&#8221;</span>&gt;<br />
<span class="kw2">&lt;?</span>=<a href="http://www.php.net/htmlspecialchars"><span class="kw3">htmlspecialchars</span></a><span class="br0">&#40;</span><span class="re0">$num</span><span class="br0">&#41;</span><span class="kw2">?&gt;</span> is valid<br />
&lt;/div&gt;<br />
<span class="kw2">&lt;?php</span>&nbsp; &nbsp;<span class="br0">&#125;</span> <span class="kw1">else</span> <span class="br0">&#123;</span> <span class="kw2">?&gt;</span><br />
&lt;div style=<span class="st0">&#8220;background:#ffdddd;border:1px solid #880000;&#8221;</span>&gt;<br />
<span class="kw2">&lt;?</span>=<a href="http://www.php.net/htmlspecialchars"><span class="kw3">htmlspecialchars</span></a><span class="br0">&#40;</span><span class="re0">$num</span><span class="br0">&#41;</span><span class="kw2">?&gt;</span> is NOT valid<br />
&lt;/div&gt;<br />
<span class="kw2">&lt;?php</span>&nbsp; &nbsp;<span class="br0">&#125;</span> <span class="kw2">?&gt;</span><br />
<span class="kw2">&lt;?php</span> <span class="br0">&#125;</span> <span class="kw2">?&gt;</span><br />
&lt;form action=<span class="st0">&#8220;luhn.php&#8221;</span> method=<span class="st0">&#8220;GET&#8221;</span>&gt;<br />
&lt;div&gt;<br />
Number: &lt;input type=<span class="st0">&#8220;text&#8221;</span> name=<span class="st0">&#8220;number&#8221;</span> value=<span class="st0">&#8220;&lt;?=urlencode($num)?&gt;&#8221;</span> size=<span class="st0">&#8220;40&#8243;</span>/&gt;<br />
&lt;input type=<span class="st0">&#8220;button&#8221;</span> name=<span class="st0">&#8220;btSend&#8221;</span> value=<span class="st0">&#8220;Check&#8221;</span>/&gt;<br />
&lt;/div&gt;<br />
&lt;/form&gt;<br />
&lt;/body&gt;</div>
</div>
<p>(<a href="/code/luhn-test-php.txt">Download</a>)<br />
You may test this script at <a href="http://javier.rodriguez.org.mx/code/luhn-test.php">http://javier.rodriguez.org.mx/code/luhn-test.php</a>.<br />
Please consider that this is a demo, so please do not use this to check credit card numbers <a href="#" title="Yes, this is a joke. Laugh.">unless you send me an expiry date</a>. <a href="http://en.wikipedia.org/wiki/CVV2">CCV2</a> has taken over as the preferred method for credit card number validation anyway.</p>
]]></content:encoded>
			<wfw:commentRss>http://javier.rodriguez.org.mx/index.php/2006/02/24/demo-for-luhn-algorithm-in-php/feed</wfw:commentRss>
		<slash:comments>7</slash:comments>
		</item>
		<item>
		<title>Find out LDAP client IPs</title>
		<link>http://javier.rodriguez.org.mx/index.php/2006/01/23/find-out-ldap-client-ips</link>
		<comments>http://javier.rodriguez.org.mx/index.php/2006/01/23/find-out-ldap-client-ips#comments</comments>
		<pubDate>Tue, 24 Jan 2006 02:11:47 +0000</pubDate>
		<dc:creator>javier</dc:creator>
				<category><![CDATA[Code]]></category>
		<category><![CDATA[General]]></category>
		<category><![CDATA[Perl]]></category>
		<category><![CDATA[SysAdmin]]></category>

		<guid isPermaLink="false">http://javier.rodriguez.org.mx/?p=50</guid>
		<description><![CDATA[ips.pl is a simple perl filter that processes SunONE Directory Server 5.2 access logs to find out the IP addresses that queries are coming from. It&#8217;s very useful to evaluate the impact for migrating LDAP infrastructures. Most comments and variable names are in spanish but the code should be clear enough to any SODS sysadmin. [...]]]></description>
			<content:encoded><![CDATA[<p>ips.pl is a simple perl filter that processes SunONE Directory Server 5.2 access logs to find out the IP addresses that queries are coming from. It&#8217;s very useful to evaluate the impact for migrating LDAP infrastructures. Most comments and variable names are in spanish but the code should be clear enough to any SODS sysadmin. Or drop me a line if you absolutely need an all-english version.</p>
<div class="codesnip-container" >
<div class="codesnip"><span class="co1">#!/usr/bin/perl</span><br />
<span class="co1"># ips.pl $Revision: 1.1 $</span><br />
<span class="co1"># Analiza archivos access de Sun ONE Directory Server 5.2 para generar</span><br />
<span class="co1"># reporte de IPs de clientes y servidores</span><br />
<span class="co1"># Copyright (C) 2005 Javier Arturo Rodriguez</span><br />
<span class="kw2">use</span> strict;<br />
<span class="kw1">my</span><span class="br0">&#40;</span><span class="re0">$acceso</span><span class="br0">&#41;</span>;<br />
<span class="kw1">my</span> <span class="re0">$filename</span> = <a href="http://www.perldoc.com/perl5.6/pod/func/shift.html"><span class="kw3">shift</span></a> <span class="re0">@ARGV</span>;<br />
<a href="http://www.perldoc.com/perl5.6/pod/func/die.html"><span class="kw3">die</span></a><span class="br0">&#40;</span><span class="st0">&#8220;Usage:<span class="es0">\t</span>$0 &lt;filename&gt;<span class="es0">\n</span><span class="es0">\t</span>bunzip2 -c &lt;filename.bz2&gt; | $0 -<span class="es0">\n</span>&#8220;</span><span class="br0">&#41;</span> <span class="kw1">unless</span> <span class="re0">$file</span><br />
name;<br />
<a href="http://www.perldoc.com/perl5.6/pod/func/open.html"><span class="kw3">open</span></a><span class="br0">&#40;</span>FILE,<span class="st0">&#8220;&lt;$filename&#8221;</span><span class="br0">&#41;</span>;<br />
<span class="kw1">while</span><span class="br0">&#40;</span><span class="re4">&lt;FILE&gt;</span><span class="br0">&#41;</span> <span class="br0">&#123;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; <a href="http://www.perldoc.com/perl5.6/pod/func/chomp.html"><span class="kw3">chomp</span></a>;<br />
&nbsp; &nbsp; &nbsp; &nbsp; <span class="kw1">if</span><span class="br0">&#40;</span><span class="re0">$_</span>=~<a href="http://www.perldoc.com/perl5.6/pod/func/m.html"><span class="kw3">m</span></a>,^\<span class="br0">&#91;</span><span class="br0">&#40;</span>.*?<span class="br0">&#41;</span>\<span class="br0">&#93;</span>.*?connection from <span class="br0">&#40;</span><span class="br0">&#91;</span>\d\.<span class="br0">&#93;</span>+<span class="br0">&#41;</span> to <span class="br0">&#40;</span><span class="br0">&#91;</span>\d\.<span class="br0">&#93;</span>+<span class="br0">&#41;</span>,<span class="br0">&#41;</span> <span class="br0">&#123;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span class="re0">$acceso</span>-&gt;<span class="br0">&#123;</span>$<span class="nu0">3</span><span class="br0">&#125;</span>-&gt;<span class="br0">&#123;</span>$<span class="nu0">2</span><span class="br0">&#125;</span>-&gt;<span class="br0">&#123;</span>TS<span class="br0">&#125;</span>=$<span class="nu0">1</span>;<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; ++<span class="re0">$acceso</span>-&gt;<span class="br0">&#123;</span>$<span class="nu0">3</span><span class="br0">&#125;</span>-&gt;<span class="br0">&#123;</span>$<span class="nu0">2</span><span class="br0">&#125;</span>-&gt;<span class="br0">&#123;</span>CNT<span class="br0">&#125;</span>;<br />
&nbsp; &nbsp; &nbsp; &nbsp; <span class="br0">&#125;</span><br />
<span class="br0">&#125;</span><br />
<a href="http://www.perldoc.com/perl5.6/pod/func/close.html"><span class="kw3">close</span></a><span class="br0">&#40;</span>FILE<span class="br0">&#41;</span>;<br />
<span class="kw1">foreach</span> <span class="kw1">my</span> <span class="re0">$dst</span> <span class="br0">&#40;</span><a href="http://www.perldoc.com/perl5.6/pod/func/sort.html"><span class="kw3">sort</span></a> <a href="http://www.perldoc.com/perl5.6/pod/func/keys.html"><span class="kw3">keys</span></a> %<span class="br0">&#123;</span><span class="re0">$acceso</span>||<span class="br0">&#123;</span><span class="br0">&#125;</span><span class="br0">&#125;</span><span class="br0">&#41;</span> <span class="br0">&#123;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; <a href="http://www.perldoc.com/perl5.6/pod/func/print.html"><span class="kw3">print</span></a> <span class="st0">&#8220;Acceden a traves de $dst<span class="es0">\n</span>&#8220;</span>;<br />
&nbsp; &nbsp; &nbsp; &nbsp; <span class="kw1">foreach</span> <span class="kw1">my</span> <span class="re0">$src</span> <span class="br0">&#40;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <a href="http://www.perldoc.com/perl5.6/pod/func/reverse.html"><span class="kw3">reverse</span></a> <a href="http://www.perldoc.com/perl5.6/pod/func/sort.html"><span class="kw3">sort</span></a> <span class="br0">&#123;</span> <span class="re0">$acceso</span>-&gt;<span class="br0">&#123;</span><span class="re0">$dst</span><span class="br0">&#125;</span>-&gt;<span class="br0">&#123;</span><span class="re0">$a</span><span class="br0">&#125;</span>-&gt;<span class="br0">&#123;</span>CNT<span class="br0">&#125;</span> &lt;=&gt; <span class="re0">$acceso</span>-&gt;<span class="br0">&#123;</span><span class="re0">$dst</span><span class="br0">&#125;</span><br />
-&gt;<span class="br0">&#123;</span><span class="re0">$b</span><span class="br0">&#125;</span>-&gt;<span class="br0">&#123;</span>CNT<span class="br0">&#125;</span> <span class="br0">&#125;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <a href="http://www.perldoc.com/perl5.6/pod/func/keys.html"><span class="kw3">keys</span></a> %<span class="br0">&#123;</span><span class="re0">$acceso</span>-&gt;<span class="br0">&#123;</span><span class="re0">$dst</span><span class="br0">&#125;</span>||<span class="br0">&#123;</span><span class="br0">&#125;</span><span class="br0">&#125;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; <span class="br0">&#41;</span> <span class="br0">&#123;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <a href="http://www.perldoc.com/perl5.6/pod/func/printf.html"><span class="kw3">printf</span></a><span class="br0">&#40;</span><span class="st0">&#8220;&nbsp; %-15s (last seen on %s; %d hit%s)<span class="es0">\n</span>&#8220;</span>,<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span class="re0">$src</span>,<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span class="re0">$acceso</span>-&gt;<span class="br0">&#123;</span><span class="re0">$dst</span><span class="br0">&#125;</span>-&gt;<span class="br0">&#123;</span><span class="re0">$src</span><span class="br0">&#125;</span>-&gt;<span class="br0">&#123;</span>TS<span class="br0">&#125;</span>,<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span class="re0">$acceso</span>-&gt;<span class="br0">&#123;</span><span class="re0">$dst</span><span class="br0">&#125;</span>-&gt;<span class="br0">&#123;</span><span class="re0">$src</span><span class="br0">&#125;</span>-&gt;<span class="br0">&#123;</span>CNT<span class="br0">&#125;</span>,<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span class="re0">$acceso</span>-&gt;<span class="br0">&#123;</span><span class="re0">$dst</span><span class="br0">&#125;</span>-&gt;<span class="br0">&#123;</span><span class="re0">$src</span><span class="br0">&#125;</span>-&gt;<span class="br0">&#123;</span>CNT<span class="br0">&#125;</span>==<span class="nu0">1</span>?<span class="st0">&#8221;</span>:<span class="st0">&#8217;s&#8217;</span>,<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span class="br0">&#41;</span>;<br />
&nbsp; &nbsp; &nbsp; &nbsp; <span class="br0">&#125;</span><br />
<span class="br0">&#125;</span></div>
</div>
<p>(<a href="/code/ips.txt">Download</a>)</p>
]]></content:encoded>
			<wfw:commentRss>http://javier.rodriguez.org.mx/index.php/2006/01/23/find-out-ldap-client-ips/feed</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
	</channel>
</rss>
