<?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>Everybody Dance Now &#187; programming</title>
	<atom:link href="http://blogs.n1zyy.com/andrew/category/programming/feed/" rel="self" type="application/rss+xml" />
	<link>http://blogs.n1zyy.com/andrew</link>
	<description>Just another Blogs.n1zyy.com weblog</description>
	<lastBuildDate>Wed, 07 Dec 2011 19:25:24 +0000</lastBuildDate>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=3.2.1</generator>
		<item>
		<title>Instant Storage</title>
		<link>http://blogs.n1zyy.com/andrew/2009/02/24/instant-storage/</link>
		<comments>http://blogs.n1zyy.com/andrew/2009/02/24/instant-storage/#comments</comments>
		<pubDate>Tue, 24 Feb 2009 21:27:55 +0000</pubDate>
		<dc:creator>andrew</dc:creator>
				<category><![CDATA[development]]></category>
		<category><![CDATA[hacks]]></category>
		<category><![CDATA[php]]></category>
		<category><![CDATA[programming]]></category>
		<category><![CDATA[technology]]></category>
		<category><![CDATA[tips]]></category>

		<guid isPermaLink="false">http://blogs.n1zyy.com/andrew/?p=190</guid>
		<description><![CDATA[Here&#8217;s one of my favorite PHP &#8216;hacks&#8217;: when I&#8217;m whipping up a quick script that needs a place to stash some persistent data, but don&#8217;t feel like coming up with a database structure, or doing anything remotely approaching a real solution, I instead stuff it into a &#8220;static&#8221; session. By static, I just mean that [...]]]></description>
			<content:encoded><![CDATA[<p>Here&#8217;s one of my favorite PHP &#8216;hacks&#8217;: when I&#8217;m whipping up a quick script that needs a place to stash some persistent data, but don&#8217;t feel like coming up with a database structure, or doing anything remotely approaching a real solution, I instead stuff it into a &#8220;static&#8221; session. By static, I just mean that I set the session ID to a static value, so I&#8217;m always pulling the same session. Instant data store.</p>
<pre>session_id('stash-stuff-here');
session_start();
$_SESSION['stuff'] = $w00tz;</pre>
<p>(Another quick and dirty approach would be serializing an array into a local file&#8230; oh, wait, I just recreated the default PHP session handler. <img src='http://blogs.n1zyy.com/andrew/wp-includes/images/smilies/icon_wink.gif' alt=';)' class='wp-smiley' /> )</p>
]]></content:encoded>
			<wfw:commentRss>http://blogs.n1zyy.com/andrew/2009/02/24/instant-storage/feed/</wfw:commentRss>
		<slash:comments>1</slash:comments>
		</item>
		<item>
		<title>PHPUnit + FAM + libnotify == fun</title>
		<link>http://blogs.n1zyy.com/andrew/2008/11/11/phpunit-fam-libnotify-fun/</link>
		<comments>http://blogs.n1zyy.com/andrew/2008/11/11/phpunit-fam-libnotify-fun/#comments</comments>
		<pubDate>Tue, 11 Nov 2008 16:11:21 +0000</pubDate>
		<dc:creator>andrew</dc:creator>
				<category><![CDATA[development]]></category>
		<category><![CDATA[hacks]]></category>
		<category><![CDATA[php]]></category>
		<category><![CDATA[programming]]></category>

		<guid isPermaLink="false">http://blogs.n1zyy.com/andrew/?p=156</guid>
		<description><![CDATA[Last night I &#8216;tweeted&#8217; (man, I hate that word!) on some hacking I was doing with PHPUnit, FAM (the File Alteration Monitor), and libnotify/notification-daemon to automatically run unit tests as you modify files. Credit where credit is due: this was inspired by other people&#8217;s work with other unit testing frameworks. Anyways, the short screencast in [...]]]></description>
			<content:encoded><![CDATA[<p>Last night I <a href="http://twitter.com/imarealgeek/status/1000027596">&#8216;tweeted&#8217;</a> (man, I hate that word!) on some hacking I was doing with PHPUnit, <a href="http://oss.sgi.com/projects/fam/index.html">FAM</a> (the File Alteration Monitor), and libnotify/notification-daemon to automatically run unit tests as you modify files.</p>
<p>Credit where credit is due: this was inspired by <a href="http://www.google.com/search?hl=en&amp;client=firefox-a&amp;rls=org.gentoo%3Aen-US%3Aofficial&amp;hs=F0v&amp;q=growl+unit+test&amp;btnG=Search">other people&#8217;s work</a> with other unit testing frameworks.</p>
<p>Anyways, the <a href="http://www.youtube.com/watch?v=Aq1T1Qm6ZI4">short screencast</a> in my update last night has already generated some interest, so I thought I&#8217;d get this out on the web for perhaps wider exposure.</p>
<p>Coming soon: continuous integration on your desktop for your PHPUnit projects.</p>
]]></content:encoded>
			<wfw:commentRss>http://blogs.n1zyy.com/andrew/2008/11/11/phpunit-fam-libnotify-fun/feed/</wfw:commentRss>
		<slash:comments>3</slash:comments>
		</item>
		<item>
		<title>Duck Typing</title>
		<link>http://blogs.n1zyy.com/andrew/2008/08/09/duck-typing/</link>
		<comments>http://blogs.n1zyy.com/andrew/2008/08/09/duck-typing/#comments</comments>
		<pubDate>Sat, 09 Aug 2008 06:39:50 +0000</pubDate>
		<dc:creator>andrew</dc:creator>
				<category><![CDATA[development]]></category>
		<category><![CDATA[hacks]]></category>
		<category><![CDATA[php]]></category>
		<category><![CDATA[programming]]></category>

		<guid isPermaLink="false">http://blogs.n1zyy.com/andrew/?p=131</guid>
		<description><![CDATA[I&#8217;m in fairly creative mood tonight, as evidenced by one (now two) blog postings, the PHP coding I did earlier, and the upload of some 75 random pictures to Facebook. I guess that&#8217;s what happens when I avoid the work I really should be doing. (Blech, JavaScript.) Anyways, a few days ago a coworker mentioned [...]]]></description>
			<content:encoded><![CDATA[<p>I&#8217;m in fairly creative mood tonight, as evidenced by one (now two) blog postings, the PHP coding I did earlier, and the upload of some 75 random pictures to Facebook. I guess that&#8217;s what happens when I avoid the work I really should be doing. (Blech, JavaScript.)</p>
<p>Anyways, a few days ago a coworker mentioned something to me about duck typing, and I again decided to shirk my responsibilities and experiment. The basic idea is to stand typing on its head and have an imperative system rather than declarative &#8212; as they say, &#8220;if it walks like a duck, and quacks like a duck, it must be a duck.&#8221;</p>
<p><span id="more-131"></span></p>
<p>So how does that translate to actual code? Well, normally a class exports all its interfaces in a static list defined when the class is written. But sometimes it&#8217;d be nice to ask for a class that has all the features necessary to implement a given interface <i>even if the class wasn&#8217;t declared as an implementor</i>.</p>
<p>Since there&#8217;s no language support for this in PHP, <a href="http://pastebin.com/f49b3eead">my (proof-of-concept) solution</a> relies exclusively on the <a href="http://www.php.net/reflection">Reflection</a> library to validate method existence and signatures.</p>
<p>Time for an example.</p>
<pre style="border: 1px solid #000000;margin: 5px 0 5px 0;padding: 5px"><code>class B
{
  public function woot($a)
  {
    echo 'haha';
  }
}

interface A
{
  public function woot($a);
}

var_dump(Goose::isA('A', new B()));
</code></pre>
<p>Notice that B never declares that it&#8217;s going to implement the interface A. Yet <code>Goose::isA</code> will return TRUE, because, while it&#8217;s not declared as such, B does satisfy all the requirements of the interface.</p>
]]></content:encoded>
			<wfw:commentRss>http://blogs.n1zyy.com/andrew/2008/08/09/duck-typing/feed/</wfw:commentRss>
		<slash:comments>2</slash:comments>
		</item>
		<item>
		<title>Willfull Ignorance</title>
		<link>http://blogs.n1zyy.com/andrew/2008/07/10/willfull-ignorance/</link>
		<comments>http://blogs.n1zyy.com/andrew/2008/07/10/willfull-ignorance/#comments</comments>
		<pubDate>Thu, 10 Jul 2008 21:46:43 +0000</pubDate>
		<dc:creator>andrew</dc:creator>
				<category><![CDATA[brilliance]]></category>
		<category><![CDATA[php]]></category>
		<category><![CDATA[programming]]></category>
		<category><![CDATA[rants]]></category>

		<guid isPermaLink="false">http://blogs.n1zyy.com/andrew/?p=124</guid>
		<description><![CDATA[Sometimes, writing good code is really hard. But other times, writing good code is so darn easy you shouldn&#8217;t even have to think about it. In fact, it shouldn&#8217;t even be called &#8220;good code&#8221; &#8212; in these cases there should never be anything else, so we&#8217;ll just call it &#8220;code&#8221;. For instance, if I see [...]]]></description>
			<content:encoded><![CDATA[<p>Sometimes, writing good code is really hard. But other times, writing good code is so darn easy you shouldn&#8217;t even have to think about it. In fact, it shouldn&#8217;t even be called &#8220;good code&#8221; &#8212; in these cases there should never be anything else, so we&#8217;ll just call it &#8220;code&#8221;.</p>
<p>For instance, if I see another line of code that does this:</p>
<pre>$foo = isset($foo) ? $foo : 'default value';</pre>
<p>I think I&#8217;ll kill someone.</p>
<p>Let me clear something up for you: <strong>using the ternary operator does <em>not</em> make you cool.</strong> However, assigning a variable to itself makes you very uncool.</p>
<pre>if (!isset($foo)) $foo = 'default value';</pre>
<p>Now why is that so hard to write?</p>
]]></content:encoded>
			<wfw:commentRss>http://blogs.n1zyy.com/andrew/2008/07/10/willfull-ignorance/feed/</wfw:commentRss>
		<slash:comments>2</slash:comments>
		</item>
		<item>
		<title>~Time</title>
		<link>http://blogs.n1zyy.com/andrew/2008/06/08/time/</link>
		<comments>http://blogs.n1zyy.com/andrew/2008/06/08/time/#comments</comments>
		<pubDate>Sun, 08 Jun 2008 22:35:50 +0000</pubDate>
		<dc:creator>andrew</dc:creator>
				<category><![CDATA[brilliance]]></category>
		<category><![CDATA[linux]]></category>
		<category><![CDATA[php]]></category>
		<category><![CDATA[programming]]></category>

		<guid isPermaLink="false">http://blogs.n1zyy.com/andrew/?p=119</guid>
		<description><![CDATA[I&#8217;ve been playing around with Xubuntu on an old machine, and happened to install the latest version of Eclipse + PDT (1.0.3, IIRC?). While setting up the myriad of options I require to feel comfortable in the editor, I noticed that they&#8217;ve added the ability to strip whitespace on save. May the authors be praised!]]></description>
			<content:encoded><![CDATA[<p>I&#8217;ve been playing around with <a href="http://www.xubuntu.org/">Xubuntu</a> on an old machine, and happened to install the latest version of <a href="http://www.eclipse.org/pdt/">Eclipse + PDT</a> (1.0.3, IIRC?). While setting up the myriad of options I require to feel comfortable in the editor, I noticed that they&#8217;ve added the ability to strip whitespace on save. May the authors be praised!</p>
]]></content:encoded>
			<wfw:commentRss>http://blogs.n1zyy.com/andrew/2008/06/08/time/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Represent!</title>
		<link>http://blogs.n1zyy.com/andrew/2008/04/10/represent/</link>
		<comments>http://blogs.n1zyy.com/andrew/2008/04/10/represent/#comments</comments>
		<pubDate>Thu, 10 Apr 2008 23:57:02 +0000</pubDate>
		<dc:creator>andrew</dc:creator>
				<category><![CDATA[development]]></category>
		<category><![CDATA[php]]></category>
		<category><![CDATA[programming]]></category>
		<category><![CDATA[work]]></category>

		<guid isPermaLink="false">http://blogs.n1zyy.com/andrew/2008/04/10/represent/</guid>
		<description><![CDATA[I just learned that I&#8217;ll be presenting at the 2008 installment of the DC PHP Conference (in Washington DC, oddly enough). I&#8217;m excited about the prospect.]]></description>
			<content:encoded><![CDATA[<p>I just learned that I&#8217;ll be presenting at the 2008 installment of the <a href="http://www.dcphpconference.com/">DC PHP Conference</a> (in Washington DC, oddly enough). I&#8217;m excited about the prospect.</p>
]]></content:encoded>
			<wfw:commentRss>http://blogs.n1zyy.com/andrew/2008/04/10/represent/feed/</wfw:commentRss>
		<slash:comments>5</slash:comments>
		</item>
		<item>
		<title>Open up wide</title>
		<link>http://blogs.n1zyy.com/andrew/2008/03/05/open-up-wide/</link>
		<comments>http://blogs.n1zyy.com/andrew/2008/03/05/open-up-wide/#comments</comments>
		<pubDate>Wed, 05 Mar 2008 16:15:49 +0000</pubDate>
		<dc:creator>andrew</dc:creator>
				<category><![CDATA[development]]></category>
		<category><![CDATA[programming]]></category>
		<category><![CDATA[aim aol]]></category>

		<guid isPermaLink="false">http://blogs.n1zyy.com/andrew/2008/03/05/open-up-wide/</guid>
		<description><![CDATA[When I signed into meebo this morning, I got a little pop-up with a blurb about a partnership with AOL. I was immediately intrigued. Unfortunately, muscle memory kicked in too fast, and I closed the box &#8212; the same one that opens every time I sign in &#8212; before I even realized I wanted to [...]]]></description>
			<content:encoded><![CDATA[<p>When I signed into <a href="http://meebo.com">meebo</a> this morning, I got a little pop-up with a blurb about a partnership with AOL. I was immediately intrigued. Unfortunately, muscle memory kicked in too fast, and I closed the box &#8212; the same one that opens <i>every</i> time I sign in &#8212; before I even realized I wanted to read it. So I signed out and back in.</p>
<p>Apparently, AOL is finally <a href="http://dev.aol.com/aim">opening AIM up</a> really wide. They&#8217;re talking about full protocol documentation (that&#8217;s the &#8220;oscar&#8221; protocol, not the crappy TOC one), letting people use their own AIM libraries, and full access to all the functionality (voice, video, filesharing, etc.) &#8212; as far as I know, this stuff has never been available before.</p>
<p>I also noticed that you can now convert any AIM screen name into a &#8220;bot&#8221;: the various rate limits are removed (or heightened, at the very least), you can&#8217;t be warned, and are allowed to be added to more people&#8217;s buddy lists. In return, you can&#8217;t initiate conversations.</p>
<p>You <i>know</i> what this means.</p>
<blockquote><p>The screen name crabbychild has been successfully converted to an AIM® Bot.</p></blockquote>
]]></content:encoded>
			<wfw:commentRss>http://blogs.n1zyy.com/andrew/2008/03/05/open-up-wide/feed/</wfw:commentRss>
		<slash:comments>2</slash:comments>
		</item>
		<item>
		<title>Across an Instance</title>
		<link>http://blogs.n1zyy.com/andrew/2008/02/23/across-an-instance/</link>
		<comments>http://blogs.n1zyy.com/andrew/2008/02/23/across-an-instance/#comments</comments>
		<pubDate>Sat, 23 Feb 2008 16:35:02 +0000</pubDate>
		<dc:creator>andrew</dc:creator>
				<category><![CDATA[development]]></category>
		<category><![CDATA[php]]></category>
		<category><![CDATA[programming]]></category>
		<category><![CDATA[tips]]></category>

		<guid isPermaLink="false">http://blogs.n1zyy.com/andrew/2008/02/23/across-an-instance/</guid>
		<description><![CDATA[Here's the quick PHP tip of the day: class methods can access the protected (of any shared ancestors) and private (of the same type) members of <i>any</i> instance, not only their own instance. That may sound confusing, but it's really not so much.]]></description>
			<content:encoded><![CDATA[<p>Here&#8217;s the quick PHP tip of the day: class methods can access the protected (of any shared ancestors) and private (of the same type) members of <i>any</i> instance, not only their own instance. That may sound confusing, but it&#8217;s really not so much.</p>
<p><span id="more-93"></span></p>
<p>Maybe some example code will explain it better. Let&#8217;s say I have a class that&#8217;s a counter, just wrapping an integer.</p>
<pre><code>
&lt;?php
class Counter
{
    protected $count = 0;

    public function increment()
    {
        $this-&gt;count++;
    }

    public function getCount()
    {
        return $this-&gt;count;
    }
}

?&gt;
</code></pre>
<p>And now, for some reason, I want to add two counters together. I add a method to <code>Counter</code> named <code>add()</code> that accepts another instance of <code>Counter</code>. But rather than calling <code>increment()</code> <code>$count</code> times, I can simply write:</p>
<pre><code>
    public function add(Counter $c)
    {
        $this-&gt;count += $c-&gt;count;
    }
</code></pre>
<p>Blindingly simple, really, but something I often forget about.</p>
]]></content:encoded>
			<wfw:commentRss>http://blogs.n1zyy.com/andrew/2008/02/23/across-an-instance/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>The Importance of Bits</title>
		<link>http://blogs.n1zyy.com/andrew/2008/01/07/the-importance-of-bits/</link>
		<comments>http://blogs.n1zyy.com/andrew/2008/01/07/the-importance-of-bits/#comments</comments>
		<pubDate>Tue, 08 Jan 2008 01:13:00 +0000</pubDate>
		<dc:creator>andrew</dc:creator>
				<category><![CDATA[programming]]></category>
		<category><![CDATA[rants]]></category>
		<category><![CDATA[work]]></category>

		<guid isPermaLink="false">http://blogs.n1zyy.com/andrew/2008/01/07/the-importance-of-bits/</guid>
		<description><![CDATA[With their abundant availability both in volatile and permanent storage (i.e., RAM and hard-disks), sometimes I think the value of bits is lost on more recent developers, especially those that write in a very high-level language, like, say, PHP. The past few weeks I&#8217;ve been working very closely with some data analysts in our company [...]]]></description>
			<content:encoded><![CDATA[<p>With their abundant availability both in volatile and permanent storage (i.e., RAM and hard-disks), sometimes I think the value of bits is lost on more recent developers, especially those that write in a very high-level language, like, say, PHP. The past few weeks I&#8217;ve been working very closely with some data analysts in our company &#8212; in particular, I&#8217;ve been compiling some very large tables (think nearly 1 billion rows per month) into &#8220;views&#8221; (technically, they&#8217;re completely new tables) that are much more manageable.</p>
<p>Tonight, mostly as an exercise in futility, I began looking at some of the foreign keys stored in the gargantuan tables. One of them in particular links to a table that currently contains (oddly enough) 256 rows. It grows very, very slowly. Currently the column is a long integer: 4 bytes. Imagine for a minute that we replaced that with what MySQL calls a small integer, or 2 bytes. Last month&#8217;s table was in the neighborhood of 900,000,000 rows, times 2, divided by 1024&#8230; That&#8217;s something just shy of 2 GIGAbytes that we&#8217;ve saved. (Never mind that there are about 4 other foreign keys this could also be applied to).</p>
<p>Every byte adds up, folks. Save &#8216;em while you can.</p>
<p>(Some might call this inconvenient math. I&#8217;m not quite that unscrupulous.)</p>
]]></content:encoded>
			<wfw:commentRss>http://blogs.n1zyy.com/andrew/2008/01/07/the-importance-of-bits/feed/</wfw:commentRss>
		<slash:comments>2</slash:comments>
		</item>
		<item>
		<title>The PDT (Or: I Don&#8217;t Like Zend)</title>
		<link>http://blogs.n1zyy.com/andrew/2007/11/16/the-pdt-or-i-dont-like-zend/</link>
		<comments>http://blogs.n1zyy.com/andrew/2007/11/16/the-pdt-or-i-dont-like-zend/#comments</comments>
		<pubDate>Fri, 16 Nov 2007 17:57:04 +0000</pubDate>
		<dc:creator>andrew</dc:creator>
				<category><![CDATA[php]]></category>
		<category><![CDATA[programming]]></category>
		<category><![CDATA[rants]]></category>
		<category><![CDATA[tips]]></category>

		<guid isPermaLink="false">http://blogs.n1zyy.com/andrew/2007/11/16/the-pdt-or-i-dont-like-zend/</guid>
		<description><![CDATA[My animosity towards Zend has really increased lately, due to a number of factors (the recent ZendCon, their character when dealing with open-source projects, etc.), so much so that I&#8217;ve sworn off Zend products. Which doesn&#8217;t really sound like a difficult task at first glance, since I only use one Zend product &#8212; but that [...]]]></description>
			<content:encoded><![CDATA[<p>My animosity towards <a href="http://zend.com">Zend</a> has really increased lately, due to a number of factors (the recent ZendCon, their character when dealing with open-source projects, etc.), so much so that I&#8217;ve sworn off Zend products. Which doesn&#8217;t really sound like a difficult task at first glance, since I only use one Zend product &#8212; but that one product just happens to be one of the only good PHP IDEs out there: <a href="http://www.zend.com/products/zend_studio">Zend Studio</a>.</p>
<p>Fortunately (and if you follow the PHP world, you&#8217;ve probably heard about this), Studio is receiving competent competition in the open-source world from the Eclipse platform in the guise of the PHP Developer Tools, or <a href="http://www.eclipse.org/pdt/">PDT</a>. (And that&#8217;s competition in a very liberal sense of the word, since Zend is actually backing PDT &#8212; so they can rip it of&#8211; base future versions of Zend Studio on it.)</p>
<p>Anyways, the real goal here was just to talk about a quick PDT tip (now that I&#8217;ve switched), not rant and rave about how Zend seems to have a knack for positioning themselves in the middle of hugely conflicting interests.</p>
<p>The tip: Most people know that you can Ctrl+Click &#8220;into&#8221; a function call. What I didn&#8217;t know is that you can also Ctrl+Hover to get a tooltip containing the first ~10 lines of the function.</p>
<p><a href='http://blogs.n1zyy.com/andrew/files/2007/11/blah.jpg' title='blah.jpg'><img src='http://blogs.n1zyy.com/andrew/files/2007/11/blah.jpg' alt='blah.jpg' /></a></p>
<p>This can be <em>immensely</em> useful when you&#8217;re just trying to figure out what a piece of code does, without completely losing your train of thought and switching contexts.</p>
]]></content:encoded>
			<wfw:commentRss>http://blogs.n1zyy.com/andrew/2007/11/16/the-pdt-or-i-dont-like-zend/feed/</wfw:commentRss>
		<slash:comments>1</slash:comments>
		</item>
	</channel>
</rss>

