<?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"
	>

<channel>
	<title>Groby's Coding Adventures</title>
	<atom:link href="http://www.codingadventures.com/feed/" rel="self" type="application/rss+xml" />
	<link>http://www.codingadventures.com</link>
	<description>Captain's log</description>
	<pubDate>Wed, 09 Jul 2008 04:28:49 +0000</pubDate>
	<generator>http://wordpress.org/?v=2.5.1</generator>
	<language>en</language>
			<item>
		<title>Learning Cocoa - Book Recommendations</title>
		<link>http://www.codingadventures.com/2008/07/learning-cocoa-book-recommendations/</link>
		<comments>http://www.codingadventures.com/2008/07/learning-cocoa-book-recommendations/#comments</comments>
		<pubDate>Wed, 09 Jul 2008 04:28:48 +0000</pubDate>
		<dc:creator>Groby</dc:creator>
		
		<category><![CDATA[Uncategorized]]></category>

		<category><![CDATA[book]]></category>

		<category><![CDATA[cocoa]]></category>

		<guid isPermaLink="false">http://www.codingadventures.com/?p=23</guid>
		<description><![CDATA[These days, I get quite a few questions from my fellow co-workers about resources to start with Cocoa development. So here&#8217;s a quick list of books that I absolutely recommend:



Objective C in general: Programming ObjectiveC



Intro to Cocoa: Learning Cocoa with ObjectiveC



Getting your feet wet on the iPhone: iPhone Open Application Development




And of course, when it [...]]]></description>
			<content:encoded><![CDATA[<p>These days, I get quite a few questions from my fellow co-workers about resources to start with Cocoa development. So here&#8217;s a quick list of books that I absolutely recommend:</p>

<table>
<tr>
<td>Objective C in general: </td><td><a href="http://www.amazon.com/gp/redirect.html?ie=UTF8&#038;location=http%3A%2F%2Fwww.amazon.com%2FProgramming-Objective-C-Developers-Library-Stephen%2Fdp%2F0672325861%3Fie%3DUTF8%26s%3Dbooks%26qid%3D1214336146%26sr%3D8-1&#038;tag=robertblum-20&#038;linkCode=ur2&#038;camp=1789&#038;creative=9325">Programming ObjectiveC</a><img src="http://www.assoc-amazon.com/e/ir?t=robertblum-20&amp;l=ur2&amp;o=1" width="1" height="1" border="0" alt="" style="border:none !important; margin:0px !important;" /></td>
</tr>

<tr>
<td>Intro to Cocoa:</td><td> <a href="http://www.amazon.com/gp/redirect.html?ie=UTF8&#038;location=http%3A%2F%2Fwww.amazon.com%2FLearning-Cocoa-Objective-C-Duncan-Davidson%2Fdp%2F0596003013%3Fie%3DUTF8%26s%3Dbooks%26qid%3D1215577433%26sr%3D1-1&#038;tag=robertblum-20&#038;linkCode=ur2&#038;camp=1789&#038;creative=9325">Learning Cocoa with ObjectiveC</a><img src="http://www.assoc-amazon.com/e/ir?t=robertblum-20&amp;l=ur2&amp;o=1" width="1" height="1" border="0" alt="" style="border:none !important; margin:0px !important;" /></td>
</tr>

<tr>
<td>Getting your feet wet on the iPhone:</td><td> <a href="http://www.amazon.com/gp/redirect.html?ie=UTF8&#038;location=http%3A%2F%2Fwww.amazon.com%2FiPhone-Open-Application-Development-Applications%2Fdp%2F0596518552&#038;tag=robertblum-20&#038;linkCode=ur2&#038;camp=1789&#038;creative=9325">iPhone Open Application Development</a><img src="http://www.assoc-amazon.com/e/ir?t=robertblum-20&amp;l=ur2&amp;o=1" width="1" height="1" border="0" alt="" style="border:none !important; margin:0px !important;" />
</td>
</tr>
</table>

<p>And of course, when it comes to web pages, there&#8217;s the invaluable <a href="http://www.cocoadev.com/">CocoaDev Wiki</a>.</p>
]]></content:encoded>
			<wfw:commentRss>http://www.codingadventures.com/2008/07/learning-cocoa-book-recommendations/feed/</wfw:commentRss>
		</item>
		<item>
		<title>Threshold Filter in GLSL</title>
		<link>http://www.codingadventures.com/2008/06/threshold-filter-in-glsl/</link>
		<comments>http://www.codingadventures.com/2008/06/threshold-filter-in-glsl/#comments</comments>
		<pubDate>Tue, 24 Jun 2008 07:31:13 +0000</pubDate>
		<dc:creator>Groby</dc:creator>
		
		<category><![CDATA[Uncategorized]]></category>

		<category><![CDATA[core image]]></category>

		<category><![CDATA[glsl]]></category>

		<category><![CDATA[osx]]></category>

		<category><![CDATA[shader]]></category>

		<guid isPermaLink="false">http://www.codingadventures.com/?p=22</guid>
		<description><![CDATA[I&#8217;ve been recently playing a little bit with GLSL/Core Image shaders. One of the earliest limitations I ran into was the fact that you cannot have conditional results. In other word, if you do an if/else test, the output of your shader cannot depend on it. (Not entirely sure why you&#8217;d want to use if/else [...]]]></description>
			<content:encoded><![CDATA[<p>I&#8217;ve been recently playing a little bit with GLSL/Core Image shaders. One of the earliest limitations I ran into was the fact that you <a href="http://developer.apple.com/documentation/GraphicsImaging/Conceptual/ImageUnitTutorial/Overview/chapter_3_section_4.html">cannot have conditional results</a>. In other word, if you do an if/else test, the output of your shader cannot depend on it. (Not entirely sure why you&#8217;d want to use if/else at all, then&#8230;)</p>

<p>That&#8217;s rather annoying. Thankfully, that&#8217;s a solved problem. Many CPUs prefer non-branching code, too, and there&#8217;s a long history of creating non-branching version of code that technically should branch. The trick here is &#8220;creative&#8221; use of math and/or bit-logic functions. As a simple example, let&#8217;s say I have a threshold shader - values below the minimum value should have a brightness of 0, and values higher than the max value should have a brightness of 1.</p>

<p><code>step()</code> function to the rescue: <code>step(a,b)</code> returns 0 if <code>a &lt; b</code>, <code>1 if a > b</code>. So to cut off the low range, we have</p>

<div class="dean_ch" style="white-space: wrap;">brightness = step<span class="br0">&#40;</span> low, brightness <span class="br0">&#41;</span> * brightness;</div>

<p>Very similarly, to check against the max value, we force brightness to be greater than 1 for pixels above the maximum threshold and then clamp to 1.0</p>

<div class="dean_ch" style="white-space: wrap;"><br />
&nbsp; brightness = brightness + step<span class="br0">&#40;</span> &nbsp;high, brightness <span class="br0">&#41;</span>;<br />
&nbsp; brightness = min<span class="br0">&#40;</span> <span class="nu0">1.0</span>, brightness <span class="br0">&#41;</span>;<br />
&nbsp;</div>

<p>That&#8217;s all there is to it. And in case you actually came for the filter code, here it is - with input sanitizing, nicer input values (midpoint/range), grayscale conversion, all the fun stuff.</p>

<div class="dean_ch" style="white-space: wrap;"><br />
kernel vec4 threshold<span class="br0">&#40;</span>sampler image, <span class="kw4">float</span> midPoint, <span class="kw4">float</span> range <span class="br0">&#41;</span><br />
<span class="br0">&#123;</span><br />
&nbsp; vec4 pixel=unpremultiply<span class="br0">&#40;</span> sample<span class="br0">&#40;</span>image, samplerCoord<span class="br0">&#40;</span>image<span class="br0">&#41;</span><span class="br0">&#41;</span> <span class="br0">&#41;</span>;<br />
<br />
&nbsp; <span class="kw4">float</span> high = midPoint + range * <span class="nu0">0.5</span>;<br />
&nbsp; <span class="kw4">float</span> low = midPoint - range * <span class="nu0">0.5</span>;<br />
&nbsp; <br />
&nbsp; high = min<span class="br0">&#40;</span><span class="nu0">1.0</span>, high<span class="br0">&#41;</span>;<br />
&nbsp; low = max<span class="br0">&#40;</span><span class="nu0">0.0</span>, low<span class="br0">&#41;</span>;<br />
&nbsp; <br />
&nbsp; <span class="kw4">float</span> brightness = <span class="nu0">0.3</span> * pixel.<span class="me1">x</span> + <span class="nu0">0.59</span> * pixel.<span class="me1">y</span>+ <span class="nu0">0.11</span> *pixel.<span class="me1">z</span>;<br />
&nbsp; &nbsp; <br />
&nbsp; brightness = step<span class="br0">&#40;</span> low, brightness <span class="br0">&#41;</span> * brightness;<br />
&nbsp; <br />
&nbsp; brightness = brightness + step<span class="br0">&#40;</span> &nbsp;high, brightness <span class="br0">&#41;</span>;<br />
&nbsp; brightness = min<span class="br0">&#40;</span> <span class="nu0">1.0</span>, brightness <span class="br0">&#41;</span>;<br />
&nbsp; &nbsp; <br />
&nbsp; pixel.<span class="me1">x</span> = pixel.<span class="me1">y</span> =pixel.<span class="me1">z</span> = brightness;<br />
&nbsp; <br />
&nbsp; <span class="kw1">return</span> premultiply<span class="br0">&#40;</span>pixel<span class="br0">&#41;</span>;<br />
<span class="br0">&#125;</span><br />
<br />
&nbsp;</div>
]]></content:encoded>
			<wfw:commentRss>http://www.codingadventures.com/2008/06/threshold-filter-in-glsl/feed/</wfw:commentRss>
		</item>
		<item>
		<title>Standalone RubyCocoa Applications</title>
		<link>http://www.codingadventures.com/2008/06/standalone-rubycocoa-applications/</link>
		<comments>http://www.codingadventures.com/2008/06/standalone-rubycocoa-applications/#comments</comments>
		<pubDate>Sun, 01 Jun 2008 17:11:00 +0000</pubDate>
		<dc:creator>Groby</dc:creator>
		
		<category><![CDATA[Uncategorized]]></category>

		<category><![CDATA[cocoa]]></category>

		<category><![CDATA[ruby]]></category>

		<guid isPermaLink="false">http://www.codingadventures.com/?p=16</guid>
		<description><![CDATA[RubyCocoa is one of the most fascinating tools on OSX. It makes it more than easy to rapidly prototype and try ideas with Cocoa. But unfortunately, out of the box, a RubyCocoa project seems to require an Objective-C shell to start it up. That means firing up XCode for every single prototype you&#8217;re playing with.

It [...]]]></description>
			<content:encoded><![CDATA[<p>RubyCocoa is one of the most fascinating tools on OSX. It makes it more than easy to rapidly prototype and try ideas with Cocoa. But unfortunately, out of the box, a RubyCocoa project seems to require an Objective-C shell to start it up. That means firing up XCode for every single prototype you&#8217;re playing with.</p>

<p>It only seems that way, though. A quick <a href="http://www.rubycocoa.com/mastering-cocoa-with-ruby/1">look behind the scenes</a> reveals that all that shell does is:</p>

<ul>
<li>start the ruby environment</li>
<li>&#8216;require&#8217; all included ruby scripts</li>
<li>and runs NSApplicationMain</li>
</ul>

<p>The first two, I can obviously do on my own. The third provides the main loop for all NSApplications. But you can&#8217;t simply call it from Ruby - it requires you to have an Info.plist. Again, too much baggage for quick &amp; dirty prototypes. The goal is to have <em>one</em> ruby file to play around in.</p>

<p>That one is a bit trickier to find out, but after digging around in Apple&#8217;s documentation, it turns out there is a decent explanation in the <a href="http://developer.apple.com/documentation/Cocoa/Reference/ApplicationKit/Classes/NSApplication_Class/Reference/Reference.html">overview for NSApplication</a></p>

<p>For future reference, this is what it does:</p>

<div class="dean_ch" style="white-space: wrap;"><br />
<span class="kw4">void</span> NSApplicationMain<span class="br0">&#40;</span><span class="kw4">int</span> argc, <span class="kw4">char</span> *argv<span class="br0">&#91;</span><span class="br0">&#93;</span><span class="br0">&#41;</span> <span class="br0">&#123;</span><br />
&nbsp; &nbsp; <span class="br0">&#91;</span><a href="http://developer.apple.com/documentation/Cocoa/Reference/ApplicationKit/ObjC_classic/Classes/NSApplication.html"><span class="kw6">NSApplication</span></a> sharedApplication<span class="br0">&#93;</span>;<br />
&nbsp; &nbsp; <span class="br0">&#91;</span><a href="http://developer.apple.com/documentation/Cocoa/Reference/Foundation/ObjC_classic/Classes/NSBundle.html"><span class="kw5">NSBundle</span></a> loadNibNamed:@<span class="st0">&quot;myMain&quot;</span> owner:NSApp<span class="br0">&#93;</span>;<br />
&nbsp; &nbsp; <span class="br0">&#91;</span>NSApp run<span class="br0">&#93;</span>;<br />
<span class="br0">&#125;</span><br />
&nbsp;</div>

<p>Now we&#8217;re getting somewhere. This can actually be completely duplicated in Ruby. Since I might want to quit my application, I&#8217;ve thrown in a window that shuts down the application when closed.</p>

<div class="dean_ch" style="white-space: wrap;"><br />
<span class="kw3">require</span> <span class="st0">&#8216;OSX/cocoa&#8217;</span><br />
<br />
<span class="kw1">class</span> CloseDelegate &lt; <span class="re2">OSX::NSObject</span><br />
&nbsp; <span class="kw1">def</span> windowWillClose<span class="br0">&#40;</span> sender <span class="br0">&#41;</span><br />
&nbsp; &nbsp; <span class="re2">OSX::NSApp</span>.<span class="me1">terminate_</span> sender<br />
&nbsp; <span class="kw1">end</span><br />
<span class="kw1">end</span><br />
<br />
<span class="co1"># Instantiate the shared App</span><br />
<span class="re2">OSX::NSApplication</span>.<span class="me1">sharedApplication</span><br />
<br />
window = <span class="re2">OSX::NSWindow</span>.<span class="me1">alloc</span><br />
window.<span class="me1">initWithContentRect_styleMask_backing_defer_</span><span class="br0">&#40;</span> <br />
&nbsp; <span class="re2">OSX::NSMakeRect</span><span class="br0">&#40;</span><span class="nu0">50</span>,<span class="nu0">50</span>,<span class="nu0">200</span>,<span class="nu0">400</span><span class="br0">&#41;</span>, <br />
&nbsp; <span class="re2">OSX::NSTitledWindowMask</span> <br />
&nbsp; &nbsp; + <span class="re2">OSX::NSClosableWindowMask</span>, <br />
&nbsp; <span class="re2">OSX::NSBackingStoreBuffered</span>, <span class="kw2">true</span><span class="br0">&#41;</span><br />
<br />
window.<span class="me1">setDelegate</span> CloseDelegate.<span class="me1">alloc</span>.<span class="me1">init</span><br />
window.<span class="me1">makeKeyAndOrderFront</span> <span class="kw2">nil</span><br />
<br />
<span class="co1"># run the main loop</span><br />
<span class="re2">OSX::NSApplication</span>.<span class="me1">sharedApplication</span>.<span class="me1">run</span><br />
<br />
&nbsp;</div>

<p>Or just download <a href="http://www.codingadventures.com/projects/standalone.rb">standalone.rb</a></p>
]]></content:encoded>
			<wfw:commentRss>http://www.codingadventures.com/2008/06/standalone-rubycocoa-applications/feed/</wfw:commentRss>
		</item>
		<item>
		<title>Speeding up VS.NET - Startup Times</title>
		<link>http://www.codingadventures.com/2008/05/speeding-up-vsnet-startup-times/</link>
		<comments>http://www.codingadventures.com/2008/05/speeding-up-vsnet-startup-times/#comments</comments>
		<pubDate>Thu, 01 May 2008 23:32:01 +0000</pubDate>
		<dc:creator>Groby</dc:creator>
		
		<category><![CDATA[Uncategorized]]></category>

		<category><![CDATA[c++]]></category>

		<category><![CDATA[vs.net]]></category>

		<guid isPermaLink="false">http://www.codingadventures.com/?p=15</guid>
		<description><![CDATA[If you&#8217;re developing on Windows, chances are you are using VS.NET. And if you&#8217;re using VS.NET, you&#8217;ll probably feel like the thing could go much faster. Well, it turns out it can - I spent a weekend researching how to do that, so here are the results for the startup process. (I&#8217;m taking 2005 only [...]]]></description>
			<content:encoded><![CDATA[<p>If you&#8217;re developing on Windows, chances are you are using VS.NET. And if you&#8217;re using VS.NET, you&#8217;ll probably feel like the thing could go <em>much</em> faster. Well, it turns out it can - I spent a weekend researching how to do that, so here are the results for the startup process. (I&#8217;m taking 2005 only - YMMV for other versions)</p>

<p>To actually time the startup process, you can cause Visual Studio to write a log file - just specify <code> /Log &lt;logfile&gt; </code> at the command line. I&#8217;ve written a little Ruby script that actually does that for you, and measures the time taken for the startup.</p>

<p>When I started doing that, I just kept looking at the generated log file (which conveniently contains timing info) and considered the startup done once no new info showed up in the log file. That last line is the trigger point in the script. (Why so complicated? Because VS.NET still does stuff while it <em>pretends</em> it has started. Doesn&#8217;t help me, since it&#8217;s still not doing what I want it to do during that time)</p>

<p>Just running VS.NET &#8220;out of the box&#8221;, it takes on average 11.6 seconds to start up. (I&#8217;ve always tried it 10 times in a row and averaged, in case Windows file caching throws me a curveball).</p>

<p>Just by eyeballing, the biggest time eater seems to be the &#8220;Visual C++ Developer Center&#8221; start page. Let&#8217;s turn that off. (Tools/Options/Environment/General/Startup/Show empty Environment). And while I&#8217;m at it, let&#8217;s also turn off the download off content. Since I have VS2005, there has been about one interesting article on that page, so I&#8217;ll survive.</p>

<p>The surprising result: Visual Studio does not load the &#8220;Common IDE package&#8221; anymore - whatever that is. Startup time is now down to 2.4 seconds.</p>

<p>As a next step, I disable all the add-ins I don&#8217;t need. Some, you can just turn off via Tools/Add-In Manager(<a href="http://developer.amd.com/cpu/codeanalyst/codeanalystwindows/Pages/default.aspx">AMD Code Analyst</a>). Others, you actually need to uninstall. (I&#8217;m looking at you, <a href="http://www.workspacewhiz.com/SolutionBuildEnvironmentReadme.html">Solution Build Environment</a>). That actually cut down the startup time to 2.0 seconds.</p>

<p>Next up - let&#8217;s get rid of the splash screen. Just start devenv with the <code> /nosplash</code> argument. It turns out that just <em>feels</em> faster, since you don&#8217;t have to stare at the startup screen. The startup time is still pretty much the same.</p>

<p>From here on out, we&#8217;re firmly in the realm of myth. I tested a few other suggestions, but none of them had a measurable effect on startup time. If you still want to try them, here they are:</p>

<ul>
<li><p>Turning off animated windows: Tools/Options/Environment/General/Animate Environment. Might help later in the project, when you have many windows open.</p></li>
<li><p>Another frequently repeated tip is turning off dynamic help. That option is not available in VS2005 any more. However, the other tunings above seem to have accelerated the startup of the external help viewer a bit. I have no idea why, but I&#8217;ll certainly take the speedup.</p></li>
<li><p>Cleaning MRU lists. Not really helpful. It might bring an extremely slight improvement, but variations between individual VS runs are way bigger than that improvement. That particular myth seems to be a holdover from a <a href="http://blogs.msdn.com/jledgard/archive/2004/05/08/128648.aspx">VS2003 bug with the MRU</a></p></li>
</ul>
]]></content:encoded>
			<wfw:commentRss>http://www.codingadventures.com/2008/05/speeding-up-vsnet-startup-times/feed/</wfw:commentRss>
		</item>
		<item>
		<title>Reason #947 why C++ is dangerous - and certainly not type-safe</title>
		<link>http://www.codingadventures.com/2008/04/reason-947-why-c-is-dangerous-and-certainly-not-type-safe/</link>
		<comments>http://www.codingadventures.com/2008/04/reason-947-why-c-is-dangerous-and-certainly-not-type-safe/#comments</comments>
		<pubDate>Fri, 25 Apr 2008 01:41:44 +0000</pubDate>
		<dc:creator>Groby</dc:creator>
		
		<category><![CDATA[Uncategorized]]></category>

		<category><![CDATA[c++]]></category>

		<guid isPermaLink="false">http://www.codingadventures.com/?p=14</guid>
		<description><![CDATA[Here&#8217;s the statement in question:


Vec3 v = &#40;2,3,0&#41;
&#160;

After running it, v is set to (0,0,0) - can you spot why?

In case you couldn&#8217;t, here&#8217;s what happens. C++ encounters (0,3,0) and evaluates to 0 - because comma-separated expressions evaluate left-to-right and return the rightmost expression. That&#8217;s strike one right there - the comma operator is a [...]]]></description>
			<content:encoded><![CDATA[<p>Here&#8217;s the statement in question:</p>

<div class="dean_ch" style="white-space: wrap;"><br />
Vec3 v = <span class="br0">&#40;</span><span class="nu0">2</span>,<span class="nu0">3</span>,<span class="nu0">0</span><span class="br0">&#41;</span><br />
&nbsp;</div>

<p>After running it, v is set to (0,0,0) - can you spot why?</p>

<p>In case you couldn&#8217;t, here&#8217;s what happens. C++ encounters <code>(0,3,0)</code> and evaluates to <code>0</code> - because comma-separated expressions evaluate left-to-right and return the rightmost expression. That&#8217;s strike one right there - the comma operator is a completely useless leftover from the days of C and gets silently applied. I&#8217;ve never seen a case where the comma operator actually was the intent of the programmer <em>and</em> useful in any way except to obfuscate the code.</p>

<p>Next strike against C++ is that I&#8217;m trying to initialize a vector here - which would have required curly braces, not parentheses. But even if I had gotten that right, there&#8217;s a good chance it fails - if Vec3 has any constructors (even empty ones), this assignment would be a syntax error.</p>

<p>But back to the problem at hand. The expression now boiled down to</p>

<div class="dean_ch" style="white-space: wrap;"><br />
Vec3 v = <span class="nu0">0</span>;<br />
&nbsp;</div>

<p>Now, clearly my vector class doesn&#8217;t allow alignment of a scalar. So what the heck is going on? That&#8217;s right - there is a convenience constructor that takes a single scalar and assigns it to all three components of the vector. Yes, it should have been marked as <code>explicit</code>. Which is yet another example of C++ defaulting to the more dangerous choice. (And really, in a code base maintained by more than one person, this will always be a problem)</p>

<p>Why, thank you, C++. I&#8217;ll never understand how anybody could call this language type-safe. In this simple statement, it has</p>

<ul>
<li><p>implicitly converted a list of integers to an integer</p></li>
<li><p>promoted that (silently, of course) to a float</p></li>
<li><p>created a vector from that, again silently</p></li>
</ul>

<p>At last count that&#8217;s four different types of data that have been used interchangeably. Yes, as an experienced C++ developer you find those gotchas quickly - but I&#8217;m really getting tired of having to suffer just because of an ill-conceived language. (Yes, I know why C++ does what it does here, what the design reasons were, etc. I read the ARM. It&#8217;s still a crappy result)</p>
]]></content:encoded>
			<wfw:commentRss>http://www.codingadventures.com/2008/04/reason-947-why-c-is-dangerous-and-certainly-not-type-safe/feed/</wfw:commentRss>
		</item>
		<item>
		<title>HOWTO: Building Mapnik on OSX Leopard</title>
		<link>http://www.codingadventures.com/2008/04/howto-building-mapnik-on-osx-leopard/</link>
		<comments>http://www.codingadventures.com/2008/04/howto-building-mapnik-on-osx-leopard/#comments</comments>
		<pubDate>Wed, 23 Apr 2008 19:58:49 +0000</pubDate>
		<dc:creator>Groby</dc:creator>
		
		<category><![CDATA[Uncategorized]]></category>

		<category><![CDATA[mapping]]></category>

		<category><![CDATA[osx]]></category>

		<guid isPermaLink="false">http://www.codingadventures.com/?p=13</guid>
		<description><![CDATA[I recently decided to get involved in Aaron Swartz&#8217;s latest project, watchdog.net. And since one of the most interesting jobs to me was investigating an alternative to Google Maps, I took the plunge and tried to look at Mapnik.

First challenge - just getting it to build on OSX. It seems like a trivial task, especially [...]]]></description>
			<content:encoded><![CDATA[<p>I recently decided to get involved in <a href="http://www.aaronsw.com/">Aaron Swartz&#8217;s</a> latest project, <a href="http://watchdog.net">watchdog.net</a>. And since one of the most interesting jobs to me was investigating an alternative to <a href="http://maps.google.com/">Google Maps</a>, I took the plunge and tried to look at <a href="http://mapnik.org/">Mapnik</a>.</p>

<p>First challenge - just getting it to build on OSX. It seems like a trivial task, especially since people have already built it for OSX in general, but it unfortunately isn&#8217;t. There are a few pitfalls to avoid. The main <a href="http://mapnik.org/documentation/install/">Mapnik install documentation</a> helps a lot, so I recommend reading that first. Especially the prerequisites part - you <em>really</em> need all the packages there. The port system helps a lot with this, but here are the issues I encountered:</p>

<ul>
<li>the build script <em>requires</em> libproj </li>
</ul>

<div class="dean_ch" style="white-space: wrap;">port install proj</div>

<ul>
<li>Before installing boost, you must install jam - there seems to be a dependency missing in the port file.</li>
</ul>

<div class="dean_ch" style="white-space: wrap;">port install jam</div>

<ul>
<li>When installing boost, make sure you install it with python support, specifically support for Python 2.5</li>
</ul>

<div class="dean_ch" style="white-space: wrap;">port install boost +python25</div>

<p>Now that you&#8217;ve installed all the prerequisites, it&#8217;s time to fix up the buildscript</p>

<ul>
<li><p>libtiff doesn&#8217;t live where it&#8217;s expected to live. Use the <a href="/projects/mapnik/libtiff.patch">patch</a>.</p>

<p>Or</p></li>
</ul>

<div class="dean_ch" style="white-space: wrap;">locate libtiff.a</div>

<p>and fix it by hand.</p>

<ul>
<li>Python site libraries on OSX are not installed in site-packages of the original python directory. They go to a completely separate path. Either figure it out yourself:</li>
</ul>

<div class="dean_ch" style="white-space: wrap;">python -c &quot;from distutils.sysconfig import get_python_lib; print get_python_lib()&quot;</div>

<p>or use the <a href="/projects/mapnik/python_prefix.patch">patch</a>.</p>

<ul>
<li><p>There&#8217;s a syntax error in calling unicode functions - here&#8217;s the <a href="/projects/mapnik/unicode.patch">patch</a>.</p></li>
<li><p>On machines that had a hand-install of python, mapnik will build but not run. To make sure that doesn&#8217;t hit you,  make sure you never had a home-built version of python on your machine or remove its remnants. If there are python libraries in</p></li>
</ul>

<pre>/Library/Frameworks/Python.framework</pre>

<p>, remove that folder.</p>

<p>Once all that is done, you just need to make &amp; install:</p>

<div class="dean_ch" style="white-space: wrap;">sudo python scons/scons.py install</div>
]]></content:encoded>
			<wfw:commentRss>http://www.codingadventures.com/2008/04/howto-building-mapnik-on-osx-leopard/feed/</wfw:commentRss>
		</item>
		<item>
		<title>My personal history</title>
		<link>http://www.codingadventures.com/2008/04/my-personal-history/</link>
		<comments>http://www.codingadventures.com/2008/04/my-personal-history/#comments</comments>
		<pubDate>Mon, 21 Apr 2008 02:54:49 +0000</pubDate>
		<dc:creator>Groby</dc:creator>
		
		<category><![CDATA[Uncategorized]]></category>

		<category><![CDATA[shell]]></category>

		<category><![CDATA[silly]]></category>

		<guid isPermaLink="false">http://www.codingadventures.com/?p=12</guid>
		<description><![CDATA[Bowing to the shell history meme:

history&#124;awk '{a[$2]++} END{for(i in a){printf &#8220;%5d\t%s \n&#8221;,a[i],i}}&#8217;&#124;sort -rn&#124;head

55  sudo 
45  ls 
42  git 
32  cd 
25  gem 
23  vi 
21  ruby 
15  man 
13  echo 
 7  /bin/rm 


Heh. Turns out most of my work on the command line involves [...]]]></description>
			<content:encoded><![CDATA[<p>Bowing to the shell history meme:</p>

<p><code>history|awk '{a[$2]++} END{for(i in a){printf &#8220;%5d\t%s \n&#8221;,a[i],i}}&#8217;|sort -rn|head</code></p>

<pre><code>55  sudo 
45  ls 
42  git 
32  cd 
25  gem 
23  vi 
21  ruby 
15  man 
13  echo 
 7  /bin/rm 
</code></pre>

<p>Heh. Turns out most of my work on the command line involves making changes as the actual super user. Further digging reveals that most of <em>that</em> are calls to port and gem. (And yes, I call gem a lot as local user to. Not everything requires privilege escalation).</p>

<p>The rest just proves that I&#8217;m a ruby/vi person, not python/emacs. (Although, honestly, I&#8217;m a textmate user. Just forgot to install the mate script&#8230;)</p>
]]></content:encoded>
			<wfw:commentRss>http://www.codingadventures.com/2008/04/my-personal-history/feed/</wfw:commentRss>
		</item>
		<item>
		<title>The sad state of DVCS for Windows</title>
		<link>http://www.codingadventures.com/2008/04/the-sad-state-of-dvcs-for-windows/</link>
		<comments>http://www.codingadventures.com/2008/04/the-sad-state-of-dvcs-for-windows/#comments</comments>
		<pubDate>Sat, 19 Apr 2008 19:46:21 +0000</pubDate>
		<dc:creator>Groby</dc:creator>
		
		<category><![CDATA[Uncategorized]]></category>

		<category><![CDATA[dvcs]]></category>

		<category><![CDATA[win32]]></category>

		<guid isPermaLink="false">http://www.codingadventures.com/?p=11</guid>
		<description><![CDATA[I have recently started exploring DVCS - distributed version control systems.

The power they offer you as a developer is amazing, especially if you use them with a patch management solution like quilt. The ability to juggle branches and patches with almost zero cost is extremely empowering. (At the same time, it&#8217;s also dangerous. It&#8217;s a [...]]]></description>
			<content:encoded><![CDATA[<p>I have recently started exploring <a href="http://en.wikipedia.org/wiki/Distributed_Version_Control_System">DVCS</a> - distributed version control systems.</p>

<p>The power they offer you as a developer is amazing, especially if you use them with a patch management solution like <a href="http://savannah.nongnu.org/projects/quilt">quilt</a>. The ability to juggle branches and patches with almost zero cost is extremely empowering. (At the same time, it&#8217;s also dangerous. It&#8217;s a power tool, so don&#8217;t use it if you&#8217;re not feeling your current version control is limiting you).</p>

<p>Obviously, I like using the most powerful tools for my professional work, too. There are two limiting factors here. One, everybody is using <a href="http://www.perforce.com">Perforce</a>. Two, we&#8217;re running under Windows.</p>

<p>Obstacle #1 can be overcome by running a tool like <a href="http://progetti.arstecnica.it/tailor/wiki">Tailor</a> which allows you to migrate changes between version control tools. #2 is a much bigger hurdle. Let&#8217;s take a look, shall we:</p>

<p>The three main options for Windows are <a href="http://git.or.cz/">git</a>,<a href="http://www.selenic.com/mercurial/wiki/">Mercurial</a> and <a href="http://darcs.net/">darcs</a>. All three of them have Windows versions. With a <em>big</em> but:</p>

<ul>
<li><p>GIT
While it does have Windows executables, it relies a lot on shell scripts. Which means it needs to run in a cygwin environment, which is sort of the worst of both the Unix and the Windows worlds. In other words, it&#8217;s a pain to actually run it.</p></li>
<li><p>Darcs</p>

<p>Seems to run fine under Windows, but sometimes relies on external programs. (WGet/Curl being one). And there&#8217;s no list of external dependencies. I&#8217;m certainly not basing my daily work on a tool that suddenly might stop to work, just because I&#8217;m missing a dependency</p></li>
<li><p>Mercurial</p>

<p>Seems fine. It has a Windows executable and works out of the box.</p></li>
</ul>

<p>So it seems like Mercurial should be the tool of choice. Except, we need Tailor to run. Now, it does support Mercurial out of the box, but it expects the Python version of Mercurial - not a precompiled executable.</p>

<p>Sounds easy, right? Just get python, get Mercurial source, and install it. Except&#8230;</p>

<p>Mercurial wants to compile some native modules, and they need to be compiled using the same compiler that the Python interpreter was compiled with. And wouldn&#8217;t you know it, in the year 2008 Python is still not compiled with VS.NET 2005 - we&#8217;re stuck with VS2003. (What the heck?)</p>

<p>So basically, I&#8217;m stuck. Advice so far: If you&#8217;re on Windows and don&#8217;t need Tailor, get Mercurial - it&#8217;s the least amount of hassle. If you need to interop with Perforce or another VCS, you&#8217;re completely out of luck.</p>
]]></content:encoded>
			<wfw:commentRss>http://www.codingadventures.com/2008/04/the-sad-state-of-dvcs-for-windows/feed/</wfw:commentRss>
		</item>
		<item>
		<title>You&#8217;ve got to be kidding me</title>
		<link>http://www.codingadventures.com/2008/04/youve-got-to-be-kidding-me/</link>
		<comments>http://www.codingadventures.com/2008/04/youve-got-to-be-kidding-me/#comments</comments>
		<pubDate>Wed, 16 Apr 2008 03:56:17 +0000</pubDate>
		<dc:creator>Groby</dc:creator>
		
		<category><![CDATA[Uncategorized]]></category>

		<category><![CDATA[thread]]></category>

		<category><![CDATA[win32]]></category>

		<guid isPermaLink="false">http://www.codingadventures.com/?p=10</guid>
		<description><![CDATA[During my work adventures, I have the &#8216;fortune&#8216; of working with Windows threads. One thing that&#8217;s nice to have is a name for each thread so you can actually tell them apart. Turns out, there is no easy call to set a thread name.

However, there is an officially approved way to set a thread name:


//
// [...]]]></description>
			<content:encoded><![CDATA[<p>During my work adventures, I have the &#8216;<em>fortune</em>&#8216; of working with Windows threads. One thing that&#8217;s nice to have is a <em>name</em> for each thread so you can actually tell them apart. Turns out, there is no easy call to set a thread name.</p>

<p>However, there is an <a href="http://msdn2.microsoft.com/en-us/library/xcb2z8hs(vs.71).aspx">officially approved way to set a thread name</a>:</p>

<div class="dean_ch" style="white-space: wrap;"><br />
<span class="co1">//</span><br />
<span class="co1">// Usage: SetThreadName (-1, &quot;MainThread&quot;);</span><br />
<span class="co1">//</span><br />
<span class="kw4">typedef</span> <span class="kw4">struct</span> tagTHREADNAME_INFO<br />
<span class="br0">&#123;</span><br />
&nbsp; &nbsp;DWORD dwType; <span class="co1">// must be 0&#215;1000</span><br />
&nbsp; &nbsp;LPCSTR szName; <span class="co1">// pointer to name (in user addr space)</span><br />
&nbsp; &nbsp;DWORD dwThreadID; <span class="co1">// thread ID (-1=caller thread)</span><br />
&nbsp; &nbsp;DWORD dwFlags; <span class="co1">// reserved for future use, must be zero</span><br />
<span class="br0">&#125;</span> THREADNAME_INFO;<br />
<br />
<span class="kw4">void</span> SetThreadName<span class="br0">&#40;</span> DWORD dwThreadID, LPCSTR szThreadName<span class="br0">&#41;</span><br />
<span class="br0">&#123;</span><br />
&nbsp; &nbsp;THREADNAME_INFO info;<br />
&nbsp; &nbsp;info.<span class="me1">dwType</span> = 0&#215;1000;<br />
&nbsp; &nbsp;info.<span class="me1">szName</span> = szThreadName;<br />
&nbsp; &nbsp;info.<span class="me1">dwThreadID</span> = dwThreadID;<br />
&nbsp; &nbsp;info.<span class="me1">dwFlags</span> = <span class="nu0">0</span>;<br />
<br />
&nbsp; &nbsp;__try<br />
&nbsp; &nbsp;<span class="br0">&#123;</span><br />
&nbsp; &nbsp; &nbsp; RaiseException<span class="br0">&#40;</span> 0&#215;406D1388, <br />
&nbsp; &nbsp; <span class="nu0">0</span>, <span class="kw4">sizeof</span><span class="br0">&#40;</span>info<span class="br0">&#41;</span>/<span class="kw4">sizeof</span><span class="br0">&#40;</span>DWORD<span class="br0">&#41;</span>, <br />
&nbsp; &nbsp; <span class="br0">&#40;</span>DWORD*<span class="br0">&#41;</span>&amp;info <span class="br0">&#41;</span>;<br />
&nbsp; &nbsp;<span class="br0">&#125;</span><br />
&nbsp; &nbsp;except<span class="br0">&#40;</span>EXCEPTION_CONTINUE_EXECUTION<span class="br0">&#41;</span><br />
&nbsp; &nbsp;<span class="br0">&#123;</span><br />
&nbsp; &nbsp;<span class="br0">&#125;</span><br />
<span class="br0">&#125;</span><br />
&nbsp;</div>

<p>Who is the genius responsible for <em>that</em> idea???</p>
]]></content:encoded>
			<wfw:commentRss>http://www.codingadventures.com/2008/04/youve-got-to-be-kidding-me/feed/</wfw:commentRss>
		</item>
		<item>
		<title>Ruby, OSX, and OpenGL</title>
		<link>http://www.codingadventures.com/2008/04/ruby-osx-and-opengl/</link>
		<comments>http://www.codingadventures.com/2008/04/ruby-osx-and-opengl/#comments</comments>
		<pubDate>Mon, 14 Apr 2008 11:00:56 +0000</pubDate>
		<dc:creator>Groby</dc:creator>
		
		<category><![CDATA[Uncategorized]]></category>

		<category><![CDATA[opengl]]></category>

		<category><![CDATA[osx]]></category>

		<category><![CDATA[ruby]]></category>

		<guid isPermaLink="false">http://www.codingadventures.com/?p=9</guid>
		<description><![CDATA[This is one of the wonderful detours programming takes me on from time to time. What I really wanted to do is work a little bit more on my neural network code. Next up was a back-propagation algorithm for learning. There are plenty of examples of it, but few that give a decent explanation of [...]]]></description>
			<content:encoded><![CDATA[<p>This is one of the wonderful detours programming takes me on from time to time. What I <em>really</em> wanted to do is work a little bit more on my <a href="http://www.codingadventures.com/2008/04/neural-networks-in-ruby/">neural network code</a>. Next up was a back-propagation algorithm for learning. There are plenty of examples of it, but few that give a decent explanation of the <em>why</em>. And even fewer that can show me the &#8216;why&#8217; in pretty pictures - I&#8217;m a visual learner, so that always helps.</p>

<p>After quite a bit of reading up, I finally got the idea that all this is is a gradient descent - but my math is rusty enough that I really like to see a visual explanation of it, too. (Yes, I get the math. I just want the pictures, by now). So I decide to create them myself - if something&#8217;s missing on the web, you go and add it.</p>

<p>Except I want to do it programatically, since my art skills are close to non-existent. And my mind is focused on Ruby, so that&#8217;s the language I want to do it with. Turns out that searching for &#8216;]ruby osx opengl](http://www.google.com/search?hl=en&amp;client=safari&amp;rls=en-us&amp;q=ruby+osx+opengl&amp;btnG=Search)&#8217; is not that helpful. A few searches later, I finally figure out that the proper serch term would have been &#8216;<a href="http://www.google.com/search?hl=en&amp;client=safari&amp;rls=en-us&amp;q=rubycocoa+opengl&amp;btnG=Search">rubycocoa opengl</a>&#8216; instead. Which tells me right in the first hit that Apple is actually kind enough to ships a sample application with RubyCocoa.</p>

<p>So to get started with Ruby, OSX, and OpenGL, just take a look at /Developer/Examples/Ruby/RubyCocoa/CocoaGL - and you&#8217;re set to go. Now I&#8217;m off to do some heightfield rendering in OpenGL - unless I get sidetracked again.</p>
]]></content:encoded>
			<wfw:commentRss>http://www.codingadventures.com/2008/04/ruby-osx-and-opengl/feed/</wfw:commentRss>
		</item>
	</channel>
</rss>

<!-- Dynamic Page Served (once) in 3.129 seconds -->
<!-- Cached page served by WP-Cache -->
