<?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>ChrisBellini.com &#187; Programming</title>
	<atom:link href="http://www.chrisbellini.com/category/programming/feed/" rel="self" type="application/rss+xml" />
	<link>http://www.chrisbellini.com</link>
	<description>test</description>
	<lastBuildDate>Mon, 21 Dec 2009 02:04:12 +0000</lastBuildDate>
	<generator>http://wordpress.org/?v=2.8.6</generator>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
			<item>
		<title>smokin&#8217; hash</title>
		<link>http://www.chrisbellini.com/2007/11/29/smokin-hash/</link>
		<comments>http://www.chrisbellini.com/2007/11/29/smokin-hash/#comments</comments>
		<pubDate>Thu, 29 Nov 2007 14:54:19 +0000</pubDate>
		<dc:creator>Chris</dc:creator>
				<category><![CDATA[.NET]]></category>
		<category><![CDATA[C#]]></category>
		<category><![CDATA[MD5]]></category>
		<category><![CDATA[PHP]]></category>
		<category><![CDATA[Python]]></category>

		<guid isPermaLink="false">http://www.chrisbellini.com/2007/11/29/smokin-hash/</guid>
		<description><![CDATA[No, this post will make no mention of bottle tokes.
For the remaining freelance gig in my spare time pipeline (which hopefully is winding down), an ecommerce site, I had to create simple user management system.  Obviously, I'm not going to store users' passwords as plain text in the database, but rather as a hash [...]]]></description>
			<content:encoded><![CDATA[<p>No, this post will make no mention of bottle tokes.</p>
<p>For the remaining freelance gig in my spare time pipeline (which hopefully is winding down), an ecommerce site, I had to create simple user management system.  Obviously, I'm not going to store users' passwords as plain text in the database, but rather as a hash - an MD5 hash to be exact.  Unlike the old days where you had to implement <a href="http://www.ietf.org/rfc/rfc1321.txt" target="_blank">the MD5 algorithm</a> yourself, modern programming environments have this conveniently part of some specific standard library.  From PHP, hashing a password (or any other string data) is easily accomplished like this:</p>
<pre class="php">&nbsp;
<span style="color: #0000ff;">$plain_text</span> = <span style="color: #ff0000;">&quot;ChrisBellini.com&quot;</span>;
<span style="color: #0000ff;">$md5_text</span> = <a href="http://www.php.net/md5"><span style="color: #000066;">md5</span></a><span style="color: #66cc66;">&#40;</span><span style="color: #0000ff;">$plain_text</span><span style="color: #66cc66;">&#41;</span>;
<span style="color: #808080; font-style: italic;">// hash is '56d1df360dce2f5025c71fa7697af642'</span>
&nbsp;</pre>
<p></p>
<p>That hashed value is then stored in the database and I can use it to compare during logins.  Easy peasy.  </p>
<p>Sometimes, though, I'd like to verify what a hashed string really is.  What does "12345" look like after passing through MD5?  If you can do that in your head, then you can probably move objects with your mind.  For those of us lowly creatures who can't, though,  a simple way to determine this would be nice.  I'm a .NET guy in my day job, so a quick console app should suffice.  Using .NET's MD5 library with C# is trivial.</p>
<pre class="c">&nbsp;
using System.<span style="color: #202020;">Security</span>.<span style="color: #202020;">Cryptography</span>;
&nbsp;
<span style="color: #808080; font-style: italic;">// ...</span>
&nbsp;
<span style="color: #993333;">string</span> plain_text = <span style="color: #ff0000;">&quot;ChrisBellini.com&quot;</span>;
UTF8Encoding objEnc = new UTF8Encoding<span style="color: #66cc66;">&#40;</span><span style="color: #66cc66;">&#41;</span>;
MD5CryptoServiceProvider md5Hasher = new MD5CryptoServiceProvider<span style="color: #66cc66;">&#40;</span><span style="color: #66cc66;">&#41;</span>;
byte <span style="color: #66cc66;">&#91;</span><span style="color: #66cc66;">&#93;</span> arrHashBytes = md5Hasher.<span style="color: #202020;">ComputeHash</span><span style="color: #66cc66;">&#40;</span>objEnc.<span style="color: #202020;">GetBytes</span><span style="color: #66cc66;">&#40;</span>plain_text<span style="color: #66cc66;">&#41;</span><span style="color: #66cc66;">&#41;</span>;
<span style="color: #808080; font-style: italic;">// hash is '56-D1-DF-36-0D-CE-2F-50-25-C7-1F-A7-69-7A-F6-42'</span>
&nbsp;</pre>
<p></p>
<p>That would do the trick, but what if I'm on my Linux computer?  I could use <a href="http://www.mono-project.com" target="_blank">Mono</a>, but still...  It sure would be nice to be able to do this quickly on any operating system.  Enter Python.</p>
<pre class="python">&nbsp;
<span style="color: #ff7700;font-weight:bold;">import</span> hashlib
&nbsp;
plain_text = <span style="color: #483d8b;">&quot;ChrisBellini.com&quot;</span>
md5_text = hashlib.<span style="color: #dc143c;">md5</span><span style="color: black;">&#40;</span>plain_text<span style="color: black;">&#41;</span>.<span style="color: black;">hexdigest</span><span style="color: black;">&#40;</span><span style="color: black;">&#41;</span>
<span style="color: #808080; font-style: italic;"># hash is '56d1df360dce2f5025c71fa7697af642'</span>
&nbsp;</pre>
<p></p>
<p>Pop this into Python's interactive interpreter, Idle, and you've got yourself some lovely hash.</p>
]]></content:encoded>
			<wfw:commentRss>http://www.chrisbellini.com/2007/11/29/smokin-hash/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>onFrustrate</title>
		<link>http://www.chrisbellini.com/2007/11/06/onfrustrate/</link>
		<comments>http://www.chrisbellini.com/2007/11/06/onfrustrate/#comments</comments>
		<pubDate>Tue, 06 Nov 2007 14:40:06 +0000</pubDate>
		<dc:creator>Chris</dc:creator>
				<category><![CDATA[Internet Explorer]]></category>
		<category><![CDATA[Javascript]]></category>
		<category><![CDATA[Programming]]></category>

		<guid isPermaLink="false">http://www.chrisbellini.com/?p=669</guid>
		<description><![CDATA[The onChange event for HTML form elements is fired when the value of that element actually changes in Firefox/Seamonkey, Opera, Safari and any other other modern Web browser.  It just makes sense.  Yet for some lame reason with Internet Explorer, onChange is only fired once the focus on said form element is lost, [...]]]></description>
			<content:encoded><![CDATA[<p>The onChange event for HTML form elements is fired when the value of that element actually changes in <a href="http://www.mozilla.com/firefox/" target="_blank">Firefox</a>/<a href="http://www.mozilla.org/projects/seamonkey/" target="_blank">Seamonkey</a>, <a href="http://www.opera.com/" target="_blank">Opera</a>, <a href="http://www.apple.com/safari/" target="_blank">Safari</a> and any other other modern Web browser.  It just makes sense.  Yet for some lame reason with <a href="http://www.microsoft.com/windows/products/winfamily/ie/" target="_blank">Internet Explorer</a>, onChange is only fired once the focus on said form element is lost, effectively making onChange act like some freakish onChange+onBlur hybrid.  WTF?  I'm just wondering what the design reason that the Internet Explorer team at Microsoft came up with could be, is all.</p>
]]></content:encoded>
			<wfw:commentRss>http://www.chrisbellini.com/2007/11/06/onfrustrate/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>set @my_balance = select sum(savings_balance) from client_accounts where savings_balance &gt; 0.00</title>
		<link>http://www.chrisbellini.com/2007/07/25/set-my_balance-select-sumsavings_balance-from-client_accounts-where-savings_balance-000/</link>
		<comments>http://www.chrisbellini.com/2007/07/25/set-my_balance-select-sumsavings_balance-from-client_accounts-where-savings_balance-000/#comments</comments>
		<pubDate>Wed, 25 Jul 2007 12:45:24 +0000</pubDate>
		<dc:creator>Chris</dc:creator>
				<category><![CDATA[ASP.NET]]></category>
		<category><![CDATA[C#]]></category>
		<category><![CDATA[IIS]]></category>

		<guid isPermaLink="false">http://www.chrisbellini.com/?p=636</guid>
		<description><![CDATA[Today's Daily WTF post was one of their funny screenshot articles and one of them struck me as being quite familiar:

Die-hard readers of my blog may be thinking that based on the Diebold logo in the picture, that I'm reminded of one of my rants against slow Diebold ABMs.  It's not.  That "Object [...]]]></description>
			<content:encoded><![CDATA[<p><a href="http://worsethanfailure.com/Articles/Errord-Outside.aspx" target="_blank">Today's Daily WTF post</a> was one of their funny screenshot articles and one of them struck me as being quite familiar:</p>
<p><img src="/images/blog/diebold_asp.net_error.jpg" border="0" alt="IIS Error Message on a Diebold ATM" /></p>
<p>Die-hard readers of my blog may be thinking that based on the Diebold logo in the picture, that I'm reminded of <a href="http://www.chrisbellini.com/?p=565" target="_blank">one of my rants against slow Diebold ABMs</a>.  It's not.  That "Object reference not set to an instance of an object" ASP.NET error is the one that makes me shudder - more so, since this is a banking application.</p>
<p>Sometimes this is caused by trying to access variables and object beyond the current scope, but Visual Studio can notice these more often than not during a build.  Where I really get nabbed is when trying to access a null object.  Sure, sometimes it's just a slight oversight on my part and I try to access an objects methods and properties without actually instantiating it first.  Hey, it happens.  Yet, often I find that an object doesn't instantiate and I don't find until much later....like runtime later.  So I'm now conditioned to try to catch everything:</p>
<pre class="c">&nbsp;
   MyCoolClass myobject = <span style="color: #000000; font-weight: bold;">null</span>;
&nbsp;
   try
   <span style="color: #66cc66;">&#123;</span>
      myobject = new MyCoolClass<span style="color: #66cc66;">&#40;</span><span style="color: #66cc66;">&#41;</span>;
      myobject.<span style="color: #202020;">someVoidMethod</span><span style="color: #66cc66;">&#40;</span>SOME_CONSTANT<span style="color: #66cc66;">&#41;</span>;
   <span style="color: #66cc66;">&#125;</span>
   catch <span style="color: #66cc66;">&#40;</span>Exception ex<span style="color: #66cc66;">&#41;</span>
   <span style="color: #66cc66;">&#123;</span>
      Response.<span style="color: #202020;">Write</span><span style="color: #66cc66;">&#40;</span>ex.<span style="color: #202020;">Message</span>.<span style="color: #202020;">ToString</span><span style="color: #66cc66;">&#40;</span><span style="color: #66cc66;">&#41;</span><span style="color: #66cc66;">&#41;</span>;
   <span style="color: #66cc66;">&#125;</span>
   finally
   <span style="color: #66cc66;">&#123;</span>
      myobject = <span style="color: #000000; font-weight: bold;">null</span>;
   <span style="color: #66cc66;">&#125;</span>
&nbsp;</pre>
<p>That's my two cents, anyway <img src='http://www.chrisbellini.com/wp-includes/images/smilies/icon_wink.gif' alt=';)' class='wp-smiley' /> </p>
]]></content:encoded>
			<wfw:commentRss>http://www.chrisbellini.com/2007/07/25/set-my_balance-select-sumsavings_balance-from-client_accounts-where-savings_balance-000/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>visual studio &#8211; lessons learned</title>
		<link>http://www.chrisbellini.com/2007/05/09/visual-studio-lessons-learned/</link>
		<comments>http://www.chrisbellini.com/2007/05/09/visual-studio-lessons-learned/#comments</comments>
		<pubDate>Wed, 09 May 2007 13:08:36 +0000</pubDate>
		<dc:creator>Chris</dc:creator>
				<category><![CDATA[Microsoft Visual Studio]]></category>
		<category><![CDATA[Programming]]></category>

		<guid isPermaLink="false">http://www.chrisbellini.com/?p=617</guid>
		<description><![CDATA[Note to self:
If you've created a page that is correct from a business logic point-of-view, but may not make Visual Studio's visual designer happy, don't open the file in the visual designer.  The visual designer wants to correct your "shoddy" HTML.  The visual designer thinks that it knows you.  It doesn't.  [...]]]></description>
			<content:encoded><![CDATA[<p>Note to self:</p>
<p>If you've created a page that is correct from a business logic point-of-view, but may not make <a href="http://msdn2.microsoft.com/en-ca/vstudio/default.aspx" target="_blank">Visual Studio</a>'s visual designer happy, don't open the file in the visual designer.  The visual designer wants to correct your "shoddy" HTML.  The visual designer thinks that it knows you.  It doesn't.  It wants to kill you, and charm your spouse and children so that they forget that you ever existed.  Well, maybe not entirely.  Regardless, whatever you do, don't lose your head and think that you can use your VB or C# code-behind to load up some placeholder controls with your own HTML.  That's kids' talk - crazy talk.  Keep it together, man.  Pure and simple - don't view the page in the visual designer.  Code view?  Yes.  Visual designer?  No.</p>
<p>That is all <img src='http://www.chrisbellini.com/wp-includes/images/smilies/icon_smile.gif' alt=':)' class='wp-smiley' /> </p>
]]></content:encoded>
			<wfw:commentRss>http://www.chrisbellini.com/2007/05/09/visual-studio-lessons-learned/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>coding the painful way for all to hear</title>
		<link>http://www.chrisbellini.com/2007/02/22/coding-the-painful-way/</link>
		<comments>http://www.chrisbellini.com/2007/02/22/coding-the-painful-way/#comments</comments>
		<pubDate>Thu, 22 Feb 2007 11:19:19 +0000</pubDate>
		<dc:creator>Chris</dc:creator>
				<category><![CDATA[Programming]]></category>
		<category><![CDATA[Vista]]></category>
		<category><![CDATA[VoiceCode]]></category>
		<category><![CDATA[speech recognition]]></category>

		<guid isPermaLink="false">http://www.chrisbellini.com/?p=601</guid>
		<description><![CDATA[Last summer, I posted about a cool open-source project from the National Research Council of Canada, known as Voice Code, that allows developers to code by talking.  From the demos that I've watched, VoiceCode performs very well, and shows promise.  However, Windows Vista includes speech recognition functionality, and doesn't appear to be on [...]]]></description>
			<content:encoded><![CDATA[<p>Last summer, <a href="http://www.chrisbellini.com/?p=520" target="_blank">I posted about a cool open-source project from the National Research Council of Canada, known as Voice Code, that allows developers to code by talking</a>.  From the demos that I've watched, <a href="http://iit-iti.nrc-cnrc.gc.ca/projects-projets/voicecode_e.html" target="_blank">VoiceCode</a> performs very well, and shows promise.  However, <a href="http://www.microsoft.com/windows/products/windowsvista/" target="_blank">Windows Vista</a> includes speech recognition functionality, and doesn't appear to be on par with VoiceCode in terms of recognition accuracy, as evidenced by this poor soul who attempted to create a simple <a href="http://www.perl.com" target="_blank">Perl</a> script with his voice.</p>
<p><object width="425" height="350"><param name="movie" value="http://www.youtube.com/v/KyLqUf4cdwc"></param><param name="wmode" value="transparent"></param><embed src="http://www.youtube.com/v/KyLqUf4cdwc" type="application/x-shockwave-flash" wmode="transparent" width="425" height="350"></embed></object></p>
<p>It took that guy over ten minutes to "write" simple Perl code to read the contents of a file and print them to standard output!  Now I know that it's not completely fair to compare VoiceCode (aimed at software development tasks) to Vista's speech recognition capabilities (aimed at general computer use and word processing and the like).  But that script was not an example of advanced programming techniques and methodologies - there were no classes, functions, <acronym title="Abstract Data Type">ADT</acronym> definitions or elaborate syntax.</p>
<p>I guess sometimes, you don't get what you pay for.</p>
]]></content:encoded>
			<wfw:commentRss>http://www.chrisbellini.com/2007/02/22/coding-the-painful-way/feed/</wfw:commentRss>
		<slash:comments>1</slash:comments>
		</item>
		<item>
		<title>the python programming language and its love of &#8220;whitespace&#8221;&#8230;eeeew</title>
		<link>http://www.chrisbellini.com/2006/11/23/python-language-and-its-love-of-whitespaceeeeew/</link>
		<comments>http://www.chrisbellini.com/2006/11/23/python-language-and-its-love-of-whitespaceeeeew/#comments</comments>
		<pubDate>Thu, 23 Nov 2006 11:50:58 +0000</pubDate>
		<dc:creator>Chris</dc:creator>
				<category><![CDATA[Programming]]></category>
		<category><![CDATA[Python]]></category>
		<category><![CDATA[porn]]></category>

		<guid isPermaLink="false">http://www.chrisbellini.com/?p=571</guid>
		<description><![CDATA[A couple of weeks ago, I rebuilt our desktop computer; the ol' format and reinstall everything shuffle.  I like to do it a couple of times a year; usually coinciding with when my annual anti virus subscription expires.  It is, however, dreadfully boring downloading and reinstalling the latest versions of the software that [...]]]></description>
			<content:encoded><![CDATA[<p>A couple of weeks ago, I rebuilt our desktop computer; the ol' format and reinstall everything shuffle.  I like to do it a couple of times a year; usually coinciding with when my annual anti virus subscription expires.  It is, however, dreadfully boring downloading and reinstalling the latest versions of the software that I use all over again.</p>
<p>I've written a few <a href="http://www.python.org" target="_blank">Python</a> scripts to automate various tasks, so I needed to get a Python interpreter installed on my fresh installation of Windows.  After reinstalling a lot of software in a short amount of time, my brain switched to autopilot and I entered <em>python.com</em> in Firefox's address bar.  I hit ENTER and averted my gaze to the TV.  When I turned back to look at the monitor, I noticed that there was some "hot oral and anal action" on my screen; two things that aren't typically associated with Python programming, unless you're shouting at your computer because the buggy Python script that you're writing is a pain in the ass.  I then noticed the ".com" that I mistakenly entered in the URL and promptly changed it to the proper <em>python.<strong>org</strong></em>.  I bet python.com gets many visitors who were originally looking for python.org.  Yet I wonder if any people looking for python.com accidentally visit python.org and become convinced that writing code would put their to hands to...ahem...better use.  I'm glad that porn sites were too late to register clever domain names for other scripting languages' web sites like <a href="http://www.perl.com" target="_blank">Perl</a>; they could've had fun with that one <img src='http://www.chrisbellini.com/wp-includes/images/smilies/icon_wink.gif' alt=';)' class='wp-smiley' /> </p>
]]></content:encoded>
			<wfw:commentRss>http://www.chrisbellini.com/2006/11/23/python-language-and-its-love-of-whitespaceeeeew/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
	</channel>
</rss>
