<?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>nomadhacker</title>
	<atom:link href="http://www.nomadhacker.com/feed/" rel="self" type="application/rss+xml" />
	<link>http://www.nomadhacker.com</link>
	<description>mental ramblings of a self-aknowledged geek</description>
	<lastBuildDate>Sun, 23 May 2010 03:04:32 +0000</lastBuildDate>
	<generator>http://wordpress.org/?v=2.9.1</generator>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
			<item>
		<title>PostgreSQL: The Other Open-Source Database</title>
		<link>http://www.nomadhacker.com/uncategorized/postgresql-the-other-open-source-database/</link>
		<comments>http://www.nomadhacker.com/uncategorized/postgresql-the-other-open-source-database/#comments</comments>
		<pubDate>Sun, 23 May 2010 03:04:32 +0000</pubDate>
		<dc:creator>nomadhacker</dc:creator>
				<category><![CDATA[Uncategorized]]></category>
		<category><![CDATA[databases]]></category>
		<category><![CDATA[postgresql]]></category>

		<guid isPermaLink="false">http://www.nomadhacker.com/?p=149</guid>
		<description><![CDATA[MySQL isn&#8217;t dead, despite some concerns people have had lately.  But if you&#8217;re at all concerned about its future, you may find yourself suddenly poking your head up and looking around at alternatives, like me.  
That&#8217;s not a bad thing.  Being agile and able to switch out database systems with minimal fuss [...]]]></description>
			<content:encoded><![CDATA[<p>MySQL isn&#8217;t dead, despite some concerns people have had lately.  But if you&#8217;re at all concerned about its future, you may find yourself suddenly poking your head up and looking around at alternatives, like me.  </p>
<p>That&#8217;s not a bad thing.  Being agile and able to switch out database systems with minimal fuss possible is good programming practice.  And MySQL, while it&#8217;s a good lightweight system that fits a lot of people&#8217;s needs, isn&#8217;t he only game out there.</p>
<p>PostgreSQL is one of the other options out there.  It may not get as much press as its more famous little brother, but it&#8217;s also open and free.  </p>
<p>Postgres is also a great alternative for government or corporate &#8216;enterprise&#8217; projects that may have thumbed their nose at MySQL before, however unfairly, as a &#8216;toy&#8217; database.  It&#8217;s built for security, stability, and has the transaction support and advanced features that high end Oracle users want, while still being easy to use and accessible for users without as many resources.  </p>
<p>Also, MySQL users, no more will you have to worry about needing different features that are supported in different storage engines.  There is only one storage engine.  All features are in one place.  You can have fulltext search <em>and</em> foreign keys!</p>
<p>It honestly can be a little bit more work to set up than MySQL on a linux server, due mainly to the way its user-based permission system works, but it can actually be a great security feature, and there are some <a href="http://articles.slicehost.com/2009/5/6/ubuntu-hardy-postgresql-installation">excellent tutorials</a> out there that you can follow to get it up and running with minimum fuss.</p>
<p>I&#8217;ve started using PostgreSQL in some of my projects.  It is a great system that at least deserves a look.  If you decide that MySQL is still the database for you, no worries.  The Sun/Oracle acquisition just underlines the importance of being flexible in your development.  If all that happens is programmers start being a little more modular and careful in planning their systems, putting all their database code in one place so it&#8217;s easy to replace, that&#8217;s not a bad thing at all.</p>
]]></content:encoded>
			<wfw:commentRss>http://www.nomadhacker.com/uncategorized/postgresql-the-other-open-source-database/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Creating a PHP Collection Class</title>
		<link>http://www.nomadhacker.com/uncategorized/creating-a-php-collection-class/</link>
		<comments>http://www.nomadhacker.com/uncategorized/creating-a-php-collection-class/#comments</comments>
		<pubDate>Sun, 16 May 2010 01:29:13 +0000</pubDate>
		<dc:creator>nomadhacker</dc:creator>
				<category><![CDATA[Uncategorized]]></category>

		<guid isPermaLink="false">http://www.nomadhacker.com/?p=140</guid>
		<description><![CDATA[PHP has really been growing up lately.  There are some really nice new things in the SPL (Standard PHP Library), including some nice new collection structures familiar to programmers from other languages.  We&#8217;ve got heaps, stacks, and queues.  There are also some interfaces you can implement to create your own collections with [...]]]></description>
			<content:encoded><![CDATA[<p>PHP has really been growing up lately.  There are some really nice new things in the SPL (Standard PHP Library), including some nice new collection structures familiar to programmers from other languages.  We&#8217;ve got heaps, stacks, and queues.  There are also some interfaces you can implement to create your own collections with standard array-like behavior.</p>
<p>Let&#8217;s take a look at building out our own basic collection class.  We can extend and subclass this thing later to make it even more useful.</p>
<pre>
<code>
class Collection implements IteratorAggregate, Countable
{
        /** hold the colleciton of items in an array */
        protected $_items = array();

        /**
         * Optionally accept an array of items to use for the collection, if provided
         * @params array $items (optional)
         */
        public function __construct($items = null)
        {
                if ($items !== null &amp;&amp; is_array($items)) {
                        $this-&gt;_items = $items;
                }
        }

        /**
         * Function to satisfy the IteratorAggregate interface.  Sets an
         * ArrayIterator instance for the server list to allow this class to be
         * iterable like an array.
         */
        public function getIterator()
        {
                return new ArrayIterator($this-&gt;_items);
        }

        /**
         * Function to satisfy the Countable interface, returns a count of the
         * length of the collection
         * @return int the collection length
         */
        public function count()
        {
                return $this-&gt;length();
        }

        /**
         * Function to add an item to the Collection, optionally specifying
         * the key to access the item with.  Returns the item passed in for
         * continuing work.
         * @param $item the object to add
         * @param $key the accessor key (optional)
         * @return mixed the item
         */
        public function addItem($item, $key = null)
        {
                if($key !== null) {
                        $this-&gt;_items[$key] = $item;
                } else {
                        $this-&gt;_items[] = $item;
                }

                return $item;
        }

        /**
         * Remove an item from the Collection identified by it's key
         * @param $key the identifying key of the item to remove
         */
        public function removeItem($key)
        {
                if(isset($this-&gt;_items[$key])) {
                        unset($this-&gt;_items[$key]);
                } else {
                        throw new Exception("Invalid key $key specified.");
                }
        }

        /**
         * Retrieve an item from the collection as identified by its key
         * @param $key the identifying key of the item to remove
         * @return item identified by the key
         */
        public function getItem($key)
        {
                if(isset($this-&gt;_items[$key])) {
                        return $this-&gt;_items[$key];
                } else {
                        throw new Exception("Invalid key $key specified.");
                }
        }

        /**
         * Function to return the entire list of servers as an array
         * of Server objects
         * @return array
         */
        public function getAll()
        {
                return $this-&gt;_items;
        }

        /**
         * Return the list of keys to all objects in the collection
         * @return array an array of items
         */
        public function keys()
        {
                return array_keys($this-&gt;_items);
        }

        /**
         * Return the length of the collection of items
         * @return int the size of the collection
         */
        public function length()
        {
                return count($this-&gt;_items);
        }

        /**
         * Check if an item with the identified key exists in the Collection
         * @param $key the key of the item to check
         * @return bool if the item is in the Collection
         */
        public function exists($key)
        {
                return (isset($this-&gt;_items[$key]));
        }

}</code>
</pre>
<p>This is fairly basic, but it&#8217;s already got some pretty useful stuff.  We can add, remove, and retrieve items in this collection, as you&#8217;d expect.  We can check to see if an item exists.  Also, notice that we&#8217;re returning the object in question when we add it, so we can support some handy command chainging functionality.  But we&#8217;ve got some other nifty features as well.</p>
<p>This Collection is iterrable (not irritable, it&#8217;s not grumpy).  So you can just cycle over the whole thing in a foreach loop, just like an array.  It does this by implementing the IteratorAggregate interface, which requires a function getIterator() to return an iterator object.  The iterator it returns is just the array iterator created from the protected items array.</p>
<p>We&#8217;re also countable, by implementing the Countable interface.  It requires one function count() which we just pass along to our length() function which returns the count of the items in our collection.  Why have length()?  Why not just return a count of our array in the count() method?  So we can get the number of items two ways, either by count($collection) or $collection->length().   We like flexibility.</p>
<p>We also have some nice functions, getAll(), keys() which let us get the entire collection as an array (in case we absolutely need an array for something we&#8217;re working with), and to return a list of all the object keys in the array.</p>
<p>We can stuff just about anything we want in this collection, ints, strings, objects, and more.  And it&#8217;s got some built-in behaviors that we&#8217;re used to seeing from arrays.  But why go through all this trouble?  Why not just use an array and call it a day?</p>
<p>Because this puppy&#8217;s extendable through the magic of Object-Oriented Inheritance!</p>
<p>I can easily add a method to this Collection class or a sub-class to support some specialized behavior.  Say I created a subclass AggregateCollection that had a method that cycles through and gets an aggregate total of some certain property of every item in the collection:</p>
<pre>
<code>        public function getAggregateProperty($property)
        {
                $total = 0;
                if (count($this) &gt; 0){
                        foreach ($this-&gt;_items as $item) {
                                if ($item instanceof AggregateCollection) {
                                        $total += $item-&gt;getAggregateProperty($property);
                                } else {
                                        if ($item-&gt;$property !== null) {
                                                $total += $item-&gt;$property;
                                        }
                                }
                        }
                }
                return $total;
        }</code>
</pre>
<p>What&#8217;s this doing?  We&#8217;re looping through the entire set of objects we have and aggregating the total of whatever property we passed in.  Not only that, but we can even have a collection of collections, so we check to see if the child we have is a collection, and then call its method to get the aggregate properties of its items.  This will extend as far down the chain as we need, so we can have an extensive hierarchial relationship of items, and with one method call:</p>
<pre>
<code>$total = $collection-&gt;getAggregateProperty('someProperty');</code>
</pre>
<p>And we don&#8217;t even need to know how far down the rabbit hole we need to go to get it.  </p>
<p>Another thing I find pretty helpful, especially in light of how I like to chain commands, is a method something like this:</p>
<pre>
<code>        public function getOrMakeChild($id, $type, $params = null)
        {
                if ($this-&gt;exists($id)) {
                        return $this-&gt;getItem($id);
                } else {
                        $child = new $type($params);
                        return $this-&gt;addItem($child, $id);
                }
        }</code>
</pre>
<p>You can then in one call first check to see if an item exists by key, and if so, return the item to begin working with.  If it doesn&#8217;t exist, it creates a new object based on the type you give it, then returns it.  This can be any type of object that takes either zero or one parameter which you can optionally pass in with the call.</p>
<p>As you can see, you can build out your collection objects to do almost anything you need, making these a flexible, powerful alternative to arrays.</p>
]]></content:encoded>
			<wfw:commentRss>http://www.nomadhacker.com/uncategorized/creating-a-php-collection-class/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Write PHP like JQuery</title>
		<link>http://www.nomadhacker.com/php-programming/write-php-like-jquery/</link>
		<comments>http://www.nomadhacker.com/php-programming/write-php-like-jquery/#comments</comments>
		<pubDate>Fri, 07 May 2010 01:35:17 +0000</pubDate>
		<dc:creator>nomadhacker</dc:creator>
				<category><![CDATA[PHP Programming]]></category>
		<category><![CDATA[Jquery]]></category>
		<category><![CDATA[PHP]]></category>

		<guid isPermaLink="false">http://www.nomadhacker.com/?p=128</guid>
		<description><![CDATA[So I&#8217;ve certainly made my opinion of JQuery clear.  As far as I&#8217;m concerned it&#8217;s really an integral part of the JavaScript language.  The main thing it brings to the table is its drop-dead simple css-style selection and manipulation of the DOM.
However, another thing that many JQuery programmers really appreciate is the command [...]]]></description>
			<content:encoded><![CDATA[<p>So I&#8217;ve certainly made my opinion of JQuery clear.  As far as I&#8217;m concerned it&#8217;s really an integral part of the JavaScript language.  The main thing it brings to the table is its drop-dead simple css-style selection and manipulation of the DOM.</p>
<p>However, another thing that many JQuery programmers really appreciate is the command chaining lets you pipe the object from one statement to another, futher shrinking the number of lines of code and in the process making it easy to just do a lot of different things in a row to one object.</p>
<p><code>$('.selectableClass').removeClass('selectableClass')<br />
     .addClass('unselectableClass').parent().children().slideUp();</code></p>
<p>That code is really concise, but it&#8217;s still pretty self-explanatory what&#8217;s going on.  It doesn&#8217;t reach the level of unreasonable terseness of, say, the frackin&#8217; ternary operator. (die ternary die!).</p>
<p>Wouldn&#8217;t it be great to make some of your PHP objects act like that?  Guess what?  You can!</p>
<p>There are a number of design patterns that can encourage working in your code this way.  Decorators, for example.  Obviously the factory pattern is all about creating and using brand new objects.</p>
<p>All you have to do is just pass the object you&#8217;re wanting to chain along back as the result of a method call.  For example, you might have some kind of collection object that you add a new item to and then want to use that item immediately, as in the following example:</p>
<p><code>public function addItem($childItem) {<br />
        // add the child item<br />
        return $childItem<br />
}</code></p>
<p>That&#8217;s all there is to it.  You can then call the function like:</p>
<p><code>$collection-&gt;addItem(new childItem())-&gt;doSomethingOnChild();</code></p>
<p>In a more concrete example, say you&#8217;re creating a spreadsheet.  You may want to create a new worksheet and new row all from a database.  </p>
<p><code>$spreadsheet = new Spreadsheet()-&gt;addWorksheet(new Worksheet())-&gt;addRow(new Row())-&gt;manipulateRow();</code></p>
<p>Here, we&#8217;re piping in new objects as we create them and then using them right away.  </p>
<p>Obviously this can get to be too much, so don&#8217;t go overboard with it.  The above is getting a little bit long.  But it can be a great practice to learn for certain design patterns and for hierarchial object relationships.  And it shows that there&#8217;s more than one way to code your objects.  It&#8217;s all about options.</p>
]]></content:encoded>
			<wfw:commentRss>http://www.nomadhacker.com/php-programming/write-php-like-jquery/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>NaNoWriMo or Bust!</title>
		<link>http://www.nomadhacker.com/writing/nanowrimo-or-bust/</link>
		<comments>http://www.nomadhacker.com/writing/nanowrimo-or-bust/#comments</comments>
		<pubDate>Sat, 03 Oct 2009 22:47:55 +0000</pubDate>
		<dc:creator>nomadhacker</dc:creator>
				<category><![CDATA[writing]]></category>
		<category><![CDATA[nanowrimo]]></category>

		<guid isPermaLink="false">http://www.nomadhacker.com/?p=119</guid>
		<description><![CDATA[I have recently signed up for the National Novel Writing Month Challenge! (NaNoWriMo).  NaNoWriMo is an annual, month-long challenge that takes place during the month of November.  The idea is to write a 50,000 word long novel in exactly one month.
There are no style restrictions, and editing is actually discouraged.  The goal [...]]]></description>
			<content:encoded><![CDATA[<p>I have recently signed up for the National Novel Writing Month Challenge! (NaNoWriMo).  <a href="http://www.nanowrimo.org/">NaNoWriMo</a> is an annual, month-long challenge that takes place during the month of November.  The idea is to write a 50,000 word long novel in exactly one month.</p>
<p>There are no style restrictions, and editing is actually discouraged.  The goal is to get out and write, to just splurge everything down on the paper and get an actual novel completed, instead of endlessly thinking about the plot, or getting caught in the tinkering trap of endlessly tweaking and rewriting things.</p>
<p>There&#8217;s no contest, and no prize for best novel.  The only prize is to have a complete 50,000 word piece of writing that you&#8217;ve created.</p>
<p>I&#8217;ve been neglecting my writing lately.  Instead anything I create is more likely to be crafted in PHP or C# than the English language.  Don&#8217;t get me wrong, I do enjoy grokking a tricky piece of code, but there&#8217;s a more creative side to myself that I&#8217;ve always enjoyed exploring, and it hasn&#8217;t been getting much play lately.  It will feel good to get back to actual writing again.  I feel like the <a href="http://www.nanowrimo.org/">NaNoWriMo</a> challenge is exactly the sort of event I need to get started again.</p>
<p>So that leaves me with a little more than one month to get ready.  I need set up a space to write, find some typing paper (yes I&#8217;m using a typewriter), and figure out what to write.  Anyone have any suggestions?</p>
]]></content:encoded>
			<wfw:commentRss>http://www.nomadhacker.com/writing/nanowrimo-or-bust/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Why JQuery</title>
		<link>http://www.nomadhacker.com/jquery/why-jquery/</link>
		<comments>http://www.nomadhacker.com/jquery/why-jquery/#comments</comments>
		<pubDate>Fri, 02 Oct 2009 17:37:30 +0000</pubDate>
		<dc:creator>nomadhacker</dc:creator>
				<category><![CDATA[Jquery]]></category>
		<category><![CDATA[javascript]]></category>

		<guid isPermaLink="false">http://www.nomadhacker.com/?p=111</guid>
		<description><![CDATA[I used to be one of those &#8216;He-Man&#8217; coders.  Why do I need to use libraries or frameworks?  I&#8217;l just code it all by hand and it&#8217;ll be leaner and more efficient.  Why would you bother to have an extra 15k download?  That&#8217;s an extra server call! You get the idea.
While [...]]]></description>
			<content:encoded><![CDATA[<p>I used to be one of those &#8216;He-Man&#8217; coders.  Why do I need to use libraries or frameworks?  I&#8217;l just code it all by hand and it&#8217;ll be leaner and more efficient.  Why would you bother to have an extra 15k download?  That&#8217;s an extra server call! You get the idea.</p>
<p>While there certainly are some libraries or frameworks that are too big or that run slower, that&#8217;s more a sign of a poorly made library than anything else.  JQuery is no poorly made library.</p>
<p>You may load an extra few killobytes of data once, but you more than make up for that in the code you don&#8217;t write.  That 15k contains lots of time and code-saving features that can help turn something that used to take you 5 lines of code into an elegant one-liner, streamlining your code and actually making your JavaScript more efficient.</p>
<p>The first time I saw how much power was wrapped up in simple the simple calls of JQuery, I had gone to Desert Code Camp, basically a free coder&#8217;s day camp in Phoenix with presentations on a bunch of different topics.  Looking to fill in time before the Cocoa programming intro, I hopped into the JQuery session.</p>
<p>The first thing the presenter did was probably familiar to many who have used JQuery before.  He wrote a two-inch single line of code to perform list striping, that effect you get when every other line in a list or table is a separate background color.<br />
<code>$("tr:even").css("background-color", "#eeeeee");</code><br />
He then went on to show off a couple of one-line effects like fading, roll-ups, show/hide, and while he was at it he showed off some of the drop-dead simple css-based selectors to get just the right items.</p>
<p>Needless to say I immediately went home and jumped on the jquery site, picked up a book on JQuery, and started learning the syntax.  Since then I&#8217;ve started working it into my own projects and projects at work.  I&#8217;ve even started rewriting some old stuff to use JQuery simply because it&#8217;s that much better.  Projects at work that would have taken me two weeks or more I&#8217;m able to get done in under a week with the time I&#8217;m saving from JQuery.</p>
<p>Does this all sound a little hard to believe?  An exaggeration?  Can it end World Hunger, too?  Nope, I guarantee it&#8217;s real, and once you start seeing your code collapsing into half its previous size, you&#8217;ll wonder why you&#8217;d never learned JQuery sooner.</p>
<p>Ready to dive in?  Honestly there&#8217;s not a lot to learn to get started.  Simply run over to JQuery&#8217;s site and start looking through the documentation, run to Borders and pick up a book, check out <a href="http://15daysofjquery.com/">15 Days of JQuery</a> and run through their demos.</p>
]]></content:encoded>
			<wfw:commentRss>http://www.nomadhacker.com/jquery/why-jquery/feed/</wfw:commentRss>
		<slash:comments>3</slash:comments>
		</item>
		<item>
		<title>Importing Older Drivel</title>
		<link>http://www.nomadhacker.com/site-updates/importing-older-drivel/</link>
		<comments>http://www.nomadhacker.com/site-updates/importing-older-drivel/#comments</comments>
		<pubDate>Sat, 12 Sep 2009 01:42:29 +0000</pubDate>
		<dc:creator>nomadhacker</dc:creator>
				<category><![CDATA[Site Updates]]></category>

		<guid isPermaLink="false">http://www.nomadhacker.com/?p=108</guid>
		<description><![CDATA[So just to clean up and simplify things, I&#8217;m merging my old wordpress.com blog with this one.  I&#8217;ve imported some older posts over here and am making my wordpress-hosted abandonment official.  There weren&#8217;t a lot of posts imported, but if you were browsing the archives and found some older ones from waaayyy back, that&#8217;s why. [...]]]></description>
			<content:encoded><![CDATA[<p>So just to clean up and simplify things, I&#8217;m merging my old wordpress.com blog with this one.  I&#8217;ve imported some older posts over here and am making my wordpress-hosted abandonment official.  There weren&#8217;t a lot of posts imported, but if you were browsing the archives and found some older ones from waaayyy back, that&#8217;s why.  Just FYI.</p>
]]></content:encoded>
			<wfw:commentRss>http://www.nomadhacker.com/site-updates/importing-older-drivel/feed/</wfw:commentRss>
		<slash:comments>1</slash:comments>
		</item>
		<item>
		<title>The Guy&#8230;of Science!</title>
		<link>http://www.nomadhacker.com/coolness/the-guy-of-science/</link>
		<comments>http://www.nomadhacker.com/coolness/the-guy-of-science/#comments</comments>
		<pubDate>Fri, 11 Sep 2009 15:23:51 +0000</pubDate>
		<dc:creator>nomadhacker</dc:creator>
				<category><![CDATA[Coolness]]></category>
		<category><![CDATA[bill nye]]></category>
		<category><![CDATA[johnny]]></category>
		<category><![CDATA[science]]></category>

		<guid isPermaLink="false">http://www.nomadhacker.com/?p=80</guid>
		<description><![CDATA[Belated post about going to see Science Guy Bill Nye himself with my stepson, who enjoyed it maybe even more than I.]]></description>
			<content:encoded><![CDATA[<p>I haven&#8217;t gotten a chance to mention this yet, (see last post) but I got to see Bill Nye in person a couple months ago.  Bill was giving a talk at nearby St. Louis University on environmental sustainability that was free and open to the public.  Given such a bargain-basement price, of course we went and got there plenty early.</p>
<p>The coolest part about all this is that I wasn&#8217;t the only one who was excited about this (nor probably the most excited).  My 7 year old stepson Johnny just about imploded with excitement when he found out.</p>
<p>Johnny&#8217;s a huge Bill Nye fan.  He watches the Bill Nye videos and reads Bill&#8217;s books from the local library like a lot of kids his age play video games (he really likes video games, too).  So Isa and I decided that it would be a good surprise to take him to this talk&#8230;of Science!</p>
<p>We didn&#8217;t tell him we were going.  That day we left my parents after visiting for the day, and instead of driving straight home, we drove to SLU.  When we parked, Johnny asked why we were stopping.</p>
<p>&#8216;We just feel like getting out and walking around for a minute.&#8217;</p>
<p>He didn&#8217;t question at all, but just got out and walked with us, even though it was pretty cold.</p>
<p>Finally, we passed by a sign as we were getting close to the assembly hall with a big picture of his Science-ness on it.</p>
<p>&#8220;We&#8217;re going to get to see Bill Nye?&#8221; Johnny all but vibrated through the floor.</p>
<p>So we continued in to the convention room to hear Bill speak about environmental sustainability to a bunch of college students.  We figured it would be cool for Johnny to get to see Bill Nye in person, but that he probably wouldn&#8217;t get much out of it considering the target crowd.</p>
<p>&#8220;I&#8217;m going to remember this everyday for all my life,&#8221; Johnny proclaimed.</p>
<p>The next day we were visiting my parents, and Johnny was telling them all about how we were part of the &#8216;Space Generation&#8217; and how the sky on Mars is beige in color.</p>
<p>Sounds like we&#8217;ve got another little &#8216;Science Guy&#8217; developing already.</p>
]]></content:encoded>
			<wfw:commentRss>http://www.nomadhacker.com/coolness/the-guy-of-science/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Cliff&#8217;s notes</title>
		<link>http://www.nomadhacker.com/my-life/cliffs-notes/</link>
		<comments>http://www.nomadhacker.com/my-life/cliffs-notes/#comments</comments>
		<pubDate>Fri, 11 Sep 2009 03:24:09 +0000</pubDate>
		<dc:creator>nomadhacker</dc:creator>
				<category><![CDATA[my life]]></category>
		<category><![CDATA[life updates]]></category>

		<guid isPermaLink="false">http://www.nomadhacker.com/uncategorized/cliffs-notes/</guid>
		<description><![CDATA[Well it has been a while since I&#8217;ve posted anything here, as you well know by the ear-shattering sound of nothingness coming from over here the last couple months.  Not an excuse but it has been pretty busy here lately.
To catch you up on the goings-on, here is the official Cliff&#8217;s notes version of [...]]]></description>
			<content:encoded><![CDATA[<p>Well it has been a while since I&#8217;ve posted anything here, as you well know by the ear-shattering sound of nothingness coming from over here the last couple months.  Not an excuse but it has been pretty busy here lately.</p>
<p>To catch you up on the goings-on, here is the official Cliff&#8217;s notes version of the last few months of my life, with full version to follow shortly.</p>
<p>First up, I got married. After a year up planning the Big Day finally arrived.  The ceremony was great, the church was beautiful and everything went off without a problem.  The reception afterward was very elegant, everyone said so.  And&#8211;very importantly for us&#8211;the photos came out great.</p>
<p>Well getting married was a lot to plan, but a few weeks before the wedding I found out I got an excellent new job at GoDaddy.  In Arizona.  So in the last couple weeks before the wedding we also had a move to plan.  Fortunately Isa&#8217;s the plan ahead type and everything went smoothly.</p>
<p>When we got down here of course we needed to find a place to live, and then here was settling into the new job.  Then, just about a month ago, my Dad found out he was going to need bypass surgery.  I flew back and my brother drove home from school to be there.  Fortunately the doctors found his blockages before he had a heart attack, and they&#8217;re getting really handy with heart surgery nowadays.  It&#8217;s almost become a routine thing.  Still it is a pretty big event and can really make you worry.</p>
<p>Finally, just this week, Isa and I made the switch and got iPhones, on which I am composing this post.</p>
<p>Anyway, that catches up most of the major events that have been occuring lately.  Hopefully things have settled enough that I&#8217;ll be able to keep connected more, and maybe be able to get back to working on my movie reviews site.</p>
]]></content:encoded>
			<wfw:commentRss>http://www.nomadhacker.com/my-life/cliffs-notes/feed/</wfw:commentRss>
		<slash:comments>4</slash:comments>
		</item>
		<item>
		<title>Introducing Conditionals</title>
		<link>http://www.nomadhacker.com/php-programming/introducing-conditionals/</link>
		<comments>http://www.nomadhacker.com/php-programming/introducing-conditionals/#comments</comments>
		<pubDate>Mon, 02 Mar 2009 23:52:29 +0000</pubDate>
		<dc:creator>nomadhacker</dc:creator>
				<category><![CDATA[PHP Programming]]></category>
		<category><![CDATA[Conditionals]]></category>
		<category><![CDATA[If]]></category>
		<category><![CDATA[PHP]]></category>

		<guid isPermaLink="false">http://www.nomadhacker.com/?p=73</guid>
		<description><![CDATA[Conditionals basically allow you to tell PHP what to do, depending on certain conditions.  This is where you really start getting into PHP programming.  This is where you’ll find the ‘If…Then’ you may have seen before in programming.
Conditionals aren’t too hard.  The most basic form of a conditional is the ‘If’ statement.
If something is true…
Then [...]]]></description>
			<content:encoded><![CDATA[<p>Conditionals basically allow you to tell PHP what to do, depending on certain conditions.  This is where you really start getting into PHP programming.  This is where you’ll find the ‘If…Then’ you may have seen before in programming.</p>
<p>Conditionals aren’t too hard.  The most basic form of a conditional is the ‘If’ statement.</p>
<p>If something is true…<br />
Then do something else</p>
<p>In PHP this is written like so…</p>
<p><code>if (something) {<br />
something else<br />
}</code></p>
<p>Let’s look at an example.</p>
<p><code>$a = 2;<br />
$b = 1;<br />
if ($a &amp;gt; $b){<br />
echo $a;<br />
}</code></p>
<p>So in this example, we first test whether $a is greater than $b (using the &gt; symbol again from Algebra).  If this is true, we print the value of $a.  In this case, the browser would see the number 2 because $a is indeed greater than $b.</p>
<p>However, say $b was equal to 3.  In that case, we would not print the value of a, and the PHP interpreter would simply continue its merry little way on to the rest of the code.</p>
<p>You can put more than one statement in the curly braces of an ‘If’ statement, by the way.  We could also have:</p>
<p><code>if ($a &amp;gt; $b){<br />
echo ‘A is greater&amp;lt;br /&amp;gt;’;<br />
echo $a;<br />
}</code></p>
<p>This would output:</p>
<blockquote><p>A is greater<br />
2</p></blockquote>
<p>Notice I included the html &lt;br /&gt; in there.  You have to include whatever html tags you need, including line breaks, inside the strings you send to PHP.</p>
<p>Now what if we wanted to test to see if $a and $b were equal?  Well, like I mentioned in the previous section, we use two equals signs for this:</p>
<p><code>if ($a == $b){<br />
echo ‘They are equal’;<br />
}</code></p>
<p>If the two numbers are equal, and only if they are equal, the browser will see ‘They are equal’ printed.</p>
<p>However, as I warned before, you must be careful not to use the single equals sign for this.</p>
<p><code>if ($a = $b){<br />
echo ‘They are equal’;<br />
}</code></p>
<p>Because that will assign the value of $b to $a.  So even if $a started out as 3 and $b started out as 56, this would be considered a true statement, because PHP would assign the value of 56 to $a, and then declare it a true statement.  So our browser would always see ‘They are equal’ even if they are not.</p>
<p>Using our form example from a past lesson, we could display a message only if someone put ‘Fred’ in as their username.</p>
<p><code>if( $_POST[‘username’] == ‘fred’){<br />
echo ‘Heya Fred!’;<br />
}</code></p>
<p>So you can hopefully begin to see how some of the magic happens when you send that web form.</p>
]]></content:encoded>
			<wfw:commentRss>http://www.nomadhacker.com/php-programming/introducing-conditionals/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Simple Math with PHP</title>
		<link>http://www.nomadhacker.com/php-programming/simple-math-with-php/</link>
		<comments>http://www.nomadhacker.com/php-programming/simple-math-with-php/#comments</comments>
		<pubDate>Sat, 28 Feb 2009 23:42:23 +0000</pubDate>
		<dc:creator>nomadhacker</dc:creator>
				<category><![CDATA[PHP Programming]]></category>
		<category><![CDATA[math]]></category>
		<category><![CDATA[PHP]]></category>

		<guid isPermaLink="false">http://www.nomadhacker.com/?p=69</guid>
		<description><![CDATA[PHP has built-in math functionality for most of your mathematical desires.  Here are a few of the common math operators and what they do:
+      adds numbers
-    subtracts
*    multiplies
/    divides
%    modulus (the remainder of a division)
These are pretty common and you’re probably pretty familiar with these.  Though the modulus operator at the bottom may be [...]]]></description>
			<content:encoded><![CDATA[<p>PHP has built-in math functionality for most of your mathematical desires.  Here are a few of the common math operators and what they do:</p>
<p>+      adds numbers<br />
-    subtracts<br />
*    multiplies<br />
/    divides<br />
%    modulus (the remainder of a division)</p>
<p>These are pretty common and you’re probably pretty familiar with these.  Though the modulus operator at the bottom may be a bit strange.  It’s needed because if you divide two integers, PHP is still going to return an integer with no decimal or remainder.  For example:</p>
<p><code>echo 5/2;</code></p>
<p>Would output</p>
<blockquote><p>2</p></blockquote>
<p>If you were to use:</p>
<p><code>echo 5%2;</code></p>
<p>You would get 1, which is the remainder of 5 divided by 2.</p>
<p>Notice that the numbers don’t have quotation marks around them like text does.  Numbers don’t need them.  If you put quotation marks around ‘2’, then it would be the string ‘2’, not the actual number 2.  You can’t do math on text.</p>
<p>Let’s look at a few examples of using PHP for math:</p>
<p><code>$num1 = 3;<br />
$num2 = 2;&lt;br /&gt;&lt;br /&gt;<br />
echo $num1 * $num2;</code></p>
<p>outputs</p>
<blockquote><p>6</p></blockquote>
<p><code>echo $num1 - $num2;</code></p>
<p>outputs</p>
<blockquote><p>1</p></blockquote>
<p><code>echo $num2 - $num1;</code></p>
<p>outputs</p>
<blockquote><p>-1</p></blockquote>
<p>…and so forth.</p>
<p>Now, we can also assign the value of whatever mathematical operation to a variable as we’re doing it.  Like so…</p>
<p><code>$total = $num1 + $num2;<br />
echo $total;</code></p>
<p>outputs</p>
<blockquote><p>5</p></blockquote>
<p>Or</p>
<p><code>$total = $num1 * $num2;</code></p>
<p>outputs</p>
<blockquote><p>6</p></blockquote>
<p>Basically PHP will do whatever is on the right side of the equals sign first, then assign the value to the variable on the left.</p>
<p>Just like with Algebra, the PHP math functions do things in the ‘Order of Operations’.  So multiplication and division first, then addition and subtraction, etc.</p>
<p><code>$num1 - $num2 * $num3;</code></p>
<p>would first multiply $num2 and $num3, and subtract the result from $num1.  However, also just like with Algebra, you can also use parentheses to control what order things are done in.  So…</p>
<p><code>($num1 - $num2) * $num3;</code></p>
<p>would first subtract $num2 from $num1, and then multiply times $num3.</p>
<p>There is one major difference from normal Algebra in how PHP handles math.  Notice how PHP uses the equals sign to assign values to variables.  PHP does not use an equals sign like we traditionally think of it, to state equivalence.  That is,</p>
<p><code>$num1 = $num2;</code></p>
<p>Assigns the value of $num2 to $num1.  It does not say, $num1 is equal to $num2.  Or compare $num1 to $num2.  To talk about the more traditional comparison we’re expecting, we use two equals signs together.</p>
<p><code>$num1 == $num2;</code></p>
<p>This tests whether the two values are equal.  It’s a very common mistake to interchange these.</p>
]]></content:encoded>
			<wfw:commentRss>http://www.nomadhacker.com/php-programming/simple-math-with-php/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
	</channel>
</rss>
