<?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>Gawain’s World &#187; Development</title>
	<atom:link href="http://gawain.org/blog/category/development/feed/" rel="self" type="application/rss+xml" />
	<link>http://gawain.org/blog</link>
	<description>Learning to drive upside down...</description>
	<lastBuildDate>Sun, 05 Feb 2012 12:00:00 +0000</lastBuildDate>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=3.0.1</generator>
		<item>
		<title>Geek dad vs. Normal dad: A homework story</title>
		<link>http://gawain.org/blog/2009/09/21/geek-dad-vs-normal-dad/</link>
		<comments>http://gawain.org/blog/2009/09/21/geek-dad-vs-normal-dad/#comments</comments>
		<pubDate>Tue, 22 Sep 2009 00:37:26 +0000</pubDate>
		<dc:creator>Gawain</dc:creator>
				<category><![CDATA[Development]]></category>
		<category><![CDATA[Family]]></category>

		<guid isPermaLink="false">http://gawain.org/blog/?p=511</guid>
		<description><![CDATA[When I was in school, math homework was my nemesis. The seemingly endless (and at the time, seemingly pointless) repetition drove me crazy. As a kid, I wasn&#8217;t given much sense of the practical usefulness of any of the things I was being taught. I had much more important things to occupy my mind with, ]]></description>
			<content:encoded><![CDATA[<p>When I was in school, math homework was my nemesis. The seemingly endless (and at the time, seemingly pointless) repetition drove me crazy. As a kid, I wasn&#8217;t given much sense of the practical usefulness of any of the things I was being taught. I had much more important things to occupy my mind with, like Star Wars, Led Zeppelin, and astronomy.</p>
<p>I&#8217;m a dreamer. I am blessed with the type of personality that allows me to focus for long periods on things. <em>If they interest me.</em> Conversely, if something <strong>doesn&#8217;t</strong> interest me, to this day I still find it extremely hard to concentrate. I get especially irked if I sense that something is being done inefficiently or is unnecessarily repetitive. I mean, after all that&#8217;s why we invented computers, right?</p>
<p>Fast forward to 2009 and I&#8217;m helping my daughter with her math homework. She&#8217;s working on a sort of &#8216;math trick&#8217; with number palindromes. That&#8217;s a number like 2447442 that reads the same forward and backward. One creates this via an iterative process. You reverse numbers and add them together. If you don&#8217;t have a palindrome you take the output of the previous operation and repeat until you get a palindrome. Or not.</p>
<p>Most of the first batch of problems went pretty well. My daughter was doing her work and I was checking the results with a calculator. Finally we came to the last couple of examples. Here&#8217;s where the problem started. It turned out we had misread one part of the instructions concerning how to handle decimals. Thus, we started out with a number that never became a palindrome. Sarah quickly gave up. Then my wife and I filled up a couple sheets of scratch paper with numbers that quickly spiraled into the Land of the Insanely Huge. I even went upstairs and banged out numbers on the calculator for twenty minutes. By this time, we were all miserable, so we agreed to take it up the next day.</p>
<p>So now I was irked (see above) and the wheels were turning. This wasn&#8217;t hard from a mathematical point of view. It just involved some juggling and a whole bunch of repetitive calculations. Perfect job for a script!</p>
<p>Any normal dad would&#8217;ve probably just re-read the instructions, fixed the calculation and called it good. Me? Geek dad? Nooooooo&#8230; I couldn&#8217;t leave it alone. I went upstairs and set to work on a command-line PHP script to expunge the drudgery from this thankless chore once and for all!</p>
<p>When it was done I had fun checking Sarah&#8217;s work, and discovered an earlier example she&#8217;d gotten wrong. For the record, we made sure our daughter understood the process and I only used the script to check her work, not give her the answers.</p>
<p>This is a total hack written late at night, so no flames please! Suggestions for improving it are welcome, however. I may create a web-ready version of this and stick it on the site if anybody&#8217;s interested in searching out new and amazing number palindromes. Aside from that, it&#8217;s now basically a solution to a nonexistent problem. And I can once again sleep at night.</p>
<pre class="brush: php;">
#! /usr/bin/php

&lt;?
	# The input number.

	$input = $argv[1];

	# Set up some variables
	$palindrome = 0;
	$limit = 10000; // how many iterations?
	$iterations = 0;

# ------------------------------------------------------------#
# Main 'while' loop
# ------------------------------------------------------------#

while($palindrome === 0 &amp;&amp; $iterations &lt;= $limit) {
	$iterations++;

	echo 'Testing: ' . $input . &quot;\r\n&quot;;

	$result = testInput($input);

	if(is_numeric($result)) {
		echo &quot;Palindrome found! : &quot; . $result . &quot;\r\n&quot;;
		break;
	} else {
		# next iteration, please.
		$input = genNewInput($input);
	}
} // end while

# ------------------------------------------------------------#
# Function: genNewInput
# ------------------------------------------------------------#
function genNewInput($input) {
	$fwd_array = str_split($input);
	$rev_array = array_reverse($fwd_array);

	# add reversed numbers together
	$fwd_num = implode($fwd_array);
	$rev_num = implode($rev_array);

	echo 'Adding: ' . $fwd_num  . ' + ' . $rev_num . &quot;\r\n&quot;;

	$input = $fwd_num + $rev_num;
	return $input;
}

# ------------------------------------------------------------#
# Function: testInput
# ------------------------------------------------------------#
function testInput($input) {

	$fwd_array = str_split($input);
	$rev_array = array_reverse($fwd_array);

	# get the digit count
	$digit_count = count($fwd_array);

	$r = $digit_count - 1; // zero indexed

	# Determine if the output is a palindrome
	for($f=0;$f&lt;$digit_count;$f++) {

		# inner loop. this takes the new input and tests it. If it passes, we've found our palindrome! If not, it continues the outer loop with the next input number.

		# compare the numbers.
		if($fwd_array[$f] === $fwd_array[$r]) {
			$r--;

			if($f === ($digit_count - 1)) {
				# BINGO!
				return $input;
			} else {
				continue;
			}

		} else {
			return false;
		}
	}
}

?&gt;
</pre>
<p>[Note: I had originally posted more code here. I'm going to bring this back up as a separate page at a later date.]</p>
]]></content:encoded>
			<wfw:commentRss>http://gawain.org/blog/2009/09/21/geek-dad-vs-normal-dad/feed/</wfw:commentRss>
		<slash:comments>6</slash:comments>
		</item>
		<item>
		<title>e-Sword LIVE goes, um&#8230; Live!</title>
		<link>http://gawain.org/blog/2008/05/25/e-sword-live-goes-um-live/</link>
		<comments>http://gawain.org/blog/2008/05/25/e-sword-live-goes-um-live/#comments</comments>
		<pubDate>Sun, 25 May 2008 17:50:06 +0000</pubDate>
		<dc:creator>Gawain</dc:creator>
				<category><![CDATA[Development]]></category>

		<guid isPermaLink="false">http://gawain.org/blog/?p=100</guid>
		<description><![CDATA[I have a tee shirt that reads &#8220;I never finish anyth.&#8221; The caption is tongue-in-cheek, but as I often have several projects in the hopper at once it sometimes feels like the truth. e-Sword LIVE is a project that after a long incubation period has finally escaped into the wild. I&#8217;ve had the privilege of ]]></description>
			<content:encoded><![CDATA[<p>I have a tee shirt that reads &#8220;I never finish anyth.&#8221; The caption is tongue-in-cheek, but as I often have several projects in the hopper at once it sometimes feels like the truth. <a title="e-Sword LIVE" href="http://live.e-Sword.net/app/" target="_blank">e-Sword LIVE</a> is a project that after a long incubation period has finally escaped into the wild.</p>
<p>I&#8217;ve had the privilege of working on e-Sword LIVE for about the last eighteen months. It&#8217;s a web application version of Rick Meyer&#8217;s e-Sword Bible software. The original e-Sword is a standalone Windows program that is by all accounts the most popular Bible study software in the world, with over 7 million downloads worldwide.</p>
<p>Rick wanted to create a version that could be used on the web by anyone and from anywhere. He headed up the project and I built the system from scratch using the <a title="MooTools Javascript Framework" href="http://mootools.net" target="_blank">MooTools</a> javascript framework and the usual suspects PHP, MySQL and Smarty templates. There&#8217;s a wide variety of different Bibles, Commentaries, Dictionaries and other cross reference tools available, all tied together by some nice technology that makes it easy to use and navigate.</p>
<p>You can type in a reference like &#8220;John 3:16&#8243; or search for words or phrases. If you want to link to a specific passage from your own site you can do so like this:</p>
<p><a title="A Link to 1 Kings 19:11" href="http://live.e-sword.net/app/?bibleref=1ki_19:11" target="_blank">http://live.e-sword.net/app/?bibleref=1ki_19:11</a></p>
<p><a title="e-Sword LIVE" href="http://live.e-sword.net/app/" target="_blank">Check it out here</a> and let me know what you think.There&#8217;s a default Bible and Commentary, but lots more are available once you register.</p>
<p>Soon we&#8217;ll have it shortened and you&#8217;ll be able to omit the &#8220;/app&#8221; part of the URL. Oh wait&#8230; I guess that means it isn&#8217;t finished after all!</p>
<p><a title="e-Sword LIVE" href="http://live.e-sword.net/app/" target="_blank"><br />
</a></p>
]]></content:encoded>
			<wfw:commentRss>http://gawain.org/blog/2008/05/25/e-sword-live-goes-um-live/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Climbing Flash Mountain</title>
		<link>http://gawain.org/blog/2007/09/04/climbing-flash-mountain/</link>
		<comments>http://gawain.org/blog/2007/09/04/climbing-flash-mountain/#comments</comments>
		<pubDate>Tue, 04 Sep 2007 17:20:02 +0000</pubDate>
		<dc:creator>Gawain</dc:creator>
				<category><![CDATA[Development]]></category>

		<guid isPermaLink="false">http://gawain.org/blog/?p=58</guid>
		<description><![CDATA[I consider myself a decently skilled Flash developer. However, I don&#8217;t use the program frequently enough to keep up with the constant pace of change in ActionScript. So it seems that every time I start with a significant Flash project I&#8217;m faced with the decision of either sticking with the backward-compatible language choices or forging ]]></description>
			<content:encoded><![CDATA[<p>I consider myself a decently skilled Flash developer. However, I don&#8217;t use the program frequently enough to keep up with the constant pace of change in ActionScript. So it seems that every time I start with a significant Flash project I&#8217;m faced with the decision of either sticking with the backward-compatible language choices or forging ahead into uncharted territory and learning new skills. I&#8217;ve always been the type that wants to use what&#8217;s best—not necessarily what&#8217;s easiest—so I again find myself scaling a learning curve.</p>
<p>Adobe&#8217;s decision to rewrite AS from the ground up was a good one. A lot of the schizophrenic weirdness of AS2 seems to be gone, and AS3 is now a proper object-oriented language with all the standard features that are expected these days. Maybe now it&#8217;ll stabilize for a while&#8230;</p>
<p>So here I am once again surrounded by a stack of books. Poking, prodding and testing to see how things work under the new regime. It&#8217;s one thing to understand how to use a given feature or two. The trick is to grok (did I just say that?) what the best practices are and use the tools to the best advantage.</p>
<p>So no pretty pictures to share this time, unfortunately. Perhaps I can put together a little Flash gizmo to post here before long though&#8230; Until then, I&#8217;m clearing the desk to make room for more manuals.</p>
]]></content:encoded>
			<wfw:commentRss>http://gawain.org/blog/2007/09/04/climbing-flash-mountain/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
	</channel>
</rss>

