<?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>randys.org</title>
	<atom:link href="http://www.randys.org/feed/" rel="self" type="application/rss+xml" />
	<link>http://www.randys.org</link>
	<description>wasting your precious bandwidth since 1998</description>
	<lastBuildDate>Fri, 23 Mar 2012 04:20:50 +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>Homebrew &#8211; Building a working APC 3.1.9</title>
		<link>http://www.randys.org/2011/08/26/homebrew-building-a-working-apc-3-1-9/?utm_source=rss&#038;utm_medium=rss&#038;utm_campaign=homebrew-building-a-working-apc-3-1-9</link>
		<comments>http://www.randys.org/2011/08/26/homebrew-building-a-working-apc-3-1-9/#comments</comments>
		<pubDate>Fri, 26 Aug 2011 04:06:21 +0000</pubDate>
		<dc:creator>randy</dc:creator>
				<category><![CDATA[Code Chunks]]></category>
		<category><![CDATA[General Nerdery]]></category>
		<category><![CDATA[How-To]]></category>

		<guid isPermaLink="false">http://www.randys.org/?p=563</guid>
		<description><![CDATA[I&#8217;ve recently started using Homebrew as a means to get a working PHP/APC on my local MACs. It was fairly straight forward, however, after installing APC, PHP stopped working. Turns out there was a tiny bug in apc_lock.h that needed &#8230; <a href="http://www.randys.org/2011/08/26/homebrew-building-a-working-apc-3-1-9/">Continue reading <span class="meta-nav">&#8594;</span></a>]]></description>
			<content:encoded><![CDATA[<p>I&#8217;ve recently started using <a href="https://github.com/mxcl/homebrew">Homebrew</a> as a means to get a working <a href="http://www.php.net">PHP</a>/<a href="http://pecl.php.net/package/APC">APC</a> on my local MACs. It was fairly straight forward, however, after installing APC, PHP stopped working. Turns out there was a <a href="http://pecl.php.net/bugs/bug.php?id=22688">tiny bug in <code>apc_lock.h</code></a> that needed to be fixed. Literally, one extra character in the header caused the whole thing to go kaput.</p>
<p>Turns out it&#8217;s a pretty simple fix. Just have to <a href="http://news.php.net/php.pecl.cvs/15669">remove ONE ampersand</a> (&amp;) in the file and everything is kosher. But, since I <a href="https://github.com/mxcl/homebrew/commit/d6cd00ab3a284120711fb6d3775a165803411e3c#commitcomment-540394">couldn&#8217;t figure how to incorporate a patch</a> in Homebrew, I <a href="https://github.com/sesser/homebrew/blob/fbbf0652902fa0c8a330d1da30bde8e57656d656/Library/Formula/apc.rb">wrote some hacky ruby</a> in the <code>apc.rb</code> file to fix the situation.</p>
<p>Hacky code to follow:</p>
<pre class="brush: ruby; gutter: true">   def install
        Dir.chdir "APC-#{version}" do
            text = File.read("apc_lock.h")
            text.gsub!(/apc_fcntl_unlock\(&amp;a TSRMLS_CC\)/, "apc_fcntl_unlock(a TSRMLS_CC)")
            File.open("apc_lock.h", 'w') { |f| f.write(text) }
            system "phpize"
            system "./configure", "--prefix=#{prefix}"
            system "make"

            prefix.install %w(modules/apc.so apc.php)
        end
    end</pre>
<p>Enjoy!</p>
<div style=" text-align: center;  margin: 8px; ">
				<script type="text/javascript">
				google_ad_client = "pub-6476605957445525";
				google_ad_width = 468;
				google_ad_height = 60;
				google_ad_format = "468x60_as";
				google_ad_type = "text_image";
				google_ad_channel = "8409641020";
				google_color_border = "#C7C7C7";
				google_color_bg = "#FFFFFF";
				google_color_link = "#777777";
				google_color_text = "#777777";
				google_color_url = "#3333CC";
				google_ui_features = "rc:0";
				</script>
				<script type="text/javascript" src="http://pagead2.googlesyndication.com/pagead/show_ads.js"></script>
			</div><!-- PHP 5.x -->]]></content:encoded>
			<wfw:commentRss>http://www.randys.org/2011/08/26/homebrew-building-a-working-apc-3-1-9/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>AFP: Fourteen US states sue to block health reform</title>
		<link>http://www.randys.org/2010/03/24/afp-fourteen-us-states-sue-to-block-health-reform/?utm_source=rss&#038;utm_medium=rss&#038;utm_campaign=afp-fourteen-us-states-sue-to-block-health-reform</link>
		<comments>http://www.randys.org/2010/03/24/afp-fourteen-us-states-sue-to-block-health-reform/#comments</comments>
		<pubDate>Thu, 25 Mar 2010 03:35:20 +0000</pubDate>
		<dc:creator>randy</dc:creator>
				<category><![CDATA[Photos]]></category>

		<guid isPermaLink="false">http://www.randys.org/2010/03/24/afp-fourteen-us-states-sue-to-block-health-reform/</guid>
		<description><![CDATA[&#8220;State law is irrelevant,&#8221; Siegel said. &#8220;Where state and federal law conflict, federal law wins.&#8221; via google.com Except tax laws. http://www.examiner.com/x-16414-SF-Personal-Banking-Examiner~y2009m12d29-The-&#8230; United states. Whatever. via shakeit]]></description>
			<content:encoded><![CDATA[<div class="posterous_autopost">
<div class="posterous_bookmarklet_entry">
<blockquote class="posterous_short_quote"><p>&#8220;State law is irrelevant,&#8221; Siegel said. &#8220;Where state and federal law conflict, federal law wins.&#8221;</p></blockquote>
<div class="posterous_quote_citation">via <a href="http://www.google.com/hostednews/afp/article/ALeqM5jtsrgf47GepL2kOVZk048vYORzXg">google.com</a></div>
<p>Except tax laws.</p>
<p><a href="http://www.examiner.com/x-16414-SF-Personal-Banking-Examiner~y2009m12d29-The-Grinch-that-stole-the-money-that-isnt-there">http://www.examiner.com/x-16414-SF-Personal-Banking-Examiner~y2009m12d29-The-&#8230;</a></p>
<p>United states. Whatever.</p>
</div>
<p>via <a href="http://shakeit.randys.org/afp-fourteen-us-states-sue-to-block-health-re" target="_blank">shakeit</a></p>
</div>
<!-- PHP 5.x -->]]></content:encoded>
			<wfw:commentRss>http://www.randys.org/2010/03/24/afp-fourteen-us-states-sue-to-block-health-reform/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Random Comment Spam #1</title>
		<link>http://www.randys.org/2010/03/20/random-comment-spam-1/?utm_source=rss&#038;utm_medium=rss&#038;utm_campaign=random-comment-spam-1</link>
		<comments>http://www.randys.org/2010/03/20/random-comment-spam-1/#comments</comments>
		<pubDate>Sun, 21 Mar 2010 04:19:39 +0000</pubDate>
		<dc:creator>randy</dc:creator>
				<category><![CDATA[Randomness]]></category>

		<guid isPermaLink="false">http://www.randys.org/2010/03/20/random-comment-spam-1/</guid>
		<description><![CDATA[eventhough I commit just about all of my daytime hours on the web using games like myspace poker or restaurant city, I nonetheless like to utilize some spare time to check out a small amount of sites sometimes and I&#8217;m &#8230; <a href="http://www.randys.org/2010/03/20/random-comment-spam-1/">Continue reading <span class="meta-nav">&#8594;</span></a>]]></description>
			<content:encoded><![CDATA[<div class='posterous_autopost'><span style="font-family: monospace;">eventhough I commit just about all of my daytime hours on the web using games like myspace poker or restaurant city, I nonetheless like to utilize some spare time to check out a small amount of sites sometimes and I&#8217;m grateful to report this most recent page is in fact quite good and greatly superior than 1 / 2 the various poor quality stuff I read today , anyways i&#8217;m off to take up a couple of rounds of zynga poker</span>
<p>via <a href="http://shakeit.randys.org/random-comment-spam-1" target="_blank">shakeit</a></p>
</p></div>
<!-- PHP 5.x -->]]></content:encoded>
			<wfw:commentRss>http://www.randys.org/2010/03/20/random-comment-spam-1/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Somehow, I don&#039;t think he&#039;s going to find what he&#039;s looking for</title>
		<link>http://www.randys.org/2010/01/27/somehow-i-dont-think-hes-going-to-find-what-hes-looking-for/?utm_source=rss&#038;utm_medium=rss&#038;utm_campaign=somehow-i-dont-think-hes-going-to-find-what-hes-looking-for</link>
		<comments>http://www.randys.org/2010/01/27/somehow-i-dont-think-hes-going-to-find-what-hes-looking-for/#comments</comments>
		<pubDate>Wed, 27 Jan 2010 18:11:26 +0000</pubDate>
		<dc:creator>randy</dc:creator>
				<category><![CDATA[Randomness]]></category>

		<guid isPermaLink="false">http://www.randys.org/2010/01/27/somehow-i-dont-think-hes-going-to-find-what-hes-looking-for/</guid>
		<description><![CDATA[via i303.photobucket.com I&#8217;m just sayin&#8217; via shakeit]]></description>
			<content:encoded><![CDATA[<div class='posterous_autopost'>
<div class="posterous_bookmarklet_entry"> <img src="http://posterous.com/getfile/files.posterous.com/sesser/ekghmJGaGjDjJqDpJrsqfeujjiwbDtyGuIfafdEnsCpmBjpDdknBHHywtdBA/media_httpi303photobu_akhjr.png.scaled500.png" width="500" height="375"/>
<div class="posterous_quote_citation">via <a href="http://i303.photobucket.com/albums/nn122/kuppo1/Were-All-Little-Bit-Darren-Inside_5.png">i303.photobucket.com</a></div>
<p>I&#8217;m just sayin&#8217;</p>
</div>
<p>via <a href="http://shakeit.randys.org/somehow-i-dont-think-hes-going-to-find-what-h" target="_blank">shakeit</a>  </div>
<!-- PHP 5.x -->]]></content:encoded>
			<wfw:commentRss>http://www.randys.org/2010/01/27/somehow-i-dont-think-hes-going-to-find-what-hes-looking-for/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Gary Coleman arrested in Utah on domestic assault warrant; In jail working on bail</title>
		<link>http://www.randys.org/2010/01/24/gary-coleman-arrested-in-utah-on-domestic-assault-warrant-in-jail-working-on-bail/?utm_source=rss&#038;utm_medium=rss&#038;utm_campaign=gary-coleman-arrested-in-utah-on-domestic-assault-warrant-in-jail-working-on-bail</link>
		<comments>http://www.randys.org/2010/01/24/gary-coleman-arrested-in-utah-on-domestic-assault-warrant-in-jail-working-on-bail/#comments</comments>
		<pubDate>Mon, 25 Jan 2010 02:18:41 +0000</pubDate>
		<dc:creator>randy</dc:creator>
				<category><![CDATA[Randomness]]></category>

		<guid isPermaLink="false">http://www.randys.org/2010/01/24/gary-coleman-arrested-in-utah-on-domestic-assault-warrant-in-jail-working-on-bail/</guid>
		<description><![CDATA[Gary Coleman arrested in Utah on domestic assault warrant; In jail working on bail By Katie Nelson DAILY NEWS STAFF WRITER Sunday, January 24th 2010, 9:02 PM via nydailynews.com Whatchu talkin&#8217; &#8217;bout Willis? via shakeit]]></description>
			<content:encoded><![CDATA[<div class='posterous_autopost'>
<div class="posterous_bookmarklet_entry">
<blockquote class="posterous_long_quote">
<div>
<h1>Gary Coleman arrested in Utah on domestic assault warrant; In jail working on bail</h1>
<p class="byline">By <a href="http://www.nydailynews.com/gossip/2010/01/24/2010-01-24_gary_coleman_arrested_in_utah_on_domestic_assault_warrant_in_jail_working_on_bai.html/authors/Katie%20Nelson">Katie Nelson</a>					     					<br />DAILY NEWS STAFF WRITER  				</p>
<p class="datestamp"><span class="datestamp_update">Sunday, January 24th 2010,  9:02 PM</span></p>
</p></div>
<div class="art_img_lrg">    				<img title="Gary Coleman has been arrested in Utah for domestic violence, authorities say. The actor had previously been charged with misdemeanor domestic violence after a fight in July with his wife." src="http://assets.nydailynews.com/img/2010/01/25/alg_coleman.jpg" alt="Gary Coleman has been arrested in Utah for domestic violence, authorities say. The actor had previously been charged with misdemeanor domestic violence after a fight in July with his wife." />
<p /></div>
</blockquote>
<div class="posterous_quote_citation">via <a href="http://www.nydailynews.com/gossip/2010/01/24/2010-01-24_gary_coleman_arrested_in_utah_on_domestic_assault_warrant_in_jail_working_on_bai.html">nydailynews.com</a></div>
<p>Whatchu talkin&#8217; &#8217;bout Willis?</p>
</div>
<p>via <a href="http://shakeit.randys.org/gary-coleman-arrested-in-utah-on-domestic-ass" target="_blank">shakeit</a>  </div>
<!-- PHP 5.x -->]]></content:encoded>
			<wfw:commentRss>http://www.randys.org/2010/01/24/gary-coleman-arrested-in-utah-on-domestic-assault-warrant-in-jail-working-on-bail/feed/</wfw:commentRss>
		<slash:comments>1</slash:comments>
		</item>
		<item>
		<title>Porn video shown on Moscow highway billboard</title>
		<link>http://www.randys.org/2010/01/15/porn-video-shown-on-moscow-highway-billboard/?utm_source=rss&#038;utm_medium=rss&#038;utm_campaign=porn-video-shown-on-moscow-highway-billboard</link>
		<comments>http://www.randys.org/2010/01/15/porn-video-shown-on-moscow-highway-billboard/#comments</comments>
		<pubDate>Fri, 15 Jan 2010 16:07:11 +0000</pubDate>
		<dc:creator>randy</dc:creator>
				<category><![CDATA[Randomness]]></category>

		<guid isPermaLink="false">http://www.randys.org/2010/01/15/porn-video-shown-on-moscow-highway-billboard/</guid>
		<description><![CDATA[MOSCOW (AP) &#8212; Drivers in downtown Moscow were squinting in disbelief as an electronic highway billboard blazed a two-minute pornographic video in place of the regular advertising clips. Late-night traffic on one of the Russian capital&#8217;s busiest roads slowed Thursday &#8230; <a href="http://www.randys.org/2010/01/15/porn-video-shown-on-moscow-highway-billboard/">Continue reading <span class="meta-nav">&#8594;</span></a>]]></description>
			<content:encoded><![CDATA[<div class='posterous_autopost'>MOSCOW (AP) &#8212; Drivers in downtown Moscow were squinting in disbelief <br />as an electronic highway billboard blazed a two-minute pornographic <br />video in place of the regular advertising clips.
<p /> Late-night traffic on one of the Russian capital&#8217;s busiest roads <br />slowed Thursday as a couple&#8217;s explicit escapades appeared across the 9- <br />by-6-meter (yard) display.
<p /> The screen&#8217;s owner &#8212; the 3 Stars advertising agency &#8212; has told The <br />Associated Press that a hacker attack is likely to blame. City police <br />say they have yet to receive any complaints and have not opened an <br />investigation.
<p /> Russian news agency RIA Novosti quoted a city official as saying that <br />Moscow will bolster security of data transmission to ad screens.
<p /> Mobile phone camera footage has been posted on popular video-sharing <br />Web sites.
<p /> <a href="http://biz.yahoo.com/ap/100115/eu_odd_russia_porn_in_the_city.html?.v=1">http://biz.yahoo.com/ap/100115/eu_odd_russia_porn_in_the_city.html?.v=1</a>via <a href="http://shakeit.randys.org/porn-video-shown-on-moscow-highway-billboard" target="_blank">shakeit</a>  </div>
<!-- PHP 5.x -->]]></content:encoded>
			<wfw:commentRss>http://www.randys.org/2010/01/15/porn-video-shown-on-moscow-highway-billboard/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Kodak challenges Apple and RIM on patent: Digital Photography Review</title>
		<link>http://www.randys.org/2010/01/14/kodak-challenges-apple-and-rim-on-patent-digital-photography-review/?utm_source=rss&#038;utm_medium=rss&#038;utm_campaign=kodak-challenges-apple-and-rim-on-patent-digital-photography-review</link>
		<comments>http://www.randys.org/2010/01/14/kodak-challenges-apple-and-rim-on-patent-digital-photography-review/#comments</comments>
		<pubDate>Fri, 15 Jan 2010 00:51:13 +0000</pubDate>
		<dc:creator>randy</dc:creator>
				<category><![CDATA[Randomness]]></category>

		<guid isPermaLink="false">http://www.randys.org/2010/01/14/kodak-challenges-apple-and-rim-on-patent-digital-photography-review/</guid>
		<description><![CDATA[The Kodak complaint, filed with the U.S. International Trade Commission (ITC), specifically claims that Apple’s iPhones and RIM’s camera-enabled BlackBerry devices infringe a Kodak patent that covers technology related to a method for previewing images. Separately, Kodak filed two suits &#8230; <a href="http://www.randys.org/2010/01/14/kodak-challenges-apple-and-rim-on-patent-digital-photography-review/">Continue reading <span class="meta-nav">&#8594;</span></a>]]></description>
			<content:encoded><![CDATA[<div class='posterous_autopost'>
<div class="posterous_bookmarklet_entry">
<blockquote class="posterous_medium_quote">The Kodak complaint, filed with the U.S. International Trade  Commission (ITC), specifically claims that Apple’s iPhones and RIM’s  camera-enabled BlackBerry devices infringe a Kodak patent that covers  technology related to a method for previewing images. Separately, Kodak  filed two suits today against Apple in U.S. District Court for the  Western District of New York that claim the infringement of patents  related to digital cameras and certain computer processes.</p></blockquote>
<div class="posterous_quote_citation">via <a href="http://www.dpreview.com/news/1001/10011402kodakchallengesapplerim.asp">dpreview.com</a></div>
<p>Good luck Kodak.</p>
</div>
<p>via <a href="http://shakeit.randys.org/kodak-challenges-apple-and-rim-on-patent-digi" target="_blank">shakeit</a>  </div>
<!-- PHP 5.x -->]]></content:encoded>
			<wfw:commentRss>http://www.randys.org/2010/01/14/kodak-challenges-apple-and-rim-on-patent-digital-photography-review/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Lightty Cake: CakePHP + Lighttpd Rewrite Rules</title>
		<link>http://www.randys.org/2010/01/05/lightty-cake-cakephp-lighttpd-rewrite-rules/?utm_source=rss&#038;utm_medium=rss&#038;utm_campaign=lightty-cake-cakephp-lighttpd-rewrite-rules</link>
		<comments>http://www.randys.org/2010/01/05/lightty-cake-cakephp-lighttpd-rewrite-rules/#comments</comments>
		<pubDate>Wed, 06 Jan 2010 04:57:25 +0000</pubDate>
		<dc:creator>randy</dc:creator>
				<category><![CDATA[General Nerdery]]></category>
		<category><![CDATA[How-To]]></category>
		<category><![CDATA[Code Chunks]]></category>
		<category><![CDATA[howto]]></category>
		<category><![CDATA[lighttpd]]></category>
		<category><![CDATA[php]]></category>

		<guid isPermaLink="false">http://www.randys.org/2010/01/05/lightty-cake-cakephp-lighttpd-rewrite-rules/</guid>
		<description><![CDATA[This little snippet will also allow you to capture your query string variables should the need arise. url.rewrite-once = ( "^/(css&#124;files&#124;img&#124;js)/(.*)" =&#62; "/$1/$2", "^/([^?]*)(?:\?(.+))?$" =&#62; "/index.php?url=$1&#38;$2" ) Posted via email from shakeit]]></description>
			<content:encoded><![CDATA[<p>This little snippet will also allow you to capture your query string variables should the need arise.</p>
<pre><code>url.rewrite-once = (
    "^/(css|files|img|js)/(.*)" =&gt; "/$1/$2",
    "^/([^?]*)(?:\?(.+))?$" =&gt; "/index.php?url=$1&amp;$2"
)
</code></pre>
<p style="font-size: 10px;">
    <a href="http://posterous.com">Posted via email</a> from <a href="http://shakeit.randys.org/lightty-cake-cakephp-lighttpd-rewrite-rules">shakeit</a></p>
<!-- PHP 5.x -->]]></content:encoded>
			<wfw:commentRss>http://www.randys.org/2010/01/05/lightty-cake-cakephp-lighttpd-rewrite-rules/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>New post</title>
		<link>http://www.randys.org/2009/11/05/new-post/?utm_source=rss&#038;utm_medium=rss&#038;utm_campaign=new-post</link>
		<comments>http://www.randys.org/2009/11/05/new-post/#comments</comments>
		<pubDate>Fri, 06 Nov 2009 00:03:18 +0000</pubDate>
		<dc:creator>randy</dc:creator>
				<category><![CDATA[Uncategorized]]></category>

		<guid isPermaLink="false">http://www.randys.org/?p=371</guid>
		<description><![CDATA[This post is only for people who complain that I haven&#8217;t posted since May.]]></description>
			<content:encoded><![CDATA[<p>This post is only for people who complain that I haven&#8217;t posted since May.</p>
<!-- PHP 5.x -->]]></content:encoded>
			<wfw:commentRss>http://www.randys.org/2009/11/05/new-post/feed/</wfw:commentRss>
		<slash:comments>2</slash:comments>
		</item>
		<item>
		<title>Prototype: It&#8217;s Not Just a JavaScript Library</title>
		<link>http://www.randys.org/2009/05/14/prototype-its-not-just-a-javascript-library/?utm_source=rss&#038;utm_medium=rss&#038;utm_campaign=prototype-its-not-just-a-javascript-library</link>
		<comments>http://www.randys.org/2009/05/14/prototype-its-not-just-a-javascript-library/#comments</comments>
		<pubDate>Fri, 15 May 2009 05:08:25 +0000</pubDate>
		<dc:creator>randy</dc:creator>
				<category><![CDATA[Code Chunks]]></category>
		<category><![CDATA[General Nerdery]]></category>
		<category><![CDATA[Home]]></category>
		<category><![CDATA[howto]]></category>
		<category><![CDATA[javascript]]></category>
		<category><![CDATA[prototype]]></category>

		<guid isPermaLink="false">http://www.randys.org/2009/05/14/prototype-its-not-just-a-javascript-library/</guid>
		<description><![CDATA[Used to be that writing front-end code (HTML, CSS, JavaScript) wasn&#8217;t terribly complex. The syntax of HTML and CSS isn&#8217;t all that difficult to get the hang of and JavaScript (back in the day) was just a tool to validate &#8230; <a href="http://www.randys.org/2009/05/14/prototype-its-not-just-a-javascript-library/">Continue reading <span class="meta-nav">&#8594;</span></a>]]></description>
			<content:encoded><![CDATA[<p>Used to be that writing front-end code (HTML, CSS, JavaScript) wasn&#8217;t terribly complex. The syntax of HTML and CSS isn&#8217;t all that difficult to get the hang of and JavaScript (back in the day) was just a tool to validate form fields and play funny tricks on poor unsuspecting visitors. These days, JavaScript has become <em>the</em> language for front-end development and it&#8217;s not just for printing the &#8216;lastModifiedDate&#8217; of a document.</p>
<p><script src="http://static.randys.org/js/prototype-date.js" type="text/javascript"></script></p>
<p>Anyone who has kept up with the advancements of JavaScript knows the <a href="http://www.prototypejs.org/">Prototype</a> library. For those who don&#8217;t know, it&#8217;s a JavaScript library that wraps a whole bunch of functionality into easy to use (and remember) &#8220;shortcuts&#8221; for doing things like getting elements on a page, manipulating said elements, and dealing with data. It&#8217;s all written in <a href="http://www.json.org/">JSON</a> notation and allows you do things like:</p>
<pre><code>$('element-id').addClassName('active').show();
</code></pre>
<p>Instead of</p>
<pre><code>var element = document.getElementById('element-id');
    element.className = 'active';
    element.style.display = 'block';
</code></pre>
<p>Anyway, things like Prototype, <a href="http://jquery.com/">jQuery</a>, <a href="http://www.dojotoolkit.org/">Dojo</a>, and <a href="http://developer.yahoo.com/yui/">YUI</a> all provide some convenience to writing custom JavaScript applications. I haven&#8217;t dug super deep into any of the frameworks&#8217; source (mostly because the code has been somewhat obfuscated and &#8220;compressed&#8221; to save space), but I imagine that they all have one thing in common; they make use of the <a href="http://phrogz.net/JS/Classes/ExtendingJavaScriptObjectsAndClasses.html#prototype">prototype</a> property to extend both existing and custom built objects/classes in JavaScript.</p>
<h3>The prototype Property</h3>
<p>Even if you don&#8217;t make heavy use of one of the afforementioned framework/toolkits, using the <em>prototype</em> property to extend existing JavaScript objects and/or classes can be quite useful. Say you want an easy way to print out a date. Rather than createing a separate function, just extend the <code>Date</code> object itself.</p>
<pre><code>Date.prototype.months = new Array(
    {name: "January", abbrev: "Jan", number: "01"},
    {name: "February",    abbrev: "Feb", number: "02"},
    {name: "March",       abbrev: "Mar", number: "03"},
    {name: "April",       abbrev: "Apr", number: "04"},
    {name: "May",     abbrev: "May", number: "05"},
    {name: "June",        abbrev: "Jun", number: "06"},
    {name: "July",        abbrev: "Jul", number: "07"},
    {name: "August",  abbrev: "Aug", number: "08"},
    {name: "September", abbrev: "Sep", number: "09"},
    {name: "October", abbrev: "Oct", number: "10"},
    {name: "November",    abbrev: "Nov", number: "11"},
    {name: "December",    abbrev: "Dec", number: "12"}
);
Date.prototype.dow = new Array(
    {name: 'Sunday',  abbrev: 'Sun', number: "01"},
    {name: 'Monday',  abbrev: 'Mon', number: "02"},
    {name: 'Tuesday', abbrev: 'Tue', number: "03"},
    {name: 'Wednesday',   abbrev: 'Wed', number: "04"},
    {name: 'Thursday',    abbrev: 'Thu', number: "05"},
    {name: 'Friday',  abbrev: 'Fri', number: "06"},
    {name: 'Saturday',    abbrev: 'Sat', number: "07"}
);
Date.prototype.getShortDate = function() {
    return this.months[this.getMonth()].abbrev + ' ' + this.getDate() + ' ' + this.getFullYear();
};
Date.prototype.getLongDate = function() {
    return this.dow[this.getDay()].name + ', ' + this.months[this.getMonth()].name + ' ' + this.getDate() + ', ' + this.getFullYear();
};
Date.prototype.getValueDate = function() {
    var d = (this.getDate() &lt; 10) ? '0'+this.getDate():this.getDate();
    return this.getFullYear() + '/' + this.months[this.getMonth()].number + '/' + d;
};

var now = new Date();
document.write(now.getLongDate());
</code></pre>
<p>And you get something like this <script type="text/javascript">var now = new Date();document.write(now.getLongDate());</script>. Handy.</p>
<p>Now, there&#8217;s a couple of issues with the above script. One, the names aren&#8217;t localized and two, there&#8217;s probalby a more efficient way to formatting a date (much like the example on <a href="http://phrogz.net/JS/Classes/ExtendingJavaScriptObjectsAndClasses.html#example2">this page</a>). But, it works in all the browsers I tested (Chrome, Firefox, IE7, Safari [Mac]).</p>
<p>You can prototype most of the default objects in JavaScript. Say you have an application the has to validate a bunch of text fields. Prototype the <code>String</code> objects to add built in parsing methods for various fields.</p>
<pre><code>String.prototype.isValidEmail = function() { ... }
String.prototype.isValidPhone = function() { ... }
</code></pre>
<p>You get the idea.</p>
<p>The <code>prototype</code> property is a handy little tool. There maybe some limitations between browsers, but overall, it should help simplify your code and prevent repetitive and reduntant methods.</p>
<!-- PHP 5.x -->]]></content:encoded>
			<wfw:commentRss>http://www.randys.org/2009/05/14/prototype-its-not-just-a-javascript-library/feed/</wfw:commentRss>
		<slash:comments>1</slash:comments>
		</item>
	</channel>
</rss>

