<?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>Joe Crotty &#187; Tech</title>
	<atom:link href="http://joecrotty.com/category/tech/feed/" rel="self" type="application/rss+xml" />
	<link>http://joecrotty.com</link>
	<description>Joe Crotty</description>
	<lastBuildDate>Mon, 05 Jul 2010 01:42:40 +0000</lastBuildDate>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=3.0</generator>
		<item>
		<title>Whose world order?</title>
		<link>http://joecrotty.com/2010/06/whose-world-order/</link>
		<comments>http://joecrotty.com/2010/06/whose-world-order/#comments</comments>
		<pubDate>Sun, 27 Jun 2010 17:03:24 +0000</pubDate>
		<dc:creator>Joseph Crotty</dc:creator>
				<category><![CDATA[Tech]]></category>

		<guid isPermaLink="false">http://joecrotty.com/?p=702</guid>
		<description><![CDATA[    Warning, this is a an article by a software geek for said geeks. Rapid boredom will probably ensue even for the target audience. Most of us at one time or another have worked on a Big Ball of Mud. For a less seasoned hacker the first tour or two of such a haphazard [...]]]></description>
			<content:encoded><![CDATA[<p> </p>
<p><div id="attachment_727" class="wp-caption alignnone" style="width: 500px"><img class="size-full wp-image-727" title="Gulliver and Phones" src="http://joecrotty.com/wp-content/uploads/2010/03/gulliver_and_phones.jpg" alt="" width="490" height="213" /><p class="wp-caption-text">Gulliver, as the system, washes ashore to be tamed by the custodians.</p></div>
<p> </p>
<p>Warning, this is a an article by a software geek for said geeks. Rapid boredom will probably ensue even for the target audience. Most of us at one time or another have worked on a <a title="Big Ball of Mud" href="http://www.laputan.org/mud/">Big Ball of Mud</a>. For a less seasoned hacker the first tour or two of such a haphazard system may go unnoticed due to a number of circumstances the least of which being naivety. But, over time, the imprints of sloppy, duct tape, spaghetti code jungles come to be recognizable. By no means complete a few standout examples from my career:</p>
<p><span id="more-702"></span></p>
<ol>
<li>Code is not stored in an <a title="Wiki Source Code Management" href="http://en.wikipedia.org/wiki/Source_Code_Management">SCM</a>.</li>
<li>Bug fires rage 24/7 consuming all resources perpetually.</li>
<li>Poor code abounds with total disregard for any <a title="GNU Coding Standards" href="http://www.gnu.org/prep/standards/">standards</a> (e.g., wheel is reinvented regularly, 10 screen shot methods, classes with 100&#8242;s of members, etc.).</li>
<li>Duplicate data and functionality throughout including &#8220;clone&#8221; systems.</li>
<li>Management, via ignorance, insists things are basal or worse are in complete denial.</li>
</ol>
<p>Once one can identify a subset of ailments it&#8217;s tempting to run from these helter-skelter systems in haste. Knowledge arms us not to repeat them &#8211; maybe. Yet <a title="Brian Foote" href="http://www.laputan.org/index.html">Foote</a> and <a title="Joseph Yoder" href="http://www.joeyoder.com/">Yoder</a> make clear in <a title="Big Ball of Mud" href="http://www.laputan.org/mud/">BBOM</a> many profitable such systems exist. Profitability aside the fact is they abound! Having designed, developed, and maintained such systems myself the temptation is to disparage. What is it about these hastily crafted boomtown&#8217;s that irk us? Is it the simple fact that the architects and custodians are all to comfortable with a level of expediency we are uncomfortable with?</p>
<p>I am poorly equipped to answer from my limited exposure. Both <a title="Big Ball of Mud" href="http://www.laputan.org/mud/">BBOM</a>s I worked on were absolutely driven by a perceived fleeting window of business opportunity. Design marathons, repositories, code standards, pair coding, QC, test harnesses, continuous integration, etc. where all pushed aside in the rush to launch. Once there and stably afloat i.e.,  profitable, did the realization often slowly set in that the system was ineptly fashioned. Once built management forever demands hastily cobbled features to increase ROI almost always at the cost of sane design &#8211; the &#8220;structure&#8221; worsens. Of course, as engineers we fight to avert such quagmires whether through evangelization and/or example.  However, we all have to eat &#8211; to deny human nature is foolhardy.</p>
<p>An inverse universe exists where architecture, means and process are king. Laugh if you will but it&#8217;s well known that <a title="Microsoft" href="http://www.microsoft.com/en/us/default.aspx">Microsoft</a> runs one of the most process driven engineering shops the world over. For them sheer scale dictates a process rooted approach. However, for the average web business outlet day to day operation is about finding the middle ground between launch mentality and design nirvana.</p>
<p>So, whose world order should prevail in software engineering? The one that works.</p>
<p><object classid="clsid:d27cdb6e-ae6d-11cf-96b8-444553540000" width="500" height="344" codebase="http://download.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=6,0,40,0"><param name="allowFullScreen" value="true" /><param name="allowscriptaccess" value="always" /><param name="src" value="http://www.youtube.com/v/LH_e8NfNV-c&amp;hl=en_US&amp;fs=1&amp;" /><param name="allowfullscreen" value="true" /><embed type="application/x-shockwave-flash" width="500" height="344" src="http://www.youtube.com/v/LH_e8NfNV-c&amp;hl=en_US&amp;fs=1&amp;" allowscriptaccess="always" allowfullscreen="true"></embed></object></p>
]]></content:encoded>
			<wfw:commentRss>http://joecrotty.com/2010/06/whose-world-order/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Quote Panel</title>
		<link>http://joecrotty.com/2010/03/quote-panel/</link>
		<comments>http://joecrotty.com/2010/03/quote-panel/#comments</comments>
		<pubDate>Fri, 26 Mar 2010 19:19:35 +0000</pubDate>
		<dc:creator>Joseph Crotty</dc:creator>
				<category><![CDATA[Tech]]></category>

		<guid isPermaLink="false">http://joecrotty.com/?p=674</guid>
		<description><![CDATA[Yesterday while looking at the new blog header I decided to have a hand at adding a quote mechanism. I have always been fond of the hilarious tongue in check The Tao Of Programming series &#8211; the first self titled book being best by far. My initial notion was to put it in the footer [...]]]></description>
			<content:encoded><![CDATA[<p>Yesterday while looking at the <a title="Nothing to Say" href="http://joecrotty.com/2010/03/nothing-to-say/">new blog header</a> I decided to have a hand at adding a quote mechanism. I have always been fond of the hilarious tongue in check <a title="The Tao Of Programming series" href="http://tal.forum2.org/tao">The Tao Of Programming series</a> &#8211; the first self titled book being best by far. My initial notion was to put it in the footer which seemed vacuous. Puzzled I gave up for a few hours and wandered to a tangential stream of thought. Later, while talking with my wife just before bed an idea hit me like a ton of bricks.  Why not put a sliding quote panel in the header animated by <a title="jQuery" href="http://jquery.com/">jQuery</a>? Nearly sick with excitement I &#8220;uhm&#8221;-ed my way through the rest of the talk with my wife and then stole off the first chance to get to a computer to hammer out some initial code before the ephemeral concept evaporated from my mind.</p>
<p><span id="more-674"></span><a title="Quotes Collection WordPress plugin" href="http://wordpress.org/extend/plugins/quotes-collection/">Quotes Collection</a>, a <a title="WordPress plugin" href="http://wordpress.org/extend/plugins/">WordPress plugin</a>, looked great but after playing with it for five minutes warts appeared. For starters it smartly used a database table, but there were no tools baked in for bulk import.  Secondly, the plugin <a title="UI Wiki" href="http://en.wikipedia.org/wiki/User_interface">UI</a> was badly munging anything I bothered to manually insert into the database. However, the plugin provided an easy to use and feature rich <a title="PHP" href="http://php.net/index.php">PHP</a> function for dropping the quotes into <a title="HTML Wiki" href="http://en.wikipedia.org/wiki/HTML">HTML</a>. I decided to keep the plugin for displaying the quotes and hack a <a title="Perl" href="http://www.perl.org/">perl</a> script to do the bulk database quote insert.</p>
<p>Fortunately, the <a title="The Tao Of Programming" href="http://www.canonical.org/~kragen/tao-of-programming.html">quotes  themselves were easy enough to obtain</a> and due to a lapsed copyright  available for the taking. After copy and pasting them into <a title="Vim" href="http://www.vim.org/">vim</a> and staring at one line for nearly three minutes fatigue settled in. I made a few conceptual mental notes for the morrow and went to bed.</p>
<p>Early today I finished the edit of the quotes file, ttop.dat, in a vim editor. The tedium of manually stripping poor double quote characters, blank lines, and extra spaces raced by with a rested mind. I settled on using &#8216;&#8212;&#8217; as a delimiter between all quotes as most contained multiple lines knowing that perl&#8217;s <a title="Perl Input Record Separator" href="http://perldoc.perl.org/perlvar.html#$/">input record separator</a> would permit parsing pliability. Once the quote file edit was complete I hacked up the perl script to slurp and parse the file and insert each quote to the database. After a few trail runs to ferret out the bugs the quotes were neatly tucked away in the database.</p>
<pre class="brush: perl; toolbar: true;">
#!/usr/bin/perl

use strict;
use warnings;

use DBI;

# insert the new uirs into the db
sub db_insert_quotes {
    my $quote_sref = shift;
    my $dbh = shift;

    my $sql = &quot;INSERT INTO wp_quotescollection (quote, author, source, tags, visible, time_added, time_updated)
               VALUES (?, 'Geoffrey James', 'The Tao Of Programming', 'TTOP', 'yes', NOW(), NOW())&quot;;
    my $sth = $$dbh-&gt;prepare($sql);
    $sth-&gt;bind_param(1, $$quote_sref);
    $sth-&gt;execute;
}

# Connect to the database.
my $dbh = DBI-&gt;connect(&quot;DBI:mysql:database=DATABASE;host=localhost&quot;,
                       &quot;USER&quot;, &quot;PASSWORD&quot;,
                       {'RaiseError' =&gt; 1});

$/ = &quot;---\n&quot;;
while (&lt;&gt;) {
    chomp;
    chop;
    my $quote = $_;
    #db_insert_quotes(\$quote, \$dbh);
}

exit;
</pre>
<p>A few months back I vaguely recalled reading a <a title="WebDesinger Wall" href="http://www.webdesignerwall.com/tutorials/jquery-tutorials-for-designers/">jQuery article</a> with a great <a title="Simple Sliding Panel Demo" href="http://www.webdesignerwall.com/demo/jquery/simple-slide-panel.html">simple sliding panel demo</a>. After grabbing a few images and applying a dollop or two of CSS, Javascript, and HTML my panel was functional. <a title="Kuler" href="http://kuler.adobe.com/">Kuler</a>&#8216;s color insights came to the rescue again saving site visitors from my train wreck artistic spasms.</p>
<p>This site enhancement was a joy to work on. I hope visitors are enthused about it as I am.</p>
]]></content:encoded>
			<wfw:commentRss>http://joecrotty.com/2010/03/quote-panel/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Nothing to Say</title>
		<link>http://joecrotty.com/2010/03/nothing-to-say/</link>
		<comments>http://joecrotty.com/2010/03/nothing-to-say/#comments</comments>
		<pubDate>Thu, 25 Mar 2010 22:54:28 +0000</pubDate>
		<dc:creator>Joseph Crotty</dc:creator>
				<category><![CDATA[Tech]]></category>

		<guid isPermaLink="false">http://joecrotty.com/?p=666</guid>
		<description><![CDATA[It was an arid posting week here at the blog trying to come up with something fresh to say. In the process of looking around at the ship shape of the blog the realization that the header and logo look squirrelly occurred. So I fired up Photoshop, vim and git and changed things around to [...]]]></description>
			<content:encoded><![CDATA[<p>It was an arid posting week here at the blog trying to come up with something fresh to say. In the process of looking around at the ship shape of the blog the realization that the header and logo look squirrelly occurred. So I fired up <a title="Adobe Photoshop" href="http://www.adobe.com/products/photoshop/photoshop/">Photoshop</a>, <a title="Vim" href="http://www.vim.org/">vim</a> and <a title="Git" href="http://git-scm.com/">git</a> and changed things around to a more streamlined, recognizable and social/web 2.0 header area.  Also, the <a title="Archive Layout Issue Blog Post" href="http://joecrotty.com/2010/03/design-tweaks/">archive layout issue</a> was fixed yet again. Now if I could only come up with a good idea to blog about.</p>
]]></content:encoded>
			<wfw:commentRss>http://joecrotty.com/2010/03/nothing-to-say/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Nikon D90 Learning Tools</title>
		<link>http://joecrotty.com/2010/03/nikon-d90-learn-tools/</link>
		<comments>http://joecrotty.com/2010/03/nikon-d90-learn-tools/#comments</comments>
		<pubDate>Mon, 15 Mar 2010 15:00:19 +0000</pubDate>
		<dc:creator>Joseph Crotty</dc:creator>
				<category><![CDATA[Tech]]></category>

		<guid isPermaLink="false">http://joecrotty.com/?p=630</guid>
		<description><![CDATA[In have been eying the Nikon D90 DSLR for the better part of three months. At the start of March, 2010 Nikon Rumors reported some deep online discounts were in the works and with my birthday pending at the end of the month I pulled the trigger and purchased a D90 camera kit including a [...]]]></description>
			<content:encoded><![CDATA[<p>In have been eying the <a title="Nikon D90" href="http://www.nikonusa.com/Find-Your-Nikon/Product/Digital-SLR/25446/D90.html">Nikon D90</a> <a title="DSLR Wiki" href="http://en.wikipedia.org/wiki/Digital_single-lens_reflex_camera">DSLR</a> for the better part of three months. At the start of March, 2010 <a title="Nikon Rumors" href="http://nikonrumors.com/">Nikon Rumors</a> reported some <a title="Nikon Rumors discount roundup" href="http://nikonrumors.com/2010/03/03/the-latest-nikon-instant-rebates-list.aspx">deep online discounts</a> were in the works and with my birthday pending at the end of the month I pulled the trigger and purchased a D90 camera kit including a <a title="Nikkor Lenses" href="http://www.nikonusa.com/Find-Your-Nikon/Product/Camera-Lenses/2192/AF-S-DX-NIKKOR-18-200mm-f%252F3.5-5.6G-ED-VR-II.html">Nikkor 18-200mm f/3.5-5.6G ED VRII</a> all around lens from <a title="B&amp;H Photo Video" href="http://www.bhphotovideo.com/">B&amp;H Photo Video</a>. Much to my joy even my wife approved the purchase. Now that the easy part is done it&#8217;s time to learn how to use this interface monster.</p>
<p><span id="more-630"></span>Set up with a 16G <a title="SDHC Wiki" href="http://en.wikipedia.org/wiki/Secure_Digital#SDHC">SDHC</a> memory card and a decent <a title="Schneider Optics" href="http://www.schneideroptics.com/">B+W</a> lens filter I spent my first day poking around for D90 learning tools and culled the following list:</p>
<ul>
<li>Nikon D90 <a title="Nikon D90 manual" href="http://www.nikonusa.com/pdf/manuals/noprint/D90_ennoprint.pdf">manual</a></li>
<li>Nikon D90 <a title="Digitutor videos" href="http://www.nikondigitutor.com/eng/d90/index.shtml">Digitutor</a> videos</li>
<li>Ken Rockwell&#8217;s Nikon D90 <a title="Ken Rockwell's Nikon D90 User's Guide" href="http://www.kenrockwell.com/nikon/d90/users-guide/index.htm">Users&#8217;s Guide</a></li>
</ul>
<p>This probably sounds trite but reading parts of the manual, especially the camera body layout and control panel diagrams, taught me a great deal. After shooting some pictures around the apartment I drove to one of my favorite outdoor haunts, <a title="Eldorado Canyon State Park" href="http://parks.state.co.us/parks/eldoradocanyon/Pages/EldoradoCanyonHome.aspx">Eldorado Canyon State Park</a>, for an afternoon of milling around the trails with an itchy trigger finger.</p>
<div class="wp-caption alignnone" style="width: 500px"><a href="http://i168.photobucket.com/albums/u196/joecrotty/joecrottycom/2010-03-13_15-40-58.jpg"><img class="noborder" title="Fowler Trail Hikers" src="http://i168.photobucket.com/albums/u196/joecrotty/joecrottycom/2010-03-13_15-40-58_webjc.jpg" alt="" width="490" height="325" /></a><p class="wp-caption-text">Fowler Trail Hikers</p></div>
<div class="wp-caption alignnone" style="width: 500px"><a href="http://i168.photobucket.com/albums/u196/joecrotty/joecrottycom/2010-03-13_15-54-44.jpg"><img title="One dream begins as another ends" src="http://i168.photobucket.com/albums/u196/joecrotty/joecrottycom/2010-03-13_15-54-44_webjc.jpg" alt="" width="490" height="738" /></a><p class="wp-caption-text">One dream begins as another ends</p></div>
]]></content:encoded>
			<wfw:commentRss>http://joecrotty.com/2010/03/nikon-d90-learn-tools/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>GoF Design Patterns</title>
		<link>http://joecrotty.com/2010/03/gof-design-patterns/</link>
		<comments>http://joecrotty.com/2010/03/gof-design-patterns/#comments</comments>
		<pubDate>Wed, 10 Mar 2010 19:56:21 +0000</pubDate>
		<dc:creator>Joseph Crotty</dc:creator>
				<category><![CDATA[Tech]]></category>
		<category><![CDATA[Featured Content]]></category>

		<guid isPermaLink="false">http://joecrotty.com/?p=618</guid>
		<description><![CDATA[As a programmer and all around nerd dating back to my teen years I have covered a fair bit of computing terrain. However, at a recent job interview requiring Java skills I completely floundered when asked, "Talk to us about design patterns and illustrate some instances where you have applied them?"]]></description>
			<content:encoded><![CDATA[<p>As a programmer and all around nerd dating back to my teen years I have covered a fair bit of computing terrain. However, at a recent job interview requiring Java skills I completely floundered when asked, &#8220;Talk to us about design patterns and illustrate some instances where you have applied them?&#8221;  Baffled and not one to beat around the bush I admitted my naivety immediatley. In a gesture of kindness the interview panel threw a few classic design patterns at me like singleton and abstract factory both of which I was aware of, but only had a vague grasp of. One guy on the panel suggested I read up on a famous engineering design pattern book by a group referred to as the Gang of Four. I took him up on that offer a few days later and ordered a used copy of <a title="Design Patterns Wiki" href="http://en.wikipedia.org/wiki/Design_Patterns"><em>Design Patterns: Elements of Reusable Object-Oriented Software</em></a> from <a title="Buy Design Patterns at Amazon" href="http://www.amazon.com/Design-Patterns-Elements-Reusable-Object-Oriented/dp/0201633612">Amazon</a>.</p>
<p><span id="more-618"></span></p>
<div id="attachment_623" class="wp-caption alignnone" style="width: 500px"><img class="size-large wp-image-623" title="Design Patterns Front Cover" src="http://joecrotty.com/wp-content/uploads/2010/03/design_patterns_bookfc-490x490.jpg" alt="" width="490" height="490" /><p class="wp-caption-text">Design Patterns Front Cover</p></div>
<p>The book arrived two days ago and I have been busy poring over it in my spare time. I am using a <a title="GoF/Gamma Patterns" href="http://mahemoff.com/paper/software/learningGoFPatterns/">study guide</a> that groups the patterns by difficulty ranging from easy to advanced. Can&#8217;t wait to finish reading and possibly start applying these new nuggets of knowledge to my current AJAX charting application project.</p>
]]></content:encoded>
			<wfw:commentRss>http://joecrotty.com/2010/03/gof-design-patterns/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Math Combinations, RDBMS and Perl</title>
		<link>http://joecrotty.com/2010/03/math-combinations-rdbms-and-perl/</link>
		<comments>http://joecrotty.com/2010/03/math-combinations-rdbms-and-perl/#comments</comments>
		<pubDate>Mon, 08 Mar 2010 15:00:46 +0000</pubDate>
		<dc:creator>Joseph Crotty</dc:creator>
				<category><![CDATA[Tech]]></category>

		<guid isPermaLink="false">http://joecrotty.com/?p=507</guid>
		<description><![CDATA[Recently, while developing a web charting application I ran into a problem involving combinations and permutations. The application mimics an existing paper charting method with it&#8217;s own meta language to describe certain visual biological markers.  One subset of the meta language defines eight shorthand notation character codes: B = Brown (or Black) Bleeding C = [...]]]></description>
			<content:encoded><![CDATA[<p>Recently, while developing a web charting application I ran into a problem involving <a title="Combinations and Permutations Mathfun" href="http://www.mathsisfun.com/combinatorics/combinations-permutations.html">combinations and permutations</a>. The application mimics an existing paper charting method with it&#8217;s own meta language to describe certain visual biological markers.  One subset of the meta language defines eight shorthand notation character codes:</p>
<ul>
<li>B = Brown (or Black) Bleeding</li>
<li>C = Cloudy (white)</li>
<li>C/K = Cloudy/Clear</li>
<li>G = Gummy (gluey)</li>
<li>K = Clear</li>
<li>L = Lubricative</li>
<li>P = Pasty (creamy)</li>
<li>Y = Yellow (even pale yellow)</li>
</ul>
<p>Each code can be selected once with any other combination of codes.  Some examples of possible code string combinations with dash separator(s):</p>
<p><span id="more-507"></span></p>
<ol>
<li>B &#8211; C</li>
<li>C/K &#8211; K &#8211; P &#8211; Y</li>
<li>K &#8211; P &#8211; Y &#8211; C/K</li>
<li>L &#8211; L &#8211; Y Note, not valid due to duplicate L code</li>
</ol>
<p>Eventually, these code strings are stored in a <a title="RDBMS Wiki" href="http://en.wikipedia.org/wiki/Relational_database_management_system">RDBMS</a>.  The question is how to store them efficiently? We could store them as a string datatype (e.g.,  VARCHAR), but this would be inefficient because on average a code string would take up more bytes then a number datatype (e.g., INT) used to represent the code string.  This implies a look up table of code strings with related numbers and a <a title="Foreign Key Wiki" href="http://en.wikipedia.org/wiki/Foreign_key">foreign key</a> on the main storage table(s) <a title="Referential Integrity Wiki" href="http://en.wikipedia.org/wiki/Referential_integrity">referentially constrained</a> to the look up table.</p>
<div id="attachment_611" class="wp-caption alignnone" style="width: 392px"><img class="size-full wp-image-611 " title="Entity Relationship Diagram" src="http://joecrotty.com/wp-content/uploads/2010/03/er_codes.png" alt="" width="382" height="114" /><p class="wp-caption-text">Entity Relationship Diagram</p></div>
<p>Further, consider the third string code example above. Semantically it&#8217;s the same as example two, but is ordered differently (AKA permutation). To properly <a title="RDBMS Data Normilization Wiki" href="http://en.wikipedia.org/wiki/Database_normalization">normalize</a> the data we should alphabetically arrange the permutations so that order does not matter which will vastly reduce the number of possible string code combinations.</p>
<p>Now that we know how the data should be modeled we must populate the string code look up table. The first obvious question is how many combinations are possible when order doesn&#8217;t matter? Use the formula below where <em><strong>n</strong></em> is the number of things to choose from, and you  choose <em><strong>r</strong></em> of them (No repetition, order doesn&#8217;t  matter). ! means <a title="Factorial Wiki" href="http://en.wikipedia.org/wiki/Factorial">factorial</a>.</p>
<p><img class="alignnone size-full wp-image-537 noborder" title="Formula Combinations No Repeat" src="http://joecrotty.com/wp-content/uploads/2010/03/combinations-no-repeat.png" alt="" width="150" height="53" /></p>
<p>For example, for the eight possible codes if we select four then there are 70 possible code combinations where order doesn&#8217;t matter.  However, we need to know the number of non repeating combinations possible for our set of eight codes given we can select between one to eight codes. I&#8217;ll leave that simple exercise as reader homework, but excluding the possibility of selecting no codes the answer is 255.</p>
<p>Now the crux of the matter. Insert the 255 non repeating combinations, alphabetically arranged, with a unique number for each into the RDBMS lookup table. Assuming you managed the math part and have made it this far you can now go and gently beat your head against a wall for a few minutes &#8211; then return, please.  <a title="The Perl Programming Language" href="http://www.perl.org/">Perl</a> to the rescue! With it&#8217;s ease of extensions via <a title="Comprehensive Perl Archive Network" href="http://www.cpan.org/">CPAN</a> modules and high level programming abstractions it is the ideal glue language to tackle what looks to be a formidable problem.</p>
<p>Our first order is to google CPAN and see what, if any, perl modules are available to deal with math combinations.  Ah, the <a title="Math Combinatorics Module" href="http://search.cpan.org/~allenday/Math-Combinatorics-0.09/lib/Math/Combinatorics.pm">Math::Combinatorics</a> module should fit the bill nicely. Second, we need to install the Math::Combinatorics module locally. While we are at we also need to install <a title="DBI CPAN" href="http://search.cpan.org/~TIMB/DBI/DBI.pm">DBI</a> and <a title="DBD::mysql CPAN" href="http://search.cpan.org/~capttofu/DBD-mysql-4.013/lib/DBD/mysql.pm">DBD::mysql</a> modules to enable perl access to our <a title="MySQL" href="http://www.mysql.com/">MySQL</a> RDBMS so we can insert the combinations into our look up table. Most default perl installs come with a handy tool called <a title="Cpan for CPAN" href="http://search.cpan.org/~andk/CPAN-1.9402/lib/CPAN.pm">cpan</a> which gives command line access to the CPAN online module repository to ease searching and installing locally.</p>
<pre class="brush: bash; toolbar: true;">
joecrotty@macpro:~ $ sudo cpan
Terminal does not support AddHistory.

cpan shell -- CPAN exploration and modules installation (v1.9402)
Enter 'h' for help.

cpan[1]&gt; install Math::Combinatorics
...

cpan[2]&gt; q
Terminal does not support GetHistory.
Lockfile removed.
</pre>
<p>With the modules in place our finished perl script is below. Note, the actual database inserts are commented out on lines 29 and 30. String_codes.code_id is an <a title="MySQL auto_increment" href="http://dev.mysql.com/doc/refman/5.0/en/example-auto-increment.html">AUTO_INCREMENT</a> column.</p>
<pre class="brush: perl; toolbar: true;">
#!/opt/local/bin/perl

use strict;
use warnings;

use Math::Combinatorics;
use DBI;

$| = 1; # disable buffering
my @codes = ('B', 'C', 'C/K', 'G',
             'K', 'L', 'P', 'Y');

# Connect to the database.
my $dbh = DBI-&gt;connect(&quot;DBI:mysql:database=DB;host=HOST&quot;,
                       &quot;USER&quot;, &quot;PASSWD&quot;,
                      {'RaiseError' =&gt; 1});
my $sql = 'INSERT INTO string_codes (codes)
           VALUES (?)';
my $sth = $dbh-&gt;prepare($sql);

for ( 1 .. 8 ) {
    my $combinat = Math::Combinatorics-&gt;new(count =&gt; $_,
                                             data =&gt; [@codes]);

    while(my @combo = $combinat-&gt;next_combination){
        @combo = sort @combo;
        my $combi = join('-', @combo);
        print $combi, &quot;\n&quot;;
        #$sth-&gt;bind_param(1, $combi);
        #$sth-&gt;execute;
    }
}
</pre>
]]></content:encoded>
			<wfw:commentRss>http://joecrotty.com/2010/03/math-combinations-rdbms-and-perl/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Design tweaks</title>
		<link>http://joecrotty.com/2010/03/design-tweaks/</link>
		<comments>http://joecrotty.com/2010/03/design-tweaks/#comments</comments>
		<pubDate>Fri, 05 Mar 2010 02:06:10 +0000</pubDate>
		<dc:creator>Joseph Crotty</dc:creator>
				<category><![CDATA[Tech]]></category>

		<guid isPermaLink="false">http://joecrotty.com/?p=468</guid>
		<description><![CDATA[About a month ago I revised the website look.  Today I fixed a few subtle things: &#8216;Featured Posts&#8217; widget images in the sidebar now link directly to the post. Padding between all the sidebar widgets (e.g., &#8216;Featured Posts&#8217;, &#8216;Recent Posts&#8217;, etc.) is now even. &#8216;Archives&#8217; sidebar widget is now collapsible. Note, there is a bug [...]]]></description>
			<content:encoded><![CDATA[<p>About a month ago I <a title="Website Redesign" href="/2010/01/design-reload/">revised</a> the website look.  Today I fixed a few subtle things:</p>
<ol>
<li>&#8216;Featured Posts&#8217; widget images in the sidebar now link directly to the post.</li>
<li>Padding between all the sidebar widgets (e.g., &#8216;Featured Posts&#8217;, &#8216;Recent Posts&#8217;, etc.) is now even.</li>
<li>&#8216;Archives&#8217; sidebar widget is now collapsible. Note, there is a bug in IE6-8 and I am not sure when I&#8217;ll have time to fix it. My recommendation is to switch your browser to <a title="FireFox" href="http://www.mozilla.com/en-US/firefox/personal.html">Firefox</a>, <a title="Chrome" href="http://www.google.com/chrome">Chrome</a>, or <a title="Safari" href="http://www.apple.com/safari/">Safari</a>.</li>
</ol>
]]></content:encoded>
			<wfw:commentRss>http://joecrotty.com/2010/03/design-tweaks/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Design Reload</title>
		<link>http://joecrotty.com/2010/01/design-reload/</link>
		<comments>http://joecrotty.com/2010/01/design-reload/#comments</comments>
		<pubDate>Fri, 22 Jan 2010 18:05:24 +0000</pubDate>
		<dc:creator>Joseph Crotty</dc:creator>
				<category><![CDATA[Tech]]></category>

		<guid isPermaLink="false">http://joecrotty.com/?p=428</guid>
		<description><![CDATA[This is probably the third site re-design in the last six months or so, but for the first time I can honestly say this one just might stick. First, let&#8217;s give due credit to WooThemes design team for this fabulous free Bueno theme. In the future I&#8217;ll be using almost exclusively free and premium themes [...]]]></description>
			<content:encoded><![CDATA[<p>This is probably the third site re-design in the last six months or so, but for the first time I can honestly say this one just might stick. First, let&#8217;s give due credit to <a title="WooThemes" href="http://www.woothemes.com/">WooThemes</a> design team for this fabulous free <a title="Bueno Theme" href="http://www.woothemes.com/2009/11/bueno/">Bueno</a> theme. In the future I&#8217;ll be using almost exclusively free and premium  themes from ad hoc design shops like WooThemes due to the time saved and my lack of design skills.</p>
<p>Bueno is a simple modern theme that puts the focus squarely on structure and typography that fits well with my general post style. The only theme switch  hassle was resizing all of the larger images which is typical. The only old design element lost was the roll up archives which I&#8217;ll make an effort to reinstate at a later date when I tidy up this new theme.  For now we are ready to roll!</p>
]]></content:encoded>
			<wfw:commentRss>http://joecrotty.com/2010/01/design-reload/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Website Redesign</title>
		<link>http://joecrotty.com/2009/11/website-redesign/</link>
		<comments>http://joecrotty.com/2009/11/website-redesign/#comments</comments>
		<pubDate>Wed, 04 Nov 2009 23:15:16 +0000</pubDate>
		<dc:creator>Joseph Crotty</dc:creator>
				<category><![CDATA[Tech]]></category>

		<guid isPermaLink="false">http://joecrotty.com/?p=363</guid>
		<description><![CDATA[It&#8217; pretty obvious thing have changed. The old is out and in it&#8217;s place a new bright blue look is born based on the WordPress Stripey theme.  Really, there are only a few key changes with the new look: Header logo and binary code which adds a cleaner more professional feel.  I plan to add [...]]]></description>
			<content:encoded><![CDATA[<p>It&#8217; pretty obvious thing have changed.  The old is out and in it&#8217;s place a new bright blue look is born based on the WordPress <a title="WP Stripey theme" href="http://www.free-wptheme.com/free-wordpress-themes/page1/stripey-v1.6">Stripey</a> theme.  Really, there are only a few key changes with the new look:</p>
<ol>
<li>Header logo and binary code which adds a cleaner more professional feel.  I plan to add a maltese cross, but ran out of time on this effort.</li>
<li>Better search box.</li>
<li>Subtle post header meta data changes.</li>
<li>Archive posts in the right sidebar are rolled up by year and counts listed for each month.</li>
</ol>
<p>Shot me an email or drop a comment if you find any bugs or simply can&#8217;t stand it!</p>
]]></content:encoded>
			<wfw:commentRss>http://joecrotty.com/2009/11/website-redesign/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Optimizing WordPress Websites</title>
		<link>http://joecrotty.com/2009/10/optimizing-websites/</link>
		<comments>http://joecrotty.com/2009/10/optimizing-websites/#comments</comments>
		<pubDate>Fri, 23 Oct 2009 02:13:24 +0000</pubDate>
		<dc:creator>Joseph Crotty</dc:creator>
				<category><![CDATA[Tech]]></category>

		<guid isPermaLink="false">http://joecrotty.com/?p=318</guid>
		<description><![CDATA[Recently a web client asked me if I could figure out why their page was loading so slowly. Simple enough question on the surface. Like any sensible web engineer I immediately opened Firefox enabled the Firebug plug-in and went to Net Panel. It was clearly evident after poking around for a few minutes that the [...]]]></description>
			<content:encoded><![CDATA[<div class="wp-caption alignleft" style="width: 250px"><img title="Website Speed" src="http://i168.photobucket.com/albums/u196/joecrotty/joecrottycom/timer-icon.png" alt="Website Speed" width="240" height="240" /><p class="wp-caption-text">Website Speed</p></div>
<p>Recently a web client asked me if I could figure out why their page was loading so slowly. Simple enough question on the surface. Like any sensible web engineer I immediately opened <a title="FireFox" href="http://www.mozilla.com/en-US/firefox/personal.html">Firefox</a> enabled the <a title="Firebug" href="http://getfirebug.com/">Firebug</a> plug-in and went to <a title="Firebug Net Panel" href="http://getfirebug.com/net.html">Net Panel</a>. It was clearly evident after poking around for a few minutes that the <a title="WordPress" href="http://wordpress.org/">WordPress</a> site in question, which I built but didn&#8217;t do the design and image work for, was sized at just over a megabyte of which ~50% was images. In the scramble to get the site up and running I just took the images the designer handed me and plugged them in without any further thought then &#8220;Hey, those do look very good!&#8221; I informed the client that the images were hogging up a good bit of bandwidth and they should have a graphics expert put the  images on a diet via <a title="Adobe Products" href="http://www.adobe.com/">PhotoShop</a>.  However, that other 50% of overall slowness that was not related to the images nagged at me.</p>
<p>Within the hour I had mentally resolved to figure out why the rest of the site was slow and apply anything learned to improving current and future site builds. My basic game plan after googling for a few hours and discovering <a title="YSlow" href="http://developer.yahoo.com/yslow/">YSlow</a> was as follows:</p>
<ol>
<li>Serve the HTML gzip&#8217;ed and cached</li>
<li>Serve the CSS/JS gzip&#8217;ed and cached</li>
<li>Reduce the number of overall requests by combining CSS/JS files where possible</li>
<li>Add Expires Headers</li>
<li>Move as many images as possible externally</li>
</ol>
<p><span id="more-318"></span></p>
<p>I know YSlow has some other recommendations, but the above are the really low fruit. With WordPress <a title="WP SuperCache" href="http://wordpress.org/extend/plugins/wp-super-cache/">SuperCache</a> enabled the first one is a no brainer.</p>
<p>The second one also seems like a no brainer &#8211; just enable <a title="Apache" href="http://www.apache.org/">apache&#8217;s</a> <a title="Apache 2.2 mod_deflate" href="http://httpd.apache.org/docs/2.2/mod/mod_deflate.html">mod_deflate</a> and be done with it.  Ah, but wait a minute.  What if your host doesn&#8217;t have mod_deflate enabled?  Even if they do have mod_deflate enabled you could just be pushing your servers CPU and memory to the limit by gziping everything on every request.  <a title="PHP Gziping" href="http://www.fiftyfoureleven.com/weblog/web-development/css/the-definitive-css-gzip-method">Some argue</a> to use a PHP script in conjunction with .htaccess to gzip on the fly.  Again, your just straining the server needlessly all the time. The solution I settled on is to <a title="Minify" href="http://en.wikipedia.org/wiki/Minification_%28programming%29">minify</a> and gzip the CSS/JS files on the webserver into psuedo .gz extensions (e.g., *.css = *.css.cgz and *.js = *.js.jgz) with the following script:</p>
<pre class="brush: bash;">
#!/bin/sh

# minify and gzip css and js files, Apache .htaccess
# will deliver them to the client encoded

# WP core css files are not minified. All WP core css files and theme files
# are minified and then gziped.  WP core js files are all already minified.  Some of
# the theme files are also minified, but a few are not.  Experiments show that
# minifying theme files caused rendering problems and gave very little
# optimization, so we don't bother to minify them.

yuicomp='yuicompressor-2.4.2'

# gzip all css files
for i in `find . -type f -name &quot;*.css&quot;`; do
echo &quot;minifying and gziping $i&quot;
java -jar $HOME/java/${yuicomp}/build/${yuicomp}.jar --nomunge $i &gt; ${i%.*}.min.css
gzip -c ${i%.*}.min.css &gt; ${i}.cgz
rm -f ${i%.*}.min.css
done

# gzip all js files
for i in `find . -type f -name &quot;*.js&quot;`; do
echo &quot;gziping $i&quot;
gzip -c $i &gt; ${i}.jgz
done
</pre>
<p>Note, WordPress core JS files are already minified so you only need to gzip.  Further, be careful minifying JS files as there are sometimes unintended consequences.  Given the performance and headache trade-off I only gzip JS and don&#8217;t bother to minify.</p>
<p>Then add the following to .htaccess file:</p>

<div class="wp_syntax"><div class="code"><pre class="apache" style="font-family:monospace;"><span style="color: #00007f;">RewriteCond</span> %{HTTP:Accept-Encoding} gzip
&nbsp;
<span style="color: #adadad; font-style: italic;"># serve gzipped css</span>
<span style="color: #00007f;">RewriteCond</span> %{REQUEST_FILENAME}.cgz -f
<span style="color: #00007f;">RewriteRule</span> (.*)\.css$ $<span style="color: #ff0000;">1</span>\.css.cgz [L]
<span style="color: #00007f;">AddType</span> <span style="color: #7f007f;">&quot;text/css&quot;</span> .css.cgz
<span style="color: #00007f;">AddEncoding</span> gzip .cgz
&nbsp;
<span style="color: #adadad; font-style: italic;"># serve gzipped js</span>
<span style="color: #00007f;">RewriteCond</span> %{REQUEST_FILENAME}.jgz -f
<span style="color: #00007f;">RewriteRule</span> (.*)\.js$ $<span style="color: #ff0000;">1</span>\.js.jgz [L]
<span style="color: #00007f;">AddType</span> <span style="color: #7f007f;">&quot;text/javascript&quot;</span> .js.jgz
<span style="color: #00007f;">AddEncoding</span> gzip .jgz</pre></div></div>

<p>Third item turns out to be a real hassle in WordPress.  WordPress is a great CMS that offers a great environment for themes and a diverse selection of plugins. But the price is an architecture where components are spread about a large file tree in a fashion that makes it nearly impossible to combine CSS/JS files without threatening to break when WordPress core, plugin, and theme upgrades roll in which is frequently. I didn&#8217;t bother as it just seemed too dangerous to even think about touching with the proverbial ten foot pole.</p>
<p>Number four is another apache related issue.  Either you have, or can have via your host, <a title="Apache 2.2 mod_expire" href="http://httpd.apache.org/docs/2.2/mod/mod_expires.html">mod_expire</a> enabled or you don&#8217;t.  If you do then it&#8217;s just as easy as the following .htaccess line to get the ball rolling:</p>

<div class="wp_syntax"><div class="code"><pre class="apache" style="font-family:monospace;"><span style="color: #00007f;">ExpiresActive</span> <span style="color: #0000ff;">On</span>
<span style="color: #00007f;">ExpiresDefault</span> <span style="color: #7f007f;">&quot;access plus 1 week&quot;</span></pre></div></div>

<p>Remember, though, this assumes your server controls the request.  If you have a large image file on your site that loads frequently and you moved it to <a title="Amazon S3" href="http://aws.amazon.com/s3/">Amazon S3</a> to reduce you load time and bandwidth (IMHO &#8211; probably a good move most of time) chances are the external host will not expire the image at all.</p>
<p>Lastly, try to move your big images to an external host like <a title="PhotoBucket" href="http://photobucket.com/">PhotoBucket</a>. Let PhotoBucket deal with the overhead and if you need to pay them for a Pro account. It&#8217;s worth a mislay $20/year so that your loyal online readers don&#8217;t have to suffer through frequent slow page loads.</p>
<p>Speaking of loyal readers I have applied the lessons from this post to the site and it&#8217;s definitively faster!</p>
]]></content:encoded>
			<wfw:commentRss>http://joecrotty.com/2009/10/optimizing-websites/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
	</channel>
</rss>
