<?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>The Random Thoughts of a Programmer</title>
	<atom:link href="http://mike.crute.org/blog/feed/" rel="self" type="application/rss+xml" />
	<link>http://mike.crute.org/blog</link>
	<description>import random; return random.shuffle(mike_crute.thoughts)</description>
	<lastBuildDate>Wed, 09 Sep 2009 13:28:46 +0000</lastBuildDate>
	<generator>http://wordpress.org/?v=2.8.4</generator>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
			<item>
		<title>Java Woes on Snow Leopard (10.6)</title>
		<link>http://mike.crute.org/blog/2009/09/09/java-woes-on-snow-leopard-10-6/</link>
		<comments>http://mike.crute.org/blog/2009/09/09/java-woes-on-snow-leopard-10-6/#comments</comments>
		<pubDate>Wed, 09 Sep 2009 13:19:55 +0000</pubDate>
		<dc:creator>Mike</dc:creator>
				<category><![CDATA[randomness]]></category>
		<category><![CDATA[apple]]></category>
		<category><![CDATA[hacks]]></category>
		<category><![CDATA[java]]></category>
		<category><![CDATA[mac10.6]]></category>
		<category><![CDATA[macosx]]></category>
		<category><![CDATA[snow leopard]]></category>
		<category><![CDATA[software]]></category>
		<category><![CDATA[suck]]></category>

		<guid isPermaLink="false">http://mike.crute.org/blog/?p=226</guid>
		<description><![CDATA[Correction: I just discovered that this is not a J2SE 6.0 issue but rather a 64-bit issue. The 64-bit version of the J2SE doesn&#8217;t play nice with Aventail Connection. Simple updating your preferences to put J2SE 6.0 (32-bit) ahead of the 64-bit version works and you don&#8217;t have to do all of this.
I just installed [...]]]></description>
			<content:encoded><![CDATA[<p><strong>Correction:</strong> <em>I just discovered that this is not a J2SE 6.0 issue but rather a 64-bit issue. The 64-bit version of the J2SE doesn&#8217;t play nice with Aventail Connection. Simple updating your preferences to put J2SE 6.0 (32-bit) ahead of the 64-bit version works and you don&#8217;t have to do all of this.</em></p>
<p>I just installed Mac OS 10.6, Snow Leopard, on Friday before I went on vacation and was disappointed to find that the upgraded version of java that it had installed broke my Aventail Connect VPN client. Neither the web interface nor the desktop client works under Snow leopard.</p>
<p><span id="more-226"></span></p>
<p>It would appear that you can run different versions of java concurrently but Snow Leopard lies marking java 1.6 as 1.5.0; looking at the confusing mess of java version symlinks it&#8217;s no wonder things don&#8217;t work:</p>
<div id="attachment_230" class="wp-caption alignnone" style="width: 430px"><a href="http://mike.crute.org/blog/wp-content/uploads/2009/09/Screen-shot-2009-09-09-at-8.52.12-AM.png"><img class="size-full wp-image-230" title="Snow Leopard Lies About Java Versions" src="http://mike.crute.org/blog/wp-content/uploads/2009/09/Screen-shot-2009-09-09-at-8.52.12-AM.png" alt="Snow Leopard Lies About Java Versions" width="420" height="151" /></a><p class="wp-caption-text">Snow Leopard Lies About Java Versions</p></div>
<p>It turns out the fix for this is pretty simple, just downgrade java versions. To do that you&#8217;ll need to grab a version from 10.5 Leopard. There&#8217;s a version posted at the <a href="http://www.cs.washington.edu/homes/isdal/snow_leopard_workaround/java.1.5.0-leopard.tar.gz" target="_blank" onclick="pageTracker._trackPageview('/outgoing/www.cs.washington.edu/homes/isdal/snow_leopard_workaround/java.1.5.0-leopard.tar.gz?referer=');">University of Washington</a> and I&#8217;ll mirror a copy when I get a chance. Download this and untar it. Here&#8217;s the complete set of steps:</p>

<div class="wp_syntax"><div class="code"><pre class="bash" style="font-family:monospace;"><span style="color: #7a0874; font-weight: bold;">cd</span> <span style="color: #000000; font-weight: bold;">/</span>tmp<span style="color: #000000; font-weight: bold;">/</span>
<span style="color: #c20cb9; font-weight: bold;">wget</span> http:<span style="color: #000000; font-weight: bold;">//</span>www.cs.washington.edu<span style="color: #000000; font-weight: bold;">/</span>homes<span style="color: #000000; font-weight: bold;">/</span>isdal<span style="color: #000000; font-weight: bold;">/</span>snow_leopard_workaround<span style="color: #000000; font-weight: bold;">/</span>java.1.5.0-leopard.tar.gz
<span style="color: #c20cb9; font-weight: bold;">tar</span> <span style="color: #660033;">-xvzf</span> java.1.5.0-leopard.tar.gz
<span style="color: #c20cb9; font-weight: bold;">su</span>
<span style="color: #c20cb9; font-weight: bold;">mv</span> 1.5.0 <span style="color: #000000; font-weight: bold;">/</span>System<span style="color: #000000; font-weight: bold;">/</span>Library<span style="color: #000000; font-weight: bold;">/</span>Frameworks<span style="color: #000000; font-weight: bold;">/</span>JavaVM.framework<span style="color: #000000; font-weight: bold;">/</span>Versions<span style="color: #000000; font-weight: bold;">/</span>1.5.0-leopard
<span style="color: #7a0874; font-weight: bold;">cd</span> <span style="color: #000000; font-weight: bold;">/</span>System<span style="color: #000000; font-weight: bold;">/</span>Library<span style="color: #000000; font-weight: bold;">/</span>Frameworks<span style="color: #000000; font-weight: bold;">/</span>JavaVM.framework<span style="color: #000000; font-weight: bold;">/</span>Versions<span style="color: #000000; font-weight: bold;">/</span>
<span style="color: #c20cb9; font-weight: bold;">rm</span> 1.5.0
<span style="color: #c20cb9; font-weight: bold;">ln</span> <span style="color: #660033;">-s</span> 1.5.0-leopard 1.5.0</pre></div></div>

<p>Once that&#8217;s done you should now be able to mark that version of java as the preferred version. To do this you need to run the &#8216;Java Preferences.app&#8217; which is located in /Applications/Utilities. The only required changes are to re-arrange the versions of java for both applets and applications. This is what my final configuration looks like:</p>
<div id="attachment_240" class="wp-caption alignnone" style="width: 513px"><a href="http://mike.crute.org/blog/wp-content/uploads/2009/09/Screen-shot-2009-09-09-at-9.12.09-AM.png"><img class="size-full wp-image-240" title="Revised Java Settings" src="http://mike.crute.org/blog/wp-content/uploads/2009/09/Screen-shot-2009-09-09-at-9.12.09-AM.png" alt="Revised Java Settings" width="503" height="337" /></a><p class="wp-caption-text">Revised Java Settings</p></div>
<p>Now that java has been downgraded successfully you should be able to start up Aventail Connect and connect to your VPN just fine. The browser version works again too. This shouldn&#8217;t affect any other java applications on your system but I haven&#8217;t done any testing to verify this. In any case, once Sonicwall updates their client for Aventail you can just move the J2SE 5.0 version to the bottom of the priority list and continue working as usual.</p>
]]></content:encoded>
			<wfw:commentRss>http://mike.crute.org/blog/2009/09/09/java-woes-on-snow-leopard-10-6/feed/</wfw:commentRss>
		<slash:comments>10</slash:comments>
		</item>
		<item>
		<title>Python AST</title>
		<link>http://mike.crute.org/blog/2009/04/21/python-ast/</link>
		<comments>http://mike.crute.org/blog/2009/04/21/python-ast/#comments</comments>
		<pubDate>Wed, 22 Apr 2009 03:58:55 +0000</pubDate>
		<dc:creator>Mike</dc:creator>
				<category><![CDATA[talks]]></category>

		<guid isPermaLink="false">http://mike.crute.org/blog/?p=218</guid>
		<description><![CDATA[This talk was given to the Cleveland Python Users Group in March 2009.
The talk covers the Abstract Syntax features in Python from their introduction in 2.3 all the way through the current state of AST in 2.6 and 3.0. This is a high-level overview with a couple of interesting use cases for the AST module. [...]]]></description>
			<content:encoded><![CDATA[<p>This talk was given to the Cleveland Python Users Group in March 2009.</p>
<p>The talk covers the Abstract Syntax features in Python from their introduction in 2.3 all the way through the current state of AST in 2.6 and 3.0. This is a high-level overview with a couple of interesting use cases for the AST module. The talk covers the module itself and the underlying techniques that are used to generate the AST tree including a short tour of the Python parser.</p>
<p><a href="http://mike.crute.org/blog/wp-content/uploads/2009/04/clepy-python-ast.pdf">Presentation Slides</a></p>
]]></content:encoded>
			<wfw:commentRss>http://mike.crute.org/blog/2009/04/21/python-ast/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Pointy-Haired Bosses and Pragmatic Programmers</title>
		<link>http://mike.crute.org/blog/2009/01/08/pointy-haired-bosses-and-pragmatic-programmers/</link>
		<comments>http://mike.crute.org/blog/2009/01/08/pointy-haired-bosses-and-pragmatic-programmers/#comments</comments>
		<pubDate>Thu, 08 Jan 2009 14:48:12 +0000</pubDate>
		<dc:creator>Mike</dc:creator>
				<category><![CDATA[randomness]]></category>
		<category><![CDATA[agile]]></category>
		<category><![CDATA[codemash]]></category>
		<category><![CDATA[cool]]></category>
		<category><![CDATA[interesting]]></category>
		<category><![CDATA[programming]]></category>

		<guid isPermaLink="false">http://mike.crute.org/blog/?p=175</guid>
		<description><![CDATA[The keynote at CodeMash this morning was really excellent. Venkat Subramanian
made some excellent points about testability, maintainability and outsourcing.

At one point he drew a correlation between exercise and unit testing. All of us
will admit that exercise is a &#8220;good thing&#8221; to do but when asked to actually
exercise we have any number of excuses why we [...]]]></description>
			<content:encoded><![CDATA[<p>The keynote at CodeMash this morning was really excellent. <a href="http://www.agiledeveloper.com/" onclick="pageTracker._trackPageview('/outgoing/www.agiledeveloper.com/?referer=');">Venkat Subramanian</a><br />
made some excellent points about testability, maintainability and outsourcing.<br />
<span id="more-175"></span></p>
<p>At one point he drew a correlation between exercise and unit testing. All of us<br />
will admit that exercise is a &#8220;good thing&#8221; to do but when asked to actually<br />
exercise we have any number of excuses why we don&#8217;t want to or <i>can&#8217;t</i>.<br />
The same thing happens with unit testing. We&#8217;ll all admit that its a good thing<br />
to do but we never have the time to do it.</p>
<p>One argument we make for why we don&#8217;t write tests is because our code &#8220;isn&#8217;t<br />
testable.&#8221; Well the phrase &#8220;My code isn&#8217;t testable.&#8221; really just means &#8220;My<br />
design sucks.&#8221;</p>
<p>He also talked about outsourcing and why the normal excuses for it just don&#8217;t<br />
work anymore. Outsourcing 1.0 was basically the idea that you should hire<br />
designers in American and lowly programmers in Asia. Think back to the .com boom<br />
when we had the programmers and designers all in the same physical location and<br />
how that worked out for us. Now add oceans in-between them and that should work<br />
better, right? The real strategy you&#8217;re adopting by throwing more, albeit cheap,<br />
people at a project is you fail-for-less.</p>
<p>Outsourcing 2.0 involves more than just simply hiring programmers in Asia, it<br />
involves integrating them into the team. Sending people from America to Asia and<br />
bringing the Asian programmers to America is what&#8217;s needed to integrate the team<br />
and set yourself up for success. At that points it&#8217;s no longer a cost saving<br />
measure, you&#8217;re adding team members for the perspective and talents.</p>
<p>Overall quite excellent. I hope they where taping that and that he posts his<br />
slides. I&#8217;ll update the post if they do.</p>
]]></content:encoded>
			<wfw:commentRss>http://mike.crute.org/blog/2009/01/08/pointy-haired-bosses-and-pragmatic-programmers/feed/</wfw:commentRss>
		<slash:comments>1</slash:comments>
		</item>
		<item>
		<title>Impressions of .NET</title>
		<link>http://mike.crute.org/blog/2009/01/07/impressions-of-net/</link>
		<comments>http://mike.crute.org/blog/2009/01/07/impressions-of-net/#comments</comments>
		<pubDate>Thu, 08 Jan 2009 03:17:20 +0000</pubDate>
		<dc:creator>Mike</dc:creator>
				<category><![CDATA[randomness]]></category>
		<category><![CDATA[.NET]]></category>
		<category><![CDATA[codemash]]></category>
		<category><![CDATA[conference]]></category>
		<category><![CDATA[cool]]></category>
		<category><![CDATA[interesting]]></category>
		<category><![CDATA[microsoft]]></category>
		<category><![CDATA[programming]]></category>

		<guid isPermaLink="false">http://mike.crute.org/blog/?p=166</guid>
		<description><![CDATA[Today I spent the entire day in the .NET session at CodeMash. Now I have pretty much no practical interest in .NET but the whole point of CodeMash is to expand your mind, so why not. I was pleasantly surprised and in cases downright impressed.
For the purpose of background it&#8217;s worth noting that Microsoft has [...]]]></description>
			<content:encoded><![CDATA[<p>Today I spent the entire day in the .NET session at CodeMash. Now I have pretty much no practical interest in .NET but the whole point of CodeMash is to expand your mind, so why not. I was pleasantly surprised and in cases downright impressed.<span id="more-166"></span></p>
<p>For the purpose of background it&#8217;s worth noting that Microsoft has put a pretty substantial chunk of change into this conference. They have signs everywhere as well as a room or two dedicated to their workshops. They&#8217;re also listed as an adamantium sponsor (the highest level).</p>
<p>Before I get into the rest of the post I have two mini-rants to address. First of all is that Windows Vista is UGLY, like really ugly. Whoever thought huge translucent borders for windows was a good idea was clearly on something. It&#8217;s pretty distracting and wastes lots of screen real-estate. All the superfluous animations are annoying and distracting too. The other thing is that GUI development environments and wizards drive me batshit and EVERYTHING you do in .NET assumes that you&#8217;re using Visual Studio. I&#8217;m with Charles Petzhold in the thought that <a style="font-size: 13.4556px; line-height: 19.3556px;" href="http://www.charlespetzold.com/etc/DoesVisualStudioRotTheMind.html" onclick="pageTracker._trackPageview('/outgoing/www.charlespetzold.com/etc/DoesVisualStudioRotTheMind.html?referer=');">Visual Studio rots the mind</a>. If I&#8217;m editing text I want to edit text and get the GUI crap out of my face, it just gets in the way.</p>
<p>Okay&#8230; on to the real post&#8230;</p>
<p>I haven&#8217;t actually be &#8220;into&#8221; Windows desktop development for the better part of 8 years and even back then it was just VB 6 which is comparatively quite primitive to the current state of .NET. When .NET originally came out was about the time I was making the transition to web development and so I basically wrote off Windows as a lost cause. I&#8217;ve got to say that I&#8217;m honestly really impressed with the current state of Windows development. Apple has really thrown down the gauntlet with their beautiful interfaces and really nice development tools which Microsoft has picked up. They are taking the challenge very seriously and it shows.</p>
<p>The old way to do .NET development was WinForms which is visually pretty status-quo for Windows applications; plain, boring, ugly. The new awesomeness which appears to only be in Windows Vista and up is Windows Presentation Framework which is pretty amazing. WPF allows you to do all kinds of really nice interface fanciness from 3D interfaces that slide and flip to real-time moving graphs of data that can be stacked and rotated in 3D. The demo apps they showed are certainly up to snuff for some of the more snazzy Mac applications that I&#8217;ve seen. The only thing I can see happening with WPF is programmers getting overzealous and adding too much WPF bling to their applications.</p>
<p>The other technology that was discussed which I&#8217;d totally underestimated was Silverlight. At a first glance Silverlight was just a wanna-be Flash clone which was lame. On closer inspection Silverlight appears to be a pretty serious competitor for the likes of AIR and Flex. Basically Silverlight pairs XAML with C#. The two are really pretty powerful together, and fast&#8230; the one demo of a chess game put Silverlight at 60x the speed of Javascript (which makes sense when you consider that C# IS JITed). The authoring tools are pretty good too. Though I did have to laugh when the presenter said they where positioning Expressions Studio as a competitor for Photoshop. Seriously?</p>
<p>The last thing that was demoed was ADO.NET and Linq. ADO.NET really isn&#8217;t anything special, its a database abstraction layer. Whoopty freaking doo. Linq is the .NET attempt at an ORM. Having not done any further study on the topic I can only say what I saw, and it wasn&#8217;t pretty. Basically Linq gives you a storage-agnostic way to select data from a database. By all accounts it is inverted SQL entered directly into your source code (i.e. NOT a string). Well that&#8217;s pretty gross. What&#8217;s even worse is you have to write Linq (LINQL?) backwards, your from statement comes before your select statement. When asked why the presenter informed us all that this was so intellisense could figure out what you where trying to get at. I threw up in my mouth. The idea of tailoring the language to the tools instead of the other way around is SO preposterous that I don&#8217;t even know where to begin.</p>
<p>Overall once the sales pitch for .NET was over and the demos began it was really impressive. I&#8217;ve got to give Microsoft some serious credit, they are taking .NET seriously and forthcoming versions of Windows will be adding some really neat stuff to a Windows developer&#8217;s toolkit.</p>
<p>The one thing that I&#8217;d really like to see Microsoft take seriously is other platforms. It&#8217;s very clear that in the Microsoft world there is only Windows and the fact that you may be using an &#8220;inferior&#8221; operating system is just beyond their comprehension. Of course this is understandable since they make Windows and they all use Windows. But it would be really grand if Microsoft would officially port .NET to other operating systems like Mac and Linux. They could have some serious competition for Java and bring some of the cool stuff they&#8217;re working on to the rest of the world. Until they do that .NET is probably irrelevant to me but it was still neat to see what they&#8217;ve got and its nice to know if the web thing doesn&#8217;t work out there&#8217;s a decent toolset to go work with.</p>
]]></content:encoded>
			<wfw:commentRss>http://mike.crute.org/blog/2009/01/07/impressions-of-net/feed/</wfw:commentRss>
		<slash:comments>3</slash:comments>
		</item>
		<item>
		<title>Going to CodeMash</title>
		<link>http://mike.crute.org/blog/2009/01/04/going-to-codemash/</link>
		<comments>http://mike.crute.org/blog/2009/01/04/going-to-codemash/#comments</comments>
		<pubDate>Mon, 05 Jan 2009 01:42:20 +0000</pubDate>
		<dc:creator>Mike</dc:creator>
				<category><![CDATA[randomness]]></category>
		<category><![CDATA[conference]]></category>
		<category><![CDATA[job]]></category>
		<category><![CDATA[programming]]></category>
		<category><![CDATA[travel]]></category>

		<guid isPermaLink="false">http://mike.crute.org/blog/?p=163</guid>
		<description><![CDATA[I&#8217;ll be at CodeMash next week. Anybody else going?


]]></description>
			<content:encoded><![CDATA[<p>I&#8217;ll be at <a href="http://codemash.org/" onclick="pageTracker._trackPageview('/outgoing/codemash.org/?referer=');">CodeMash</a> next week. Anybody else going?<br />
<span id="more-163"></span></p>
<p style="text-align: center;"><a href="http://codemash.org/" onclick="pageTracker._trackPageview('/outgoing/codemash.org/?referer=');"><img class="aligncenter" title="Ill Be There" src="http://codemash.org/images/bloggerbadge2008.gif" alt="" width="140" height="100" /></a></p>
]]></content:encoded>
			<wfw:commentRss>http://mike.crute.org/blog/2009/01/04/going-to-codemash/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>This Site Brought to you By Nginx</title>
		<link>http://mike.crute.org/blog/2009/01/04/this-site-brought-to-you-by-nginx/</link>
		<comments>http://mike.crute.org/blog/2009/01/04/this-site-brought-to-you-by-nginx/#comments</comments>
		<pubDate>Mon, 05 Jan 2009 01:35:38 +0000</pubDate>
		<dc:creator>Mike</dc:creator>
				<category><![CDATA[randomness]]></category>
		<category><![CDATA[apache]]></category>
		<category><![CDATA[netadmin]]></category>
		<category><![CDATA[php]]></category>
		<category><![CDATA[programming]]></category>
		<category><![CDATA[software]]></category>

		<guid isPermaLink="false">http://mike.crute.org/blog/?p=160</guid>
		<description><![CDATA[As of today this site is being served using Nginx!
After spending a little bit of time messing around running lighttpd on some personal stuff at home I decided to give Nginx a whirl this weekend and it&#8217;s quite awesome. So awesome in-fact that I&#8217;m now working to totally replace Apache with Nginx (that&#8217;s no small [...]]]></description>
			<content:encoded><![CDATA[<p>As of today this site is being served using Nginx!</p>
<p>After spending a little bit of time messing around running lighttpd on some personal stuff at home I decided to give Nginx a whirl this weekend and it&#8217;s quite awesome. So awesome in-fact that I&#8217;m now working to totally replace Apache with Nginx (that&#8217;s no small tasks for 60+ sites).<br />
<span id="more-160"></span><br />
Apache has served me well for more than six years while I did PHP development but now that I&#8217;m not really doing very much PHP work anymore and it has just become a pain to configure and maintain. For PHP work I ended up using Apache as a combination web/application server which, on reflection, doesn&#8217;t seem like it was such a great idea. Apache ended up taking lots of memory and the whole setup was comparatively fragile; if anything where to go wrong in PHP then the whole web server would fail to start.</p>
<p>I looked at lighttpd first as a candidate to replace Apache and for the most part I liked it but in the end Nginx was the winner. Probably the biggest reason to go with Nginx over lighttpd was that the configuration and the transition from Apache was easier than with lighttpd. Nginx has a very nice rewrite module and most of my apache rewrites where very simply transferred over as where all of my htpasswd files.</p>
<p>Out of the box the setup was pretty simple. There&#8217;s a slightly older version of nginx in the Ubuntu apt repository which is compiled with everything needed to get up and running. The PHP CGI version was setup to run as FastCGI out of the box as well. A small shell script to spawn PHP as the proper user and everything was pretty much good to go. The only annoying thing was that Ubuntu has opted to configure Nginx in the same way they do for Apache which separates your default server (vhost in Apache terms) from the main config which is dumb because you can&#8217;t really run the server at all without the default server so its not really something to be enabled or disabled. Otherwise it was a very smooth change.</p>
<p>My current setup has PHP running as a FastCGI application server with a pool of five processes communicating with Nginx over a Unix socket. Nginx runs two workers of its own on a dual-core server. The only things Nginx is currently handling aside from serving web requests are rewrites, some simple authentication and proxying back to Apache traffic for sites that haven&#8217;t been migrated yet. The setup seems to have cut memory usage on the box by nearly half.</p>
<p>The one thing that I&#8217;m going to miss is mod_dav_svn for Apache. I&#8217;m not sure if there is a suitable replacement for Nginx but I&#8217;m seriously considering transitioning all of my SVN stuff to Bazzar anyhow so this is probably a moot point.</p>
]]></content:encoded>
			<wfw:commentRss>http://mike.crute.org/blog/2009/01/04/this-site-brought-to-you-by-nginx/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Lesson Learned: Don&#8217;t Monkey Patch</title>
		<link>http://mike.crute.org/blog/2008/09/29/lesson-learned-dont-monkey-patch/</link>
		<comments>http://mike.crute.org/blog/2008/09/29/lesson-learned-dont-monkey-patch/#comments</comments>
		<pubDate>Mon, 29 Sep 2008 23:42:09 +0000</pubDate>
		<dc:creator>Mike</dc:creator>
				<category><![CDATA[python]]></category>
		<category><![CDATA[randomness]]></category>
		<category><![CDATA[hard lessons]]></category>
		<category><![CDATA[programming]]></category>
		<category><![CDATA[software]]></category>
		<category><![CDATA[suck]]></category>
		<category><![CDATA[work]]></category>

		<guid isPermaLink="false">http://mike.crute.org/blog/?p=151</guid>
		<description><![CDATA[Well this post comes as a lesson learned the hard way and a warning to fellow programmers in dynamic languages. In a sentence, don&#8217;t monkey-patch. Seriously, just don&#8217;t do it.

With the advent of dynamic languages like Python we are treated with very powerful yet dangerous features. Monkey patching, the practice of substituting one unit of [...]]]></description>
			<content:encoded><![CDATA[<p>Well this post comes as a lesson learned the hard way and a warning to fellow programmers in dynamic languages. In a sentence, don&#8217;t monkey-patch. Seriously, just don&#8217;t do it.<br />
<span id="more-151"></span><br />
With the advent of dynamic languages like Python we are treated with very powerful yet dangerous features. Monkey patching, the practice of substituting one unit of functionality with another at runtime is one of those really dangerous things.</p>
<p>It started out simply enough, I wanted some functionality from the standard cgi library in python; so I copied the relevant functions into my code and went about my merry way with everything working well. This felt a little dirty at the time since it violates DRY and I really try to keep my code DRY. Well I tend to write my code first and rough in the documentation then give everything a once-over and touch up documentation and unit tests before I commit it for production use. This is where I tend to get myself in trouble.</p>
<p>Lo and behold, I&#8217;m going back over this set of code and realize that I really don&#8217;t need to copy and paste the code but rather I can just replace one function in the standard library with my customized version. So I did and so began my troubles.</p>
<p>So it bears stepping back and really understanding what was happening here. In Python the real act of importing a module happens only once for the entire life of your program. When the compiler is asked to import a module it will parse it once and after that all you&#8217;re doing is importing it into your namespace, its already parsed and any module-level variables remain the same for the entire duration of your program. So, lets say for example you import the cgi module in a class deep within your program and decide to monkey-patch it. But, unbeknown to you the application server with which you share a namespace also imports this cgi module and uses it to handle the script environment. Well now everything works just great until your monkey-patch gets executed, then all of a sudden the remainder of your script will use the modified cgi module.</p>
<p>Lets also consider that your application server runs in two modes, for the sake of example; a fastcgi mode where application server processes can linger for hours and a cgi mode where application servers are spawned and killed with each request. Now you&#8217;ve got a seriously sneaky bug on your hands. Your code is going to potentially fail in one environment and run just fine in the other. Oh and now, no matter how much you look at that code you&#8217;re not going to understand why it&#8217;s failing until you realize what you&#8217;ve done by monkey-patching something.</p>
<p>This is the story of my day. A hard learned lesson. However, much thanks to my patient co-workers who helped me to see the error of my ways. Head this warning and do not monkey-patch things, your co-workers may not be so kind <img src='http://mike.crute.org/blog/wp-includes/images/smilies/icon_smile.gif' alt=':-)' class='wp-smiley' /> .</p>
<p><em>Fine print: Ok, so I know there are some legitimate cases for monkey-patching, however I&#8217;m learning that those are pretty rare and in general its a dangerous practice in which to engage.</em></p>
]]></content:encoded>
			<wfw:commentRss>http://mike.crute.org/blog/2008/09/29/lesson-learned-dont-monkey-patch/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Perl from Python? Intriguing yet gross.</title>
		<link>http://mike.crute.org/blog/2008/09/29/perl-from-python-intriguing-yet-gross/</link>
		<comments>http://mike.crute.org/blog/2008/09/29/perl-from-python-intriguing-yet-gross/#comments</comments>
		<pubDate>Mon, 29 Sep 2008 23:29:44 +0000</pubDate>
		<dc:creator>Mike</dc:creator>
				<category><![CDATA[python]]></category>
		<category><![CDATA[randomness]]></category>
		<category><![CDATA[cool]]></category>
		<category><![CDATA[interesting]]></category>
		<category><![CDATA[perl]]></category>
		<category><![CDATA[programming]]></category>
		<category><![CDATA[software]]></category>

		<guid isPermaLink="false">http://mike.crute.org/blog/?p=150</guid>
		<description><![CDATA[So I&#8217;m probably late to the party on this one but apparently you can import perl from within python. Now, why you would want to do this kind of baffles me, however, it is really pretty interesting and could have some possibilities if you&#8217;re maintaining a legacy perl application that you&#8217;re porting to python. If [...]]]></description>
			<content:encoded><![CDATA[<p>So I&#8217;m probably late to the party on this one but apparently you can <a href="http://search.cpan.org/~gaas/pyperl-1.0/perlmodule.pod" onclick="pageTracker._trackPageview('/outgoing/search.cpan.org/_gaas/pyperl-1.0/perlmodule.pod?referer=');">import perl</a> from within python. Now, why you would want to do this kind of baffles me, however, it is really pretty interesting and could have some possibilities if you&#8217;re maintaining a legacy perl application that you&#8217;re porting to python. If nothing else its an interesting academic exercise.</p>
]]></content:encoded>
			<wfw:commentRss>http://mike.crute.org/blog/2008/09/29/perl-from-python-intriguing-yet-gross/feed/</wfw:commentRss>
		<slash:comments>1</slash:comments>
		</item>
		<item>
		<title>Mac Terminal Keys</title>
		<link>http://mike.crute.org/blog/2008/08/30/mac-terminal-keys/</link>
		<comments>http://mike.crute.org/blog/2008/08/30/mac-terminal-keys/#comments</comments>
		<pubDate>Sun, 31 Aug 2008 03:30:42 +0000</pubDate>
		<dc:creator>Mike</dc:creator>
				<category><![CDATA[randomness]]></category>
		<category><![CDATA[apple]]></category>
		<category><![CDATA[hacks]]></category>
		<category><![CDATA[mac]]></category>
		<category><![CDATA[software]]></category>
		<category><![CDATA[terminal]]></category>

		<guid isPermaLink="false">http://mike.crute.org/blog/?p=148</guid>
		<description><![CDATA[One of the most annoying things with Apple&#8217;s Terminal.app is that the key bindings for paging an home/end are all kinds of screwed up. I&#8217;ve actually had these on my MBP for a while but was setting up a new Mac today and figured I&#8217;d throw them out here for the benefit of the rest [...]]]></description>
			<content:encoded><![CDATA[<p>One of the most annoying things with Apple&#8217;s Terminal.app is that the key bindings for paging an home/end are all kinds of screwed up. I&#8217;ve actually had these on my MBP for a while but was setting up a new Mac today and figured I&#8217;d throw them out here for the benefit of the rest of the web.<br />
<span id="more-148"></span><br />
To restore keyboard settings that make sense to users coming from other terminals you&#8217;ll need to edit the &#8220;Keyboard&#8221; settings of your favorite theme. These are the correct settings, they all require setting &#8220;Action&#8221; to &#8220;send string to shell&#8221;; use the escape key to enter \033:</p>
<table>
<tr>
<th>Key</th>
<th>Action</th>
</tr>
<tr>
<td>home</td>
<td>\033[1~</td>
</tr>
<tr>
<td>end</td>
<td>\033[4~</td>
</tr>
<tr>
<td>page up</td>
<td>\033[5~</td>
</tr>
<tr>
<td>page down</td>
<td>\033[6~</td>
</tr>
</table>
]]></content:encoded>
			<wfw:commentRss>http://mike.crute.org/blog/2008/08/30/mac-terminal-keys/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>iPython Readline on Leopard</title>
		<link>http://mike.crute.org/blog/2008/08/29/ipython-readline-on-leopard/</link>
		<comments>http://mike.crute.org/blog/2008/08/29/ipython-readline-on-leopard/#comments</comments>
		<pubDate>Sat, 30 Aug 2008 00:05:59 +0000</pubDate>
		<dc:creator>Mike</dc:creator>
				<category><![CDATA[python]]></category>
		<category><![CDATA[randomness]]></category>
		<category><![CDATA[apple]]></category>
		<category><![CDATA[cool]]></category>
		<category><![CDATA[ipython]]></category>
		<category><![CDATA[software]]></category>
		<category><![CDATA[terminal]]></category>

		<guid isPermaLink="false">http://mike.crute.org/blog/?p=146</guid>
		<description><![CDATA[iPython is a really great tool for working with Python interactively but its less than awesome on Leopard. Why you might ask? Well, included in the list of sins Apple has comitted with Leopard&#8217;s terminal environment was shipping a broken version of readline. The good news is it&#8217;s easy to fix! The iPython folks have [...]]]></description>
			<content:encoded><![CDATA[<p><a href="http://ipython.scipy.org" onclick="pageTracker._trackPageview('/outgoing/ipython.scipy.org?referer=');">iPython</a> is a really great tool for working with Python interactively but its less than awesome on Leopard. Why you might ask? Well, included in the list of sins Apple has comitted with Leopard&#8217;s terminal environment was shipping a broken version of readline. The good news is it&#8217;s easy to fix! The iPython folks have a version of readline that works on Leopard. Just easy_install it and rock out with full readline support, including working home and end keys.</p>

<div class="wp_syntax"><table><tr><td class="line_numbers"><pre>1
</pre></td><td class="code"><pre class="bash" style="font-family:monospace;"><span style="color: #c20cb9; font-weight: bold;">sudo</span> easy_install <span style="color: #660033;">-f</span> http:<span style="color: #000000; font-weight: bold;">//</span>ipython.scipy.org<span style="color: #000000; font-weight: bold;">/</span>dist readline</pre></td></tr></table></div>

]]></content:encoded>
			<wfw:commentRss>http://mike.crute.org/blog/2008/08/29/ipython-readline-on-leopard/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
	</channel>
</rss>
