<?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>Think Dietz</title>
	<atom:link href="http://thinkdietz.com/feed" rel="self" type="application/rss+xml" />
	<link>http://thinkdietz.com</link>
	<description>thinking about code</description>
	<lastBuildDate>Tue, 01 May 2012 13:20:13 +0000</lastBuildDate>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=3.2.1</generator>
		<item>
		<title>Engineering Code: Thinking Practically 1</title>
		<link>http://thinkdietz.com/engineering-code-thinking-practically-1.html</link>
		<comments>http://thinkdietz.com/engineering-code-thinking-practically-1.html#comments</comments>
		<pubDate>Tue, 01 May 2012 13:14:24 +0000</pubDate>
		<dc:creator>dan</dc:creator>
				<category><![CDATA[Uncategorized]]></category>

		<guid isPermaLink="false">http://thinkdietz.com/?p=302</guid>
		<description><![CDATA[I’m a practical guy. I like utilitarian pottery, stuff like butter dishes by Warren MacKenzie. I’m not a big fan of vases that just site there and look nice. If... <a class="read-more" href="http://thinkdietz.com/engineering-code-thinking-practically-1.html">Read the Rest &#8594;</a>]]></description>
			<content:encoded><![CDATA[<p>I’m a practical guy. I like utilitarian pottery, stuff like butter dishes by Warren MacKenzie. I’m not a big fan of vases that just site there and look nice. If you’re going to make something, give it a purpose.<br />
I’ve written about ten attributes of high quality software, by analogy, in <a href="http://thinkdietz.com/engineering-code-ten-attributes-of-quality.html" title="Engineering Code: Ten Attributes of Quality">the previous article</a>.  Now I want to give some practical things that can be done to build those attributes into software for the web.</p>
<h4>- Correct: BDD</h4>
<p> A slow Porsche isn’t going to get you any ladies, and incorrect software isn’t going to meet your business objectives. If software isn’t correct, it really doesn’t solve the problem it was supposed to solve. Correct software is software that works the way it was supposed to. To produce correct software, I like Behaviour-Driven Development (BDD). BDD revolves around writing software specs that are testable with statements like:</p>
<blockquote><p>Given [initial context], when [event occurs], then [ensure some outcomes].</p></blockquote>
<p>In order to generate the tests for BDD, collaboration is needed between developers, QA, and the non-technical business guys. This collaboration makes sure that 1) the problem is understood and 2) informs everyone as to what the solution to the problem looks like. Often time software is incorrect because the developer didn’t understand #1 or the client didn’t understand #2.</p>
<p>Here&#8217;s an example BDD test using <a href="http://visionmedia.github.com/mocha/" title="Mocha - the fun, simple, flexible JavaScript test framework">Mocha</a>:</p>
<pre><code>describe('Array', function(){
  describe('#indexOf()', function(){
    it('should return -1 when the value is not present', function(){
      [1,2,3].indexOf(5).should.equal(-1);
      [1,2,3].indexOf(0).should.equal(-1);
    })
  })
})</code></pre>
<h4>- Robustness: Tests &#038; Abstraction</h4>
<p>By subjecting every input on a web page to a standard battery of tests you can generally catch common faults in robustness. The test suite should include a variety of ridiculous values which might include things like numbers in text fields, text in number fields, blanks in required fields, foreign characters, html entities, URL component separators, and others. <a href="http://seleniumhq.org/" title="selenium">Selenium</a> and other UI test suites are good candidates for this, but can take a long time to setup, run, and maintain.</p>
<p>But even with good tests, keep in mind what E. Dijkstra said “testing shows the presence, not the absence of bugs”.</p>
<p>Using abstraction layers to scrub user input is also a great way to build robust systems. The abstraction layer provides a single location where the cleaning logic resides, and keeps your code base clear of repetitive tasks like converting NULL values to empty strings (should your application need such logic) or avoiding division by zero.</p>
<p>And because it’s hard to anticipate every “wrong” input, the abstraction layer provides a way to add additional robustness with little effort. The abstraction layer can be as simple as good routines. Here’s an example from Code Complete where Steve demonstrates the value of a routine, that consisted of just one line of code, when additional robustness was later needed:</p>
<pre><code>Function DeviceUnitsToPoints ( deviceUnits Integer ): Integer
  DeviceUnitsToPoints = deviceUnits * ( POINTS_PER_INCH / DeviceUnitsPerInch() )
End Function</code></pre>
<p>Which was updated once it was discovered that DeviceUnitsPerInch() might return 0:</p>
<pre><code>Function DeviceUnitsToPoints ( deviceUnits Integer ): Integer
  If ( DeviceUnitsPerInch() <> 0 )
    DeviceUnitsToPoints = deviceUnits
                        * ( POINTS_PER_INCH / DeviceUnitsPerInch() )
  Else
    DeviceUnitsToPoints = 0
  End If
End Function</code></pre>
<h4>- User-friendliness: Failover AJAX</h4>
<p>The fact of the matter is most people don’t like using computers.  There is a handful of us out there that do, and we’re weird. The weird people that speak computer are in the minority, so it makes sense that most software isn’t written for that crowd.  Software is written for the majority, which don’t speak computer.<br />
With this fundamental principle understood it’s important to make software enjoyable to use.  Any hurdle and it’s game over. The problem is that user-friendly software is hard. I like writing console apps, they’re quick to build, and they’re easy to test. But they’re a pain to use. I find myself using &#8220;&#8211;help&#8221; more often than I would like to omit for apps that I wrote!</p>
<p>When it comes to web apps you need to keep the number of clicks down, place related information together, and explain errors (when they occur) in plain English. I’m not a graphic designer or information architect, so I’ll steer clear of the UI stuff and elaborate on user friendliness when it comes to error reporting.</p>
<p>If an ajax call fails, we don’t want to leave the user hanging.  We want to tell them that they need to login again, try the action again, or provide a valid value… something.<br />
We can do that by writing the javascript with a failover.  In other words, if the AJAX fails, the code handles it with a backup plan.  Usually we think of failover in terms of robustness, but for web applications I really like to put this into the User-friendly category because it makes using the web much more enjoyable when done right.</p>
<p>Here’s an example that looks for oData['success'] and if the success property is set to false, or isn’t even present (like a 500 error might produce) the js displays an error. </p>
<p>Here we use the OR operator to test for the success property, which produces the failover:</p>
<pre><code>//ajax that "fails over"
$.get(href, function (oData, textStatus) { 

  if ( oData['success'] || false ) {
    tgt.after("" + (oData['success'] || 'Subscription added.') + "");
    $("#subsvcmsg").attr("id", "").fadeOut(2500, function() { $(this).remove(); }); 

  } else {
    tgt.after("" + (oData['error']
      || 'An unknown error occurred trying to modify that subscription') + "");
    $("#subsvcmsg").attr("id", "").fadeOut(2500, function() { $(this).remove(); }); 

  }
});</code></pre>
<p>This approach assumes you’re always passing back JSON, which I think is a nice way to go, but something similar can we done with xml, text, etc. In this example common errors like a stale session can be managed server side with details sent to the user on logging in again.  But even if we don’t catch the error we tell the user that we didn’t save their change so they aren’t left guessing.  And keeping users from guessing is the core of user-friendly design.</p>
]]></content:encoded>
			<wfw:commentRss>http://thinkdietz.com/engineering-code-thinking-practically-1.html/feed</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Engineering Code: Ten Attributes of Quality</title>
		<link>http://thinkdietz.com/engineering-code-ten-attributes-of-quality.html</link>
		<comments>http://thinkdietz.com/engineering-code-ten-attributes-of-quality.html#comments</comments>
		<pubDate>Tue, 01 May 2012 01:39:37 +0000</pubDate>
		<dc:creator>dan</dc:creator>
				<category><![CDATA[Design]]></category>
		<category><![CDATA[Programming]]></category>

		<guid isPermaLink="false">http://thinkdietz.com/?p=287</guid>
		<description><![CDATA[Here&#8217;s some attributes that are commonly cited as being associated with high quality software: correctness, robustness, user-friendliness, adapt-ability, reuse-ability, interoper-ability, efficiency, port-ability, security, and replace-ability. Dan Wooster recently asked what... <a class="read-more" href="http://thinkdietz.com/engineering-code-ten-attributes-of-quality.html">Read the Rest &#8594;</a>]]></description>
			<content:encoded><![CDATA[<p>Here&#8217;s some attributes that are commonly cited as being associated with high quality software: <strong>correctness, robustness, user-friendliness, adapt-ability, reuse-ability, interoper-ability, efficiency, port-ability, security, and replace-ability</strong>.</p>
<p><a href="http://woosters.org/dan/education/what-makes-software-worthwhile/">Dan Wooster</a> recently asked what I thought about those attributes. My immediate reaction was that they&#8217;re a great description of what high quality code looks like. But I asked myself:</p>
<blockquote><p>What is it about those attributes that are so great? Why do those attributes go hand in hand with high quality code?</p></blockquote>
<p>Software has been around for a while, but &#8220;hardware&#8221; has been around for much longer. In this context, when I say &#8220;hardware&#8221; I&#8217;m referring to stuff like buildings, spoons, or your underwear. And because hardware has been around for so long, we&#8217;ve been designing hardware for a very long time. For example, since the inception of the wheel we&#8217;ve been trying to make a better cart. I won&#8217;t say we&#8217;ve perfected carts yet, but a <a href="http://en.wikipedia.org/wiki/Porsche_944">Porsche 944</a> is probably as close as we&#8217;ll get.</p>
<p>Engineering, the study of how to design hardware, has been around for so long that we&#8217;ve started to <a href="http://www.amazon.com/The-Boy-Engineer-Engineering-Prehistoric/dp/B0007E6I00">study Engineering</a> itself. When we boil down Engineering to its syrupy-goodness we find that it&#8217;s really about solving problems. After all, the hardware that engineering produces fills a need that we have: going down the highway really fast and attracting the ladies.</p>
<p>What does this have to do with programming? Code solves problems, just like cars solve problems. And the things that we know about the engineering of hardware applies to the engineering of software. When we approach a problem in the digital world, we solve it just like problems in the physical world. The application of engineering in both cases should produce a high quality solution, whether tangible like a Porsche 944, or intangible like <a title="ThinkDietz" href="http://thinkdietz.com">my blog</a>.</p>
<p>Defining &#8220;high quality&#8221; for things like Porches is easy: does it go fast and do the ladies flock in your direction. Doing so for software isn&#8217;t so easy because, well it&#8217;s intangible. Okay so maybe a 944 is high quality for more than just going fast and being a chic magnet. In fact, I&#8217;d say that a 944 exhibits those ten attributes I got started with. Again, good engineering produces high quality stuff, regardless of whether the stuff is tangible or intangible.</p>
<p>There&#8217;s lots of web &#8220;developers&#8221; out there that fail to engineer the code they write. The result is the same as if we were to build a car without engineering. Imagine if you had a car that lacked any of these attributes, and then think about what that means for software that is lacking the same:</p>
<h4>- Correct (Works)</h4>
<p><strong>Car:</strong> Does the engine run, lights work, and breaks engage?<br />
<strong>Software:</strong> Does the software do what it is suppose to do (according to the design specs)?</p>
<h4>- Robustness</h4>
<p><strong>Car:</strong> Can you use unleaded gasoline from any fueling station, or just the one at the dealership? Can you turn on the radio while the windows are both up and down? Those are silly… what if you misuse the brakes: slam your foot to the floor? Do the wheels lock and skid or do they “anti-lock”?<br />
<strong>Software:</strong> Does the software respond to unexpected conditions (wrong input)?</p>
<h4>- User-friendliness</h4>
<p><strong>Car:</strong> Do you need to hand crank the engine, or can you just turn a key? Can you go forwards and backwards, or do you need to get out and push to back out?<br />
<strong>Software:</strong> Is the software easy to use by users from the intended audience?</p>
<h4>- Adapt-ability</h4>
<p><strong>Car:</strong> Can you change out the tires on snowy days, or put in special headlights?<br />
<strong>Software:</strong> How difficult is it to modify the software to adjust to an ever-changing world?</p>
<h4>- Reuse-ability</h4>
<p><strong>Car:</strong> Can the oil filter on your car be used on other cars, or do you need a trip to the dealership for the specific one made just for your make and model?<br />
<strong>Software:</strong> can parts of the software be easily reused to build other software systems?</p>
<h4>- Interoper-ability</h4>
<p><strong>Car:</strong> Do the rear brakes and front brakes work together or do you need two brake pedals?<br />
<strong>Software:</strong> Does the software interface with other software systems?</p>
<h4>- Efficiency</h4>
<p><strong>Car:</strong> Do you get 30 miles per gallon, or 10 gallons per mile?<br />
<strong>Software:</strong> Does the software make good use of its resources (memory, disk, CPU, network)?</p>
<h4>- Port-ability</h4>
<p><strong>Car:</strong> Can you use your car in different states, types of roads, and speeds?<br />
<strong>Software:</strong> Can the software be easily ported (moved) to other operating systems (or in today’s world, browser)?</p>
<h4>- Security</h4>
<p><strong>Car:</strong> Are you protected by seat belts, airbags, auto-shutoff fuel pumps, etc.<br />
<strong>Software:</strong> Does the software protect the information it is responsible for?</p>
<h4>- Replace-ability</h4>
<p><strong>Car:</strong> Can you get a new muffler, or does a hole in the exhaust mean buying a new car?<br />
<strong>Software:</strong> can the software be easily replaced someday?</p>
<p>No one would put up with a car that doesn&#8217;t start, only takes gas from the dealership, requires you get out and push to back it up, can&#8217;t adapt to night because there&#8217;s no lights, costs a fortune because it&#8217;s made of all custom built parts, has two brake pedals, burns 10 gallons of gas per mile, can only drive in one state, has no safety features, and requires a new car whenever the muffler goes bad.</p>
<p>No one should put up with software like that either.</p>
<p>Part Two-<br />
<a href="http://thinkdietz.com/engineering-code-thinking-practically-1.html" title="Engineering Code: Thinking Practically 1">Engineering Code: Thinking Practically</a></p>
]]></content:encoded>
			<wfw:commentRss>http://thinkdietz.com/engineering-code-ten-attributes-of-quality.html/feed</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Line Numbers in SQL Server 2005 Management Studio</title>
		<link>http://thinkdietz.com/line-numbers-in-sql-server-2005-management-studio.html</link>
		<comments>http://thinkdietz.com/line-numbers-in-sql-server-2005-management-studio.html#comments</comments>
		<pubDate>Thu, 23 Feb 2012 15:09:35 +0000</pubDate>
		<dc:creator>dan</dc:creator>
				<category><![CDATA[Uncategorized]]></category>

		<guid isPermaLink="false">http://thinkdietz.com/?p=285</guid>
		<description><![CDATA[Most line numbers I get back from MS SQL Server are all the same: line 1. However, when working on big queries with a team or reviewing logged errors from... <a class="read-more" href="http://thinkdietz.com/line-numbers-in-sql-server-2005-management-studio.html">Read the Rest &#8594;</a>]]></description>
			<content:encoded><![CDATA[<p>Most line numbers I get back from MS SQL Server are all the same: line 1.</p>
<p>However, when working on big queries with a team or reviewing logged errors from stored procedures, using the line numbers in Management Studio is invaluable.</p>
<blockquote><p>
Tools > Options<br />
Expand the Text Editor node<br />
Select the All Languages node<br />
Under the Display header in the right pane, check the Line Numbers box
</p></blockquote>
]]></content:encoded>
			<wfw:commentRss>http://thinkdietz.com/line-numbers-in-sql-server-2005-management-studio.html/feed</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>jQuery Hybrid Droplist Text Input</title>
		<link>http://thinkdietz.com/jquery-hybrid-droplist-text-input.html</link>
		<comments>http://thinkdietz.com/jquery-hybrid-droplist-text-input.html#comments</comments>
		<pubDate>Wed, 22 Feb 2012 22:47:52 +0000</pubDate>
		<dc:creator>dan</dc:creator>
				<category><![CDATA[Uncategorized]]></category>

		<guid isPermaLink="false">http://thinkdietz.com/?p=277</guid>
		<description><![CDATA[I recently needed a form input that acted like a select input with a droplist of items, but it also had to allow the customer to type in a custom... <a class="read-more" href="http://thinkdietz.com/jquery-hybrid-droplist-text-input.html">Read the Rest &#8594;</a>]]></description>
			<content:encoded><![CDATA[<p>I recently needed a form input that acted like a select input with a droplist of items, but it also had to allow the customer to type in a custom value. The customer wanted an input with and autocomplete droplist that didn&#8217;t force the user to use one of the autocomplete items.</p>
<p>In the jQuery docs there&#8217;s a jQuery UI Autocomplete Combobox Plugin. Since we use jQuery and the UI, I started with this code and did a simple update around where the autocomplete input is blanked out for &#8220;invalid&#8221; inputs:</p>
<pre><code>if ( !valid &#038;&#038; select.data(&quot;prevent_input&quot;) )</code></pre>
<p>The &#8220;prevent_input&#8221; setting will prevent the user from providing their own values if set to true (works like a standard select). Or it will allow user provided values if set to false (works like a standard input).</p>
<p>Configuring the input with jQuery data lets us set a default value like this:</p>
<pre><code>&lt;select id=&quot;your_select_id&quot; data-prevent_input=&quot;true&quot;/&gt;
...
$('#your_select_id').combobox();</code></pre>
<p>Note that the default behavior is to allow user provided values, but could be easily set to work the other way around.</p>
<p>Using jQuery.data() lets us change the behavior if your application needs to dynamically update this functionality:</p>
<pre><code>jQuery('#your_select_id').data(&quot;prevent_input&quot;, false);</code></pre>
<p>Here&#8217;s the plugin:</p>
<pre><code>
/**
 * jQuery UI Autocomplete Combobox Plugin
 *
 * Customized to allow users to type in arbitrary values
 *
 * @author dand
 * @since 10/21/2011
 * @see http://jqueryui.com/demos/autocomplete/#combobox
 */
(function( $ ) {
	$.widget( &quot;ui.combobox&quot;, {
		_create: function() {
			var self = this,
				select = this.element.hide(),
				selected = select.children( &quot;:selected&quot; ),
				value = selected.val() ? selected.text() : &quot;&quot;;
			var input = this.input = $( &#39;&lt;input id=&quot;&#39; + select.attr(&#39;id&#39;).replace(/_options/,&#39;&#39;) + &#39;&quot;&gt;&#39; )
				.insertAfter( select )
				.val( value )
				.autocomplete({
					delay: 0,
					minLength: 0,
					source: function( request, response ) {
						var matcher = new RegExp( $.ui.autocomplete.escapeRegex(request.term), &quot;i&quot; );
						response( select.children( &quot;option&quot; ).map(function() {
							var text = $( this ).text();
							if ( this.value &amp;&amp; ( !request.term || matcher.test(text) ) )
								return {
									label: text.replace(
										new RegExp(
											&quot;(?![^&amp;;]+;)(?!&lt;[^&lt;&gt;]*)(&quot; +
											$.ui.autocomplete.escapeRegex(request.term) +
											&quot;)(?![^&lt;&gt;]*&gt;)(?![^&amp;;]+;)&quot;, &quot;gi&quot;
										), &quot;&lt;strong&gt;$1&lt;/strong&gt;&quot; ),
									value: text,
									option: this
								};
						}) );
					},
					select: function( event, ui ) {
						ui.item.option.selected = true;
						self._trigger( &quot;selected&quot;, event, {
							item: ui.item.option
						});

					},
					change: function( event, ui ) {
						if ( !ui.item ) {
							var matcher = new RegExp( &quot;^&quot; + $.ui.autocomplete.escapeRegex( $(this).val() ) + &quot;$&quot;, &quot;i&quot; ),
								valid = false;
							select.children( &quot;option&quot; ).each(function() {
								if ( $( this ).text().match( matcher ) ) {
									this.selected = valid = true;
									return false;
								}
							});

							if ( !valid &amp;&amp; select.data(&quot;prevent_input&quot;) ) {
								// remove invalid value, as it didn&#39;t match anything
								$( this ).val( &quot;&quot; );
								select.val( &quot;&quot; );
								input.data( &quot;autocomplete&quot; ).term = &quot;&quot;;
								return false;
							}
						}
					}
				})
				.addClass( &quot;ui-widget ui-widget-content ui-corner-left&quot; );

			input.data( &quot;autocomplete&quot; )._renderItem = function( ul, item ) {
				return $( &quot;&lt;li&gt;&lt;/li&gt;&quot; )
					.data( &quot;item.autocomplete&quot;, item )
					.append( &quot;&lt;a&gt;&quot; + item.label + &quot;&lt;/a&gt;&quot; )
					.appendTo( ul );
			};

			this.button = $( &quot;&lt;button type=&#39;button&#39;&gt;&amp;nbsp;&lt;/button&gt;&quot; )
				.attr( &quot;tabIndex&quot;, -1 )
				.attr( &quot;title&quot;, &quot;Show All Items&quot; )
				.insertAfter( input )
				.button({
					icons: {
						primary: &quot;ui-icon-triangle-1-s&quot;
					},
					text: false
				})
				.removeClass( &quot;ui-corner-all&quot; )
				.addClass( &quot;ui-corner-right ui-button-icon&quot; )
				.click(function() {
					// close if already visible
					if ( input.autocomplete( &quot;widget&quot; ).is( &quot;:visible&quot; ) ) {
						input.autocomplete( &quot;close&quot; );
						return;
					}

					// work around a bug (likely same cause as #5265)
					$( this ).blur();

					// pass empty string as value to search for, displaying all results
					input.autocomplete( &quot;search&quot;, &quot;&quot; );
					input.focus();
				});
		},

		destroy: function() {
			this.input.remove();
			this.button.remove();
			this.element.show();
			$.Widget.prototype.destroy.call( this );
		}
	});
})( jQuery );
</code></pre>
<p>Our customer loved the solution because it was both what they wanted AND cheap since it was fast to develop. Hope you enjoy!</p>
]]></content:encoded>
			<wfw:commentRss>http://thinkdietz.com/jquery-hybrid-droplist-text-input.html/feed</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>UPS Error 111286</title>
		<link>http://thinkdietz.com/ups-error-111286.html</link>
		<comments>http://thinkdietz.com/ups-error-111286.html#comments</comments>
		<pubDate>Thu, 19 Jan 2012 14:09:03 +0000</pubDate>
		<dc:creator>dan</dc:creator>
				<category><![CDATA[Uncategorized]]></category>

		<guid isPermaLink="false">http://thinkdietz.com/?p=269</guid>
		<description><![CDATA[I had an odd issue with UPS shipment methods the other day. A customer complained that their Canadian address was not returning UPS shipment pricing. It&#8217;s important to note that... <a class="read-more" href="http://thinkdietz.com/ups-error-111286.html">Read the Rest &#8594;</a>]]></description>
			<content:encoded><![CDATA[<p>I had an odd issue with UPS shipment methods the other day.  A customer complained that their Canadian address was not returning UPS shipment pricing.  It&#8217;s important to note that on this particular (old) website, Canadian addresses are hand typed by the user into standard text inputs. Oops!</p>
<p>Don&#8217;t let users have the opportunity to enter garbage data.  If you do, they will.  It&#8217;s just one of those laws of the universe.  Thermodynamics?</p>
<p>Here&#8217;s the error:</p>
<pre><code>UPS: 111286: {Provided State} is not a valid state for the specified shipment.</code></pre>
<p>The state the user provided was:</p>
<pre><code>On</code></pre>
<p>Why didn&#8217;t that work?  The state codes are case sensitive, and must be exact.  Changing the customer&#8217;s address to use the following solved the problem:</p>
<pre><code>ON</code></pre>
<p>Note: I&#8217;ve seen other people with this problem on the web.  They complained about values like &#8220;Ontario&#8221; not being valid. Don&#8217;t let the user provide bad inputs, give them a select list of valid state codes.</p>
]]></content:encoded>
			<wfw:commentRss>http://thinkdietz.com/ups-error-111286.html/feed</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Using GIT and p4merge on Mac OSX</title>
		<link>http://thinkdietz.com/using-git-and-p4merge-on-mac-osx.html</link>
		<comments>http://thinkdietz.com/using-git-and-p4merge-on-mac-osx.html#comments</comments>
		<pubDate>Wed, 03 Aug 2011 05:13:42 +0000</pubDate>
		<dc:creator>dan</dc:creator>
				<category><![CDATA[Uncategorized]]></category>

		<guid isPermaLink="false">http://thinkdietz.com/?p=217</guid>
		<description><![CDATA[I found an article on setting up my .gitconfig file to launch p4merge as my custom merge tool: Using p4merge as a custom Git merge tool on Mac OS X... <a class="read-more" href="http://thinkdietz.com/using-git-and-p4merge-on-mac-osx.html">Read the Rest &#8594;</a>]]></description>
			<content:encoded><![CDATA[<p>I found an article on setting up my .gitconfig file to launch p4merge as my custom merge tool:<br />
<a href="http://deeperdesign.wordpress.com/2011/05/27/using-p4merge-as-a-custom-git-merge-tool-on-mac-os-x/">Using p4merge as a custom Git merge tool on Mac OS X</a></p>
<p>The problem was I would get the following errors when there were spaces in my merge file paths. For a path like <strong>/path/to the/file.rb</strong> I would get something like:</p>
<pre><code>
Incorrect parameters:
Too many files: You may enter a maximum of 4 files.
'/path/to' is (or points to) an invalid file.
'the/file.rb' is (or points to) an invalid file.
...
</code></pre>
<p>Here&#8217;s the easy solution that fixed this problem on my system:</p>
<pre><code>
[merge]
    keepBackup = false
	tool = custom
[mergetool "custom"]
	cmd = /Applications/p4merge.app/Contents/Resources/launchp4merge "\"$PWD/$BASE\"" "\"$PWD/$REMOTE\"" "\"$PWD/$LOCAL\"" "\"$PWD/$MERGED\""
	keepTemporaries = false
	trustExitCode = false
	keepBackup = false
</code></pre>
<p>Notice the extra (escaped) quote marks around the parameters.  This could also be handled with a shell script, but I didn&#8217;t want an extra moving part to make the magic happen. Life is already complicated&#8230;</p>
]]></content:encoded>
			<wfw:commentRss>http://thinkdietz.com/using-git-and-p4merge-on-mac-osx.html/feed</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Sitting Is Killing You</title>
		<link>http://thinkdietz.com/sitting-is-killing-you.html</link>
		<comments>http://thinkdietz.com/sitting-is-killing-you.html#comments</comments>
		<pubDate>Mon, 01 Aug 2011 14:58:22 +0000</pubDate>
		<dc:creator>dan</dc:creator>
				<category><![CDATA[Life]]></category>

		<guid isPermaLink="false">http://thinkdietz.com/?p=203</guid>
		<description><![CDATA[Via: Medical Billing And Coding And me at my standing desk:]]></description>
			<content:encoded><![CDATA[<p><a href="http://www.medicalbillingandcoding.org/sitting-kills"><img src="http://images.medicalbillingandcoding.org.s3.amazonaws.com/sitting-is-killing-you.jpg" alt="Sitting is Killing You" width="500"  border="0" /></a><br />Via: <a href="http://www.medicalbillingandcoding.org">Medical Billing And Coding</a></p>
<p>And me at my standing desk:<br/><br />
<a href="http://thinkdietz.com/wp-content/uploads/standing_desk_n.jpg"><img src="http://thinkdietz.com/wp-content/uploads/standing_desk_n.jpg" alt="" title="standing_desk_n" width="720" height="540" class="aligncenter size-full wp-image-205" /></a></p>
]]></content:encoded>
			<wfw:commentRss>http://thinkdietz.com/sitting-is-killing-you.html/feed</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Duff&#8217;s Device</title>
		<link>http://thinkdietz.com/javascript-algorithms.html</link>
		<comments>http://thinkdietz.com/javascript-algorithms.html#comments</comments>
		<pubDate>Thu, 24 Feb 2011 00:52:27 +0000</pubDate>
		<dc:creator>dan</dc:creator>
				<category><![CDATA[JavaScript]]></category>

		<guid isPermaLink="false">http://thinkdietz.com/?p=92</guid>
		<description><![CDATA[I&#8217;m currently enjoying reading about algorithms that have been implemented in javascript. Here&#8217;s one called Duff&#8217;s Device that speeds up the execution of large loops by reducing the number of... <a class="read-more" href="http://thinkdietz.com/javascript-algorithms.html">Read the Rest &#8594;</a>]]></description>
			<content:encoded><![CDATA[<p>I&#8217;m currently enjoying reading about algorithms that have been implemented in javascript.  Here&#8217;s one called Duff&#8217;s Device that speeds up the execution of large loops by reducing the number of iterations over the loop:</p>
<pre>
<code>
// Begin actual Duff's Device
// JS Implementation by Jeff Greenberg 2/2001

var n = iterations / 8;
var caseTest = iterations % 8;    

do {

    switch (caseTest){
    case 0:              [Do Something to tesVal here];
    case 7:              [Do Something to tesVal here];
    case 6:              [Do Something to tesVal here];
    case 5:              [Do Something to tesVal here];
    case 4:              [Do Something to tesVal here];
    case 3:              [Do Something to tesVal here];
    case 2:              [Do Something to tesVal here];
    case 1:              [Do Something to tesVal here];

    }
    caseTest=0;

}

while (--n > 0);
</code>
</pre>
]]></content:encoded>
			<wfw:commentRss>http://thinkdietz.com/javascript-algorithms.html/feed</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Dynamic CC Month and Year Drop List</title>
		<link>http://thinkdietz.com/dynamic-cc-month-and-year-drop-list.html</link>
		<comments>http://thinkdietz.com/dynamic-cc-month-and-year-drop-list.html#comments</comments>
		<pubDate>Fri, 22 Oct 2010 00:49:02 +0000</pubDate>
		<dc:creator>dan</dc:creator>
				<category><![CDATA[PHP]]></category>

		<guid isPermaLink="false">http://thinkdietz.com/?p=78</guid>
		<description><![CDATA[I did a quick little Google search for a dynamic month and year droplist for credit card expiration dates. I tried two or three searches in Google and couldn&#8217;t find... <a class="read-more" href="http://thinkdietz.com/dynamic-cc-month-and-year-drop-list.html">Read the Rest &#8594;</a>]]></description>
			<content:encoded><![CDATA[<p>I did a quick little Google search for a dynamic month and year droplist for credit card expiration dates.  I tried two or three searches in Google and couldn&#8217;t find anything for PHP.  So I rolled my own:</p>
<pre>
<code>
//Inside my view
&lt;select id=&quot;exp_month&quot; name=&quot;exp_month&quot;&gt;
	&lt;?php MonthList() ?&gt;
&lt;/select&gt;

&lt;select id=&quot;exp_year&quot; name=&quot;exp_year&quot;&gt;
	&lt;?php YearList() ?&gt;
&lt;/select&gt;

//In your model/controller or some other place you like to keep random stuff like this
/**
 * Populate the credit card expiration month drop down
 */
function MonthList(){
	for($i=0; $i&lt;=11; $i++){
		$time = mktime(0, 0, 0, 1+$i, 1, 2000);
		$sMonthOptions .= &#39;&lt;option value=&quot;&#39; . date(&#39;m&#39;, $time) . &#39;&quot;&gt;&#39; . date(&#39;M&#39;, $time) . &#39;&lt;/option&gt;&#39;;
	}
	echo $sMonthOptions;
}

/**
 * Populate the credit card expiration year drop down (go out 12 years)
 */
function YearList(){
	for($i=0; $i&lt;=11; $i++){
		$nextyear = date(&quot;Y&quot;, mktime(0, 0, 0, 1, 1, date(&quot;Y&quot;)+$i));
	    $sYearOptions .= &#39;&lt;option value=&quot;&#39; . $nextyear . &#39;&quot;&gt;&#39; . $nextyear . &#39;&lt;/option&gt;&#39;;
	}
	echo $sYearOptions;
}
</code>
</pre>
<p>Disclaimer: I have no idea if 12 years is &#8220;enough&#8221;, nor if this is the most &#8220;efficient&#8221; way of doing this.  I also think a static html droplist of the months would be better&#8230; I don&#8217;t think we&#8217;re adding new months any time soon.</p>
]]></content:encoded>
			<wfw:commentRss>http://thinkdietz.com/dynamic-cc-month-and-year-drop-list.html/feed</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Webistrano &#8211; Install&#8230; everything</title>
		<link>http://thinkdietz.com/webistrano-install-everything.html</link>
		<comments>http://thinkdietz.com/webistrano-install-everything.html#comments</comments>
		<pubDate>Sun, 19 Sep 2010 21:09:09 +0000</pubDate>
		<dc:creator>dan</dc:creator>
				<category><![CDATA[Programming]]></category>
		<category><![CDATA[Ruby]]></category>

		<guid isPermaLink="false">http://thinkdietz.com/?p=64</guid>
		<description><![CDATA[Need webistrano installed on CentOS? Well do I have the step-by-step, leave nothing out, directions for you! Skip the sections you don&#8217;t need, but this includes: installing Ruby, MySQL, Rack... <a class="read-more" href="http://thinkdietz.com/webistrano-install-everything.html">Read the Rest &#8594;</a>]]></description>
			<content:encoded><![CDATA[<p>Need webistrano installed on CentOS?  Well do I have the step-by-step, leave nothing out, directions for you!  Skip the sections you don&#8217;t need, but this includes: installing Ruby, MySQL, Rack 1.01, MySQL ruby gem, Webistrano w/ remote database.  That&#8217;s right! All the little details, even how to connect to that fathomdb database.</p>
<p>1) Ruby (and Rails)<br />
[okay... this is coming...]</p>
<p>3) &#8220;Fix&#8221; Rake</p>
<pre><code>
$ gem uninstall rack
$ gem install rack -v 1.0.1
</pre>
<p></code></p>
<p>2) MySQL<br />
(you need this even for a remote database, as it provides the necessary headers so we can install the drivers in step #4)</p>
<pre><code>
$ sudo yum remove mysql-server
$ sudo yum install mysql mysql-devel gcc
</pre>
<p></code></p>
<p>4) MySQL Gem</p>
<pre><code>
# 32 bit machine
$ sudo gem install mysql -- \
> --with-mysql-include=/usr/bin/mysql \
> --with-mysql-lib=/usr/lib/mysql

# or 64 bit like they are on SliceHost
$ sudo gem install mysql -- \
> --with-mysql-include=/usr/bin/mysql \
> --with-mysql-lib=/usr/lib64/mysq
</pre>
<p></code></p>
<p>5) Create databases (I like <a href="http://www.sequelpro.com">Sequel Pro</a>)</p>
<pre><code>
webistrano_development
webistrano_test
webistrano_production
</pre>
<p></code></p>
<p>5) Configure Webistrano - database.yml</p>
<pre><code>
...
development:
  adapter: mysql
  database: webistrano_development
  username: [user here]
  password: [password here]
  host: [dbase subdomain].mysql.fathomdb.com
  port: [port number]
...
</pre>
<p></code></p>
<p>6) Install Webistrano!!!</p>
<pre><code>
$ cd [webistrano dir]
$ rake db:migrate
</pre>
<p></code></p>
<p>7) Open port for Webistrano (or use webmin)<br />
Open-</p>
<pre><code>
/etc/sysconfig/iptables
</pre>
<p></code></p>
<p>Append rule-</p>
<pre><code>
-A RH-Firewall-1-INPUT -m state --state NEW -m tcp -p tcp --dport 3000 -j ACCEPT
</pre>
<p></code></p>
<p>Restart the service</p>
<pre><code>
$ service iptables restart
</pre>
<p></code></p>
<p>Make sure iptables is allowing port 3000 connections:</p>
<pre><code>
$ iptables -L -n
</pre>
<p></code></p>
<p>8) DEPLOY SOMETHING!</p>
]]></content:encoded>
			<wfw:commentRss>http://thinkdietz.com/webistrano-install-everything.html/feed</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
	</channel>
</rss>

