<?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/"
	xmlns:georss="http://www.georss.org/georss" xmlns:geo="http://www.w3.org/2003/01/geo/wgs84_pos#" xmlns:media="http://search.yahoo.com/mrss/"
	>

<channel>
	<title>Nerd Fortress &#187; Codealicious</title>
	<atom:link href="http://nerdfortress.com/category/codealicious/feed/" rel="self" type="application/rss+xml" />
	<link>http://nerdfortress.com</link>
	<description>Esoteric How-to&#039;s, Essays, and Rand();</description>
	<lastBuildDate>Mon, 21 May 2012 19:55:22 +0000</lastBuildDate>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.com/</generator>
<cloud domain='nerdfortress.com' port='80' path='/?rsscloud=notify' registerProcedure='' protocol='http-post' />
<image>
		<url>http://s2.wp.com/i/buttonw-com.png</url>
		<title>Nerd Fortress &#187; Codealicious</title>
		<link>http://nerdfortress.com</link>
	</image>
	<atom:link rel="search" type="application/opensearchdescription+xml" href="http://nerdfortress.com/osd.xml" title="Nerd Fortress" />
	<atom:link rel='hub' href='http://nerdfortress.com/?pushpress=hub'/>
		<item>
		<title>Ruby vs. Python vs. PyPy: Is Ruby Slower than Python for Web Development?</title>
		<link>http://nerdfortress.com/2011/09/05/ruby-vs-python-vs-pypy-is-ruby-slower-than-python-for-web-development/</link>
		<comments>http://nerdfortress.com/2011/09/05/ruby-vs-python-vs-pypy-is-ruby-slower-than-python-for-web-development/#comments</comments>
		<pubDate>Mon, 05 Sep 2011 16:45:32 +0000</pubDate>
		<dc:creator>Kurt</dc:creator>
				<category><![CDATA[Codealicious]]></category>

		<guid isPermaLink="false">http://nerdfortress.com/?p=1425</guid>
		<description><![CDATA[If you are into programming languages, you&#8217;ve probably heard people talk about how slow Ruby is, and how you should use Python instead. I&#8217;ve always loved Ruby&#8217;s beautiful syntax. On the other hand, Python isn&#8217;t that ugly, and it&#8217;s hard to argue with raw speed. Ruby 1.9 brought major performance improvements to the table, and recently [...]<img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=nerdfortress.com&#038;blog=4772118&#038;post=1425&#038;subd=nerdfortress&#038;ref=&#038;feed=1" width="1" height="1" />]]></description>
			<content:encoded><![CDATA[<p>If you are into programming languages, you&#8217;ve probably heard people talk about how slow Ruby is, and how you should use Python instead. I&#8217;ve always loved Ruby&#8217;s beautiful syntax. On the other hand, Python isn&#8217;t <em>that</em> ugly, and it&#8217;s hard to argue with raw speed.</p>
<p>Ruby 1.9 brought major performance improvements to the table, and recently I got a chance to sit down and do some web service benchmarking. Based on my tests, the tradeoff between beauty and performance isn&#8217;t as big as it used to be, but there&#8217;s still some work to be done.</p>
<p>Here is what I did.</p>
<p>First, I implemented basic &#8220;Hello World&#8221; apps using the standard web server interfaces for each language; <a title="Python WSGI Documents" href="http://www.wsgi.org/wsgi/" target="_blank">WSGI</a> for Python and <a title="Ruby Rack Interface" href="http://rack.rubyforge.org/" target="_blank">Rack</a> for Ruby.</p>
<p><pre class="brush: ruby;">
# Ruby: Simple Rack app
require 'rack'

class HelloWorld
  def call(env)
    [200, {&quot;Content-Type&quot; =&gt; &quot;text/plain&quot;}, [&quot;Hello Rack!&quot;]]
  end
end
</pre></p>
<p>&nbsp;</p>
<p><pre class="brush: python;">
# Python: Simple WSGI app
def simple_app(environ, start_response):
  start_response('200 OK[', [('Content-type','text/plain')])
  return ['Hello world!\n']
</pre></p>
<p>I also tested a simple Python app using Rawr, a fairly well-tuned WSGI/webob micro framework that I developed for Rackspace. Last&#8211;but not least&#8211;I also benchmarked a simple &#8220;Hello World&#8221; <a title="Ruby Sinatra Web Micro-framework" href="http://www.sinatrarb.com/">Sinatra</a> app so I would have something to compare against Rawr.</p>
<p><pre class="brush: ruby;">
# Ruby: Sinatra app showing tested route
require 'sinatra'

get '/hello' do
  'Hello world!'
end
</pre></p>
<p>&nbsp;</p>
<p><pre class="brush: python;">
# Python: Rawr app showing tested route
from rax.http import rawr

class HealthController(rawr.Controller):
  &quot;&quot;&quot;Provides web service health info&quot;&quot;&quot;

def get(self):
  self.response.write(&quot;Alive and kicking!\n&quot;)

class TestApplication(rawr.Rawr):
  &quot;&quot;&quot;Test class for encapsulating initialization&quot;&quot;&quot;

  def __init__(self):
    rawr.Rawr.__init__(self)

    # Setup routes
    self.add_route(r&quot;/health$&quot;, HealthController),

app = TestApplication()
</pre></p>
<h2>Ruby vs. Python: Web Performance</h2>
<p>Everything was benchmarked by running multiple iterations of apache-bench from the terminal on my MBP. I used <a title="Green Unicorn Python Web Server" href="http://gunicorn.org/" target="_blank">Green Unicorn</a> as my test WSGI server, and <a title="Thin Ruby Web Server" href="http://code.macournoyer.com/thin/" target="_blank">Thin</a> for Rack apps.</p>
<p>WSGI (PyPy 1.6.0): ~5300 req/sec<br />
WSGI (Python 2.6.1): ~3200 req/sec<br />
WSGI (Python 2.7.2): ~3000 req/sec</p>
<p>Rack (Ruby 1.9.2 MRI):  ~4500 req/sec<br />
Rack (Ruby 1.8.7 MRI): ~4050 req/sec</p>
<p>Rawr/WSGI (PyPy 1.6.0): ~4900 req/sec<br />
Rawr/WSGI (Python 2.6.1): ~2750 req/sec<br />
Rawr/WSGI (Python 2.7.2): ~2700 req/sec</p>
<p>Sinatra/Rack (Ruby 1.9.2 MRI): ~1900 req/sec<br />
Sinatra/Rack (Ruby 1.8.7 MRI): ~1399 req/sec</p>
<h2>Ruby vs Python: Conclusions</h2>
<p><strong>Rack perf beats WSGI</strong> hands-down for standard Python (hooray!), although it is unclear how much of the difference is due to Green Unicorn vs. Thin. <a title="PyPy alternative Python implementation" href="http://pypy.org/" target="_blank">PyPy</a> is astoundingly fast, but Ruby 1.9.2 isn&#8217;t too far behind.</p>
<p>Also, it was interesting to see what a difference Ruby 1.9 made when there was a lot of code to run through (Sinatra). This difference can also be seen in the Rawr tests with PyPy vs. standard Python.</p>
<p>The <strong>bad news</strong> is that Sinatra was significantly slower than Rawr (booh!). Given the benchmarks for a straight Rack app, I have to wonder whether a Ruby port of Rawr is in order.</p>
<p><em>Note: This article outlines a simple test of GETs returning small amounts of text. Before choosing a language for your next project, you will undoubtedly want to do more extensive testing, especially around concurrency, object serialization, request/response body size, and POST/PUT performance. You should also see how things look when you put everything behind a reverse proxy and/or load balancer, such as Nginx.</em></p>
<br />Filed under: <a href='http://nerdfortress.com/category/codealicious/'>Codealicious</a>  <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gocomments/nerdfortress.wordpress.com/1425/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/comments/nerdfortress.wordpress.com/1425/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godelicious/nerdfortress.wordpress.com/1425/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/delicious/nerdfortress.wordpress.com/1425/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gofacebook/nerdfortress.wordpress.com/1425/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/facebook/nerdfortress.wordpress.com/1425/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gotwitter/nerdfortress.wordpress.com/1425/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/twitter/nerdfortress.wordpress.com/1425/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gostumble/nerdfortress.wordpress.com/1425/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/stumble/nerdfortress.wordpress.com/1425/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godigg/nerdfortress.wordpress.com/1425/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/digg/nerdfortress.wordpress.com/1425/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/goreddit/nerdfortress.wordpress.com/1425/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/reddit/nerdfortress.wordpress.com/1425/" /></a> <img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=nerdfortress.com&#038;blog=4772118&#038;post=1425&#038;subd=nerdfortress&#038;ref=&#038;feed=1" width="1" height="1" />]]></content:encoded>
			<wfw:commentRss>http://nerdfortress.com/2011/09/05/ruby-vs-python-vs-pypy-is-ruby-slower-than-python-for-web-development/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
	
		<media:content url="http://1.gravatar.com/avatar/50b7c50e71c508c9874184663384efb9?s=96&#38;d=http%3A%2F%2F1.gravatar.com%2Favatar%2Fad516503a11cd5ca435acc9bb6523536%3Fs%3D96&#38;r=G" medium="image">
			<media:title type="html">Random</media:title>
		</media:content>
	</item>
		<item>
		<title>When and How to Use Singletons</title>
		<link>http://nerdfortress.com/2011/03/29/when-to-use-the-singleton-design-pattern/</link>
		<comments>http://nerdfortress.com/2011/03/29/when-to-use-the-singleton-design-pattern/#comments</comments>
		<pubDate>Tue, 29 Mar 2011 14:07:11 +0000</pubDate>
		<dc:creator>Kurt</dc:creator>
				<category><![CDATA[Codealicious]]></category>

		<guid isPermaLink="false">http://nerdfortress.com/?p=1363</guid>
		<description><![CDATA[Is the singleton design pattern inherently flawed? I don&#8217;t think so. Can you abuse the singleton pattern? Certainly. Can you use it effectively? Absolutely. A few questions I ask myself when deciding whether singletons really should be singletons: Is the singleton external to my app? Databases, queuing services, and ESBs are all perfectly valid macro examples of [...]<img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=nerdfortress.com&#038;blog=4772118&#038;post=1363&#038;subd=nerdfortress&#038;ref=&#038;feed=1" width="1" height="1" />]]></description>
			<content:encoded><![CDATA[<p><a href="http://neil.fraser.name/"><img class="alignright size-thumbnail wp-image-1373" title="Photographs Not Allowed by Neil Fraser" src="http://nerdfortress.files.wordpress.com/2011/03/nophoto-neil-fraser-name.jpg?w=150&h=112" alt="Sometimes you have to break conventional wisdom with the singleton design pattern" width="150" height="112" /></a>Is the singleton design pattern <a title="Are Singletons a Bad Idea?" href="http://stackoverflow.com/questions/1020312/are-singletons-really-that-bad/1020384#1020384" target="_blank">inherently flawed</a>? I don&#8217;t think so.</p>
<p>Can you abuse the singleton pattern? Certainly. Can you use it effectively? Absolutely.</p>
<p>A few questions I ask myself when deciding whether singletons <em>really should</em> be singletons:</p>
<ol>
<li>Is the singleton external to my app? Databases, queuing services, and ESBs are all perfectly valid macro examples of the singleton pattern.</li>
<li>KISS: Is my entire app limited to 2-3 internal singletons?</li>
<li><a title="Learn other ways to apply DRY by reading the Pragmatic Programmer " href="http://amzn.to/hgRULZ" target="_blank">DRY</a>: Are my singletons inherently global? In other words, if they <em>weren&#8217;t</em> singletons, would I have to plumb references to them into almost every object? (e.g., a logger or mediator)?</li>
<li>Do my singletons depend only on each other, and/or the operating environment?</li>
<li>Have I ensured proper start-up and shut-down sequences for each singleton, including memory management considerations? For example, a &#8220;Grand Central&#8221;-style thread pool may require Run() and Shutdown() methods. These methods would be invoked during app startup and shutdown, so that tasks are guaranteed to run only when the objects they operate on are in a valid state.</li>
</ol>
<div><strong><br />
</strong></div>
<br />Filed under: <a href='http://nerdfortress.com/category/codealicious/'>Codealicious</a>  <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gocomments/nerdfortress.wordpress.com/1363/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/comments/nerdfortress.wordpress.com/1363/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godelicious/nerdfortress.wordpress.com/1363/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/delicious/nerdfortress.wordpress.com/1363/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gofacebook/nerdfortress.wordpress.com/1363/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/facebook/nerdfortress.wordpress.com/1363/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gotwitter/nerdfortress.wordpress.com/1363/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/twitter/nerdfortress.wordpress.com/1363/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gostumble/nerdfortress.wordpress.com/1363/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/stumble/nerdfortress.wordpress.com/1363/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godigg/nerdfortress.wordpress.com/1363/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/digg/nerdfortress.wordpress.com/1363/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/goreddit/nerdfortress.wordpress.com/1363/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/reddit/nerdfortress.wordpress.com/1363/" /></a> <img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=nerdfortress.com&#038;blog=4772118&#038;post=1363&#038;subd=nerdfortress&#038;ref=&#038;feed=1" width="1" height="1" />]]></content:encoded>
			<wfw:commentRss>http://nerdfortress.com/2011/03/29/when-to-use-the-singleton-design-pattern/feed/</wfw:commentRss>
		<slash:comments>1</slash:comments>
	
		<media:content url="http://1.gravatar.com/avatar/50b7c50e71c508c9874184663384efb9?s=96&#38;d=http%3A%2F%2F1.gravatar.com%2Favatar%2Fad516503a11cd5ca435acc9bb6523536%3Fs%3D96&#38;r=G" medium="image">
			<media:title type="html">Random</media:title>
		</media:content>

		<media:content url="http://nerdfortress.files.wordpress.com/2011/03/nophoto-neil-fraser-name.jpg?w=150" medium="image">
			<media:title type="html">Photographs Not Allowed by Neil Fraser</media:title>
		</media:content>
	</item>
		<item>
		<title>You say semaphore, I say mutex</title>
		<link>http://nerdfortress.com/2011/02/18/you-say-semaphore-i-say-mutex/</link>
		<comments>http://nerdfortress.com/2011/02/18/you-say-semaphore-i-say-mutex/#comments</comments>
		<pubDate>Fri, 18 Feb 2011 14:10:11 +0000</pubDate>
		<dc:creator>Kurt</dc:creator>
				<category><![CDATA[Codealicious]]></category>

		<guid isPermaLink="false">http://nerdfortress.com/?p=1263</guid>
		<description><![CDATA[Suppose you are interviewing a candidate&#8211;let&#8217;s call him Ben&#8211;for a programming job and you ask the well-worn question:   What&#8217;s the difference between a mutex and a semaphore? Ben:   The difference between a mutex and a semaphore? Well, a mutex allows only one thread at a time, while a semaphore can allow several threads [...]<img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=nerdfortress.com&#038;blog=4772118&#038;post=1263&#038;subd=nerdfortress&#038;ref=&#038;feed=1" width="1" height="1" />]]></description>
			<content:encoded><![CDATA[<p>Suppose you are interviewing a candidate&#8211;let&#8217;s call him Ben&#8211;for a programming job and you ask the well-worn question:<br />
<code> </code></p>
<blockquote><p>What&#8217;s the difference between a mutex and a semaphore?</p></blockquote>
<p>Ben:<br />
<code> </code></p>
<blockquote><p>The difference between a mutex and a semaphore? Well, a mutex allows only one thread at a time, while a semaphore can allow several threads to run at the same time.</p></blockquote>
<p>Now, you&#8217;d like to probe a little deeper, so you follow up with:<br />
<code> </code></p>
<blockquote><p>OK. Can you give me an example of when you would use a semaphore instead of a mutex?</p></blockquote>
<p>Ben thinks for a moment. This one&#8217;s a little harder to answer, but he remembers something he read once on the Internets:<br />
<code>  </code></p>
<blockquote><p>Yeah, sure. You would use a semaphore when you need to control access to more than one resource. For example, if you&#8217;ve got a gas station with one restroom, you would only need one key, since only one person at a time can use the bathroom. You could use a mutex for that, which is basically just a binary semaphore.</p>
<p>Now, if your gas station had more than one restroom, you would need to use a semaphore so that more than one person could take care of business at the same time.</p></blockquote>
<p>Not bad. But there&#8217;s a better answer.</p>
<p>The differences between a semaphore and a mutex are more subtle than most programmers realize. And, as we all know, Subtle Things have a way of turning themselves into Bad Things when nobody happens to be paying attention to them. Fortunately, you can (mostly) avoid the whole mess by following two simple rules of thumb:<br />
<code> </code></p>
<blockquote><p>Thow shalt use the mutex to protect all thy possessions that thou hast in common among you. This is the first and greatest commandment, and the second is like unto it. Thou shalt use the mutex and the condition variable to signal all thy workers in the field.</p>
<p>On these two commandments hang all the threads and the programs.</p></blockquote>
<p>Semaphores have two traits that are particularly problematic. First, semaphores&#8211;as opposed to mutexes&#8211;have no notion of lock ownership. In other words, one thread can unlock a semaphore that was previously locked by a different thread. This is <em>bad mojo</em>.</p>
<p>In my house I have a very active 2-year old son. Now, as you may or may not know, 2-year olds are (a) too old to sleep in cribs (they just climb out), and (b) too young to stay put in a regular bed. This poses some unfortunate challenges at bed time. The solution? Turn out the lights and lock the bedroom door! Hooray! Eventually the kid will get bored and go to sleep! (This is what sleep-deprived parents everywhere desperately pray, as they lie silently in their beds.)</p>
<p>Unfortunately, 2-year olds have one more trait I didn&#8217;t mention: they are, without a doubt, too smart for their own good. This situation is compounded by the fact that the toddler in question happens to share his room with a big-brother (6 years old), who understandably finds it less-than-ideal to be locked in his own room, and who is also too smart for his own good.</p>
<p>It doesn&#8217;t take long for Big Brother to hack his way out of the room using a clip-on tie (hey, they&#8217;re stylish <em>and</em> practical!).</p>
<p>Semaphores, as it turns out, are surprisingly similar to locks on bedroom doors of ambitious children. It is really hard to ensure that once one thread (Dad) locks a semaphore, you don&#8217;t &#8220;accidentally&#8221; get another thread (Big Brother) unlocking it.</p>
<p>But wait! There&#8217;s more! Semaphores have yet one more issue, related to the first. It&#8217;s called Priority Inversion™. There&#8217;s actually a great little <a title="Priority Inversion and Semaphores" href="http://msdn.microsoft.com/en-us/library/aa450594.aspx">Windows CE article</a> (yes, Windows CE of all things) over at MSDN that does a decent job explaining the problem:<br />
<code>  </code></p>
<blockquote><p><em>Priority inversion</em> occurs when a mutex, critical section, or semaphore resource held by a lower-priority thread delays the execution of a higher-priority thread when both are contending for the same resource.</p>
<p>For mutexes and critical sections, to correct this situation and free the higher-priority thread, with priority inheritance, Windows CE enables the lower-priority thread to inherit the more critical thread&#8217;s priority and run at the higher priority until it releases its use of the resource. This mechanism does not work for semaphores, which do not have a specific owner associated with them. Therefore, priority inversion may occur when using semaphores.</p>
<p>Because an unbounded amount of time is needed to relinquish the inverted thread and it is out of the control of the kernel, the OEM loses control of the scheduling process. To guarantee real-time performance, OEMs should ensure that a priority inversion condition does not occur.</p></blockquote>
<p>Note that last line: &#8220;&#8230;[you] should ensure that a priority inversion condition does not occur.&#8221; Right. That sounds like a blast.</p>
<p>The bottom line is this: semaphores can be a royal pain. Fortunately, there are ways to avoid ever having to employ the little beasties:</p>
<ol>
<li>For managing access to a shared resource where only ONE thread should be working with the resource at any one time, simply use a mutex. Note here that a mutex != a semaphore with a count of 1.</li>
<li>If you are implementing a classic producer/consumer model with a thread pool, strongly consider using a combination of a condition variable and mutex. Chances are that the threading library you are using supports this natively (e.g., <a title="pthread condition variables tutorial" href="https://computing.llnl.gov/tutorials/pthreads/#ConditionVariables">pthread</a>, <a title="Boost threading condition variable" href="http://www.boost.org/doc/libs/1_45_0/doc/html/thread/synchronization.html#thread.synchronization.condvar_ref">Boost</a>, <a title="Win32 condition variables" href="http://msdn.microsoft.com/en-us/library/ms682052(VS.85).aspx">Win32</a>, <a title=".NET condition variables" href="http://stackoverflow.com/questions/1986055/condition-variables-in-c">.NET</a>).</li>
<li>Do something wild and crazy, like <a title="Erlang vs. Threads" href="http://www.eecs.berkeley.edu/Pubs/TechRpts/2006/EECS-2006-1.pdf">switch to Erlang</a>.</li>
</ol>
<p><em>Bonus!</em> You can choose from several specialized locks that can be more performant in certain situations, such as <a href="http://msdn.microsoft.com/en-us/library/ms682530(VS.85).aspx">critical sections</a> and multi-reader/single-writer locks. Any threading library worth its salt will support at least one or two specialized locks.</p>
<p>So, now that we&#8217;ve covered when <em>not</em> to use a semaphore, the question becomes: when <em>should</em> you use a semaphore? Honestly, I have no idea.</p>
<br />Filed under: <a href='http://nerdfortress.com/category/codealicious/'>Codealicious</a>  <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gocomments/nerdfortress.wordpress.com/1263/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/comments/nerdfortress.wordpress.com/1263/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godelicious/nerdfortress.wordpress.com/1263/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/delicious/nerdfortress.wordpress.com/1263/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gofacebook/nerdfortress.wordpress.com/1263/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/facebook/nerdfortress.wordpress.com/1263/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gotwitter/nerdfortress.wordpress.com/1263/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/twitter/nerdfortress.wordpress.com/1263/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gostumble/nerdfortress.wordpress.com/1263/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/stumble/nerdfortress.wordpress.com/1263/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godigg/nerdfortress.wordpress.com/1263/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/digg/nerdfortress.wordpress.com/1263/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/goreddit/nerdfortress.wordpress.com/1263/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/reddit/nerdfortress.wordpress.com/1263/" /></a> <img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=nerdfortress.com&#038;blog=4772118&#038;post=1263&#038;subd=nerdfortress&#038;ref=&#038;feed=1" width="1" height="1" />]]></content:encoded>
			<wfw:commentRss>http://nerdfortress.com/2011/02/18/you-say-semaphore-i-say-mutex/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
	
		<media:content url="http://1.gravatar.com/avatar/50b7c50e71c508c9874184663384efb9?s=96&#38;d=http%3A%2F%2F1.gravatar.com%2Favatar%2Fad516503a11cd5ca435acc9bb6523536%3Fs%3D96&#38;r=G" medium="image">
			<media:title type="html">Random</media:title>
		</media:content>
	</item>
		<item>
		<title>Behind the Scenes of the C++ STL Algorithm Model</title>
		<link>http://nerdfortress.com/2010/08/17/behind-the-scenes-of-the-c-stl-algorithm-model/</link>
		<comments>http://nerdfortress.com/2010/08/17/behind-the-scenes-of-the-c-stl-algorithm-model/#comments</comments>
		<pubDate>Tue, 17 Aug 2010 17:17:17 +0000</pubDate>
		<dc:creator>Kurt</dc:creator>
				<category><![CDATA[Codealicious]]></category>

		<guid isPermaLink="false">http://nerdfortress.com/?p=1217</guid>
		<description><![CDATA[Ever wonder why the C++ STL uses an external, non-member function model for implementing algorithms for containers? The following article sums it up. Although a few of the &#8220;no less efficient&#8221; examples are debatable, the underlying principles definitely have merit. Monoliths &#8220;Unstrung&#8221; One downside to the functional approach outlined in the article&#8211;that I didn&#8217;t see mentioned&#8211;is [...]<img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=nerdfortress.com&#038;blog=4772118&#038;post=1217&#038;subd=nerdfortress&#038;ref=&#038;feed=1" width="1" height="1" />]]></description>
			<content:encoded><![CDATA[<p>Ever wonder why the C++ STL uses an external, non-member function model for implementing algorithms for containers? The following article sums it up. Although a few of the &#8220;no less efficient&#8221; examples are debatable, the underlying principles definitely have merit.</p>
<p><a href="http://www.gotw.ca/gotw/084.htm" target="_blank">Monoliths &#8220;Unstrung&#8221;</a></p>
<p>One downside to the functional approach outlined in the article&#8211;that I didn&#8217;t see mentioned&#8211;is the fact that the interface is actually being split in a few cases, which is actually detrimental to cohesion. This happens when you have multiple overloaded forms of a function, and you keep one &#8220;flexible&#8221; one as a member function, but make the others external functions. Why not keep those as members for the sake of consistency? You can still implement them in terms of the one &#8220;flexible&#8221; member function, thereby continuing to ensure good encapsulation.</p>
<p>A few thoughts on applying the spirit of the law discussed in the article to other languages:</p>
<ul>
<li><strong>C#</strong> &#8211; Use extension methods, but the &#8220;this&#8221; type should be as generic as possible. You still get the benefits of DRY but in a more object-oriented fashion that works well with Intellisense and cohesion. I like the extension  method approach better than the old static-methods approach (e.g., string.Join) because it still enforces good encapsulation, and is less verbose and more cohesive than the alternative.</li>
<li><strong>Ruby</strong> &#8211; Use mix-ins that use duct-type delegation to other methods. These can be automatically mixed into all applicable classes when the mix-in is &#8220;required&#8221;.</li>
<li><strong>Lisp</strong> &#8211; Brilliant! All you <em>have </em>are functions!</li>
</ul>
<p>It&#8217;s also important to note the power you derive from combining this functional approach with lambda functions,  function objects, and covariance.</p>
<p><em>See also: </em><a href="http://www.drdobbs.com/184401197" target="_blank"><em>How Non-Member Functions Improve Encapsulation</em></a></p>
<br />Filed under: <a href='http://nerdfortress.com/category/codealicious/'>Codealicious</a>  <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gocomments/nerdfortress.wordpress.com/1217/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/comments/nerdfortress.wordpress.com/1217/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godelicious/nerdfortress.wordpress.com/1217/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/delicious/nerdfortress.wordpress.com/1217/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gofacebook/nerdfortress.wordpress.com/1217/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/facebook/nerdfortress.wordpress.com/1217/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gotwitter/nerdfortress.wordpress.com/1217/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/twitter/nerdfortress.wordpress.com/1217/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gostumble/nerdfortress.wordpress.com/1217/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/stumble/nerdfortress.wordpress.com/1217/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godigg/nerdfortress.wordpress.com/1217/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/digg/nerdfortress.wordpress.com/1217/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/goreddit/nerdfortress.wordpress.com/1217/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/reddit/nerdfortress.wordpress.com/1217/" /></a> <img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=nerdfortress.com&#038;blog=4772118&#038;post=1217&#038;subd=nerdfortress&#038;ref=&#038;feed=1" width="1" height="1" />]]></content:encoded>
			<wfw:commentRss>http://nerdfortress.com/2010/08/17/behind-the-scenes-of-the-c-stl-algorithm-model/feed/</wfw:commentRss>
		<slash:comments>1</slash:comments>
	
		<media:content url="http://1.gravatar.com/avatar/50b7c50e71c508c9874184663384efb9?s=96&#38;d=http%3A%2F%2F1.gravatar.com%2Favatar%2Fad516503a11cd5ca435acc9bb6523536%3Fs%3D96&#38;r=G" medium="image">
			<media:title type="html">Random</media:title>
		</media:content>
	</item>
		<item>
		<title>WCF Madness: Method Not Allowed on Missing Query Parameter</title>
		<link>http://nerdfortress.com/2010/02/13/wcf-madness-method-not-allowed-on-missing-query-parameter/</link>
		<comments>http://nerdfortress.com/2010/02/13/wcf-madness-method-not-allowed-on-missing-query-parameter/#comments</comments>
		<pubDate>Sat, 13 Feb 2010 16:53:52 +0000</pubDate>
		<dc:creator>Kurt</dc:creator>
				<category><![CDATA[Codealicious]]></category>

		<guid isPermaLink="false">http://nerdfortress.com/?p=1185</guid>
		<description><![CDATA[While testing some web services, I was not-so-pleasantly surprised to find that WCF cannot disambiguate two methods when one is a GET nd the other a POST: [OperationContract] [WebDispatchFormatter] [WebGet(UriTemplate = "/{encodedGameId}?startDate={startDate}&#38;endDate={endDate}&#38;tag={tag}")] Contracts.Out.Statistics GetStatistics(string gameId, string startDate, string endDate, string tag); [OperationContract] [WebInvoke(UriTemplate = "/{encodedGameId}", Method = Verbs.Post)] void AddSample(string gameId, Contracts.Sample newSample); [WebDispatchFormatter] If [...]<img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=nerdfortress.com&#038;blog=4772118&#038;post=1185&#038;subd=nerdfortress&#038;ref=&#038;feed=1" width="1" height="1" />]]></description>
			<content:encoded><![CDATA[<p><a href="http://nerdfortress.files.wordpress.com/2010/02/curved-yellow-fruit.jpg"><img src="http://nerdfortress.files.wordpress.com/2010/02/curved-yellow-fruit.jpg?w=150&h=105" alt="" title="curved-yellow-fruit" width="150" height="105" class="alignright size-thumbnail wp-image-1191" /></a>While testing some web services, I was not-so-pleasantly surprised to find that WCF cannot disambiguate two methods when one is a GET nd the other a POST:<br />
	<code><br />
        [OperationContract]<br />
	[WebDispatchFormatter]<br />
	[WebGet(UriTemplate = "/{encodedGameId}?startDate={startDate}&amp;endDate={endDate}&amp;tag={tag}")]<br />
	Contracts.Out.Statistics GetStatistics(string gameId, string startDate, string endDate, string tag);</p>
<p>	[OperationContract]<br />
	[WebInvoke(UriTemplate = "/{encodedGameId}", Method = Verbs.Post)]<br />
	void AddSample(string gameId, Contracts.Sample newSample);<br />
	[WebDispatchFormatter]</code></p>
<p>If you leave off any of the query parameters for GetStatistics, WCF cheerfully returns &#8220;Method not allowed&#8221;. I wanted to make the &#8220;tag&#8221; parameter optional, and worried this would be a deal breaker.</p>
<p>Fortunately, I came across this <a href="http://blogs.msdn.com/rjacobs/archive/2009/02/10/ambiguous-uritemplates-query-parameters-and-integration-testing.aspx">WCF post by Ron Jacobs</a>.</p>
<p>The basic idea is to leave off the optional query parameters in the UriTemplate, instead manually pulling them from the current request context. This approach is actually similar to the way you access query parameters in RoR, so I should have thought of doing it like this in the first place.</p>
<p>In fact, if you beef up Ron&#8217;s QueryString class, it can clean help you DRY up your code by taking care of data type conversions on the sly.</p>
<p>The moral of the story is that a framework&#8217;s design can induce sneaky biases that you only discover as they jump out of the shadows to bite you.</p>
<p>Thanks Ron!</p>
<br />Filed under: <a href='http://nerdfortress.com/category/codealicious/'>Codealicious</a>  <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gocomments/nerdfortress.wordpress.com/1185/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/comments/nerdfortress.wordpress.com/1185/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godelicious/nerdfortress.wordpress.com/1185/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/delicious/nerdfortress.wordpress.com/1185/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gofacebook/nerdfortress.wordpress.com/1185/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/facebook/nerdfortress.wordpress.com/1185/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gotwitter/nerdfortress.wordpress.com/1185/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/twitter/nerdfortress.wordpress.com/1185/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gostumble/nerdfortress.wordpress.com/1185/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/stumble/nerdfortress.wordpress.com/1185/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godigg/nerdfortress.wordpress.com/1185/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/digg/nerdfortress.wordpress.com/1185/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/goreddit/nerdfortress.wordpress.com/1185/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/reddit/nerdfortress.wordpress.com/1185/" /></a> <img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=nerdfortress.com&#038;blog=4772118&#038;post=1185&#038;subd=nerdfortress&#038;ref=&#038;feed=1" width="1" height="1" />]]></content:encoded>
			<wfw:commentRss>http://nerdfortress.com/2010/02/13/wcf-madness-method-not-allowed-on-missing-query-parameter/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
	
		<media:content url="http://1.gravatar.com/avatar/50b7c50e71c508c9874184663384efb9?s=96&#38;d=http%3A%2F%2F1.gravatar.com%2Favatar%2Fad516503a11cd5ca435acc9bb6523536%3Fs%3D96&#38;r=G" medium="image">
			<media:title type="html">Random</media:title>
		</media:content>

		<media:content url="http://nerdfortress.files.wordpress.com/2010/02/curved-yellow-fruit.jpg?w=150" medium="image">
			<media:title type="html">curved-yellow-fruit</media:title>
		</media:content>
	</item>
		<item>
		<title>2D Scripting: Choosing a 2D Engine Scripting Language</title>
		<link>http://nerdfortress.com/2009/09/24/2d-scripting-choosing-a-2d-engine-scripting-language/</link>
		<comments>http://nerdfortress.com/2009/09/24/2d-scripting-choosing-a-2d-engine-scripting-language/#comments</comments>
		<pubDate>Thu, 24 Sep 2009 12:48:41 +0000</pubDate>
		<dc:creator>Kurt</dc:creator>
				<category><![CDATA[Codealicious]]></category>
		<category><![CDATA[Indie Games]]></category>

		<guid isPermaLink="false">http://nerdfortress.com/?p=975</guid>
		<description><![CDATA[What scripting language would you choose for a 2D game engine? Take a couple seconds and vote now (the poll is in the sidebar). I don&#8217;t want to bias anyone, so I will save my discussion of the pros and cons of each language for later. Posted in Codealicious, Indie Games<img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=nerdfortress.com&#038;blog=4772118&#038;post=975&#038;subd=nerdfortress&#038;ref=&#038;feed=1" width="1" height="1" />]]></description>
			<content:encoded><![CDATA[<p>What scripting language would you choose for a <a href="http://nerdfortress.com/2009/08/26/2d-game-editor-project/" target="_blank">2D game engine</a>? Take a couple seconds and vote now (the poll is in the sidebar). I don&#8217;t want to bias anyone, so I will save my discussion of the pros and cons of each language for later.</p>
<br />Posted in Codealicious, Indie Games  <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gocomments/nerdfortress.wordpress.com/975/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/comments/nerdfortress.wordpress.com/975/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godelicious/nerdfortress.wordpress.com/975/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/delicious/nerdfortress.wordpress.com/975/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gofacebook/nerdfortress.wordpress.com/975/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/facebook/nerdfortress.wordpress.com/975/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gotwitter/nerdfortress.wordpress.com/975/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/twitter/nerdfortress.wordpress.com/975/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gostumble/nerdfortress.wordpress.com/975/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/stumble/nerdfortress.wordpress.com/975/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godigg/nerdfortress.wordpress.com/975/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/digg/nerdfortress.wordpress.com/975/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/goreddit/nerdfortress.wordpress.com/975/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/reddit/nerdfortress.wordpress.com/975/" /></a> <img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=nerdfortress.com&#038;blog=4772118&#038;post=975&#038;subd=nerdfortress&#038;ref=&#038;feed=1" width="1" height="1" />]]></content:encoded>
			<wfw:commentRss>http://nerdfortress.com/2009/09/24/2d-scripting-choosing-a-2d-engine-scripting-language/feed/</wfw:commentRss>
		<slash:comments>1</slash:comments>
	
		<media:content url="http://1.gravatar.com/avatar/50b7c50e71c508c9874184663384efb9?s=96&#38;d=http%3A%2F%2F1.gravatar.com%2Favatar%2Fad516503a11cd5ca435acc9bb6523536%3Fs%3D96&#38;r=G" medium="image">
			<media:title type="html">Random</media:title>
		</media:content>
	</item>
		<item>
		<title>Hex Words: How to Generate Hex Words</title>
		<link>http://nerdfortress.com/2009/04/16/hex-words-how-to-generate-hex-words/</link>
		<comments>http://nerdfortress.com/2009/04/16/hex-words-how-to-generate-hex-words/#comments</comments>
		<pubDate>Fri, 17 Apr 2009 01:02:14 +0000</pubDate>
		<dc:creator>Kurt</dc:creator>
				<category><![CDATA[Codealicious]]></category>

		<guid isPermaLink="false">http://nerdfortress.com/?p=554</guid>
		<description><![CDATA[I always got a kick out of hex words (words that only use hexadecimal characters). If you are similarly deranged, Ned Batchelder has generated an awesome list of hex words for your viewing pleasure: Lots of these words are obscure, and therefore useless. For example, what&#8217;s an abaca? Perfect for making your own T-Shirt. Like, [...]<img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=nerdfortress.com&#038;blog=4772118&#038;post=554&#038;subd=nerdfortress&#038;ref=&#038;feed=1" width="1" height="1" />]]></description>
			<content:encoded><![CDATA[<p>I always got a kick out of hex words (words that only use hexadecimal characters). If you are similarly deranged, Ned Batchelder has generated an awesome <a href="http://nedbatchelder.com/text/hexwords.html" target="_blank">list of hex words</a> for your viewing pleasure:</p>
<blockquote>
<p>Lots of these words are obscure, and therefore useless. For example, what&#8217;s an abaca?</p></blockquote>
<p>Perfect for making your own T-Shirt. Like, you could put <strong>7e55e118</strong> below a <a href="http://en.wikipedia.org/wiki/Polygon_mesh" target="_blank">mesh</a> , and only CG hackers would understand.</p>
<br />Posted in Codealicious  <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gocomments/nerdfortress.wordpress.com/554/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/comments/nerdfortress.wordpress.com/554/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godelicious/nerdfortress.wordpress.com/554/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/delicious/nerdfortress.wordpress.com/554/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gofacebook/nerdfortress.wordpress.com/554/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/facebook/nerdfortress.wordpress.com/554/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gotwitter/nerdfortress.wordpress.com/554/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/twitter/nerdfortress.wordpress.com/554/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gostumble/nerdfortress.wordpress.com/554/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/stumble/nerdfortress.wordpress.com/554/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godigg/nerdfortress.wordpress.com/554/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/digg/nerdfortress.wordpress.com/554/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/goreddit/nerdfortress.wordpress.com/554/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/reddit/nerdfortress.wordpress.com/554/" /></a> <img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=nerdfortress.com&#038;blog=4772118&#038;post=554&#038;subd=nerdfortress&#038;ref=&#038;feed=1" width="1" height="1" />]]></content:encoded>
			<wfw:commentRss>http://nerdfortress.com/2009/04/16/hex-words-how-to-generate-hex-words/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
	
		<media:content url="http://1.gravatar.com/avatar/50b7c50e71c508c9874184663384efb9?s=96&#38;d=http%3A%2F%2F1.gravatar.com%2Favatar%2Fad516503a11cd5ca435acc9bb6523536%3Fs%3D96&#38;r=G" medium="image">
			<media:title type="html">Random</media:title>
		</media:content>
	</item>
		<item>
		<title>Debugging Windows BSOD Crashes</title>
		<link>http://nerdfortress.com/2009/01/06/debugging-windows-bsod-crashes/</link>
		<comments>http://nerdfortress.com/2009/01/06/debugging-windows-bsod-crashes/#comments</comments>
		<pubDate>Tue, 06 Jan 2009 20:50:28 +0000</pubDate>
		<dc:creator>Kurt</dc:creator>
				<category><![CDATA[Codealicious]]></category>

		<guid isPermaLink="false">http://nerdfortress.com/?p=378</guid>
		<description><![CDATA[What many people don&#8217;t know about Windows BSOD crashes is that almost all of them are caused by third-party drivers. In fact, given the millions of Windows-compatible devices out there, it&#8217;s a miracle of modern (computer) science that the Redmond OS runs at all! No other operating system can match Windows for the number of [...]<img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=nerdfortress.com&#038;blog=4772118&#038;post=378&#038;subd=nerdfortress&#038;ref=&#038;feed=1" width="1" height="1" />]]></description>
			<content:encoded><![CDATA[<p>What many people don&#8217;t know about Windows BSOD crashes is that almost all of them are caused by third-party drivers. In fact, given the millions of Windows-compatible devices out there, it&#8217;s a miracle of modern (computer) science that the Redmond OS runs at all!<span id="more-378"></span></p>
<p>No other operating system can match Windows for the number of devices supported, but it definitely comes with a trade-off. If you have fallen prey to a poorly-written driver, don&#8217;t despair! All you need to do is whip out your trusty copy of WinDbg, and within a few minutes that wimpy driver will cower before your superior kernel ninja skills!</p>
<p><a href="http://www.networkworld.com/news/2005/041105-windows-crash.html?page=1" target="_blank">Learn how to debug Windows BSOD crashes</a>. Also, here is <a href="http://www.debuginfo.com/articles/easywindbg.html" target="_blank">a more general tutorial on WinDbg</a>.</p>
<p>Now, once you&#8217;ve found the culprit, you have three options. Choose wisely:</p>
<ol>
<li>Get the latest driver from Windows Update or the device manufacturer&#8217;s website.</li>
<li>Replace the rogue device with something from a company who actually tests their hardware before shipping it.</li>
<li>Buy a Mac. They never crash, right?</li>
</ol>
<br />Posted in Codealicious  <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gocomments/nerdfortress.wordpress.com/378/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/comments/nerdfortress.wordpress.com/378/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godelicious/nerdfortress.wordpress.com/378/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/delicious/nerdfortress.wordpress.com/378/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gofacebook/nerdfortress.wordpress.com/378/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/facebook/nerdfortress.wordpress.com/378/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gotwitter/nerdfortress.wordpress.com/378/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/twitter/nerdfortress.wordpress.com/378/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gostumble/nerdfortress.wordpress.com/378/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/stumble/nerdfortress.wordpress.com/378/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godigg/nerdfortress.wordpress.com/378/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/digg/nerdfortress.wordpress.com/378/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/goreddit/nerdfortress.wordpress.com/378/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/reddit/nerdfortress.wordpress.com/378/" /></a> <img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=nerdfortress.com&#038;blog=4772118&#038;post=378&#038;subd=nerdfortress&#038;ref=&#038;feed=1" width="1" height="1" />]]></content:encoded>
			<wfw:commentRss>http://nerdfortress.com/2009/01/06/debugging-windows-bsod-crashes/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
	
		<media:content url="http://1.gravatar.com/avatar/50b7c50e71c508c9874184663384efb9?s=96&#38;d=http%3A%2F%2F1.gravatar.com%2Favatar%2Fad516503a11cd5ca435acc9bb6523536%3Fs%3D96&#38;r=G" medium="image">
			<media:title type="html">Random</media:title>
		</media:content>
	</item>
		<item>
		<title>Linux XFS Does not Support dirent::d_type</title>
		<link>http://nerdfortress.com/2008/09/19/linux-xfs-does-not-support-direntd_type/</link>
		<comments>http://nerdfortress.com/2008/09/19/linux-xfs-does-not-support-direntd_type/#comments</comments>
		<pubDate>Fri, 19 Sep 2008 19:02:41 +0000</pubDate>
		<dc:creator>Kurt</dc:creator>
				<category><![CDATA[Codealicious]]></category>

		<guid isPermaLink="false">http://nerdfortress.wordpress.com/?p=156</guid>
		<description><![CDATA[Recently at work we had a couple customers mention to us that while backing up files on Linux, symlinks and FIFO (names pipe) files were not being skipped. Trying to backup a FIFO is what we call a bad idea. Very, very bad. One customer reported that most of his filesystems were XFS. Sure enough, [...]<img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=nerdfortress.com&#038;blog=4772118&#038;post=156&#038;subd=nerdfortress&#038;ref=&#038;feed=1" width="1" height="1" />]]></description>
			<content:encoded><![CDATA[<p>Recently <a href="http://jungledisk.com/" target="_blank">at work</a> we had a couple customers mention to us that while backing up files on Linux, symlinks and <a href="http://linux.about.com/library/cmd/blcmdl4_fifo.htm" target="_blank">FIFO (names pipe) files</a> were not being skipped. Trying to backup a FIFO is what we call a <em>bad idea</em>. Very, very bad. <span id="more-156"></span>One customer reported that most of his filesystems were XFS. Sure enough, after some digging around and testing, I happened to discover this most <em>useful</em> bit of information:</p>
<p><strong>XFS does not support dirent::d_type</strong></p>
<p>What the?! In other words, a line such as this will always be false:</p>
<pre><strong>de-&gt;d_type == DT_FIFO</strong></pre>
<p>Jungle Disk uses <a href="http://www.kernel.org/doc/man-pages/online/pages/man3/readdir.3.html" target="_blank">readdir_r()</a> to list files and check their types. Uh oh. That means that on XFS partitions, everything looks like a regular file! You can see this for yourself using code like this:</p>
<p><pre class="brush: cpp;">#include &lt;iostream&gt;
#include &lt;cstdlib&gt;
#include &lt;dirent.h&gt;
#include &lt;sys/stat.h&gt;

using namespace std;

int main(int argc, char *argv[])
{

  dirent holdde;
  dirent *de;
  struct stat st;

  cout &lt;&lt; &quot;DT_BLK = &quot; &lt;&lt; DT_BLK &lt;&lt; endl;
  cout &lt;&lt; &quot;DT_CHR = &quot; &lt;&lt; DT_CHR &lt;&lt; endl;
  cout &lt;&lt; &quot;DT_DIR = &quot; &lt;&lt; DT_DIR &lt;&lt; endl;
  cout &lt;&lt; &quot;DT_FIFO = &quot; &lt;&lt; DT_FIFO &lt;&lt; endl;
  cout &lt;&lt; &quot;DT_LNK = &quot; &lt;&lt; DT_LNK &lt;&lt; endl;
  cout &lt;&lt; &quot;DT_REG = &quot; &lt;&lt; DT_REG &lt;&lt; endl;
  cout &lt;&lt; &quot;DT_SOCK = &quot; &lt;&lt; DT_SOCK &lt;&lt; endl;
  cout &lt;&lt; &quot;DT_UNKNOWN = &quot; &lt;&lt; DT_LNK &lt;&lt; endl;

  DIR *dir = opendir(&quot;/home/vmuser/xfs&quot;);
  while (readdir_r(dir, &amp;holdde, &amp;de) == 0 &amp;&amp; de)
  {
	  cout &lt;&lt; de-&gt;d_name &lt;&lt; &quot; [&quot; &lt;&lt; (int)de-&gt;d_type &lt;&lt; &quot;] &quot; &lt;&lt; endl;
  }
  closedir(dir);

  lstat(&quot;/home/vmuser/xfs/TESTFIFO&quot;, &amp;st);
  if (S_ISFIFO(st.st_mode))
	  cout &lt;&lt; &quot;XFS FIFO detected: &quot; &lt;&lt; st.st_mode &lt;&lt; endl; 

  lstat(&quot;/home/vmuser/ext3/TESTFIFO&quot;, &amp;st);
  if ((st.st_mode &amp; S_IFIFO) != 0)
	  cout &lt;&lt; &quot;EXT3 FIFO detected: &quot; &lt;&lt; st.st_mode &lt;&lt; endl; 

  return EXIT_SUCCESS;
}</pre></p>
<p>So what&#8217;s the solution? Good old, reliable <a href="http://www.kernel.org/doc/man-pages/online/pages/man2/stat.2.html" target="_blank">stat()</a>. That function <em>does</em> work with XFS on Linux. Unfortunately, this means you will have to make an extra call for each file after listing the dir.</p>
<br />Posted in Codealicious  <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gocomments/nerdfortress.wordpress.com/156/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/comments/nerdfortress.wordpress.com/156/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godelicious/nerdfortress.wordpress.com/156/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/delicious/nerdfortress.wordpress.com/156/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gofacebook/nerdfortress.wordpress.com/156/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/facebook/nerdfortress.wordpress.com/156/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gotwitter/nerdfortress.wordpress.com/156/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/twitter/nerdfortress.wordpress.com/156/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gostumble/nerdfortress.wordpress.com/156/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/stumble/nerdfortress.wordpress.com/156/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godigg/nerdfortress.wordpress.com/156/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/digg/nerdfortress.wordpress.com/156/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/goreddit/nerdfortress.wordpress.com/156/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/reddit/nerdfortress.wordpress.com/156/" /></a> <img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=nerdfortress.com&#038;blog=4772118&#038;post=156&#038;subd=nerdfortress&#038;ref=&#038;feed=1" width="1" height="1" />]]></content:encoded>
			<wfw:commentRss>http://nerdfortress.com/2008/09/19/linux-xfs-does-not-support-direntd_type/feed/</wfw:commentRss>
		<slash:comments>4</slash:comments>
	
		<media:content url="http://1.gravatar.com/avatar/50b7c50e71c508c9874184663384efb9?s=96&#38;d=http%3A%2F%2F1.gravatar.com%2Favatar%2Fad516503a11cd5ca435acc9bb6523536%3Fs%3D96&#38;r=G" medium="image">
			<media:title type="html">Random</media:title>
		</media:content>
	</item>
		<item>
		<title>Hacking the Wii: Compiling and Running Wii Code</title>
		<link>http://nerdfortress.com/2008/09/18/hacking-the-wii-compiling-and-running-wii-code/</link>
		<comments>http://nerdfortress.com/2008/09/18/hacking-the-wii-compiling-and-running-wii-code/#comments</comments>
		<pubDate>Thu, 18 Sep 2008 16:10:38 +0000</pubDate>
		<dc:creator>Kurt</dc:creator>
				<category><![CDATA[Codealicious]]></category>
		<category><![CDATA[Indie Games]]></category>

		<guid isPermaLink="false">http://nerdfortress.wordpress.com/?p=152</guid>
		<description><![CDATA[What could be more fun that hacking the Wii? Compiling and running your own Wii games is actually pretty straightforward. The only caveat is that you will need a copy of The Legend of Zelda: Twilight Princess and an SD card. For remote debugging, you will also need the USB Gecko. Many people have already [...]<img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=nerdfortress.com&#038;blog=4772118&#038;post=152&#038;subd=nerdfortress&#038;ref=&#038;feed=1" width="1" height="1" />]]></description>
			<content:encoded><![CDATA[<p>What could be more fun that hacking the Wii? Compiling and running your own Wii games is actually pretty straightforward. The only caveat is that you will need a copy of <a href="http://www.zelda.com/universe/game/twilightprincess/" target="_blank">The Legend of Zelda: Twilight Princess</a> and an SD card. For remote debugging, you will also need the <a href="http://www.usbgecko.com/" target="_blank">USB Gecko</a>. Many people have already written homebrew apps using the open source <a href="http://wiibrew.org/wiki/DevkitPro" target="_blank">DevkitPro</a> to compile their stuff.</p>
<p>If you are interesting in hacking the Wii, you need to check out <a href="http://wiibrew.org/wiki/Main_Page" target="_blank">WiiBrew</a>. This is the place to go for information about compiling, running, and debugging your own custom Wii apps. For example, WiiBrew is where I found out about the excellent <a href="http://hbc.hackmii.com/" target="_blank">Homebrew Channel</a>.</p>
<p>Dotbatman <a href="http://nerdfortress.wordpress.com/2008/09/17/wii-that-was-a-fun-ride-with-direnth/" target="_blank">is porting</a> the cult classic <a href="http://smw.72dpiarmy.com/" target="_blank">Super Mario War</a> to the Wii. What are <em>you</em> going to do?</p>
<p><em>Update: You no longer need a copy of Zelda to install the Homebrew Channel! <a href="http://wiibrew.org/wiki/Setting_up_your_Wii_for_Homebrew" target="_blank">Check out the latest Bannerbomb hack</a>. </em></p>
<br />Posted in Codealicious, Indie Games  <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gocomments/nerdfortress.wordpress.com/152/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/comments/nerdfortress.wordpress.com/152/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godelicious/nerdfortress.wordpress.com/152/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/delicious/nerdfortress.wordpress.com/152/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gofacebook/nerdfortress.wordpress.com/152/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/facebook/nerdfortress.wordpress.com/152/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gotwitter/nerdfortress.wordpress.com/152/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/twitter/nerdfortress.wordpress.com/152/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gostumble/nerdfortress.wordpress.com/152/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/stumble/nerdfortress.wordpress.com/152/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godigg/nerdfortress.wordpress.com/152/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/digg/nerdfortress.wordpress.com/152/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/goreddit/nerdfortress.wordpress.com/152/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/reddit/nerdfortress.wordpress.com/152/" /></a> <img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=nerdfortress.com&#038;blog=4772118&#038;post=152&#038;subd=nerdfortress&#038;ref=&#038;feed=1" width="1" height="1" />]]></content:encoded>
			<wfw:commentRss>http://nerdfortress.com/2008/09/18/hacking-the-wii-compiling-and-running-wii-code/feed/</wfw:commentRss>
		<slash:comments>2</slash:comments>
	
		<media:content url="http://1.gravatar.com/avatar/50b7c50e71c508c9874184663384efb9?s=96&#38;d=http%3A%2F%2F1.gravatar.com%2Favatar%2Fad516503a11cd5ca435acc9bb6523536%3Fs%3D96&#38;r=G" medium="image">
			<media:title type="html">Random</media:title>
		</media:content>
	</item>
	</channel>
</rss>
