<?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 &#187; Random Thoughts</title>
	<atom:link href="http://blog.apokalyptik.com/category/random-thoughts/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>Thu, 04 Mar 2010 09:45:42 +0000</lastBuildDate>
	<generator>http://wordpress.org/?v=3.0-alpha</generator>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
			<item>
		<title>Lunch</title>
		<link>http://blog.apokalyptik.com/2010/03/03/lunch/</link>
		<comments>http://blog.apokalyptik.com/2010/03/03/lunch/#comments</comments>
		<pubDate>Wed, 03 Mar 2010 23:24:50 +0000</pubDate>
		<dc:creator>apokalyptik</dc:creator>
				<category><![CDATA[Random Thoughts]]></category>
		<category><![CDATA[rand()]]></category>

		<guid isPermaLink="false">http://blog.apokalyptik.com/?p=505</guid>
		<description><![CDATA[I make a fruit salad kind of thing almost every single day for lunch.  And for some reason, today, I thought I would record the process.  This is how I make a fruit salad&#8230; How do you do it?

for the record this is not an exciting or cool video&#8230; its just me&#8230; cutting [...]]]></description>
			<content:encoded><![CDATA[<p>I make a fruit salad kind of thing almost every single day for lunch.  And for some reason, today, I thought I would record the process.  This is how I make a fruit salad&#8230; How do you do it?</p>
<p><embed src="http://v.wordpress.com/wp-content/plugins/video/flvplayer.swf?ver=1.18" type="application/x-shockwave-flash" width="400" height="226" seamlesstabbing="true" allowfullscreen="true" allowscriptaccess="always" overstretch="true" flashvars="guid=vCEIO49R&amp;width=400&amp;height=226&amp;locksize=no&amp;qc_publisherId=p-18-mFEk4J448M" title=""></embed></p>
<p>for the record this is not an exciting or cool video&#8230; its just me&#8230; cutting up fruit&#8230; silently</p>
]]></content:encoded>
			<wfw:commentRss>http://blog.apokalyptik.com/2010/03/03/lunch/feed/</wfw:commentRss>
		<slash:comments>5</slash:comments>
		</item>
		<item>
		<title>Nikki In Training</title>
		<link>http://blog.apokalyptik.com/2010/02/09/nikki-in-training/</link>
		<comments>http://blog.apokalyptik.com/2010/02/09/nikki-in-training/#comments</comments>
		<pubDate>Wed, 10 Feb 2010 02:51:35 +0000</pubDate>
		<dc:creator>apokalyptik</dc:creator>
				<category><![CDATA[Random Thoughts]]></category>

		<guid isPermaLink="false">http://blog.apokalyptik.com/2010/02/09/nikki-in-training/</guid>
		<description><![CDATA[I just want to share with everyone how proud I am of my Nikki.  She&#8217;s been training to do a half marathon for charity (and to get into shape.)  She&#8217;s just been stellar about it.  She&#8217;s walking tons, and lost a bucketload of weight.  I&#8217;m sure that she would love it [...]]]></description>
			<content:encoded><![CDATA[<p>I just want to share with everyone how proud I am of my Nikki.  She&#8217;s been training to do a half marathon for charity (and to get into shape.)  She&#8217;s just been stellar about it.  She&#8217;s walking tons, and lost a bucketload of weight.  I&#8217;m sure that she would love it if anyone wanted to drop by and give her some words of encouragement <a href="http://ramblingme.wordpress.com/2010-rock-n-roll-san-diego-marathon/">on her blog</a> where she&#8217;s keeping a log of her Journey.  Thats my wife!</p>
]]></content:encoded>
			<wfw:commentRss>http://blog.apokalyptik.com/2010/02/09/nikki-in-training/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>This is actually pretty cool</title>
		<link>http://blog.apokalyptik.com/2010/01/14/this-is-actually-pretty-cool/</link>
		<comments>http://blog.apokalyptik.com/2010/01/14/this-is-actually-pretty-cool/#comments</comments>
		<pubDate>Thu, 14 Jan 2010 19:09:08 +0000</pubDate>
		<dc:creator>apokalyptik</dc:creator>
				<category><![CDATA[Random Thoughts]]></category>

		<guid isPermaLink="false">http://blog.apokalyptik.com/2010/01/14/this-is-actually-pretty-cool/</guid>
		<description><![CDATA[First person tetris&#8230; awesome&#8230; http://www.firstpersontetris.com/
]]></description>
			<content:encoded><![CDATA[<p>First person tetris&#8230; awesome&#8230; http://www.firstpersontetris.com/</p>
]]></content:encoded>
			<wfw:commentRss>http://blog.apokalyptik.com/2010/01/14/this-is-actually-pretty-cool/feed/</wfw:commentRss>
		<slash:comments>3</slash:comments>
		</item>
		<item>
		<title>Time based bloom filters</title>
		<link>http://blog.apokalyptik.com/2010/01/06/time-based-bloom-filters/</link>
		<comments>http://blog.apokalyptik.com/2010/01/06/time-based-bloom-filters/#comments</comments>
		<pubDate>Thu, 07 Jan 2010 04:29:56 +0000</pubDate>
		<dc:creator>apokalyptik</dc:creator>
				<category><![CDATA[Business]]></category>
		<category><![CDATA[PHP]]></category>
		<category><![CDATA[Personal]]></category>
		<category><![CDATA[Random Thoughts]]></category>
		<category><![CDATA[Ruby (on or off) Rails]]></category>
		<category><![CDATA[SRSLY]]></category>
		<category><![CDATA[Software Development]]></category>

		<guid isPermaLink="false">http://blog.apokalyptik.com/?p=498</guid>
		<description><![CDATA[I find this concept fascinating and plan to investigate further down this road.
]]></description>
			<content:encoded><![CDATA[<p>I find <a href="http://www.igvita.com/2010/01/06/flow-analysis-time-based-bloom-filters/">this concep</a>t fascinating and plan to investigate further down this road.</p>
]]></content:encoded>
			<wfw:commentRss>http://blog.apokalyptik.com/2010/01/06/time-based-bloom-filters/feed/</wfw:commentRss>
		<slash:comments>2</slash:comments>
		</item>
		<item>
		<title>lockd, a memcached like locking daemon in php</title>
		<link>http://blog.apokalyptik.com/2009/12/10/lockd-a-memcached-like-locking-daemon-in-php/</link>
		<comments>http://blog.apokalyptik.com/2009/12/10/lockd-a-memcached-like-locking-daemon-in-php/#comments</comments>
		<pubDate>Thu, 10 Dec 2009 22:07:09 +0000</pubDate>
		<dc:creator>apokalyptik</dc:creator>
				<category><![CDATA[Random Thoughts]]></category>

		<guid isPermaLink="false">http://blog.apokalyptik.com/?p=489</guid>
		<description><![CDATA[You might have seen my last post about this code (here) if you are one of my 2.3 loyal readers   . It wasnt nearly so complete or robust then (segfaulting? come on! right?)
The segfaulting was caused by stupidly using $this-&#62;function() from inside of $this-&#62;function() for recursion, overloading the stack. Note to self: don&#8217;t [...]]]></description>
			<content:encoded><![CDATA[<p>You might have seen my last post about this code (<a href="http://blog.apokalyptik.com/2009/09/14/php-open-locking-daemon/">here</a>) if you are one of my 2.3 loyal readers <img src='http://blog.apokalyptik.com/wp-includes/images/smilies/icon_wink.gif' alt=';)' class='wp-smiley' />  . It wasnt nearly so complete or robust then (segfaulting? come on! right?)</p>
<p><span style="color: #808080;">The segfaulting was caused by stupidly using $this-&gt;function() from inside of $this-&gt;function() for recursion, overloading the stack. Note to self: don&#8217;t be lazy about recursion <img src='http://blog.apokalyptik.com/wp-includes/images/smilies/icon_biggrin.gif' alt=':D' class='wp-smiley' /> </span></p>
<p>If you&#8217;re interested in the project I have it setup over here: <a href="http://code.svn.wordpress.org/lockd/">http://code.svn.wordpress.org/lockd/</a> so please feel free to try it out.</p>
<p>&nbsp;</p>
<p>What is it?  It&#8217;s a network based locking mechanism.  You can connect to it over TCPIP and get either exclusive or shared locks for as many arbitrary strings as you like.  Shared locks have the added benefit of being counted.  You can query to see if a string is locked (and how many times for shared locks.) You can also release locks.</p>
<p>&nbsp;</p>
<p>All of this is useful, but&#8230; The nice thing about lockd, though, is that if your client disconnects (say the process which had locked a string quit unexpectedly) lockd will automatically orphan those locks for you.  So you have no need to try and cleanup and guess the lock state of a failed process.   And since this runs as a network daemon you can have as many of them as you like.  You can use them for local (locks on the same box) or distributed (locks on the same resource from many boxes.)  It also comes with built in stats which you could hook up to munin, or nagios, via netcat without too much trouble.</p>
<p>&nbsp;</p>
<p>The protocol is also extremely simple</p>
<ul>
<li>g (string) &#8212; get an exclusive lock on the string</li>
<li>sg (string) &#8212; get a shared lock on the string</li>
<li>r (string) &#8212; release an exclusive lock</li>
<li>sr (string) &#8212; release a shared lock</li>
<li>i (string) &#8212; inspect an exclusive lock</li>
<li>si (string) &#8212; inspect a shared lock</li>
<li>q &#8212; query stats</li>
<li>q full &#8212; query stats and dump the exclusive and shared lock arrays</li>
</ul>
<p>&nbsp;</p>
<p>Thats it.  &#8220;(int) (string)&#8221; is returned for these commands. where (int) is for programmatic use, and (string) is for human consumption.</p>
<p>&nbsp;</p>
<p>We use this with the <a href="http://code.svn.wordpress.org/jobs/">Jobs system (also available as an OSS project)</a> for <a href="http://wordpress.com/">WordPress.com</a>, <a href="http://intensedebate.com/">Intensedebate</a>, <a href="http://en.gravatar.com/">Gravatar</a>, and more, and is currently handling nearly a million operations per day&#8230; per server&#8230;</p>
<p>&nbsp;</p>
<p>This is Itch-Scratch-Ware at its finest.</p>
]]></content:encoded>
			<wfw:commentRss>http://blog.apokalyptik.com/2009/12/10/lockd-a-memcached-like-locking-daemon-in-php/feed/</wfw:commentRss>
		<slash:comments>1</slash:comments>
		</item>
		<item>
		<title>This made me laugh :)</title>
		<link>http://blog.apokalyptik.com/2009/11/26/this-mae-me-laugh/</link>
		<comments>http://blog.apokalyptik.com/2009/11/26/this-mae-me-laugh/#comments</comments>
		<pubDate>Fri, 27 Nov 2009 07:29:15 +0000</pubDate>
		<dc:creator>apokalyptik</dc:creator>
				<category><![CDATA[Random Thoughts]]></category>
		<category><![CDATA[mupets]]></category>
		<category><![CDATA[SRSLY]]></category>
		<category><![CDATA[WTF]]></category>

		<guid isPermaLink="false">http://blog.apokalyptik.com/2009/11/26/this-mae-me-laugh/</guid>
		<description><![CDATA[
]]></description>
			<content:encoded><![CDATA[<p><object classid="clsid:d27cdb6e-ae6d-11cf-96b8-444553540000" width="425" height="344" codebase="http://download.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=6,0,40,0"><param name="allowFullScreen" value="true" /><param name="allowScriptAccess" value="always" /><param name="src" value="http://www.youtube.com/v/tgbNymZ7vqY&amp;rel=0&amp;color1=0x5d1719&amp;color2=0xcd311b&amp;hl=en_US&amp;feature=player_embedded&amp;fs=1" /><param name="allowfullscreen" value="true" /><embed type="application/x-shockwave-flash" width="425" height="344" src="http://www.youtube.com/v/tgbNymZ7vqY&amp;rel=0&amp;color1=0x5d1719&amp;color2=0xcd311b&amp;hl=en_US&amp;feature=player_embedded&amp;fs=1" allowscriptaccess="always" allowfullscreen="true"></embed></object></p>
]]></content:encoded>
			<wfw:commentRss>http://blog.apokalyptik.com/2009/11/26/this-mae-me-laugh/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>The Adventures of Lil Cthulhu</title>
		<link>http://blog.apokalyptik.com/2009/11/17/the-adventures-of-lil-cthulhu/</link>
		<comments>http://blog.apokalyptik.com/2009/11/17/the-adventures-of-lil-cthulhu/#comments</comments>
		<pubDate>Tue, 17 Nov 2009 17:40:55 +0000</pubDate>
		<dc:creator>apokalyptik</dc:creator>
				<category><![CDATA[Funny Stuff]]></category>
		<category><![CDATA[Random Thoughts]]></category>
		<category><![CDATA[WTF]]></category>

		<guid isPermaLink="false">http://blog.apokalyptik.com/?p=471</guid>
		<description><![CDATA[
]]></description>
			<content:encoded><![CDATA[<p><object width="425" height="344"><param name="movie" value="http://www.youtube.com/v/FOHJUrcVdJk&#038;hl=en_US&#038;fs=1&#038;"></param><param name="allowFullScreen" value="true"></param><param name="allowscriptaccess" value="always"></param><embed src="http://www.youtube.com/v/FOHJUrcVdJk&#038;hl=en_US&#038;fs=1&#038;" type="application/x-shockwave-flash" allowscriptaccess="always" allowfullscreen="true" width="425" height="344"></embed></object></p>
]]></content:encoded>
			<wfw:commentRss>http://blog.apokalyptik.com/2009/11/17/the-adventures-of-lil-cthulhu/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>php debugging the really really hard way</title>
		<link>http://blog.apokalyptik.com/2009/10/06/php-debugging-the-really-really-hard-way/</link>
		<comments>http://blog.apokalyptik.com/2009/10/06/php-debugging-the-really-really-hard-way/#comments</comments>
		<pubDate>Tue, 06 Oct 2009 22:18:56 +0000</pubDate>
		<dc:creator>apokalyptik</dc:creator>
				<category><![CDATA[Bash]]></category>
		<category><![CDATA[Business]]></category>
		<category><![CDATA[CLI]]></category>
		<category><![CDATA[Linux]]></category>
		<category><![CDATA[PHP]]></category>
		<category><![CDATA[Random Thoughts]]></category>
		<category><![CDATA[SRSLY]]></category>
		<category><![CDATA[Software Development]]></category>
		<category><![CDATA[WTF]]></category>
		<category><![CDATA[Web Stuff]]></category>

		<guid isPermaLink="false">http://blog.apokalyptik.com/?p=469</guid>
		<description><![CDATA[If you&#8217;re ever in a situation where something is only happening intermittently, and only on a live server, and only while it&#8217;s under load&#8230; Lets say its not generating any error_log or stderr output, and you cant run it manually to reproduce&#8230; (we&#8217;ve all been in this situation) How do you get any debugging output [...]]]></description>
			<content:encoded><![CDATA[<p>If you&#8217;re ever in a situation where something is only happening intermittently, and only on a live server, and only while it&#8217;s under load&#8230; Lets say its not generating any error_log or stderr output, and you cant run it manually to reproduce&#8230; (we&#8217;ve all been in this situation) How do you get any debugging output at all?</p>
<p>Step 1: add this to the top of your entry point php file</p>

<div class="wp_syntax"><div class="code"><pre class="php" style="font-family:monospace;"><span style="color: #b1b100;">if</span> <span style="color: #009900;">&#40;</span> <span style="color: #000088;">$_SERVER</span><span style="color: #009900;">&#91;</span><span style="color: #0000ff;">'REMOTE_ADDR'</span><span style="color: #009900;">&#93;</span> <span style="color: #339933;">==</span> <span style="color: #0000ff;">'127.0.0.1'</span> <span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
       <span style="color: #990000;">error_log</span><span style="color: #009900;">&#40;</span> <span style="color: #0000ff;">' :: '</span> <span style="color: #339933;">.</span> <span style="color: #990000;">getmypid</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
       <span style="color: #990000;">sleep</span><span style="color: #009900;">&#40;</span> <span style="color: #cc66cc;">10</span> <span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
<span style="color: #009900;">&#125;</span></pre></div></div>

<p>Step 2: use curl on the localhost to make the request</p>
<p>Step 3: (this assumes your error log is /tmp/php-error-output) run the following command in a second (root) terminal window</p>

<div class="wp_syntax"><div class="code"><pre class="bash" style="font-family:monospace;"><span style="color: #c20cb9; font-weight: bold;">strace</span> <span style="color: #660033;">-p</span> $<span style="color: #7a0874; font-weight: bold;">&#40;</span><span style="color: #c20cb9; font-weight: bold;">tail</span> <span style="color: #660033;">-n</span> <span style="color: #000000;">1000</span> <span style="color: #000000; font-weight: bold;">/</span>tmp<span style="color: #000000; font-weight: bold;">/</span>php-error-output <span style="color: #000000; font-weight: bold;">|</span> <span style="color: #c20cb9; font-weight: bold;">grep</span> <span style="color: #ff0000;">' :: '</span> <span style="color: #000000; font-weight: bold;">|</span> <span style="color: #c20cb9; font-weight: bold;">tail</span> <span style="color: #660033;">-n</span> <span style="color: #000000;">1</span> <span style="color: #000000; font-weight: bold;">|</span> <span style="color: #c20cb9; font-weight: bold;">sed</span> <span style="color: #660033;">-r</span> s<span style="color: #000000; font-weight: bold;">/</span><span style="color: #ff0000;">'^.+ :: '</span><span style="color: #000000; font-weight: bold;">//</span>g<span style="color: #7a0874; font-weight: bold;">&#41;</span> <span style="color: #660033;">-s</span> <span style="color: #000000;">10240</span> <span style="color: #000000;">2</span><span style="color: #000000; font-weight: bold;">&gt;&amp;</span><span style="color: #000000;">1</span></pre></div></div>

<p>Good luck&#8230;</p>
]]></content:encoded>
			<wfw:commentRss>http://blog.apokalyptik.com/2009/10/06/php-debugging-the-really-really-hard-way/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>My inner geek is really showing tonight</title>
		<link>http://blog.apokalyptik.com/2009/10/02/my-inner-geek-is-really-showing-tonight/</link>
		<comments>http://blog.apokalyptik.com/2009/10/02/my-inner-geek-is-really-showing-tonight/#comments</comments>
		<pubDate>Sat, 03 Oct 2009 06:28:36 +0000</pubDate>
		<dc:creator>apokalyptik</dc:creator>
				<category><![CDATA[Random Thoughts]]></category>

		<guid isPermaLink="false">http://blog.apokalyptik.com/?p=462</guid>
		<description><![CDATA[I think its the Penny Arcade posts&#8230; I really do&#8230; But lately I miss the old days when I used to play Magic the Gathering, or Dungeons and Dragons.  Maybe some geek(s) out there in cyberspace and in the Pittsburg, Ca area will find this floating message in a bottle and reach out. Maybe [...]]]></description>
			<content:encoded><![CDATA[<p>I think its the Penny Arcade posts&#8230; I really do&#8230; But lately I miss the old days when I used to play Magic the Gathering, or Dungeons and Dragons.  Maybe some geek(s) out there in cyberspace and in the Pittsburg, Ca area will find this floating message in a bottle and reach out. Maybe not, and if they don&#8217;t maybe its for the better?</p>
]]></content:encoded>
			<wfw:commentRss>http://blog.apokalyptik.com/2009/10/02/my-inner-geek-is-really-showing-tonight/feed/</wfw:commentRss>
		<slash:comments>10</slash:comments>
		</item>
		<item>
		<title>Some WordPress XMLRPC Love</title>
		<link>http://blog.apokalyptik.com/2009/08/28/some-wordpress-xmlrpc-love/</link>
		<comments>http://blog.apokalyptik.com/2009/08/28/some-wordpress-xmlrpc-love/#comments</comments>
		<pubDate>Fri, 28 Aug 2009 22:33:17 +0000</pubDate>
		<dc:creator>apokalyptik</dc:creator>
				<category><![CDATA[Random Thoughts]]></category>

		<guid isPermaLink="false">http://blog.apokalyptik.com/?p=443</guid>
		<description><![CDATA[So I had to help fix an internal issue on WordPress.com where some largsish bits of data are transferred around via XMLRPC.  We like XMLRPC, its simple, extensible, and works. But one thing that the IXR_Server is not is &#8216;light&#8217;.  Because of the way that it works all of the data is transferred [...]]]></description>
			<content:encoded><![CDATA[<p>So I had to help fix an internal issue on WordPress.com where some largsish bits of data are transferred around via XMLRPC.  We like XMLRPC, its simple, extensible, and works. But one thing that the IXR_Server is not is &#8216;light&#8217;.  Because of the way that it works all of the data is transferred base64_encoded which means that a 10mb attachment just grows and grows and grows in ram on the server side&#8230; Which is exactly the problem I was faced with.  I spent about a full day pouring through the code and its current and peak memory usage at various places in the flow of execution and put together <a href="http://core.trac.wordpress.org/ticket/10698">a patch to help address some of the most glaring memory hogs</a>.</p>
<p>I asked Joseph to go over it and submit the good stuff upstream to the wordpress.org project (he&#8217;s had a lot more experience working with the actual xmlrpc clients than I do, so his experience there in making sure that they wouldn&#8217;t be disturbed by my changes was very valuable.)</p>
<p>The takeaway from this is pretty simple, but at the same time quite profound. When working with arbitrary data inputs that you expect to be large you really have to watch the copy-by-value operations that you do.  Referencing is one of those things that you may not need to know in detail for every day coding, but its good to be aware of them and <a href="http://www.php.net/manual/en/language.references.php">have an idea of what they are/do</a>.  In cases where you find yourself inexplicably running out of RAM a couple of references can save the day.</p>
<p>Related/restated take-aways are:</p>
<ul>
<li>The idea of balacing two variables in ram by adding X bytes to one and then subtracting those xbytes from the other. (xml parsing)</li>
<li>Also that certain types of operations create a temporary variable in ram with which to work with your data, so limiting the amount of data they need to function can be helpful when the variable is of considerable size (preg_replace)</li>
</ul>
<p>All in all this should be a considerable win for WordPress (dot com and dot org) xmlrpc users.  If you&#8217;re running a self-hosted wordpress install and want to test it out and comment on the patch i&#8217;m sure everyone would be greatful.</p>
<p>DK</p>
]]></content:encoded>
			<wfw:commentRss>http://blog.apokalyptik.com/2009/08/28/some-wordpress-xmlrpc-love/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
	</channel>
</rss>
