<?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>CodeWord: Apokalyptik</title>
	<atom:link href="http://blog.apokalyptik.com/feed/" rel="self" type="application/rss+xml" />
	<link>http://blog.apokalyptik.com</link>
	<description>The random things that spew forth from my brain...</description>
	<lastBuildDate>Mon, 15 Jun 2009 19:44:38 +0000</lastBuildDate>
	<generator>http://wordpress.org/?v=2.9-rare</generator>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
			<item>
		<title>Bigger Aint Always Better</title>
		<link>http://blog.apokalyptik.com/2009/06/15/bigger-aint-always-better/</link>
		<comments>http://blog.apokalyptik.com/2009/06/15/bigger-aint-always-better/#comments</comments>
		<pubDate>Mon, 15 Jun 2009 19:44:38 +0000</pubDate>
		<dc:creator>apokalyptik</dc:creator>
				<category><![CDATA[MySQL]]></category>
		<category><![CDATA[PHP]]></category>
		<category><![CDATA[Software Development]]></category>

		<guid isPermaLink="false">http://blog.apokalyptik.com/?p=430</guid>
		<description><![CDATA[Recently I was troubleshooting some inefficiencies with the jobs systems locking and fetching queries at work.  Like a good little boy I, originally, came up with one index which satisfied all the queries that I needed to run against this particular critical table.

 &#40;`completed`,`heartbeat`,`priority`,`datacenter`,`worker`&#41; 
-- datetime,datetime,tinyint,varchar(16),varchar(255)

the query looked like this:

SELECT `id`,GET_LOCK&#40;CONCAT&#40;'foo_',`id`&#41;,0&#41; as mylock FROM [...]]]></description>
			<content:encoded><![CDATA[<p>Recently I was troubleshooting some inefficiencies with the jobs systems locking and fetching queries at work.  Like a good little boy I, originally, came up with one index which satisfied all the queries that I needed to run against this particular critical table.</p>

<div class="wp_syntax"><div class="code"><pre class="mysql" style="font-family:monospace;"> <span style="color: #FF00FF;">&#40;</span><span style="color: #008000;">`completed`</span><span style="color: #000033;">,</span><span style="color: #008000;">`heartbeat`</span><span style="color: #000033;">,</span><span style="color: #008000;">`priority`</span><span style="color: #000033;">,</span><span style="color: #008000;">`datacenter`</span><span style="color: #000033;">,</span><span style="color: #008000;">`worker`</span><span style="color: #FF00FF;">&#41;</span> 
<span style="color: #808080; font-style: italic;">-- datetime,datetime,tinyint,varchar(16),varchar(255)</span></pre></div></div>

<p>the query looked like this:</p>

<div class="wp_syntax"><div class="code"><pre class="mysql" style="font-family:monospace;"><span style="color: #990099; font-weight: bold;">SELECT</span> <span style="color: #008000;">`id`</span><span style="color: #000033;">,</span><span style="color: #000099;">GET_LOCK</span><span style="color: #FF00FF;">&#40;</span><span style="color: #000099;">CONCAT</span><span style="color: #FF00FF;">&#40;</span><span style="color: #008000;">'foo<span style="color: #008080; font-weight: bold;">_</span>'</span><span style="color: #000033;">,</span><span style="color: #008000;">`id`</span><span style="color: #FF00FF;">&#41;</span><span style="color: #000033;">,</span><span style="color: #008080;">0</span><span style="color: #FF00FF;">&#41;</span> <span style="color: #990099; font-weight: bold;">as</span> mylock <span style="color: #990099; font-weight: bold;">FROM</span> <span style="color: #008000;">`foo<span style="color: #008080; font-weight: bold;">_</span>jobs`</span> 
<span style="color: #990099; font-weight: bold;">WHERE</span> <span style="color: #008000;">`completed`</span> <span style="color: #CC0099;">=</span> <span style="color: #008000;">'0000-00-00 00:00:00'</span> <span style="color: #CC0099; font-weight: bold;">AND</span> <span style="color: #008000;">`worker`</span> <span style="color: #CC0099;">=</span> <span style="color: #008000;">''</span> <span style="color: #CC0099; font-weight: bold;">AND</span> <span style="color: #008000;">`dirty`</span> <span style="color: #CC0099;">=</span> <span style="color: #008080;">0</span> 
<span style="color: #CC0099; font-weight: bold;">AND</span> <span style="color: #000099;">IS_FREE_LOCK</span><span style="color: #FF00FF;">&#40;</span><span style="color: #000099;">CONCAT</span><span style="color: #FF00FF;">&#40;</span><span style="color: #008000;">'foo<span style="color: #008080; font-weight: bold;">_</span>'</span><span style="color: #000033;">,</span><span style="color: #008000;">`id`</span><span style="color: #FF00FF;">&#41;</span><span style="color: #FF00FF;">&#41;</span> <span style="color: #CC0099;">=</span> <span style="color: #008080;">1</span> <span style="color: #CC0099; font-weight: bold;">AND</span> <span style="color: #008000;">`priority`</span> <span style="color: #CC0099;">=</span> <span style="color: #008000;">'0'</span> <span style="color: #990099; font-weight: bold;">LIMIT</span> <span style="color: #008080;">1</span></pre></div></div>

<p>This worked really well as long as the number of jobs in the table remained small.. But there was an event horizon of sorts&#8230; where after a certain number of rows (say 10k-25k) the query above took so long to get rows that the system could no longer catch up, but would fall invariably behind&#8230;  Apparently, the problem was that there was too much data in the key.  Because the requirements for these queries had changed slightly (due to other scaling improvements) I was able to simplify and break the indexes into parts which vastly outperform the previous index.</p>

<div class="wp_syntax"><div class="code"><pre class="mysql" style="font-family:monospace;"><span style="color: #990099; font-weight: bold;">KEY</span> <span style="color: #008000;">`get<span style="color: #008080; font-weight: bold;">_</span>a<span style="color: #008080; font-weight: bold;">_</span>job`</span> <span style="color: #FF00FF;">&#40;</span><span style="color: #008000;">`priority`</span><span style="color: #000033;">,</span><span style="color: #008000;">`workerpid`</span><span style="color: #FF00FF;">&#41;</span>
<span style="color: #808080; font-style: italic;">-- tinyint, int</span>
<span style="color: #990099; font-weight: bold;">KEY</span> <span style="color: #008000;">`janitor`</span> <span style="color: #FF00FF;">&#40;</span><span style="color: #008000;">`completed`</span><span style="color: #000033;">,</span><span style="color: #008000;">`heartbeat`</span><span style="color: #000033;">,</span><span style="color: #008000;">`worker`</span><span style="color: #000033;">,</span><span style="color: #008000;">`dirty`</span><span style="color: #FF00FF;">&#41;</span>
<span style="color: #808080; font-style: italic;">-- datetime,datetime,varchar(255),tinyint</span></pre></div></div>

<p>This works because workerpid is enough to tell us whether a job definition is in process (or was, and has not been cleaned yet.)  and makes the following query run against a super small index&#8230;</p>

<div class="wp_syntax"><div class="code"><pre class="mysql" style="font-family:monospace;"><span style="color: #990099; font-weight: bold;">SELECT</span> <span style="color: #008000;">`id`</span><span style="color: #000033;">,</span><span style="color: #000099;">GET_LOCK</span><span style="color: #FF00FF;">&#40;</span><span style="color: #000099;">CONCAT</span><span style="color: #FF00FF;">&#40;</span><span style="color: #008000;">'foo<span style="color: #008080; font-weight: bold;">_</span>'</span><span style="color: #000033;">,</span><span style="color: #008000;">`id`</span><span style="color: #FF00FF;">&#41;</span><span style="color: #000033;">,</span><span style="color: #008080;">0</span><span style="color: #FF00FF;">&#41;</span> <span style="color: #990099; font-weight: bold;">as</span> mylock <span style="color: #990099; font-weight: bold;">FROM</span> <span style="color: #008000;">`foo<span style="color: #008080; font-weight: bold;">_</span>jobs`</span>
<span style="color: #990099; font-weight: bold;">WHERE</span> <span style="color: #008000;">`priority`</span> <span style="color: #CC0099;">=</span> <span style="color: #008000;">'0'</span> <span style="color: #CC0099; font-weight: bold;">AND</span> <span style="color: #008000;">`workerpid`</span> <span style="color: #CC0099; font-weight: bold;">IS</span> <span style="color: #9900FF; font-weight: bold;">NULL</span> 
<span style="color: #CC0099; font-weight: bold;">AND</span> <span style="color: #000099;">IS_FREE_LOCK</span><span style="color: #FF00FF;">&#40;</span><span style="color: #000099;">CONCAT</span><span style="color: #FF00FF;">&#40;</span><span style="color: #008000;">'foo<span style="color: #008080; font-weight: bold;">_</span>,`id`)) = 1 LIMIT 1</span></pre></div></div>

<p>If you&#8217;re interested in what dark monstrosity could possibly require queries like these (and are a brave PHP developer) I invite you to <a href="http://code.trac.wordpress.org/browser/jobs">check out the jobs system</a></p>
]]></content:encoded>
			<wfw:commentRss>http://blog.apokalyptik.com/2009/06/15/bigger-aint-always-better/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Erlang&#8230; Starting to come together&#8230;</title>
		<link>http://blog.apokalyptik.com/2009/03/30/erlang-starting-to-come-together/</link>
		<comments>http://blog.apokalyptik.com/2009/03/30/erlang-starting-to-come-together/#comments</comments>
		<pubDate>Tue, 31 Mar 2009 05:55:28 +0000</pubDate>
		<dc:creator>apokalyptik</dc:creator>
				<category><![CDATA[Erlang]]></category>
		<category><![CDATA[Personal]]></category>
		<category><![CDATA[Software Development]]></category>

		<guid isPermaLink="false">http://blog.apokalyptik.com/?p=426</guid>
		<description><![CDATA[I&#8217;m finally starting to &#8220;get&#8221; erlang&#8230; just a little bit&#8230; I&#8217;ve managed to make several TCP daemons&#8230; an echo server, a reverse echo server, and a server which spits out an md5 values of the input given.  
Yea&#8230; I know&#8230; Lame&#8230; but its one hump I&#8217;m finally over&#8230;
]]></description>
			<content:encoded><![CDATA[<p>I&#8217;m finally starting to &#8220;get&#8221; erlang&#8230; just a little bit&#8230; I&#8217;ve managed to make several TCP daemons&#8230; an echo server, a reverse echo server, and a server which spits out an md5 values of the input given.  </p>
<p>Yea&#8230; I know&#8230; Lame&#8230; but its one hump I&#8217;m finally over&#8230;</p>
]]></content:encoded>
			<wfw:commentRss>http://blog.apokalyptik.com/2009/03/30/erlang-starting-to-come-together/feed/</wfw:commentRss>
		<slash:comments>1</slash:comments>
		</item>
		<item>
		<title>Just because you build it, doesnt mean they will come</title>
		<link>http://blog.apokalyptik.com/2009/03/19/just-because-you-build-it-doesnt-mean-they-will-come/</link>
		<comments>http://blog.apokalyptik.com/2009/03/19/just-because-you-build-it-doesnt-mean-they-will-come/#comments</comments>
		<pubDate>Thu, 19 Mar 2009 16:39:14 +0000</pubDate>
		<dc:creator>apokalyptik</dc:creator>
				<category><![CDATA[API]]></category>
		<category><![CDATA[Business]]></category>
		<category><![CDATA[Random Thoughts]]></category>
		<category><![CDATA[Software Development]]></category>
		<category><![CDATA[Web Stuff]]></category>

		<guid isPermaLink="false">http://blog.apokalyptik.com/?p=424</guid>
		<description><![CDATA[Here&#8217;s a small bit of advice for all you would-be &#8220;cloud storage providers.&#8221;  Just because you have a buttload of disks doesn&#8217;t mean people will be falling over themselves to use your software.  If I have to spend *any* of my time worrying about your load, storage, or other internal algorithms (or unnecessary [...]]]></description>
			<content:encoded><![CDATA[<p>Here&#8217;s a small bit of advice for all you would-be &#8220;cloud storage providers.&#8221;  Just because you have a buttload of disks doesn&#8217;t mean people will be falling over themselves to use your software.  If I have to spend *any* of my time worrying about your load, storage, or other internal algorithms (or unnecessary limitations for that matter) then YOU . HAVE . FAILED.  </p>
<p>If I have to take the time to shard my data into 4096 different containers because you couldn&#8217;t be bothered to think &#8220;hey what if a service with a lot of users that create a lot of stuff decides to use us as a store?&#8221;  Then you&#8217;re obviously not in it to win it (so to speak.)  </p>
<p>Give us ABSTRACTED storage.  Non abstracted storage we can do on our own thank you.</p>
]]></content:encoded>
			<wfw:commentRss>http://blog.apokalyptik.com/2009/03/19/just-because-you-build-it-doesnt-mean-they-will-come/feed/</wfw:commentRss>
		<slash:comments>1</slash:comments>
		</item>
		<item>
		<title>Just what you need to know to write a CouchDB reduce function</title>
		<link>http://blog.apokalyptik.com/2009/02/18/just-what-you-need-to-know-to-write-a-couchdb-view/</link>
		<comments>http://blog.apokalyptik.com/2009/02/18/just-what-you-need-to-know-to-write-a-couchdb-view/#comments</comments>
		<pubDate>Wed, 18 Feb 2009 22:47:45 +0000</pubDate>
		<dc:creator>apokalyptik</dc:creator>
				<category><![CDATA[API]]></category>
		<category><![CDATA[Business]]></category>
		<category><![CDATA[CLI]]></category>
		<category><![CDATA[MySQL]]></category>
		<category><![CDATA[PHP]]></category>
		<category><![CDATA[Random Thoughts]]></category>
		<category><![CDATA[Software Development]]></category>
		<category><![CDATA[Web Stuff]]></category>

		<guid isPermaLink="false">http://blog.apokalyptik.com/?p=408</guid>
		<description><![CDATA[Lets say you have the CouchDB classes (located here) all compiled together and included into your test.php script.  Lets also say that you have created a database with the built-in web ui called &#8220;testing&#8221;.  Finally let us say that your test.php has the following code in it, which would add a record to [...]]]></description>
			<content:encoded><![CDATA[<p>Lets say you have <a href="http://wiki.apache.org/couchdb/Getting_started_with_PHP">the CouchDB classes (located here)</a> all compiled together and included into your test.php script.  Lets also say that you have created a database with the built-in web ui called &#8220;testing&#8221;.  Finally let us say that your test.php has the following code in it, which would add a record to the db every time it is run. (i know that the data in the document serves no useful purpose&#8230; but really I just want to figure out this map/reduce thing so that I can make awesome views&#8230; so this suffices sufficiently.)</p>

<div class="wp_syntax"><div class="code"><pre class="php" style="font-family:monospace;"><span style="color: #b1b100;">require_once</span> <span style="color: #990000;">dirname</span><span style="color: #009900;">&#40;</span> <span style="color: #990000;">dirname</span><span style="color: #009900;">&#40;</span> <span style="color: #009900; font-weight: bold;">__FILE__</span> <span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#41;</span> <span style="color: #339933;">.</span> <span style="color: #0000ff;">'/includes/couchdb.php'</span><span style="color: #339933;">;</span>
<span style="color: #000088;">$couchdb</span> <span style="color: #339933;">=</span> <span style="color: #000000; font-weight: bold;">new</span> CouchDB<span style="color: #009900;">&#40;</span><span style="color: #0000ff;">'testing'</span><span style="color: #339933;">,</span> <span style="color: #0000ff;">'localhost'</span><span style="color: #339933;">,</span> <span style="color: #cc66cc;">5984</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
<span style="color: #000088;">$key</span> <span style="color: #339933;">=</span> <span style="color: #990000;">microtime</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
<span style="color: #000088;">$result</span> <span style="color: #339933;">=</span> <span style="color: #000088;">$couchdb</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">send</span><span style="color: #009900;">&#40;</span>
    <span style="color: #0000ff;">'/'</span><span style="color: #339933;">.</span><span style="color: #990000;">md5</span><span style="color: #009900;">&#40;</span><span style="color: #000088;">$key</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">,</span>
    <span style="color: #0000ff;">'put'</span><span style="color: #339933;">,</span>
    <span style="color: #990000;">json_encode</span><span style="color: #009900;">&#40;</span>
        <span style="color: #990000;">array</span><span style="color: #009900;">&#40;</span>
            <span style="color: #0000ff;">&quot;_id&quot;</span> <span style="color: #339933;">=&gt;</span> <span style="color: #990000;">md5</span><span style="color: #009900;">&#40;</span><span style="color: #000088;">$key</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">,</span>
            <span style="color: #0000ff;">&quot;time&quot;</span> <span style="color: #339933;">=&gt;</span> <span style="color: #000088;">$key</span><span style="color: #339933;">,</span>
            <span style="color: #0000ff;">'md5'</span> <span style="color: #339933;">=&gt;</span> <span style="color: #990000;">md5</span><span style="color: #009900;">&#40;</span><span style="color: #000088;">$key</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">,</span>
            <span style="color: #0000ff;">'sha1'</span> <span style="color: #339933;">=&gt;</span> <span style="color: #990000;">sha1</span><span style="color: #009900;">&#40;</span><span style="color: #000088;">$key</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">,</span>
            <span style="color: #0000ff;">'crc'</span> <span style="color: #339933;">=&gt;</span> <span style="color: #990000;">crc32</span><span style="color: #009900;">&#40;</span><span style="color: #000088;">$key</span><span style="color: #009900;">&#41;</span>
        <span style="color: #009900;">&#41;</span>
    <span style="color: #009900;">&#41;</span>
<span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
<span style="color: #990000;">print_r</span><span style="color: #009900;">&#40;</span><span style="color: #000088;">$result</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">getBody</span><span style="color: #009900;">&#40;</span><span style="color: #009900; font-weight: bold;">true</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span></pre></div></div>

<p>After running the code a bunch of times you would end up with a bunch of documents which look more or less like this:</p>
<p><a href="http://blog.apokalyptik.com/wp-content/uploads/2009/02/picture-1.png"><img width="600" src="http://blog.apokalyptik.com/wp-content/uploads/2009/02/picture-1.png" alt="picture-1" title="picture-1" class="alignnone size-medium wp-image-412" />(click for full size)</a></p>
<p>Now lets say you want to write a view that told you what the first characters of the _id were and how many documents share that first letter.  This is analogous to the following in MySQL</p>

<div class="wp_syntax"><div class="code"><pre class="mysql" style="font-family:monospace;"><span style="color: #990099; font-weight: bold;">SELECT</span> <span style="color: #000099;">LEFT</span><span style="color: #FF00FF;">&#40;</span><span style="color: #000099;">md5</span><span style="color: #000033;">,</span> <span style="color: #008080;">1</span><span style="color: #FF00FF;">&#41;</span> <span style="color: #990099; font-weight: bold;">AS</span> <span style="color: #008000;">`lchar`</span><span style="color: #000033;">,</span> <span style="color: #000099;">count</span><span style="color: #FF00FF;">&#40;</span><span style="color: #000099;">md5</span><span style="color: #FF00FF;">&#41;</span> <span style="color: #990099; font-weight: bold;">FROM</span> <span style="color: #008000;">`md5table`</span> <span style="color: #990099; font-weight: bold;">GROUP BY</span> <span style="color: #008000;">`lchar`</span></pre></div></div>

<p>Your map function is easy, because you dont have any selection criteria, so we process all rows</p>

<div class="wp_syntax"><div class="code"><pre class="javascript" style="font-family:monospace;"><span style="color: #003366; font-weight: bold;">function</span><span style="color: #009900;">&#40;</span>doc<span style="color: #009900;">&#41;</span><span style="color: #009900;">&#123;</span> emit<span style="color: #009900;">&#40;</span>doc._id<span style="color: #339933;">,</span>doc<span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span> <span style="color: #009900;">&#125;</span></pre></div></div>

<p>The reduce function is where the actual programming comes in&#8230;  And it seems there aren&#8217;t many well explained examples of exactly how to do this (I just brute forced it by trial and error)</p>

<div class="wp_syntax"><div class="code"><pre class="javascript" style="font-family:monospace;"><span style="color: #003366; font-weight: bold;">function</span><span style="color: #009900;">&#40;</span>key<span style="color: #339933;">,</span> values<span style="color: #339933;">,</span> rereduce<span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span> 
    <span style="color: #003366; font-weight: bold;">var</span> output <span style="color: #339933;">=</span> <span style="color: #009900;">&#123;</span><span style="color: #009900;">&#125;</span><span style="color: #339933;">;</span>
    <span style="color: #000066; font-weight: bold;">if</span> <span style="color: #009900;">&#40;</span> rereduce <span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span> 
        <span style="color: #006600; font-style: italic;">// key is null, and values are values returned by previous calls</span>
	<span style="color: #006600; font-style: italic;">//</span>
	<span style="color: #006600; font-style: italic;">// see http://wiki.apache.org/couchdb/Introduction_to_CouchDB_views</span>
	<span style="color: #006600; font-style: italic;">//</span>
	<span style="color: #006600; font-style: italic;">// essentially we are taking the previously reduced view, and the </span>
	<span style="color: #006600; font-style: italic;">// reduced view for new records, and we are reducing those two things</span>
	<span style="color: #006600; font-style: italic;">// together.  Summarizing two summaries, essentially</span>
        <span style="color: #000066; font-weight: bold;">for</span> <span style="color: #009900;">&#40;</span> <span style="color: #003366; font-weight: bold;">var</span> i <span style="color: #000066; font-weight: bold;">in</span> values <span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
	    <span style="color: #006600; font-style: italic;">// here we have multiple prebuilt output objects and we're simply combining them</span>
  	    <span style="color: #006600; font-style: italic;">// just like below we have an array with a numeric id and an output object</span>
	    <span style="color: #006600; font-style: italic;">// </span>
	    <span style="color: #006600; font-style: italic;">// retrieve a summary</span>
            <span style="color: #003366; font-weight: bold;">var</span> vals <span style="color: #339933;">=</span> values<span style="color: #009900;">&#91;</span>i<span style="color: #009900;">&#93;</span><span style="color: #339933;">;</span>
            <span style="color: #000066; font-weight: bold;">for</span> <span style="color: #009900;">&#40;</span> <span style="color: #003366; font-weight: bold;">var</span> key <span style="color: #000066; font-weight: bold;">in</span> vals <span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
		<span style="color: #006600; font-style: italic;">// debugging</span>
                <span style="color: #006600; font-style: italic;">// log(key);</span>
		<span style="color: #006600; font-style: italic;">// </span>
		<span style="color: #006600; font-style: italic;">// store in or increment our new output object </span>
                <span style="color: #000066; font-weight: bold;">if</span> <span style="color: #009900;">&#40;</span> output<span style="color: #009900;">&#91;</span>key<span style="color: #009900;">&#93;</span> <span style="color: #339933;">==</span> undefined <span style="color: #009900;">&#41;</span>
                    output<span style="color: #009900;">&#91;</span>key<span style="color: #009900;">&#93;</span> <span style="color: #339933;">=</span> vals<span style="color: #009900;">&#91;</span>key<span style="color: #009900;">&#93;</span><span style="color: #339933;">;</span>
                <span style="color: #000066; font-weight: bold;">else</span>
                    output<span style="color: #009900;">&#91;</span>key<span style="color: #009900;">&#93;</span> <span style="color: #339933;">=</span> output<span style="color: #009900;">&#91;</span>key<span style="color: #009900;">&#93;</span> <span style="color: #339933;">+</span> vals<span style="color: #009900;">&#91;</span>key<span style="color: #009900;">&#93;</span><span style="color: #339933;">;</span>
            <span style="color: #009900;">&#125;</span>
        <span style="color: #009900;">&#125;</span>
    <span style="color: #009900;">&#125;</span> <span style="color: #000066; font-weight: bold;">else</span> <span style="color: #009900;">&#123;</span>
        <span style="color: #006600; font-style: italic;">// key is an array, which we dont care about, and values are the </span>
	<span style="color: #006600; font-style: italic;">// values returned by the map</span>
	<span style="color: #006600; font-style: italic;">//</span>
	<span style="color: #006600; font-style: italic;">// see http://wiki.apache.org/couchdb/Introduction_to_CouchDB_views</span>
	<span style="color: #006600; font-style: italic;">//</span>
	<span style="color: #006600; font-style: italic;">// we are taking each document and processing that, reducing it down</span>
	<span style="color: #006600; font-style: italic;">// to a summary object (output) for each of the rows passed</span>
        <span style="color: #000066; font-weight: bold;">for</span> <span style="color: #009900;">&#40;</span> <span style="color: #003366; font-weight: bold;">var</span> i <span style="color: #000066; font-weight: bold;">in</span> values <span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
	    <span style="color: #006600; font-style: italic;">// we have an array, values, with numeric ids and a document objects</span>
	    <span style="color: #006600; font-style: italic;">//</span>
	    <span style="color: #006600; font-style: italic;">// retrieve a document</span>
            <span style="color: #003366; font-weight: bold;">var</span> doc <span style="color: #339933;">=</span> values<span style="color: #009900;">&#91;</span>i<span style="color: #009900;">&#93;</span><span style="color: #339933;">;</span>
	    <span style="color: #006600; font-style: italic;">// get what we want from it, the first char of the md5</span>
            <span style="color: #003366; font-weight: bold;">var</span> key <span style="color: #339933;">=</span> doc._id.<span style="color: #660066;">substr</span><span style="color: #009900;">&#40;</span><span style="color: #CC0000;">0</span><span style="color: #339933;">,</span> <span style="color: #CC0000;">1</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
	    <span style="color: #006600; font-style: italic;">// debugging</span>
            <span style="color: #006600; font-style: italic;">// log( key + &quot; :: &quot; + doc._id );</span>
	    <span style="color: #006600; font-style: italic;">//</span>
	    <span style="color: #006600; font-style: italic;">// store or increment the output object</span>
            <span style="color: #000066; font-weight: bold;">if</span> <span style="color: #009900;">&#40;</span> output<span style="color: #009900;">&#91;</span>key<span style="color: #009900;">&#93;</span> <span style="color: #339933;">!==</span> undefined <span style="color: #009900;">&#41;</span>
                output<span style="color: #009900;">&#91;</span>key<span style="color: #009900;">&#93;</span> <span style="color: #339933;">=</span> output<span style="color: #009900;">&#91;</span>key<span style="color: #009900;">&#93;</span> <span style="color: #339933;">+</span> <span style="color: #CC0000;">1</span><span style="color: #339933;">;</span>
            <span style="color: #000066; font-weight: bold;">else</span>
                output<span style="color: #009900;">&#91;</span>key<span style="color: #009900;">&#93;</span> <span style="color: #339933;">=</span> <span style="color: #CC0000;">1</span><span style="color: #339933;">;</span>
        <span style="color: #009900;">&#125;</span>
    <span style="color: #009900;">&#125;</span>
    <span style="color: #006600; font-style: italic;">// done</span>
    <span style="color: #000066; font-weight: bold;">return</span> output<span style="color: #339933;">;</span>
<span style="color: #009900;">&#125;</span></pre></div></div>

<p>and in code, using a temporary view, ( if you used this view all the time you would want to make it permanent&#8230; but this is about how to lay out a reduce function, nothing more ) so request code that looks like this</p>

<div class="wp_syntax"><div class="code"><pre class="php" style="font-family:monospace;"><span style="color: #000088;">$view</span> <span style="color: #339933;">=</span> <span style="color: #990000;">array</span><span style="color: #009900;">&#40;</span>
    <span style="color: #0000ff;">'map'</span> <span style="color: #339933;">=&gt;</span> <span style="color: #0000ff;">'function(doc){ emit(doc._id,doc); }'</span><span style="color: #339933;">,</span>
    <span style="color: #0000ff;">'reduce'</span> <span style="color: #339933;">=&gt;</span> <span style="color: #0000ff;">'
        function(key, values, rereduce) { 
            var output = {};
            if ( rereduce ) { 
                // key is null, and values are values returned by previous calls
                for ( var i in values ) {
                    var vals = values[i];
                    for ( var key in vals ) {
                        // log(key);
                        if ( output[key] == undefined )
                            output[key] = vals[key];
                        else
                            output[key] = output[key] + vals[key];
                    }
                }
            } else {
                // key is an array, which we dont care about, and values are the values returneb by the map
                for ( var i in values ) {
                    var doc = values[i];
                    var key = doc._id.substr(0, 1);
                    // log( key + &quot; :: &quot; + doc._id );
                    if ( output[key] !== undefined )
                        output[key] = output[key] + 1;
                    else
                        output[key] = 1;
                }
            }
            return output;
        }
    '</span>
    <span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
<span style="color: #000088;">$result</span> <span style="color: #339933;">=</span> <span style="color: #000088;">$couchdb</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">send</span><span style="color: #009900;">&#40;</span><span style="color: #0000ff;">'/_temp_view'</span><span style="color: #339933;">,</span> <span style="color: #0000ff;">'POST'</span><span style="color: #339933;">,</span> <span style="color: #990000;">json_encode</span><span style="color: #009900;">&#40;</span><span style="color: #000088;">$view</span><span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
<span style="color: #990000;">print_r</span><span style="color: #009900;">&#40;</span><span style="color: #000088;">$result</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">getBody</span><span style="color: #009900;">&#40;</span><span style="color: #009900; font-weight: bold;">true</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span></pre></div></div>

<p>would give you output that looks like this:</p>

<div class="wp_syntax"><div class="code"><pre class="php" style="font-family:monospace;">stdClass Object
<span style="color: #009900;">&#40;</span>
    <span style="color: #009900;">&#91;</span>rows<span style="color: #009900;">&#93;</span> <span style="color: #339933;">=&gt;</span> <span style="color: #990000;">Array</span>
        <span style="color: #009900;">&#40;</span>
            <span style="color: #009900;">&#91;</span><span style="color: #cc66cc;">0</span><span style="color: #009900;">&#93;</span> <span style="color: #339933;">=&gt;</span> stdClass Object
                <span style="color: #009900;">&#40;</span>
                    <span style="color: #009900;">&#91;</span><span style="color: #990000;">key</span><span style="color: #009900;">&#93;</span> <span style="color: #339933;">=&gt;</span> 
                    <span style="color: #009900;">&#91;</span>value<span style="color: #009900;">&#93;</span> <span style="color: #339933;">=&gt;</span> stdClass Object
                        <span style="color: #009900;">&#40;</span>
                            <span style="color: #009900;">&#91;</span><span style="color: #cc66cc;">0</span><span style="color: #009900;">&#93;</span> <span style="color: #339933;">=&gt;</span> <span style="color: #cc66cc;">15</span>
                            <span style="color: #009900;">&#91;</span><span style="color: #cc66cc;">1</span><span style="color: #009900;">&#93;</span> <span style="color: #339933;">=&gt;</span> <span style="color: #cc66cc;">17</span>
                            <span style="color: #009900;">&#91;</span><span style="color: #cc66cc;">2</span><span style="color: #009900;">&#93;</span> <span style="color: #339933;">=&gt;</span> <span style="color: #cc66cc;">16</span>
                            <span style="color: #009900;">&#91;</span><span style="color: #cc66cc;">3</span><span style="color: #009900;">&#93;</span> <span style="color: #339933;">=&gt;</span> <span style="color: #cc66cc;">13</span>
                            <span style="color: #009900;">&#91;</span><span style="color: #cc66cc;">4</span><span style="color: #009900;">&#93;</span> <span style="color: #339933;">=&gt;</span> <span style="color: #cc66cc;">27</span>
                            <span style="color: #009900;">&#91;</span><span style="color: #cc66cc;">5</span><span style="color: #009900;">&#93;</span> <span style="color: #339933;">=&gt;</span> <span style="color: #cc66cc;">18</span>
                            <span style="color: #009900;">&#91;</span><span style="color: #cc66cc;">6</span><span style="color: #009900;">&#93;</span> <span style="color: #339933;">=&gt;</span> <span style="color: #cc66cc;">26</span>
                            <span style="color: #009900;">&#91;</span><span style="color: #cc66cc;">7</span><span style="color: #009900;">&#93;</span> <span style="color: #339933;">=&gt;</span> <span style="color: #cc66cc;">15</span>
                            <span style="color: #009900;">&#91;</span><span style="color: #cc66cc;">8</span><span style="color: #009900;">&#93;</span> <span style="color: #339933;">=&gt;</span> <span style="color: #cc66cc;">18</span>
                            <span style="color: #009900;">&#91;</span><span style="color: #cc66cc;">9</span><span style="color: #009900;">&#93;</span> <span style="color: #339933;">=&gt;</span> <span style="color: #cc66cc;">21</span>
                            <span style="color: #009900;">&#91;</span>a<span style="color: #009900;">&#93;</span> <span style="color: #339933;">=&gt;</span> <span style="color: #cc66cc;">12</span>
                            <span style="color: #009900;">&#91;</span>b<span style="color: #009900;">&#93;</span> <span style="color: #339933;">=&gt;</span> <span style="color: #cc66cc;">23</span>
                            <span style="color: #009900;">&#91;</span>c<span style="color: #009900;">&#93;</span> <span style="color: #339933;">=&gt;</span> <span style="color: #cc66cc;">20</span>
                            <span style="color: #009900;">&#91;</span>d<span style="color: #009900;">&#93;</span> <span style="color: #339933;">=&gt;</span> <span style="color: #cc66cc;">27</span>
                            <span style="color: #009900;">&#91;</span>e<span style="color: #009900;">&#93;</span> <span style="color: #339933;">=&gt;</span> <span style="color: #cc66cc;">28</span>
                            <span style="color: #009900;">&#91;</span>f<span style="color: #009900;">&#93;</span> <span style="color: #339933;">=&gt;</span> <span style="color: #cc66cc;">26</span>
                        <span style="color: #009900;">&#41;</span>
&nbsp;
                <span style="color: #009900;">&#41;</span>
&nbsp;
        <span style="color: #009900;">&#41;</span>
&nbsp;
<span style="color: #009900;">&#41;</span></pre></div></div>

<p>I hope this helps somebody out.</p>
]]></content:encoded>
			<wfw:commentRss>http://blog.apokalyptik.com/2009/02/18/just-what-you-need-to-know-to-write-a-couchdb-view/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>random php&#8230; a multi-channel chat rooom class using memcached for persistence</title>
		<link>http://blog.apokalyptik.com/2009/02/16/random-php-a-multi-channel-chat-rooom-class-using-memcached-for-persistence/</link>
		<comments>http://blog.apokalyptik.com/2009/02/16/random-php-a-multi-channel-chat-rooom-class-using-memcached-for-persistence/#comments</comments>
		<pubDate>Tue, 17 Feb 2009 01:59:54 +0000</pubDate>
		<dc:creator>apokalyptik</dc:creator>
				<category><![CDATA[PHP]]></category>
		<category><![CDATA[Random Thoughts]]></category>

		<guid isPermaLink="false">http://blog.apokalyptik.com/?p=404</guid>
		<description><![CDATA[why? i dunno&#8230; just because&#8230; just a toy&#8230;
no sql, no flat file, no write permissions required anywhere, no fuss

class mc_chat &#123;
&#160;
        var $chan = null;
        var $mc = null;
        var $ret = 5;
&#160;
  [...]]]></description>
			<content:encoded><![CDATA[<p>why? i dunno&#8230; just because&#8230; just a toy&#8230;</p>
<p>no sql, no flat file, no write permissions required anywhere, no fuss</p>

<div class="wp_syntax"><div class="code"><pre class="php" style="font-family:monospace;"><span style="color: #000000; font-weight: bold;">class</span> mc_chat <span style="color: #009900;">&#123;</span>
&nbsp;
        <span style="color: #000000; font-weight: bold;">var</span> <span style="color: #000088;">$chan</span> <span style="color: #339933;">=</span> <span style="color: #009900; font-weight: bold;">null</span><span style="color: #339933;">;</span>
        <span style="color: #000000; font-weight: bold;">var</span> <span style="color: #000088;">$mc</span> <span style="color: #339933;">=</span> <span style="color: #009900; font-weight: bold;">null</span><span style="color: #339933;">;</span>
        <span style="color: #000000; font-weight: bold;">var</span> <span style="color: #000088;">$ret</span> <span style="color: #339933;">=</span> <span style="color: #cc66cc;">5</span><span style="color: #339933;">;</span>
&nbsp;
        <span style="color: #000000; font-weight: bold;">function</span> __construct<span style="color: #009900;">&#40;</span><span style="color: #000088;">$memcached</span><span style="color: #339933;">,</span> <span style="color: #000088;">$channel</span><span style="color: #339933;">,</span> <span style="color: #000088;">$retention</span><span style="color: #339933;">=</span><span style="color: #cc66cc;">5</span><span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
                <span style="color: #000088;">$this</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">mc</span> <span style="color: #339933;">=</span> <span style="color: #000088;">$memcached</span><span style="color: #339933;">;</span>
                <span style="color: #000088;">$this</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">chan</span> <span style="color: #339933;">=</span> <span style="color: #000088;">$channel</span><span style="color: #339933;">;</span>
                <span style="color: #000088;">$this</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">ret</span> <span style="color: #339933;">=</span> <span style="color: #000088;">$retention</span><span style="color: #339933;">;</span>
        <span style="color: #009900;">&#125;</span>
&nbsp;
        <span style="color: #000000; font-weight: bold;">function</span> messages<span style="color: #009900;">&#40;</span> <span style="color: #000088;">$from</span><span style="color: #339933;">=</span><span style="color: #cc66cc;">0</span> <span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
                <span style="color: #000088;">$max</span> <span style="color: #339933;">=</span> <span style="color: #009900;">&#40;</span>int<span style="color: #009900;">&#41;</span><span style="color: #000088;">$this</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">mc</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">get</span><span style="color: #009900;">&#40;</span><span style="color: #0000ff;">&quot;<span style="color: #006699; font-weight: bold;">$this-&gt;chan</span>:max:posted&quot;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
                <span style="color: #000088;">$min</span> <span style="color: #339933;">=</span> <span style="color: #009900;">&#40;</span>int<span style="color: #009900;">&#41;</span><span style="color: #000088;">$this</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">mc</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">get</span><span style="color: #009900;">&#40;</span><span style="color: #0000ff;">&quot;<span style="color: #006699; font-weight: bold;">$this-&gt;chan</span>:min:posted&quot;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
                <span style="color: #000088;">$messages</span> <span style="color: #339933;">=</span> <span style="color: #990000;">array</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
                <span style="color: #b1b100;">for</span> <span style="color: #009900;">&#40;</span> <span style="color: #000088;">$i</span><span style="color: #339933;">=</span><span style="color: #000088;">$min</span><span style="color: #339933;">;</span> <span style="color: #000088;">$i</span><span style="color: #339933;">&lt;</span> <span style="color: #339933;">=</span><span style="color: #000088;">$max</span><span style="color: #339933;">;</span> <span style="color: #000088;">$i</span><span style="color: #339933;">++</span> <span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
                        <span style="color: #b1b100;">if</span> <span style="color: #009900;">&#40;</span> <span style="color: #000088;">$i</span> <span style="color: #339933;">&lt;</span> <span style="color: #000088;">$from</span> <span style="color: #009900;">&#41;</span>
                                <span style="color: #b1b100;">continue</span><span style="color: #339933;">;</span>
                        <span style="color: #000088;">$m</span> <span style="color: #339933;">=</span> <span style="color: #000088;">$this</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">get</span><span style="color: #009900;">&#40;</span><span style="color: #000088;">$i</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
                        <span style="color: #b1b100;">if</span> <span style="color: #009900;">&#40;</span> <span style="color: #000088;">$m</span><span style="color: #009900;">&#91;</span><span style="color: #0000ff;">'user'</span><span style="color: #009900;">&#93;</span> <span style="color: #339933;">&amp;&amp;</span> <span style="color: #000088;">$m</span><span style="color: #009900;">&#91;</span><span style="color: #0000ff;">'message'</span><span style="color: #009900;">&#93;</span> <span style="color: #009900;">&#41;</span>
                                <span style="color: #000088;">$messages</span><span style="color: #009900;">&#91;</span><span style="color: #000088;">$i</span><span style="color: #009900;">&#93;</span> <span style="color: #339933;">=</span> <span style="color: #000088;">$m</span><span style="color: #339933;">;</span>
                <span style="color: #009900;">&#125;</span>
                <span style="color: #b1b100;">return</span> <span style="color: #000088;">$messages</span><span style="color: #339933;">;</span>
        <span style="color: #009900;">&#125;</span>
&nbsp;
        <span style="color: #000000; font-weight: bold;">function</span> get<span style="color: #009900;">&#40;</span><span style="color: #000088;">$id</span><span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
                <span style="color: #b1b100;">return</span> <span style="color: #990000;">array</span><span style="color: #009900;">&#40;</span>
                        <span style="color: #0000ff;">'user'</span> <span style="color: #339933;">=&gt;</span><span style="color: #009900;">&#40;</span>string<span style="color: #009900;">&#41;</span><span style="color: #000088;">$this</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">mc</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">get</span><span style="color: #009900;">&#40;</span><span style="color: #0000ff;">&quot;<span style="color: #006699; font-weight: bold;">$this-&gt;chan</span>:msg:<span style="color: #006699; font-weight: bold;">$id</span>:user&quot;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">,</span>
                        <span style="color: #0000ff;">'message'</span> <span style="color: #339933;">=&gt;</span> <span style="color: #009900;">&#40;</span>string<span style="color: #009900;">&#41;</span><span style="color: #000088;">$this</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">mc</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">get</span><span style="color: #009900;">&#40;</span><span style="color: #0000ff;">&quot;<span style="color: #006699; font-weight: bold;">$this-&gt;chan</span>:msg:<span style="color: #006699; font-weight: bold;">$id</span>&quot;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">,</span>
                <span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
        <span style="color: #009900;">&#125;</span>
&nbsp;
        <span style="color: #000000; font-weight: bold;">function</span> add<span style="color: #009900;">&#40;</span><span style="color: #000088;">$user</span><span style="color: #339933;">,</span> <span style="color: #000088;">$message</span><span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
                <span style="color: #000088;">$id</span> <span style="color: #339933;">=</span> <span style="color: #009900;">&#40;</span>int<span style="color: #009900;">&#41;</span><span style="color: #000088;">$this</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">mc</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">increment</span><span style="color: #009900;">&#40;</span><span style="color: #0000ff;">&quot;<span style="color: #006699; font-weight: bold;">$this-&gt;chan</span>:max:posted&quot;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
                <span style="color: #b1b100;">if</span> <span style="color: #009900;">&#40;</span> <span style="color: #339933;">!</span><span style="color: #000088;">$id</span> <span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
                        <span style="color: #000088;">$id</span><span style="color: #339933;">=</span><span style="color: #cc66cc;">1</span><span style="color: #339933;">;</span>
                        <span style="color: #000088;">$this</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">mc</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">set</span><span style="color: #009900;">&#40;</span><span style="color: #0000ff;">&quot;<span style="color: #006699; font-weight: bold;">$this-&gt;chan</span>:max:posted&quot;</span><span style="color: #339933;">,</span> <span style="color: #cc66cc;">1</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
                <span style="color: #009900;">&#125;</span>
                <span style="color: #000088;">$this</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">mc</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">set</span><span style="color: #009900;">&#40;</span><span style="color: #0000ff;">&quot;<span style="color: #006699; font-weight: bold;">$this-&gt;chan</span>:msg:<span style="color: #006699; font-weight: bold;">$id</span>:user&quot;</span><span style="color: #339933;">,</span> <span style="color: #009900;">&#40;</span>string<span style="color: #009900;">&#41;</span><span style="color: #000088;">$user</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
                <span style="color: #000088;">$this</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">mc</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">set</span><span style="color: #009900;">&#40;</span><span style="color: #0000ff;">&quot;<span style="color: #006699; font-weight: bold;">$this-&gt;chan</span>:msg:<span style="color: #006699; font-weight: bold;">$id</span>&quot;</span><span style="color: #339933;">,</span> <span style="color: #009900;">&#40;</span>string<span style="color: #009900;">&#41;</span><span style="color: #000088;">$message</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
                <span style="color: #b1b100;">if</span> <span style="color: #009900;">&#40;</span> <span style="color: #000088;">$id</span> <span style="color: #339933;">&gt;=</span> <span style="color: #000088;">$this</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">ret</span> <span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
                        <span style="color: #b1b100;">if</span> <span style="color: #009900;">&#40;</span> <span style="color: #339933;">!</span><span style="color: #000088;">$this</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">mc</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">increment</span><span style="color: #009900;">&#40;</span><span style="color: #0000ff;">&quot;<span style="color: #006699; font-weight: bold;">$this-&gt;chan</span>:min:posted&quot;</span><span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#41;</span>
                                <span style="color: #000088;">$this</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">mc</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">set</span><span style="color: #009900;">&#40;</span><span style="color: #0000ff;">&quot;<span style="color: #006699; font-weight: bold;">$this-&gt;chan</span>:min:posted&quot;</span><span style="color: #339933;">,</span> <span style="color: #cc66cc;">1</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
                <span style="color: #009900;">&#125;</span>
&nbsp;
        <span style="color: #009900;">&#125;</span>
&nbsp;
<span style="color: #009900;">&#125;</span>
&nbsp;
<span style="color: #000088;">$mc</span> <span style="color: #339933;">=</span> <span style="color: #000000; font-weight: bold;">new</span> Memcache<span style="color: #339933;">;</span>
<span style="color: #000088;">$mc</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">connect</span><span style="color: #009900;">&#40;</span><span style="color: #0000ff;">'localhost'</span><span style="color: #339933;">,</span> <span style="color: #cc66cc;">11211</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
<span style="color: #000088;">$keep_messages</span> <span style="color: #339933;">=</span> <span style="color: #cc66cc;">10</span><span style="color: #339933;">;</span>
<span style="color: #000088;">$chatter_id</span> <span style="color: #339933;">=</span> <span style="color: #cc66cc;">1</span><span style="color: #339933;">;</span>
<span style="color: #000088;">$chat</span> <span style="color: #339933;">=</span> <span style="color: #000000; font-weight: bold;">new</span> mc_chat<span style="color: #009900;">&#40;</span><span style="color: #000088;">$mc</span><span style="color: #339933;">,</span> <span style="color: #0000ff;">'chat-room-id'</span><span style="color: #339933;">,</span> <span style="color: #000088;">$keep_messages</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
<span style="color: #000088;">$chat</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">add</span><span style="color: #009900;">&#40;</span><span style="color: #000088;">$chatter_id</span><span style="color: #339933;">,</span> <span style="color: #990000;">date</span><span style="color: #009900;">&#40;</span><span style="color: #0000ff;">&quot;r&quot;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">.</span><span style="color: #0000ff;">&quot;: <span style="color: #006699; font-weight: bold;">$chatter_id</span> : foo&quot;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
<span style="color: #000088;">$chat</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">messages</span><span style="color: #009900;">&#40;</span><span style="color: #cc66cc;">37</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span> <span style="color: #666666; font-style: italic;">// messages only above id=37</span>
<span style="color: #000088;">$chat</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">messages</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span> <span style="color: #666666; font-style: italic;">// all the latest messages</span></pre></div></div>

]]></content:encoded>
			<wfw:commentRss>http://blog.apokalyptik.com/2009/02/16/random-php-a-multi-channel-chat-rooom-class-using-memcached-for-persistence/feed/</wfw:commentRss>
		<slash:comments>2</slash:comments>
		</item>
		<item>
		<title>Debian Lenny, Avahi, AFP&#8230; Linux Fileserver for OSX Clients</title>
		<link>http://blog.apokalyptik.com/2009/02/12/debian-lenny-avahi-afp-linux-fileserver-for-osx-clients/</link>
		<comments>http://blog.apokalyptik.com/2009/02/12/debian-lenny-avahi-afp-linux-fileserver-for-osx-clients/#comments</comments>
		<pubDate>Fri, 13 Feb 2009 01:25:51 +0000</pubDate>
		<dc:creator>apokalyptik</dc:creator>
				<category><![CDATA[Apple]]></category>
		<category><![CDATA[CLI]]></category>
		<category><![CDATA[Linux]]></category>
		<category><![CDATA[Personal]]></category>
		<category><![CDATA[Random Thoughts]]></category>
		<category><![CDATA[Software Development]]></category>

		<guid isPermaLink="false">http://blog.apokalyptik.com/?p=391</guid>
		<description><![CDATA[If you&#8217;re like me you have an OSX computer or 3 at home, and a debian file server. If you&#8217;re like me you hate samba/nfs on principle and want your debian server to show up in finder.  If you&#8217;re like me you arent using debian 3 which is what most of the walkthroughs seem to [...]]]></description>
			<content:encoded><![CDATA[<p>If you&#8217;re like me you have an OSX computer or 3 at home, and a debian file server. If you&#8217;re like me you hate samba/nfs on principle and want your debian server to show up in finder.  If you&#8217;re like me you arent using debian 3 which is what most of the walkthroughs seem to expect&#8230;  This is how I did it&#8230; With Debian Lenny.</p>
<p>What we&#8217;re using, and why:</p>
<ul>
<li>Avahi handles zeroconf (making it show up in finder) (most howtos involve howl which is no longer in apt)</li>
<li>netatalk has afpd</li>
<li>afpd is the fileserver</li>
</ul>
<p>From: <a href="http://blog.damontimm.com/how-to-install-netatalk-afp-on-ubuntu-with-encrypted-authentication/">http://blog.damontimm.com/how-to-install-netatalk-afp-on-ubuntu-with-encrypted-authentication/</a></p>
<ul>
<li>apt-get update</li>
<li>mkdir -p ~/src/netatalk</li>
<li>cd ~/src/netatalk</li>
<li>apt-get install cracklib2-dev libssl-dev</li>
<li>apt-get source netatalk</li>
<li>apt-get build-dep netatalk</li>
<li>cd netatalk-2.0.3</li>
</ul>
<p>From: <a href="http://www.sharedknowhow.com/2008/05/installing-netatalk-under-centos-5-with-leopard-support/">http://www.sharedknowhow.com/2008/05/installing-netatalk-under-centos-5-with-leopard-support/</a></p>
<ul>
<li>vim bin/cnid/cnid_index.c ## replace &#8220;ret = db-&gt;stat(db, &amp;sp, 0);&#8221; with &#8220;ret = db-&gt;stat(db, NULL, &amp;sp, 0);&#8221; line 277</li>
<li>vim etc/cnid_dbd/dbif.c ## replace &#8220;ret = db-&gt;stat(db, &amp;sp, 0);&#8221; with &#8220;ret = db-&gt;stat(db, NULL, &amp;sp, 0);&#8221; line 517</li>
</ul>
<p>Mine</p>
<ul>
<li>./configure &#8211;prefix=/usr/local/netatalk</li>
<li>make</li>
<li>make install</li>
<li>vim /etc/rc.local ## add &#8220;/usr/local/netatalk/sbin/afpd&#8221;</li>
<li>/usr/local/netatalk/sbin/afpd</li>
</ul>
<p>From: <a href="http://www.disgruntled-dutch.com/2007/general/how-to-get-your-linux-based-afp-server-to-show-up-correctly-in-leopards-new-finder">http://www.disgruntled-dutch.com/2007/general/how-to-get-your-linux-based-afp-server-to-show-up-correctly-in-leopards-new-finder</a></p>
<ul>
<li>apt-get install avahi-daemon</li>
<li>vim /etc/nsswitch.conf ## make the hosts line read &#8220;hosts: files dns mdns4&#8243;</li>
<li>cd /etc/avahi/services</li>
<li>wget http://www.disgruntled-dutch.com/media/afpd.service</li>
<li>/etc/init.d/avahi-daemon restart</li>
</ul>
<p>in case that file drops off the face of the net, this is its contents (except &#8220;&lt; ?&#8221; is &#8220;&lt;?&#8221; and &#8220;&lt; !&#8221; is &#8220;&lt;!&#8221;) :</p>

<div class="wp_syntax"><div class="code"><pre class="xml" style="font-family:monospace;"><span style="color: #009900;">&lt; ?xml <span style="color: #000066;">version</span>=<span style="color: #ff0000;">&quot;1.0&quot;</span> <span style="color: #000066;">standalone</span>=<span style="color: #ff0000;">'no'</span><span style="color: #000000; font-weight: bold;">?&gt;</span></span><span style="color: #808080; font-style: italic;">&lt;!--*-nxml-*--&gt;</span>
<span style="color: #009900;">&lt; !DOCTYPE service-group SYSTEM <span style="color: #ff0000;">&quot;avahi-service.dtd&quot;</span><span style="color: #000000; font-weight: bold;">&gt;</span></span>
<span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;service</span> -group<span style="color: #000000; font-weight: bold;">&gt;</span></span>
<span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;name</span> <span style="color: #000066;">replace-wildcards</span>=<span style="color: #ff0000;">&quot;yes&quot;</span><span style="color: #000000; font-weight: bold;">&gt;</span></span>%h<span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;/name<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>
<span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;/service<span style="color: #000000; font-weight: bold;">&gt;</span></span><span style="color: #000000; font-weight: bold;">&lt;service<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>
<span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;type<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>_afpovertcp._tcp<span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;/type<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>
<span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;port<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>548<span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;/port<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>
<span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;/service<span style="color: #000000; font-weight: bold;">&gt;</span></span></span></pre></div></div>

<p>At this point your server should show up under the network in your finder&#8230; and you should be able to connect with any system username/pw combo</p>
]]></content:encoded>
			<wfw:commentRss>http://blog.apokalyptik.com/2009/02/12/debian-lenny-avahi-afp-linux-fileserver-for-osx-clients/feed/</wfw:commentRss>
		<slash:comments>2</slash:comments>
		</item>
		<item>
		<title>randomly decided to install opensolaris inside virtualbox</title>
		<link>http://blog.apokalyptik.com/2009/02/05/randomly-decided-to-install-opensolaris-inside-virtualbox/</link>
		<comments>http://blog.apokalyptik.com/2009/02/05/randomly-decided-to-install-opensolaris-inside-virtualbox/#comments</comments>
		<pubDate>Fri, 06 Feb 2009 07:21:06 +0000</pubDate>
		<dc:creator>apokalyptik</dc:creator>
				<category><![CDATA[Random Thoughts]]></category>

		<guid isPermaLink="false">http://blog.apokalyptik.com/2009/02/05/randomly-decided-to-install-opensolaris-inside-virtualbox/</guid>
		<description><![CDATA[just to try it out.  its not done installing&#8230;. but&#8230; 8 char max for the user login is pretty lame&#8230; what is this&#8230; 1990?
]]></description>
			<content:encoded><![CDATA[<p>just to try it out.  its not done installing&#8230;. but&#8230; 8 char max for the user login is pretty lame&#8230; what is this&#8230; 1990?</p>
]]></content:encoded>
			<wfw:commentRss>http://blog.apokalyptik.com/2009/02/05/randomly-decided-to-install-opensolaris-inside-virtualbox/feed/</wfw:commentRss>
		<slash:comments>1</slash:comments>
		</item>
		<item>
		<title>making munin-graph take advantage of multiple cpus/cores</title>
		<link>http://blog.apokalyptik.com/2009/01/23/making-munin-graph-take-advantage-of-multiple-cpuscores/</link>
		<comments>http://blog.apokalyptik.com/2009/01/23/making-munin-graph-take-advantage-of-multiple-cpuscores/#comments</comments>
		<pubDate>Fri, 23 Jan 2009 18:23:47 +0000</pubDate>
		<dc:creator>apokalyptik</dc:creator>
				<category><![CDATA[Business]]></category>
		<category><![CDATA[CLI]]></category>
		<category><![CDATA[Linux]]></category>
		<category><![CDATA[Software Development]]></category>

		<guid isPermaLink="false">http://blog.apokalyptik.com/?p=383</guid>
		<description><![CDATA[I do a lot of things for Automattic, and many of the things I do are quite esoteric (for a php developer anyways.)  Perl is not my language of choice, but I&#8217;ve never balked at a challenge&#8230;. just&#8230; did it have to be perl?  Anyways.  We have more than a thousand machines [...]]]></description>
			<content:encoded><![CDATA[<p>I do a lot of things for Automattic, and many of the things I do are quite esoteric (for a php developer anyways.)  Perl is not my language of choice, but I&#8217;ve never balked at a challenge&#8230;. just&#8230; did it have to be perl?  Anyways.  We have more than a thousand machines that we track with munin&#8230; which means a TON of graphs.  munin-update is efficient, taking advantage of all cpus and getting done in the fastest time possible, but munin-graph started taking so long as to be useless (and munin-cgi-graph takes almost a minute to fully render the servers day/week summary page which is completely unacceptable when we&#8217;re trying to troubleshoot a sudden, urgent, problem.)  So I got to dive in and make it faster&#8230;</p>
<p>Step 1: add in this function (<a href="http://www.perlmonks.org/?node_id=585853">which i borrowed from somewhere else</a>)</p>

<div class="wp_syntax"><div class="code"><pre class="perl" style="font-family:monospace;"><span style="color: #000000; font-weight: bold;">sub</span> afork <span style="color: #009900;">&#40;</span>\<span style="color: #339933;">@</span><span style="color: #0000ff;">$&amp;</span><span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
  <span style="color: #b1b100;">my</span> <span style="color: #009900;">&#40;</span><span style="color: #0000ff;">$data</span><span style="color: #339933;">,</span> <span style="color: #0000ff;">$max</span><span style="color: #339933;">,</span> <span style="color: #0000ff;">$code</span><span style="color: #009900;">&#41;</span> <span style="color: #339933;">=</span> <span style="color: #0000ff;">@_</span><span style="color: #339933;">;</span>
  <span style="color: #b1b100;">my</span> <span style="color: #0000ff;">$c</span> <span style="color: #339933;">=</span> <span style="color: #cc66cc;">0</span><span style="color: #339933;">;</span>
  <span style="color: #b1b100;">foreach</span> <span style="color: #b1b100;">my</span> <span style="color: #0000ff;">$data</span> <span style="color: #009900;">&#40;</span><span style="color: #0000ff;">@$data</span><span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
    <span style="color: #000066;">wait</span> <span style="color: #b1b100;">unless</span> <span style="color: #339933;">++</span> <span style="color: #0000ff;">$c</span> <span style="color: #339933;">&lt;</span> <span style="color: #339933;">=</span> <span style="color: #0000ff;">$max</span><span style="color: #339933;">;</span>
    <span style="color: #000066;">die</span> <span style="color: #ff0000;">&quot;Fork failed: $!<span style="color: #000099; font-weight: bold;">\n</span>&quot;</span> <span style="color: #b1b100;">unless</span> <span style="color: #000066;">defined</span> <span style="color: #009900;">&#40;</span><span style="color: #b1b100;">my</span> <span style="color: #0000ff;">$pid</span> <span style="color: #339933;">=</span> <span style="color: #000066;">fork</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
    <span style="color: #000066;">exit</span> <span style="color: #0000ff;">$code</span> <span style="color: #339933;">-&gt;</span> <span style="color: #009900;">&#40;</span><span style="color: #0000ff;">$data</span><span style="color: #009900;">&#41;</span> <span style="color: #b1b100;">unless</span> <span style="color: #0000ff;">$pid</span><span style="color: #339933;">;</span>
  <span style="color: #009900;">&#125;</span>
  <span style="color: #cc66cc;">1</span> <span style="color: #b1b100;">until</span> <span style="color: #339933;">-</span><span style="color: #cc66cc;">1</span> <span style="color: #339933;">==</span> <span style="color: #000066;">wait</span><span style="color: #339933;">;</span>
<span style="color: #009900;">&#125;</span></pre></div></div>

<p>Step 2: replace this</p>

<div class="wp_syntax"><div class="code"><pre class="perl" style="font-family:monospace;"><span style="color: #b1b100;">for</span> <span style="color: #b1b100;">my</span> <span style="color: #0000ff;">$service</span> <span style="color: #009900;">&#40;</span><span style="color: #0000ff;">@$work_array</span><span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
    process_service <span style="color: #009900;">&#40;</span><span style="color: #0000ff;">$service</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
<span style="color: #009900;">&#125;</span></pre></div></div>

<p>with this</p>

<div class="wp_syntax"><div class="code"><pre class="perl" style="font-family:monospace;">afork<span style="color: #009900;">&#40;</span><span style="color: #0000ff;">@$work_array</span><span style="color: #339933;">,</span> <span style="color: #cc66cc;">16</span><span style="color: #339933;">,</span> <span style="color: #0000ff;">\&amp;process_service</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span></pre></div></div>

<p>I also have munin-html and munin-graph running side-by-side</p>

<div class="wp_syntax"><div class="code"><pre class="bash" style="font-family:monospace;"><span style="color: #7a0874; font-weight: bold;">&#40;</span> <span style="color: #7a0874; font-weight: bold;">&#91;</span> <span style="color: #660033;">-x</span> <span style="color: #000000; font-weight: bold;">/</span>usr<span style="color: #000000; font-weight: bold;">/</span>local<span style="color: #000000; font-weight: bold;">/</span>munin<span style="color: #000000; font-weight: bold;">/</span>lib<span style="color: #000000; font-weight: bold;">/</span>munin-graph  <span style="color: #7a0874; font-weight: bold;">&#93;</span> <span style="color: #000000; font-weight: bold;">&amp;&amp;</span>
    <span style="color: #c20cb9; font-weight: bold;">nice</span> <span style="color: #000000; font-weight: bold;">/</span>usr<span style="color: #000000; font-weight: bold;">/</span>local<span style="color: #000000; font-weight: bold;">/</span>munin<span style="color: #000000; font-weight: bold;">/</span>lib<span style="color: #000000; font-weight: bold;">/</span>munin-graph <span style="color: #660033;">--cron</span> $<span style="color: #000000; font-weight: bold;">@</span> <span style="color: #000000;">2</span><span style="color: #000000; font-weight: bold;">&gt;&amp;</span><span style="color: #000000;">1</span> <span style="color: #000000; font-weight: bold;">|</span>
    <span style="color: #c20cb9; font-weight: bold;">fgrep</span> <span style="color: #660033;">-v</span> <span style="color: #ff0000;">&quot;*** attempt to put segment in horiz list twice&quot;</span> <span style="color: #7a0874; font-weight: bold;">&#41;</span><span style="color: #000000; font-weight: bold;">&amp;</span> <span style="color: #007800;">$waitgraph</span>=<span style="color: #007800;">$!</span>
<span style="color: #7a0874; font-weight: bold;">&#40;</span> <span style="color: #7a0874; font-weight: bold;">&#91;</span> <span style="color: #660033;">-x</span> <span style="color: #000000; font-weight: bold;">/</span>usr<span style="color: #000000; font-weight: bold;">/</span>local<span style="color: #000000; font-weight: bold;">/</span>munin<span style="color: #000000; font-weight: bold;">/</span>lib<span style="color: #000000; font-weight: bold;">/</span>munin-html   <span style="color: #7a0874; font-weight: bold;">&#93;</span> <span style="color: #000000; font-weight: bold;">&amp;&amp;</span> <span style="color: #c20cb9; font-weight: bold;">nice</span> <span style="color: #000000; font-weight: bold;">/</span>usr<span style="color: #000000; font-weight: bold;">/</span>local<span style="color: #000000; font-weight: bold;">/</span>munin<span style="color: #000000; font-weight: bold;">/</span>lib<span style="color: #000000; font-weight: bold;">/</span>munin-html $<span style="color: #000000; font-weight: bold;">@</span>; <span style="color: #7a0874; font-weight: bold;">&#41;</span><span style="color: #000000; font-weight: bold;">&amp;</span> <span style="color: #007800;">$waithtml</span>=<span style="color: #007800;">$!</span>
<span style="color: #7a0874; font-weight: bold;">wait</span> <span style="color: #007800;">$waitgraph</span>
<span style="color: #7a0874; font-weight: bold;">wait</span> <span style="color: #007800;">$waithtml</span></pre></div></div>

<p>I did several other, more complicated hacks as well. Such as not generating month and year graphs via cron, letting those render on-demand with munin-cgi-graph</p>
<p>All said we&#8217;re doing in under 2.5 minutes what was taking 7 or 8 minutes previously</p>
]]></content:encoded>
			<wfw:commentRss>http://blog.apokalyptik.com/2009/01/23/making-munin-graph-take-advantage-of-multiple-cpuscores/feed/</wfw:commentRss>
		<slash:comments>1</slash:comments>
		</item>
		<item>
		<title>Google stops development on 6 services</title>
		<link>http://blog.apokalyptik.com/2009/01/18/google-stops-development-on-6-services/</link>
		<comments>http://blog.apokalyptik.com/2009/01/18/google-stops-development-on-6-services/#comments</comments>
		<pubDate>Sun, 18 Jan 2009 18:24:51 +0000</pubDate>
		<dc:creator>apokalyptik</dc:creator>
				<category><![CDATA[Random Thoughts]]></category>

		<guid isPermaLink="false">http://blog.apokalyptik.com/?p=380</guid>
		<description><![CDATA[[edit: link]
I already see the Stallmanites rallying for their battle cries.  Never using anything you didn&#8217;t write yourself is an asinine concept, in my opinion&#8230; This coming from someone who can write web services himself.  The truth is that using services &#8220;in the cloud,&#8221; &#8220;on the web,&#8221; or anywhere else is just like [...]]]></description>
			<content:encoded><![CDATA[<p>[edit: <a href="http://tech.slashdot.org/article.pl?sid=09%2F01%2F18%2F1321235&#038;from=rss">link</a>]</p>
<p>I already see the Stallmanites rallying for their battle cries.  Never using anything you didn&#8217;t write yourself is an asinine concept, in my opinion&#8230; This coming from someone who can write web services himself.  The truth is that using services &#8220;in the cloud,&#8221; &#8220;on the web,&#8221; or anywhere else is just like using local software in one very important sense. (I particularly like one comment I heard on this once which went something like: &#8220;Would you be able to validate the source code to the ls binary on your own?&#8221;)</p>
<p>If your data is not in two completely separate locations, then it&#8217;s not safe.</p>
<p>My wife, who&#8217;s in need of some extra storage space (shes starting to get into photography some) got two external 120gb hard drives (which were on clearance.)  Before I let her use them I sat her down and gave her some important advice:  &#8220;If you store your data on one of these drives&#8230; it is NOT backed up&#8230; it&#8217;s just stored on that disk.  And if something happens to that disk there is NOTHING that I can do to save your photos. Period.  I bought you two because every so often you need to copy whats important to the second disk.  That was if one disk dies, you don&#8217;t loose your stuff&#8221; </p>
<p>I&#8217;m not sure why people feel that if they&#8217;re using apps in the cloud that this doesn&#8217;t apply to them. A service shutting down is basically equivalent to loosing a hard disk.  Be prepared.  Back your data up if it&#8217;s that important!</p>
<p>As an aside.  All WordPress installations allow you to export your data &#8212; even WordPress.com.  I suggest people take advantage of that on occasion!</p>
]]></content:encoded>
			<wfw:commentRss>http://blog.apokalyptik.com/2009/01/18/google-stops-development-on-6-services/feed/</wfw:commentRss>
		<slash:comments>2</slash:comments>
		</item>
		<item>
		<title>A Pure Memcached Queue</title>
		<link>http://blog.apokalyptik.com/2009/01/16/a-pure-memcached-queue/</link>
		<comments>http://blog.apokalyptik.com/2009/01/16/a-pure-memcached-queue/#comments</comments>
		<pubDate>Sat, 17 Jan 2009 05:03:34 +0000</pubDate>
		<dc:creator>apokalyptik</dc:creator>
				<category><![CDATA[Random Thoughts]]></category>

		<guid isPermaLink="false">http://blog.apokalyptik.com/?p=377</guid>
		<description><![CDATA[This is pretty clever&#8230;  Might have to code this up in PHP&#8230; memcachequeue-a-pure-memcached-queue
]]></description>
			<content:encoded><![CDATA[<p>This is pretty clever&#8230;  Might have to code this up in PHP&#8230; <a href="http://coderrr.wordpress.com/2009/01/17/memcachequeue-a-pure-memcached-queue/">memcachequeue-a-pure-memcached-queue</a></p>
]]></content:encoded>
			<wfw:commentRss>http://blog.apokalyptik.com/2009/01/16/a-pure-memcached-queue/feed/</wfw:commentRss>
		<slash:comments>2</slash:comments>
		</item>
	</channel>
</rss>