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

<channel>
	<title>Jim&#039;s Random Notes</title>
	<atom:link href="http://blog.mischel.com/feed/" rel="self" type="application/rss+xml" />
	<link>http://blog.mischel.com</link>
	<description></description>
	<lastBuildDate>Wed, 09 May 2012 14:30:00 +0000</lastBuildDate>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=3.3.2</generator>
		<item>
		<title>Don&#8217;t depend on what you don&#8217;t control</title>
		<link>http://blog.mischel.com/2012/05/08/dont-depend-on-what-you-dont-control/</link>
		<comments>http://blog.mischel.com/2012/05/08/dont-depend-on-what-you-dont-control/#comments</comments>
		<pubDate>Tue, 08 May 2012 17:41:34 +0000</pubDate>
		<dc:creator>Jim</dc:creator>
				<category><![CDATA[Programming]]></category>

		<guid isPermaLink="false">http://blog.mischel.com/?p=1580</guid>
		<description><![CDATA[<p>Let&#8217;s say that you have a particular task in your program that is executed as the result of an external signal, but you don&#8217;t want the task to execute more often than once per second. This is different from a periodic task that you want to execute once per second. This one, you don&#8217;t want <span style="color:#777"> . . . &#8594; Read More: <a href="http://blog.mischel.com/2012/05/08/dont-depend-on-what-you-dont-control/">Don&#8217;t depend on what you don&#8217;t control</a></span>]]></description>
			<content:encoded><![CDATA[<p>Let&#8217;s say that you have a particular task in your program that is executed as the result of an external signal, but you don&#8217;t want the task to execute more often than once per second. This is different from a periodic task that you want to execute once per second. This one, you don&#8217;t want to execute unless the external signal is received. Your first cut of the function might look like this:</p>
<pre>// The last time a signal was processed
// Initialized to DateTime.MinValue so the first signal received
// will not be lost
DateTime LastSignalTime = DateTime.MinValue;

// Lock object to prevent re-entrancy
object SignalLock = new object();

// Minimum time between invocations
static readonly TimeSpan MinimumTime = TimeSpan.FromSeconds(1.0);

void SignalReceived(SomeObject dataObject)
{
    if (!Monitor.TryEnter(SignalLock))
    {
        // Currently processing. Exit.
        return;
    }
    try
    {
        if ((DateTime.Now - LastSignalTime) &lt; MinimumTime)
        {
            // Already processed within the last second.
            return;
        }
        // ...
        // do processing here
        // ...
        // And then save the last signal time.
        LastSignalTime = DateTime.Now;
    }
    finally
    {
        Monitor.Exit(SignalLock);
    }
}</pre>
<p>That looks reasonable. I covered all the bases, protecting the processing with a <code>Monitor</code> to prevent re-entrant use, and checking the time to ensure that I don&#8217;t process a signal more often than once per second.</p>
<p>There&#8217;s only one problem. The program assumes that <code>DateTime.Now</code> will increase by one second for every wall clock second. This code does not take into account Daylight Saving Time changes, changes caused by updating with an NTP service, or the user resetting the clock. If one of those events occurs, things fall apart.</p>
<p>For example, when we set the clocks ahead in the spring, this code could process twice in a very short period of time. Imagine that you processed a signal at 01:59:59.800. 200 milliseconds later, the time will be 03:00:00.000. Your code would then process another signal, even though less than one second has passed.</p>
<p>It&#8217;s worse when the time is set back in the fall. Say you process a signal at 01:59:59.100. 900 milliseconds after that, the time is changed to 01:00:00.000, and it will be another <em>hour</em> before the code does any more processing.</p>
<p>You can avoid those DST errors by using <code>DateTime.UtcNow</code> in place of <code>DateTime.Now</code>, but that won&#8217;t solve the problem that occurs with NTP or user-initiated time changes.</p>
<p>The problem here is that your code is depending on the system clock, which the program doesn&#8217;t control. The clock can change at any time, and if you depend on it for critical processing you&#8217;re going to be sorry.</p>
<p>You can remove that dependency by using a <a href="http://msdn.microsoft.com/en-us/library/System.Diagnostics.Stopwatch.aspx">Stopwatch</a>, which measures elapsed time independent of the system clock. In the code below, I initialize a <code>Stopwatch</code> when the program starts. I&#8217;ve modified the logic slightly to save a <code>NextSignalTime</code>, which represents the time when another signal can be processed.</p>
<pre>// The amount of time elapsed since the program started
static readonly Stopwatch ProgramTimer = Stopwatch.StartNew();

// The next time a signal can be processed.
TimeSpan NextSignalTime = TimeSpan.Zero;

// Lock object to prevent re-entrancy
object SignalLock = new object();

// Minimum time between invocations
static readonly TimeSpan MinimumTime = TimeSpan.FromSeconds(1.0);

void SignalReceived(SomeObject dataObject)
{
    if (!Monitor.TryEnter(SignalLock))
    {
        // Currently processing. Exit.
        return;
    }
    try
    {
        if (ProgramTimer.Elapsed &lt; NextSignalTime)
        {
            // Already processed within the last second.
            return;
        }
        // ...
        // do processing here
        // ...
        // And then save the next signal time.
        NextSignalTime = ProgramTimer.Elapsed + MinimumTime;
    }
    finally
    {
        Monitor.Exit(SignalLock);
    }
}</pre>
<p>This code can&#8217;t be affected by system time changes because it doesn&#8217;t depend on the system time.</p>
<p>You don&#8217;t control the system clock. Don&#8217;t depend on it for measuring elapsed time. It&#8217;s fine to depend on it to tell you what time of day it is. If the user changes his clock, that&#8217;s his problem. But you can&#8217;t be at the mercy of the system clock if you want accurate elapsed time measurements.</p>
]]></content:encoded>
			<wfw:commentRss>http://blog.mischel.com/2012/05/08/dont-depend-on-what-you-dont-control/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>New mesquite spoon</title>
		<link>http://blog.mischel.com/2012/05/07/new-mesquite-spoon/</link>
		<comments>http://blog.mischel.com/2012/05/07/new-mesquite-spoon/#comments</comments>
		<pubDate>Tue, 08 May 2012 00:51:11 +0000</pubDate>
		<dc:creator>Jim</dc:creator>
				<category><![CDATA[Carving]]></category>

		<guid isPermaLink="false">http://blog.mischel.com/?p=1572</guid>
		<description><![CDATA[<p>I&#8217;d go crazy if all I carved was those little birds. I&#8217;m up to 40 different types of wood now, and am still on track to make 100 by the end of the year.</p> <p>I wanted to make a spoon a few weeks back, and ended up carving this one. Then I got involved in <span style="color:#777"> . . . &#8594; Read More: <a href="http://blog.mischel.com/2012/05/07/new-mesquite-spoon/">New mesquite spoon</a></span>]]></description>
			<content:encoded><![CDATA[<p>I&#8217;d go crazy if all I carved was those <a href="http://100birds.mischel.com">little birds</a>. I&#8217;m up to 40 different types of wood now, and am still on track to make 100 by the end of the year.</p>
<p>I wanted to make a spoon a few weeks back, and ended up carving this one. Then I got involved in other things. I found this almost done spoon on my desk over the weekend and took the time to sand and finish it.</p>
<p><a href="http://blog.mischel.com/wp-content/uploads/2012/05/spoon1.jpg"><img class="aligncenter size-full wp-image-1574" title="spoon1_s" src="http://blog.mischel.com/wp-content/uploads/2012/05/spoon1_s.jpg" alt="" width="640" height="153" /></a><br />
<a href="http://blog.mischel.com/wp-content/uploads/2012/05/spoon2.jpg"><img class="aligncenter size-full wp-image-1576" title="spoon2_s" src="http://blog.mischel.com/wp-content/uploads/2012/05/spoon2_s.jpg" alt="" width="640" height="148" /></a></p>
<p>Click on the pictures to get a larger image.</p>
<p>The spoon is carved from a piece of mesquite that I trimmed from one of my trees last year. I cut out the rough shape on the bandsaw, shaped the handle and bowl with the Foredom power carver. I started to use the Foredom to hollow out the bowl, but the only hollowing bit I had at the time is very small and not very aggressive. So I clamped the spoon in my vise and took a gouge to the bowl.</p>
<p><a href="http://blog.mischel.com/wp-content/uploads/2012/05/spoon3.jpg"><img class="aligncenter size-full wp-image-1577" title="spoon3" src="http://blog.mischel.com/wp-content/uploads/2012/05/spoon3.jpg" alt="" width="640" height="457" /></a></p>
<p><a href="http://blog.mischel.com/wp-content/uploads/2012/05/spoon4.jpg"><img class="aligncenter size-full wp-image-1578" title="spoon4" src="http://blog.mischel.com/wp-content/uploads/2012/05/spoon4.jpg" alt="" width="640" height="514" /></a></p>
<p>The spoon is right at 12 inches long. The bowl is 3 inches long and 2.5 inches wide. It&#8217;s about 3/4 inch deep at the back.</p>
<p>As you can see, there are several largish cracks. I filled those with two part epoxy and then sanded them. There was also a much larger worm hole on the handle (the discolored part in the first picture) that I filled with epoxy. Next time I&#8217;ll think about doing some kind of inlay there. Perhaps some crushed turquoise.</p>
<p>I usually use an oil and wax finish on my spoons because I like simple finishes. But there were enough little cracks in this piece of wood that I thought I&#8217;d go with something else. I used <a href="http://www.rockler.com/product.cfm?page=5344">Salad Bowl Finish</a>, which is a pretty popular finish for wooden utensils. It&#8217;s durable and food safe. But a pain in the neck to apply. You have to apply it, wait 12 hours, sand, and repeat. They recommend at least three coats, which is what I applied. I think I&#8217;ll go with two coats the next time I use this stuff. And I might have to sand a little better between coats.</p>
<p>I like that the finish doesn&#8217;t darken the wood like the oil finishes I&#8217;ve used. But I don&#8217;t much like the shiny look. I think next time I&#8217;ll try melting some beeswax. I know of some people who use that to great effect.</p>
<p>Still, I like the spoon. I hope Debra gets good use from it.</p>
]]></content:encoded>
			<wfw:commentRss>http://blog.mischel.com/2012/05/07/new-mesquite-spoon/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Woodcarving Round-Up</title>
		<link>http://blog.mischel.com/2012/04/25/woodcarving-round-up/</link>
		<comments>http://blog.mischel.com/2012/04/25/woodcarving-round-up/#comments</comments>
		<pubDate>Wed, 25 Apr 2012 20:24:42 +0000</pubDate>
		<dc:creator>Jim</dc:creator>
				<category><![CDATA[Carving]]></category>

		<guid isPermaLink="false">http://blog.mischel.com/?p=1566</guid>
		<description><![CDATA[<p>I headed south to New Braunfels, TX yesterday to get a look at the Texas Woodcarvers Guild Spring Round-Up. The Round-Up is a week-long event that features classes, a banquet, a Whittlin&#8217; Contest, and a few vendors set up to sell things that carvers buy. A lot of carvers are unabashed tool junkies, there were <span style="color:#777"> . . . &#8594; Read More: <a href="http://blog.mischel.com/2012/04/25/woodcarving-round-up/">Woodcarving Round-Up</a></span>]]></description>
			<content:encoded><![CDATA[<p>I headed south to New Braunfels, TX yesterday to get a look at the <a href="http://www.texaswoodcarversguild.com/">Texas Woodcarvers Guild</a> Spring Round-Up. The Round-Up is a week-long event that features classes, a banquet, a Whittlin&#8217; Contest, and a few vendors set up to sell things that carvers buy. A lot of carvers are unabashed tool junkies, there were <em>lots</em> of tools available for sale.</p>
<p>The Spring Round-Up does not feature a show or any real &#8220;public&#8221; appeal. The general public is welcome to come in and look around, of course, but there are no tables set up with pieces on display, and there is no judged contest. The judged show takes place in the fall&#8211;typically the last week of September or first week of October.</p>
<p>I had two goals for my trip: to participate in the Whittlin&#8217; Contest, and to buy some tools. I&#8217;m decidedly <em>not</em> a tool junkie, but I&#8217;ve been carving for three years with just a knife (okay, I own a handful of knives), one V-tool, and one gouge. There are things I can&#8217;t do (or can&#8217;t do easily) with those few tools, so I thought I&#8217;d pick up a few other gouges. I could have ordered the tools online, but wanted some advice from more experienced carvers, and the ability to hold the tools in my hand before I shelled out money for them. I ended up with six new gouges and a few new power carving bits, all of which should help me improve my carving.</p>
<p>I spent Tuesday afternoon wandering around the floor, briefly watching and listening to the classes that were taking place, talking to other carvers, and generally having a good ol&#8217; wood nerd time. I also spent a little time in the Carving Corner, whittling a little dog and chatting with other carvers. Once again I was struck by how <em>friendly</em> and inclusive carvers are. Every carver there, from those who are just starting out to the most accomplished, were happy to sit around and chat while whittling away on a project. And they&#8217;re happy to answer questions and spend their time demonstrating some technique or other. Whittling with this group is a relaxing and entertaining experience.</p>
<p>The Whittlin&#8217; Contest was scheduled for 7:00 PM. There are three classes: Novice, Intermediate, and Open. There are a few set rules, the most important being that if you win in one of the lower classes, you have to move up. Beyond that, the person in charge of the contest (who, by tradition, is the person who won the Open class the year before) sets the other rules.</p>
<p>Because I had never done this before, I entered into the Novice class. There were five of us in Novice, five or six in Intermediate, and almost a dozen in the Open class. We all sat down at our respective tables and they passed out the wood. The Novices got a block of basswood, 2-1/2&#8243; x 2-1/2&#8243; x 3&#8243;. They told us to carve a &#8220;Civil War hat,&#8221; further clarified as &#8220;any kind of hat you would have seen during the Civil War.&#8221;</p>
<p>The Intermediates were given a piece that was approximately 8 inches long, and cut in to a triangle that was about 2&#8243; on a side. I think their instructions were to carve &#8220;a military scene.&#8221; The Open contestants were given a block about 2-1/2 inches square and maybe six inches tall, and told to carve &#8220;a Civil War caricature.&#8221;</p>
<p>We Novices were told that we could use any tool in our toolbox. The Intermediates were limited to, I think, three tools, and those in the Open category could use only one knife. They told us that we had an hour, and started the clock.</p>
<p>I don&#8217;t know much about hats in general, and I know even less about the kinds of hats worn during the Civil War. I could picture the Confederate cap, but not well enough to try carving one without a reference. But I figured that I could do a cowboy hat. Certainly <em>somebody</em> during that time was wearing cowboy hats. The only problem was that I had to remove a whole lot of wood to realize my vision.</p>
<p>At one point, after I made a mistake and broke the brim of what I was working on, I considered changing to a stovepipe hat, but I ended up having enough time left over to make it look kind of like a cowboy hat.</p>
<p>Judging is done based on originality, technical quality (proportion, symmetry, clean cuts, etc.), and also on completeness. Somebody told me that completing the project within the time allotted was worth a lot in the judges&#8217; eyes. I had carved a couple of stovepipe hats before, and one (failed) cowboy hat, so I was pretty sure I could finish this project in an hour.</p>
<p>I did finish it in an hour, and although it&#8217;s a bit of a goofy looking hat, I ended up winning first place in the Novice category. Here&#8217;s my hat along with the second and third place winners.</p>
<p><a href="http://blog.mischel.com/wp-content/uploads/2012/04/novice.jpg"><img class="aligncenter size-full wp-image-1569" title="novice" src="http://blog.mischel.com/wp-content/uploads/2012/04/novice.jpg" alt="" width="640" height="243" /></a></p>
<p>I think that either of the other two would have beat mine, had the carvers finished them in time.  My hat is two inches tall, and the brim is two inches in diameter. Here&#8217;s a closer picture.</p>
<p><a href="http://blog.mischel.com/wp-content/uploads/2012/04/winner.jpg"><img class="aligncenter size-full wp-image-1567" title="winner" src="http://blog.mischel.com/wp-content/uploads/2012/04/winner.jpg" alt="" width="516" height="580" /></a></p>
<p>I was going to show the Intermediate and Open winners, as well, but the pictures were very blurry.</p>
<p>My prize was a plaque:</p>
<p><a href="http://blog.mischel.com/wp-content/uploads/2012/04/plaque.jpg"><img class="aligncenter size-full wp-image-1568" title="plaque" src="http://blog.mischel.com/wp-content/uploads/2012/04/plaque.jpg" alt="" width="538" height="580" /></a></p>
<p>I&#8217;ll be the first to admit that my hat is no great carving. But then, I was under pressure just to <em>finish</em> something in the allotted time. Given advanced notice and unlimited time, I could do a much better hat.</p>
<p>I honestly was very surprised to win this little contest. But now I have to move up to Intermediate, and that&#8217;s going to require a lot of practice. Even the worst of the Intermediate entries was beyond my current skills.</p>
]]></content:encoded>
			<wfw:commentRss>http://blog.mischel.com/2012/04/25/woodcarving-round-up/feed/</wfw:commentRss>
		<slash:comments>1</slash:comments>
		</item>
		<item>
		<title>The things you see on the road</title>
		<link>http://blog.mischel.com/2012/04/18/the-things-you-see-on-the-road/</link>
		<comments>http://blog.mischel.com/2012/04/18/the-things-you-see-on-the-road/#comments</comments>
		<pubDate>Wed, 18 Apr 2012 16:43:14 +0000</pubDate>
		<dc:creator>Jim</dc:creator>
				<category><![CDATA[Cycling]]></category>

		<guid isPermaLink="false">http://blog.mischel.com/?p=1562</guid>
		<description><![CDATA[<p>I had my bike repainted last year, and even started riding it. Then I got busy with other things (or maybe I just got lazy). The bike spent most of the last 12 months hanging in the garage overlooking the bandsaw. I&#8217;d take it out every couple of months just to assuage my own guilt, <span style="color:#777"> . . . &#8594; Read More: <a href="http://blog.mischel.com/2012/04/18/the-things-you-see-on-the-road/">The things you see on the road</a></span>]]></description>
			<content:encoded><![CDATA[<p>I had my bike repainted last year, and even started riding it. Then I got busy with other things (or maybe I just got lazy). The bike spent most of the last 12 months hanging in the garage overlooking the bandsaw. I&#8217;d take it out every couple of months just to assuage my own guilt, but then it&#8217;d go back on the rack and I wouldn&#8217;t think much about it for a while.</p>
<p>I&#8217;ve been saying for the last month that I&#8217;m going to get back on the bike, but I&#8217;ve been putting it off. This morning I got frustrated with the program I was working on, and decided to take a ride and clear my head. An hour on the bike usually does.</p>
<p>Every time I come back to cycling after a long absence, I unable to understand how I could possibly have stopped. That first few miles feels so <em>good</em>: back out on the road, enjoying the fresh air and the wind in my face, nothing heavy on my mind. It&#8217;s very liberating.</p>
<p>It hurts, of course. My legs aren&#8217;t used to climbing even the smallest hills. But I know that within a couple of weeks the pain will be gone and I&#8217;ll feel a lot better. I just can&#8217;t understand how I could have stopped riding again.</p>
<p>I took an experimental loop through a new subdivision and was on my way home when I saw a large group of riders&#8211;perhaps as many as 50&#8211;coming up on the other side of the road. There were two motorcycles in front, obviously part of the ride, and three vans following. One of the vans said, &#8220;<a href="http://ride2recovery.com">Ride 2 Recovery</a>&#8221; on it, and &#8220;Wounded Veterans Ahead.&#8221;</p>
<p>I had to go see what that was all about.</p>
<p>I turned around, sprinted past the vans, and caught up with the riders. I struck up a conversation with one of the riders, a former Army Ranger from Albuquerque, NM. They&#8217;re participating in the <a href="http://www.ride2recovery.com/texas-challenge.html">Texas Challenge</a>: a 6-day ride from San Antonio to Arlington. The riders raise money to help support the programs that Ride 2 Recovery sponsors. I talked to this guy for a few more minutes, then rode up the line offering encouragement before turning around and heading home.</p>
<p>Had I been in better shape, I probably would have stayed with them all the way to Fort Hood, and then found a ride back somehow. But I figured that 50 miles was probably a bit too far for my first ride after over a year of not riding seriously.</p>
<p>&#8220;The Ride 2 Recovery,&#8221; the web site says, &#8220;is produced by the Fitness Challenge Foundation, (501C3) in partnership with the Military and VA Volunteer Service Office, to benefit Mental and Physical Rehabilitation Programs for our country&#8217;s wounded veterans that feature cycling as the core activity.&#8221;</p>
<p>Call it fate, coincidence, serendipity, whatever. The likelihood of me running into a group of riders on a Wednesday morning, out on the back roads on my first ride of the season is pretty low. But then, improbable events happen quite frequently. After all, people <em>do</em> win the lottery. Whatever the reason, or even if there was no reason, I sure am glad I encountered this group today. That&#8217;s some serious motivation.</p>
<p>&nbsp;</p>
]]></content:encoded>
			<wfw:commentRss>http://blog.mischel.com/2012/04/18/the-things-you-see-on-the-road/feed/</wfw:commentRss>
		<slash:comments>1</slash:comments>
		</item>
		<item>
		<title>Hash codes are not unique</title>
		<link>http://blog.mischel.com/2012/04/13/hash-codes-are-not-unique/</link>
		<comments>http://blog.mischel.com/2012/04/13/hash-codes-are-not-unique/#comments</comments>
		<pubDate>Fri, 13 Apr 2012 21:32:05 +0000</pubDate>
		<dc:creator>Jim</dc:creator>
				<category><![CDATA[Uncategorized]]></category>

		<guid isPermaLink="false">http://blog.mischel.com/?p=1559</guid>
		<description><![CDATA[<p>It&#8217;s surprising how often I hear (or see written) a programmer saying, &#8220;&#8230;and then I&#8217;ll compute a unique hash code that I can use for a key.&#8221;</p> <p>The term &#8220;unique hash code&#8221; is a red flag indicating that the programmer who uttered it does not understand hash codes and is about to do something incredibly <span style="color:#777"> . . . &#8594; Read More: <a href="http://blog.mischel.com/2012/04/13/hash-codes-are-not-unique/">Hash codes are not unique</a></span>]]></description>
			<content:encoded><![CDATA[<p>It&#8217;s surprising how often I hear (or see written) a programmer saying, &#8220;&#8230;and then I&#8217;ll compute a unique hash code that I can use for a key.&#8221;</p>
<p>The term &#8220;unique hash code&#8221; is a red flag indicating that the programmer who uttered it does not understand hash codes and is about to do something incredibly stupid. Let me provide a simple example.</p>
<p>In .NET, every object has a <a href="http://msdn.microsoft.com/en-us/library/system.object.gethashcode.aspx">GetHashCod</a>e method that computes a 32-bit number that can serve as a key in a dictionary or hash table. Used properly, the hash code lets you create very efficient data structures for looking things up by name. But there&#8217;s no magic involved, really.</p>
<p>Used as intended&#8211;as the keys in a dictionary or hash table&#8211;hash codes work very well. If you try to use them for something else, it&#8217;s not going to work.</p>
<p>Let&#8217;s say you foolishly decide to use a hash code for a &#8220;unique key&#8221; when indexing some strings.</p>
<p>The number of strings is essentially infinite. The number of unique values that a 32-bit hash code can represent is a little more than four billion. So it&#8217;s a certainty that two or more strings will produce the same hash code. You might think, if you&#8217;re only storing 100,000 values, that the chance of collision (two strings hashing to the same value) is so small as not to matter. You&#8217;d be wrong.</p>
<p>If you&#8217;re familiar with the <a href="http://en.wikipedia.org/wiki/Birthday_problem">Birthday Paradox</a> you know that, in any group of 25 people selected at random, the chance of two having the same birthday (month and day) are better than 50%. In a group of 60 people, it&#8217;s almost a certainty. If you don&#8217;t believe the math, you can do some empirical research of your own.</p>
<p>Hash codes are a lot like birthdays in this regard. A good rule of thumb is that the chance of collision (two items hashing to the same value) is 50% when the number of items hashed is equal to the <em>square root</em> of the number of possible values. So with a 32-bit hash code, the chance of two items hashing to the same value will be 50% when you&#8217;ve hashed 2^16, or 65,536 items. Again, if you don&#8217;t believe me just write a program that generates random strings and try it.</p>
<p>Another rule of thumb is that you&#8217;re almost certain to get a collision when the number of items is four times the square root. So with a 32-bit hash code, the chance of getting a collision when adding 256,000 items is almost 100%.</p>
<p>This is second year Computer Science stuff. Maybe even first year? And yet I hear the term &#8220;unique hash code&#8221; thrown around distressingly often by experienced programmers who should know better. It&#8217;s frightening.</p>
<p>If you&#8217;re interested in a bit more discussion and some sample programs that illustrate this point better, see <a href="http://www.informit.com/guides/content.aspx?g=dotnet&amp;seqNum=792">Birthdays, Random Numbers, and Hash Keys</a>.</p>
]]></content:encoded>
			<wfw:commentRss>http://blog.mischel.com/2012/04/13/hash-codes-are-not-unique/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Dolphins, an experiment</title>
		<link>http://blog.mischel.com/2012/03/29/dolphins-an-experiment/</link>
		<comments>http://blog.mischel.com/2012/03/29/dolphins-an-experiment/#comments</comments>
		<pubDate>Fri, 30 Mar 2012 03:21:28 +0000</pubDate>
		<dc:creator>Jim</dc:creator>
				<category><![CDATA[Carving]]></category>

		<guid isPermaLink="false">http://blog.mischel.com/?p=1553</guid>
		<description><![CDATA[<p>This piece is an unfinished experiment. I carved the black walnut dolphin last year and had it on a temporary base. Somebody gave me the mahogany dolphin cutout a few weeks ago and after I finished it I was wondering how to display them together. I was considering trying to relief carve some waves when <span style="color:#777"> . . . &#8594; Read More: <a href="http://blog.mischel.com/2012/03/29/dolphins-an-experiment/">Dolphins, an experiment</a></span>]]></description>
			<content:encoded><![CDATA[<p>This piece is an unfinished experiment. I carved the <a href="http://blog.mischel.com/2011/01/15/walnut-dolphin/">black walnut dolphin</a> last year and had it on a temporary base. Somebody gave me the mahogany dolphin cutout a few weeks ago and after I finished it I was wondering how to display them together. I was considering trying to relief carve some waves when Debra mentioned the possibility of using a piece of bark.</p>
<p>I just happen to have a whole lot of bark from an oak tree . . .</p>
<p><a href="http://blog.mischel.com/wp-content/uploads/2012/03/dolphins1.jpg"><img class="aligncenter size-full wp-image-1557" title="dolphins1_sm" src="http://blog.mischel.com/wp-content/uploads/2012/03/dolphins1_sm.jpg" alt="" width="640" height="308" /></a></p>
<p>As I said, the piece is unfinished. I&#8217;ve sanded and finished the dolphin carvings, but the oak bark is still raw. I&#8217;ll have to put something on the bark so that it won&#8217;t flake off and deteriorate over time.</p>
<p>I realize that neither of the dolphin carvings is especially good. I goofed on the back of the walnut piece&#8211;making it too straight and too thin. And I didn&#8217;t round the front of the mahogany dolphin very well. That one&#8217;s dorsal fin is too small, too. That&#8217;s not my fault. The person who gave me the blank had cut it a bit short.</p>
<p>That said, I rather like the idea of using bark as a substitute ocean surface. What do you think?</p>
<p>Here&#8217;s another view, closer up.</p>
<p><a href="http://blog.mischel.com/wp-content/uploads/2012/03/dolphins.jpg"><img class="aligncenter size-full wp-image-1555" title="dolphins_sm" src="http://blog.mischel.com/wp-content/uploads/2012/03/dolphins_sm.jpg" alt="" width="640" height="328" /></a></p>
]]></content:encoded>
			<wfw:commentRss>http://blog.mischel.com/2012/03/29/dolphins-an-experiment/feed/</wfw:commentRss>
		<slash:comments>1</slash:comments>
		</item>
		<item>
		<title>A couple of yard pictures</title>
		<link>http://blog.mischel.com/2012/03/28/a-couple-of-yard-pictures/</link>
		<comments>http://blog.mischel.com/2012/03/28/a-couple-of-yard-pictures/#comments</comments>
		<pubDate>Thu, 29 Mar 2012 04:49:15 +0000</pubDate>
		<dc:creator>Jim</dc:creator>
				<category><![CDATA[Odds 'n Ends]]></category>
		<category><![CDATA[Pets]]></category>

		<guid isPermaLink="false">http://blog.mischel.com/?p=1548</guid>
		<description><![CDATA[<p>I spent most of the weekend doing yard work. Specifically, burning the remains of the fig and the wisteria that didn&#8217;t fare well over two or three years of drought. I also took down the garden fence, seeing as how we hadn&#8217;t actually cultivated a garden for a few years.</p> <p></p> <p>Removing the fence posts <span style="color:#777"> . . . &#8594; Read More: <a href="http://blog.mischel.com/2012/03/28/a-couple-of-yard-pictures/">A couple of yard pictures</a></span>]]></description>
			<content:encoded><![CDATA[<p>I spent most of the weekend doing yard work. Specifically, burning the remains of the fig and the wisteria that didn&#8217;t fare well over two or three years of drought. I also took down the garden fence, seeing as how we hadn&#8217;t actually cultivated a garden for a few years.</p>
<p><a href="http://blog.mischel.com/wp-content/uploads/2012/03/gate.jpg"><img class="aligncenter size-full wp-image-1551" title="gate" src="http://blog.mischel.com/wp-content/uploads/2012/03/gate.jpg" alt="" width="640" height="388" /></a></p>
<p>Removing the fence posts was no problem. But I set the gate posts in concrete. Removing those is going to be some work. Unless I decide to leave the gate as an artifact.</p>
<p>I also mowed the back yard. I ran out of time to do the front, and I won&#8217;t get to it until Sunday. That&#8217;s going to be a big job. The recent rains and abundant sunshine have made for ideal grass and weed growing conditions.</p>
<p>It&#8217;s surprising how much the grass grows in just a week. If I let it go two weeks, it will be high enough to scratch Charlie&#8217;s belly.</p>
<p><a href="http://blog.mischel.com/wp-content/uploads/2012/03/charlie1.jpg"><img class="aligncenter size-full wp-image-1550" title="charlie1_sm" src="http://blog.mischel.com/wp-content/uploads/2012/03/charlie1_sm.jpg" alt="" width="640" height="520" /></a></p>
<p>Charlie, by the way, is doing well. He was feeling his oats this afternoon, doing laps around the pool. Still a heck of a good lookin&#8217; dog, ain&#8217;t he? The bald spots are from surgery to remove some mast cell tumors.</p>
]]></content:encoded>
			<wfw:commentRss>http://blog.mischel.com/2012/03/28/a-couple-of-yard-pictures/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Gnome home</title>
		<link>http://blog.mischel.com/2012/03/20/gnome-home-2/</link>
		<comments>http://blog.mischel.com/2012/03/20/gnome-home-2/#comments</comments>
		<pubDate>Tue, 20 Mar 2012 05:58:50 +0000</pubDate>
		<dc:creator>Jim</dc:creator>
				<category><![CDATA[Carving]]></category>

		<guid isPermaLink="false">http://blog.mischel.com/?p=1542</guid>
		<description><![CDATA[<p>The Hundred Birds Project has occupied most of my limited carving time the last few months. But I&#8217;d go crazy if that&#8217;s all I carved. Last week I started working on this whimsical house (gnome home) in cottonwood bark, and I finally finished it Monday night. All told I probably have six or eight hours <span style="color:#777"> . . . &#8594; Read More: <a href="http://blog.mischel.com/2012/03/20/gnome-home-2/">Gnome home</a></span>]]></description>
			<content:encoded><![CDATA[<p>The <a href="http://100birds.mischel.com">Hundred Birds Projec</a>t has occupied most of my limited carving time the last few months. But I&#8217;d go crazy if that&#8217;s all I carved. Last week I started working on this whimsical house (gnome home) in cottonwood bark, and I finally finished it Monday night. All told I probably have six or eight hours in it.</p>
<p><a href="http://blog.mischel.com/wp-content/uploads/2012/03/house.jpg"><img class="aligncenter size-full wp-image-1544" title="house_sm" src="http://blog.mischel.com/wp-content/uploads/2012/03/house_sm.jpg" alt="" width="312" height="800" /></a></p>
<p>The piece is a wall hanging, about nine inches tall on the right side, and about two and a half inches wide. Don&#8217;t know yet where I&#8217;ll hang it.</p>
<p>This is the second &#8220;flat back&#8221; I&#8217;ve carved. I did <a href="http://blog.mischel.com/2010/10/03/gnome-home/">the other one</a> about two years ago. I also carved a <a href="http://blog.mischel.com/2010/10/04/carving-whimsical-houses-day-3/">larger whimsical house</a> in a class back in October of 2010.</p>
<p>I like carving the cottonwood bark. The only real problem is that I have to <em>buy</em> the stuff! I might have to find a good supplier, though, and stock up. These things are addictive.</p>
]]></content:encoded>
			<wfw:commentRss>http://blog.mischel.com/2012/03/20/gnome-home-2/feed/</wfw:commentRss>
		<slash:comments>2</slash:comments>
		</item>
		<item>
		<title>Codesion free Subversion hosting: Fail</title>
		<link>http://blog.mischel.com/2012/02/20/codesion-free-subversion-hosting-fail/</link>
		<comments>http://blog.mischel.com/2012/02/20/codesion-free-subversion-hosting-fail/#comments</comments>
		<pubDate>Tue, 21 Feb 2012 02:26:06 +0000</pubDate>
		<dc:creator>Jim</dc:creator>
				<category><![CDATA[Internet]]></category>

		<guid isPermaLink="false">http://blog.mischel.com/?p=1538</guid>
		<description><![CDATA[<p>I thought I&#8217;d try cloud hosting for source code version control. I&#8217;ve been using version control on my local box, but figured it&#8217;d be better to have that stuff stored offsite so that I can get to it from wherever I am.</p> <p>Codesion came highly recommended, and I was pleased with the ease of setting <span style="color:#777"> . . . &#8594; Read More: <a href="http://blog.mischel.com/2012/02/20/codesion-free-subversion-hosting-fail/">Codesion free Subversion hosting: Fail</a></span>]]></description>
			<content:encoded><![CDATA[<p>I thought I&#8217;d try cloud hosting for source code version control. I&#8217;ve been using version control on my local box, but figured it&#8217;d be better to have that stuff stored offsite so that I can get to it from wherever I am.</p>
<p><a href="http://codesion.com/">Codesion</a> came highly recommended, and I was pleased with the ease of setting up a new trial account. At least, I was impressed until I tried to <em>access</em> my new repository. If I try to access it from my Subversion command line client, I get this message:</p>
<pre>svn: E175002: Unable to connect to a repository at URL 'https://jimmischel.svn.cvsdude.com/jimsstuff'
svn: E175002: The OPTIONS request returned invalid XML in the response: XML parse error at line 1: no element found (https://jimmischel.svn.cvsdude.com/jimsstuff)</pre>
<p>I get a similar error if I try to access it with the <a href="http://tortoisesvn.net/">TortoiseSVN</a> GUI client.</p>
<p>So I thought maybe I misread the terms of the free trial. I went to the Codesion site and tried to view the repository with their ViewVC browser. The result is a browser window containing this information:</p>
<h3>An Exception Has Occurred</h3>
<h4>Python Traceback</h4>
<p>&nbsp;</p>
<pre>Traceback (most recent call last):
  File "/services/viewvc_template/lib/viewvc.py", line 4396, in main
    request.run_viewvc()
  File "/services/viewvc_template/lib/viewvc.py", line 268, in run_viewvc
    self.repos.open()
  File "/services/viewvc_template/lib/vclib/svn/svn_ra.py", line 204, in open
    self.ctx.config)
  File "/usr/local/python/lib/python2.5/site-packages/libsvn/ra.py", line 518, in svn_ra_open
    return apply(_ra.svn_ra_open, args)
SubversionException: 175002 - Unable to connect to a repository at URL 'http://10.36.235.136/svn/jimmischel/jimsstuff'
175002 - The OPTIONS request returned invalid XML in the response: XML parse error at line 1: no element found (http://10.36.235.136/svn/jimmischel/jimsstuff)</pre>
<p>Checking their online forums, it looks as though others have had similar issues in the past few weeks. Sorry, Codesion. If you can&#8217;t get a simple free trial to work, I&#8217;m not going to trust you with my source code.</p>
<p>There are dozens of sites that offer free or inexpensive Subversion hosting. I don&#8217;t have the time or inclination to try every one of them. Anybody have a recommendation?</p>
<p>And, no, I&#8217;m not interested in using GIT. Please don&#8217;t suggest it.</p>
]]></content:encoded>
			<wfw:commentRss>http://blog.mischel.com/2012/02/20/codesion-free-subversion-hosting-fail/feed/</wfw:commentRss>
		<slash:comments>4</slash:comments>
		</item>
		<item>
		<title>Purpleheart heart</title>
		<link>http://blog.mischel.com/2012/02/18/purpleheart-heart/</link>
		<comments>http://blog.mischel.com/2012/02/18/purpleheart-heart/#comments</comments>
		<pubDate>Sat, 18 Feb 2012 22:56:03 +0000</pubDate>
		<dc:creator>Jim</dc:creator>
				<category><![CDATA[Carving]]></category>

		<guid isPermaLink="false">http://blog.mischel.com/?p=1533</guid>
		<description><![CDATA[<p>Debra&#8217;s Valentine&#8217;s Day present from me this year was this stylized heart, carved from Purpleheart. The rough cutout was about 2-3/4 inches tall, 2-1/2 inches wide, and 1 inch thick. I cut it from a 6&#8243; x 12&#8243; x 1&#8243; piece of Purpleheart that a friend gave me some time ago.</p> <p></p> <p>I did the <span style="color:#777"> . . . &#8594; Read More: <a href="http://blog.mischel.com/2012/02/18/purpleheart-heart/">Purpleheart heart</a></span>]]></description>
			<content:encoded><![CDATA[<p>Debra&#8217;s Valentine&#8217;s Day present from me this year was this stylized heart, carved from Purpleheart. The rough cutout was about 2-3/4 inches tall, 2-1/2 inches wide, and 1 inch thick. I cut it from a 6&#8243; x 12&#8243; x 1&#8243; piece of Purpleheart that a friend gave me some time ago.</p>
<p><a href="http://blog.mischel.com/wp-content/uploads/2012/02/heart1_lg.jpg"><img class="aligncenter size-full wp-image-1534" title="heart1" src="http://blog.mischel.com/wp-content/uploads/2012/02/heart1.jpg" alt="" width="640" height="605" /></a></p>
<p>I did the cutout on the bandsaw, of course, and shaping with the Foredom power carver. After that, a lot of sanding with 100, 120, 220, 400, 600, 800, and 1,200 grit paper. Finish is Howard Feed &#8216;n Wax.</p>
<p>The heart is just the right size to fit in the hand, and it&#8217;s very pleasant to hold or to rub absently, similar to a <a href="http://en.wikipedia.org/wiki/Worry_stone">worry stone.</a></p>
]]></content:encoded>
			<wfw:commentRss>http://blog.mischel.com/2012/02/18/purpleheart-heart/feed/</wfw:commentRss>
		<slash:comments>1</slash:comments>
		</item>
	</channel>
</rss>

