<?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>quiet despair &#187; code</title>
	<atom:link href="http://quietdespair.com/category/tech/code/feed" rel="self" type="application/rss+xml" />
	<link>http://quietdespair.com</link>
	<description>a long series of disappointments</description>
	<lastBuildDate>Thu, 16 Oct 2008 12:38:31 +0000</lastBuildDate>
	<generator>http://wordpress.org/?v=2.8.3</generator>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
			<item>
		<title>Interfacing With Another Species 7.2 Ksecs Too Early</title>
		<link>http://quietdespair.com/special/interfacing-with-another-species-72-ksecs-too-early.html</link>
		<comments>http://quietdespair.com/special/interfacing-with-another-species-72-ksecs-too-early.html#comments</comments>
		<pubDate>Mon, 29 Sep 2008 10:57:39 +0000</pubDate>
		<dc:creator>Maker</dc:creator>
				<category><![CDATA[code]]></category>
		<category><![CDATA[special]]></category>
		<category><![CDATA[coding]]></category>
		<category><![CDATA[conference]]></category>
		<category><![CDATA[japan]]></category>
		<category><![CDATA[meeting]]></category>
		<category><![CDATA[programming]]></category>
		<category><![CDATA[work]]></category>

		<guid isPermaLink="false">http://quietdespair.com/?p=281</guid>
		<description><![CDATA[I&#8217;ve been scheduled for a conference call without my input on the time for more than 7Ksecs before I usually resume consciousness.  In the past this has usually resulted in disaster for the other involved parties, as I typically can&#8217;t resume from standby that early, let alone speak in coherent sentences or form what humans [...]]]></description>
			<content:encoded><![CDATA[<p>I&#8217;ve been scheduled for a conference call without my input on the time for more than <a title="Kiloseconds" href="http://en.wikipedia.org/wiki/Kilosecond">7Ksecs</a> before I usually resume consciousness.  In the past this has usually resulted in disaster for the other involved parties, as I typically can&#8217;t resume from standby that early, let alone speak in coherent sentences or form what humans would consider lucid thoughts.  My ideal employer would either be able to work with this better, or be located in <a title="Satellite Map View of Tokyo, Japan." href="http://maps.google.com/maps?q=tokyo,+japan&amp;ie=UTF8&amp;oe=UTF-8&amp;cd=1&amp;t=h&amp;layer=x&amp;ll=36.093499,139.682922&amp;spn=1.125208,2.513123&amp;z=9" target="_blank">Japan</a>.</p>
<p>This article on <a title="Why Code at Night?" href="http://codeclimber.blogspot.com/2008/04/burning-midnight-oil.html">Code Climber</a> identifies a lot of the most important reasons I and so many others work best at night.  There are numerous benefits to working at night:</p>
<ul>
<li>There are far less interruptions by email, instant message, and news via RSS</li>
<li>There is minimal interaction with human species, as they seem to prefer sleeping while <a title="Your local star" href="http://photojournal.jpl.nasa.gov/target/Sun" target="_blank">Sol</a> illuminates the oppopsite side of their planet</li>
<li>My best and most productive work requires long periods of concentration and <a title="A Deepness in the Sky by Vernor Vinge" href="http://books.google.com/books?id=CzbMxAcAE-QC&amp;output=html" target="_blank">Focus</a></li>
</ul>
]]></content:encoded>
			<wfw:commentRss>http://quietdespair.com/special/interfacing-with-another-species-72-ksecs-too-early.html/feed</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>A little regex in php for fun</title>
		<link>http://quietdespair.com/tech/code/a-little-regex-in-php-for-fun.html</link>
		<comments>http://quietdespair.com/tech/code/a-little-regex-in-php-for-fun.html#comments</comments>
		<pubDate>Thu, 14 Aug 2008 08:01:44 +0000</pubDate>
		<dc:creator>Maker</dc:creator>
				<category><![CDATA[code]]></category>
		<category><![CDATA[coding]]></category>
		<category><![CDATA[php]]></category>
		<category><![CDATA[programming]]></category>
		<category><![CDATA[regex]]></category>

		<guid isPermaLink="false">http://quietdespair.com/?p=277</guid>
		<description><![CDATA[So after working thirteen hours in a row I came home and thought of a handy function to bandaid some legacy code that returns a url with double slashes after the TLD. I realize this is a worse solution than fixing the code in question, but my regex-fu could use work so I though I&#8217;d [...]]]></description>
			<content:encoded><![CDATA[<p>So after working thirteen hours in a row I came home and thought of a handy function to bandaid some legacy code that returns a url with double slashes after the TLD. I realize this is a worse solution than fixing the code in question, but my regex-fu could use work so I though I&#8217;d do a little exploring. motel6 sparked my imagination and deserves full credit for my work below. Here&#8217;s what I came up with:</p>
<p><code> &lt;?php<br />
</code><code> $url = remove_url_slashes('http://www.killallhumans.com//?robots_eating=hobos&amp;passion=361', 'killallhumans');</code></p>
<p>function remove_url_slashes($url=&#8221;,$domain=&#8221;) {<br />
<code> </code><code> </code><code>if(empty($url))<br />
</code><code> </code><code> </code><code> </code><code> </code><code>return false;<br />
</code><code> </code><code> </code><code>if(empty($domain))<br />
</code><code> </code><code> </code><code> </code><code> </code><code> $domain = 'killallhumans';</code><code><br />
</code><code> </code><code> </code><code>$pattern = "/($domain)(.*?)(\/+)/ie";</code><code><br />
</code><code> </code><code> </code><code>return preg_replace($pattern, "'\\1\\2/'", $url);<br />
}<br />
</code>?&gt;</p>
]]></content:encoded>
			<wfw:commentRss>http://quietdespair.com/tech/code/a-little-regex-in-php-for-fun.html/feed</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Warning: SQL Statement is Missing SQL</title>
		<link>http://quietdespair.com/tech/code/sqlmissing.html</link>
		<comments>http://quietdespair.com/tech/code/sqlmissing.html#comments</comments>
		<pubDate>Wed, 26 Mar 2008 21:33:24 +0000</pubDate>
		<dc:creator>Maker</dc:creator>
				<category><![CDATA[code]]></category>

		<guid isPermaLink="false">http://quietdespair.com/code/sqlmissing.html</guid>
		<description><![CDATA[I found some great code at work today I&#8217;d like to share. I&#8217;ve omitted anything that might qualify as a trade secret or proprietary information. I&#8217;ve also changed the names of the innocent variables to make it more readable. Also, this won&#8217;t be funny if code makes your brain hurt.
Here&#8217;s the error I kept finding:
Warning: [...]]]></description>
			<content:encoded><![CDATA[<p>I found some great code at work today I&#8217;d like to share. I&#8217;ve omitted anything that might qualify as a trade secret or proprietary information. I&#8217;ve also changed the names of the innocent variables to make it more readable. Also, this won&#8217;t be funny if code makes your brain hurt.</p>
<p>Here&#8217;s the error I kept finding:<br />
<code>Warning:  pg_query_params(): Query failed: ERROR:  bind message supplies 3 parameters, but prepared statement "" requires 0 on line 9175</code></p>
<p><code></code><br />
Upon investigation, I determined that the reason our postgres query was failing was because we forgot to actually give it any SQL statement (pay attention to the second parameter here.. it should contain the SQL query that you want to apply the third parameter for):<br />
<code>$ret = pg_query_params($this-&gt;connection, "",  array($shipping_type, $customer_id, $payment));</code></p>
<p>Well, fine.. but I thought it was funny.</p>
]]></content:encoded>
			<wfw:commentRss>http://quietdespair.com/tech/code/sqlmissing.html/feed</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>In which a system administrator is an idiot</title>
		<link>http://quietdespair.com/tech/code/asshat.html</link>
		<comments>http://quietdespair.com/tech/code/asshat.html#comments</comments>
		<pubDate>Mon, 10 Mar 2008 05:45:11 +0000</pubDate>
		<dc:creator>Maker</dc:creator>
				<category><![CDATA[code]]></category>

		<guid isPermaLink="false">http://quietdespair.com/code/asshat.html</guid>
		<description><![CDATA[I recently did some freelance work for a friend of mine. It was extremely basic, just adding some includes so he didn&#8217;t have to manage a hundred different navigations for each page he had made. Well, I did it fast and I skipped some basic checking in my script. My code would work unless you [...]]]></description>
			<content:encoded><![CDATA[<p>I recently did some freelance work for a friend of mine. It was extremely basic, just adding some includes so he didn&#8217;t have to manage a hundred different navigations for each page he had made. Well, I did it fast and I skipped some basic checking in my script. My code would work unless you had the error logging turned up all the way, which is fairly excessive. The other way it would fail is if you had <a href="http://us.php.net/error_reporting">display_errors</a> set, which is the default PHP configuration.  No one with any ounce of experience or common sense would let display_errors be set for a production server. This gives out sensitive information about the environment of the server. Here is what the <a href="http://phpsec.org">PHP Security Consortium </a>has to say about <a href="http://phpsec.org/projects/phpsecinfo/tests/display_errors.html">display_errors</a>:</p>
<blockquote><p>&#8220;The display_errors directive determines whether error messages should be sent to the browser. These messages frequently contain sensitive information about your web application environment, and should <em>never</em> be presented to untrusted sources.</p>
<p>Unless you are in a closed development state, display_errors should be disabled, and all error messages should be passed to system log files using the log_errors directive.&#8221;</p></blockquote>
<p>So I fixed my code to be able to run in a very strict error checking environment, to such a point that it&#8217;s excessive. It checks to see if a variable exists immediately after I&#8217;ve set it. This is sort of my passive aggressive  way of telling the syadmin who had a problem with my code to take a long walk off a short beach. The icing on my cake is that I check at the very beginning of the first include to see if display_errors is on. If it&#8217;s on and isn&#8217;t set to log errors to a file, I disable it. Then I check to see if the supeglobal $_SERVER is set. I&#8217;m not even sure if it&#8217;s possible to <em>NOT </em>have it set. But just for good measure, if by some miracle it isn&#8217;t set, and I can&#8217;t figure out the name of the script that&#8217;s running, I exit which causes a white screen to display.</p>
<blockquote><p> <code>// http://us3.php.net/errorfunc     Note: You're strongly advised to use error logging in place of error displaying on production web sites.<br />
if(ini_get('display_errors') &amp;&amp; ini_get('display_errors') == '1') error_reporting(0);<br />
if(!isset($_SERVER) &amp;&amp; !isset($_SERVER['SCRIPT_FILENAME'])) exit;</code></p></blockquote>
<p>He also calls this production server, &#8220;the dedicated box&#8221; even though it runs many virtual hosted sites.</p>
]]></content:encoded>
			<wfw:commentRss>http://quietdespair.com/tech/code/asshat.html/feed</wfw:commentRss>
		<slash:comments>1</slash:comments>
		</item>
	</channel>
</rss>
