<?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>devFAIL &#187; FAIL</title>
	<atom:link href="http://www.devfail.com/category/fail/feed/" rel="self" type="application/rss+xml" />
	<link>http://www.devfail.com</link>
	<description>Adventures in Bad Programming</description>
	<lastBuildDate>Fri, 01 Jul 2011 21:54:12 +0000</lastBuildDate>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=3.2.1</generator>
		<item>
		<title>Performant SQL</title>
		<link>http://www.devfail.com/2011/07/01/performant-sql/</link>
		<comments>http://www.devfail.com/2011/07/01/performant-sql/#comments</comments>
		<pubDate>Fri, 01 Jul 2011 21:53:47 +0000</pubDate>
		<dc:creator>beau</dc:creator>
				<category><![CDATA[FAIL]]></category>

		<guid isPermaLink="false">http://www.devfail.com/?p=98</guid>
		<description><![CDATA[This query performs amazingly on a table with 8 million rows: SELECT `id`, `account`, `post` FROM `subscribers` WHERE MD5( CONCAT( account, post, email ) ) = '8ada1291a95d8919ba80f2d00167b86f' LIMIT 1;]]></description>
			<content:encoded><![CDATA[<p>This query performs amazingly on a table with 8 million rows:</p>
<pre class="brush: sql;">
SELECT `id`, `account`, `post` FROM `subscribers` WHERE MD5( CONCAT( account, post, email ) ) = '8ada1291a95d8919ba80f2d00167b86f' LIMIT 1;
</pre>
]]></content:encoded>
			<wfw:commentRss>http://www.devfail.com/2011/07/01/performant-sql/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Perfectly readable</title>
		<link>http://www.devfail.com/2009/11/23/perfectly-readable/</link>
		<comments>http://www.devfail.com/2009/11/23/perfectly-readable/#comments</comments>
		<pubDate>Mon, 23 Nov 2009 23:58:32 +0000</pubDate>
		<dc:creator>beau</dc:creator>
				<category><![CDATA[FAIL]]></category>
		<category><![CDATA[formatting]]></category>

		<guid isPermaLink="false">http://www.devfail.com/?p=77</guid>
		<description><![CDATA[I have reformatted this single line of unspaced code to make it more readable&#8230; $commentText = preg_replace(&#34;/\n/&#34;, &#34;&#34;, stripExcessLineBreaks( str_replace( &#34;&#38;nbsp;&#34;, &#34;&#34;, str_replace( &#34;&#38;amp;&#34;,&#34;&#38;&#34;,str_replace( &#34;u0026#39;&#34;,&#34;&#38;#039;&#34;, str_replace( &#34;'&#34;, &#34;&#38;#039;&#34;, str_replace( &#34;u0026amp;&#34;, &#34;&#38;amp;&#34;, str_replace( &#34;u0026quot;&#34;, &#34;&#38;quot;&#34;, nl2br( htmlspecialchars( htmlspecialchars_decode( stripHTML( stripReplyText( $message['body'], true ) ) ), ENT_NOQUOTES ) ) ) ) ) ) ) ) ) );]]></description>
			<content:encoded><![CDATA[<p>I have reformatted this single line of unspaced code to make it more readable&#8230;</p>
<pre class="brush: php;">
$commentText = preg_replace(&quot;/\n/&quot;, &quot;&quot;, stripExcessLineBreaks(
                                 str_replace(
                                    &quot;&amp;nbsp;&quot;, &quot;&quot;, str_replace(
                                       &quot;&amp;amp;&quot;,&quot;&amp;&quot;,str_replace(
                                          &quot;u0026#39;&quot;,&quot;&amp;#039;&quot;, str_replace(
                                             &quot;'&quot;, &quot;&amp;#039;&quot;, str_replace(
                                                &quot;u0026amp;&quot;, &quot;&amp;amp;&quot;, str_replace(
                                                   &quot;u0026quot;&quot;, &quot;&amp;quot;&quot;, nl2br(
                                                      htmlspecialchars(
                                                         htmlspecialchars_decode(
                                                            stripHTML(
                                                               stripReplyText(
                                                                  $message['body'], true
                                                               )
                                                            )
                                                         ),
                                                      ENT_NOQUOTES
                                                   )
                                                )
                                             )
                                          )
                                       )
                                    )
                                 )
                              )
                           )
                        );
</pre>
]]></content:encoded>
			<wfw:commentRss>http://www.devfail.com/2009/11/23/perfectly-readable/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Redundancy? I got yer redundancy right here!</title>
		<link>http://www.devfail.com/2009/11/19/redundancy-i-got-yer-redundancy-right-here/</link>
		<comments>http://www.devfail.com/2009/11/19/redundancy-i-got-yer-redundancy-right-here/#comments</comments>
		<pubDate>Fri, 20 Nov 2009 02:26:30 +0000</pubDate>
		<dc:creator>beau</dc:creator>
				<category><![CDATA[FAIL]]></category>

		<guid isPermaLink="false">http://www.devfail.com/?p=74</guid>
		<description><![CDATA[Remove slashes, add slashes, add slashes, remove slashes&#8230; what was I doing again? I don&#8217;t remember, oh well, add more slashes, remove some slashes, keep adding slashes. $text = addslashes( addslashes( stripslashes( preg_replace(&#34;/\n&#124;\r/&#34;, &#34;&#34;, $text) ) ) );]]></description>
			<content:encoded><![CDATA[<p>Remove slashes, add slashes, add slashes, remove slashes&#8230; what was I doing again? I don&#8217;t remember, oh well, add more slashes, remove some slashes, keep adding slashes.</p>
<pre class="brush: php;">$text = addslashes( addslashes( stripslashes( preg_replace(&quot;/\n|\r/&quot;, &quot;&quot;, $text) ) ) );</pre>
]]></content:encoded>
			<wfw:commentRss>http://www.devfail.com/2009/11/19/redundancy-i-got-yer-redundancy-right-here/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Maintainability FAIL</title>
		<link>http://www.devfail.com/2009/05/04/maintainability-fail/</link>
		<comments>http://www.devfail.com/2009/05/04/maintainability-fail/#comments</comments>
		<pubDate>Mon, 04 May 2009 18:34:23 +0000</pubDate>
		<dc:creator>beau</dc:creator>
				<category><![CDATA[FAIL]]></category>
		<category><![CDATA[maintainability]]></category>
		<category><![CDATA[single line]]></category>

		<guid isPermaLink="false">http://www.devfail.com/2009/05/04/maintainability-fail/</guid>
		<description><![CDATA[I dare you to read this without crossing your eyes: $commentText = preg_replace(&#34;/\n/&#34;, &#34;&#34;, stripExcessLineBreaks(str_replace(&#34; &#34;, &#34;&#34;, str_replace(&#34;&#38;amp;&#34;,&#34;&#38;amp;&#34;,str_replace(&#34;u0026#39;&#34;,&#34;'&#34;, str_replace(&#34;'&#34;, &#34;'&#34;, str_replace(&#34;u0026amp;&#34;, &#34;&#38;amp;&#34;, str_replace(&#34;u0026quot;&#34;, &#34;&#34;&#34;, nl2br(htmlspecialchars(htmlspecialchars_decode(stripHTML(stripReplyText($message['body'], true))),ENT_NOQUOTES)))))))))); ICANHAZLINEBREAKZ?]]></description>
			<content:encoded><![CDATA[<p>
I dare you to read this without crossing your eyes:
</p>
<pre class="brush: php;">$commentText = preg_replace(&quot;/\n/&quot;, &quot;&quot;, stripExcessLineBreaks(str_replace(&quot; &quot;, &quot;&quot;, str_replace(&quot;&amp;amp;&quot;,&quot;&amp;amp;&quot;,str_replace(&quot;u0026#39;&quot;,&quot;'&quot;, str_replace(&quot;'&quot;, &quot;'&quot;, str_replace(&quot;u0026amp;&quot;, &quot;&amp;amp;&quot;, str_replace(&quot;u0026quot;&quot;, &quot;&quot;&quot;, nl2br(htmlspecialchars(htmlspecialchars_decode(stripHTML(stripReplyText($message['body'], true))),ENT_NOQUOTES))))))))));</pre>
<p>
ICANHAZLINEBREAKZ?</p>
]]></content:encoded>
			<wfw:commentRss>http://www.devfail.com/2009/05/04/maintainability-fail/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Hand-Crafted Serialization FTW!</title>
		<link>http://www.devfail.com/2009/03/01/hand-crafted-serialization-ftw/</link>
		<comments>http://www.devfail.com/2009/03/01/hand-crafted-serialization-ftw/#comments</comments>
		<pubDate>Sun, 01 Mar 2009 07:41:15 +0000</pubDate>
		<dc:creator>beau</dc:creator>
				<category><![CDATA[FAIL]]></category>

		<guid isPermaLink="false">http://www.devfail.com/?p=65</guid>
		<description><![CDATA[Not that it surprises me that much, but there are some truly bizarre chunks of code in WordPressMU. Check out this hot piece of love: $wpdb-&#62;query( &#34;UPDATE $wpdb-&#62;usermeta SET meta_value = 'a:1:{s:&#34; . strlen( $role ) . &#34;:\&#34;&#34; . $role . &#34;\&#34;;b:1;}' WHERE user_id = '$userid'  AND meta_key = '&#34; . $wpdb-&#62;base_prefix . $id . [...]]]></description>
			<content:encoded><![CDATA[<p>Not that it surprises me that much, but there are some truly bizarre chunks of code in WordPressMU. Check out this hot piece of love:</p>
<pre class="brush: php;">$wpdb-&gt;query( &quot;UPDATE $wpdb-&gt;usermeta SET meta_value = 'a:1:{s:&quot; . strlen( $role ) . &quot;:\&quot;&quot; . $role . &quot;\&quot;;b:1;}' WHERE user_id = '$userid'  AND meta_key = '&quot; . $wpdb-&gt;base_prefix . $id . &quot;_capabilities'&quot; );</pre>
<p>Yeah that&#8217;s right, a manually constructed string, representing a serialized array. WTF?</p>
]]></content:encoded>
			<wfw:commentRss>http://www.devfail.com/2009/03/01/hand-crafted-serialization-ftw/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Even the best fall down</title>
		<link>http://www.devfail.com/2009/01/08/even-the-best-fall-down/</link>
		<comments>http://www.devfail.com/2009/01/08/even-the-best-fall-down/#comments</comments>
		<pubDate>Thu, 08 Jan 2009 21:32:20 +0000</pubDate>
		<dc:creator>evan</dc:creator>
				<category><![CDATA[FAIL]]></category>

		<guid isPermaLink="false">http://www.devfail.com/?p=58</guid>
		<description><![CDATA[I just wrote "if (!$retval) {". In C code. :facepalm: From Andrei Zmievski via Twitter. Andrei is a leader in the PHP community, spearheading PHP development and bringing us closer to PHP6. Just goes to show that developers are human too. (Sorta.)]]></description>
			<content:encoded><![CDATA[<pre class="code">I just wrote "if (!$retval) {". In C code. :facepalm:</pre>
<p>From <a href="http://twitter.com/a/statuses/1105254459" target="_blank">Andrei Zmievski</a> via <a href="http://www.twitter.com" target="_blank">Twitter</a>.</p>
<p>Andrei is a leader in the PHP community, spearheading PHP development and bringing us closer to PHP6.</p>
<p>Just goes to show that developers are human too. (Sorta.)</p>
]]></content:encoded>
			<wfw:commentRss>http://www.devfail.com/2009/01/08/even-the-best-fall-down/feed/</wfw:commentRss>
		<slash:comments>1</slash:comments>
		</item>
		<item>
		<title>&#8230;and one more thing</title>
		<link>http://www.devfail.com/2009/01/08/and-one-more-thing/</link>
		<comments>http://www.devfail.com/2009/01/08/and-one-more-thing/#comments</comments>
		<pubDate>Thu, 08 Jan 2009 19:45:15 +0000</pubDate>
		<dc:creator>evan</dc:creator>
				<category><![CDATA[FAIL]]></category>

		<guid isPermaLink="false">http://www.devfail.com/?p=53</guid>
		<description><![CDATA[Screwed by the Goog!]]></description>
			<content:encoded><![CDATA[<p>Screwed by the Goog!</p>
<p><img class="aligncenter size-full wp-image-54" title="Google Reader Confused" src="http://www.devfail.com/wp-content/uploads/2009/01/picture-4.png" alt="Google Reader Confused" width="617" height="166" /></p>
]]></content:encoded>
			<wfw:commentRss>http://www.devfail.com/2009/01/08/and-one-more-thing/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>I hate you, Bill Gates</title>
		<link>http://www.devfail.com/2009/01/07/i-hate-you-bill-gates/</link>
		<comments>http://www.devfail.com/2009/01/07/i-hate-you-bill-gates/#comments</comments>
		<pubDate>Wed, 07 Jan 2009 21:54:19 +0000</pubDate>
		<dc:creator>evan</dc:creator>
				<category><![CDATA[FAIL]]></category>

		<guid isPermaLink="false">http://www.devfail.com/?p=41</guid>
		<description><![CDATA[Found on http://www.americanbaby.com/404.html (You need to disable javascript before loading to see it.) &#60;body onLoad=&#34;redirect()&#34;&#62; &#60;!-- this is a comment the whole thing please disregard this unless you're Bill GAtes and in which case this is all your fault --&#62; &#60;/html&#62; Ugh. Gotta love Microsoft&#8217;s inability to adhere to standards. Also, see this: Open Letter [...]]]></description>
			<content:encoded><![CDATA[<p>Found on <a href="http://www.americanbaby.com/404.html">http://www.americanbaby.com/404.html</a> (You need to disable javascript before loading to see it.)</p>
<pre class="brush: xml;">
&lt;body onLoad=&quot;redirect()&quot;&gt;
&lt;!-- this is a comment
the whole thing
please disregard this
unless you're Bill GAtes and
in which case this is all your fault
--&gt;
&lt;/html&gt;
</pre>
<p>Ugh. Gotta love Microsoft&#8217;s inability to adhere to standards.</p>
<p>Also, see this: <a href="http://dentedreality.com.au/2009/01/goodbye-internet-explorer-6/" target="_blank">Open Letter to IE6 for 2009</a></p>
]]></content:encoded>
			<wfw:commentRss>http://www.devfail.com/2009/01/07/i-hate-you-bill-gates/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>return true, or&#8230; return true</title>
		<link>http://www.devfail.com/2009/01/05/return-true-or-return-true/</link>
		<comments>http://www.devfail.com/2009/01/05/return-true-or-return-true/#comments</comments>
		<pubDate>Mon, 05 Jan 2009 22:30:04 +0000</pubDate>
		<dc:creator>jon</dc:creator>
				<category><![CDATA[FAIL]]></category>

		<guid isPermaLink="false">http://www.devfail.com/?p=36</guid>
		<description><![CDATA[This method is supposed to determine if a post is a draft or not. I&#8217;ll let it speak for itself. public function __get_draft() { if ($this-&#62;visible == 0 &#38;&#38; $this-&#62;archived == 0 &#38;&#38; $this-&#62;deleted = 0) { return true; } else { return true; } }]]></description>
			<content:encoded><![CDATA[<p>This method is supposed to determine if a post is a draft or not. I&#8217;ll let it speak for itself.</p>
<pre class="brush: php;">public function __get_draft() {
    if ($this-&gt;visible == 0 &amp;&amp; $this-&gt;archived == 0 &amp;&amp; $this-&gt;deleted = 0) {
        return true;
    } else {
        return true;
    }
}</pre>
]]></content:encoded>
			<wfw:commentRss>http://www.devfail.com/2009/01/05/return-true-or-return-true/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>worlds most unnecessary loop</title>
		<link>http://www.devfail.com/2008/12/29/worlds-most-unnecessary-loop/</link>
		<comments>http://www.devfail.com/2008/12/29/worlds-most-unnecessary-loop/#comments</comments>
		<pubDate>Tue, 30 Dec 2008 01:41:57 +0000</pubDate>
		<dc:creator>jon</dc:creator>
				<category><![CDATA[FAIL]]></category>

		<guid isPermaLink="false">http://www.devfail.com/?p=32</guid>
		<description><![CDATA[Found this bit in a model class of my own. static public function active_product($product_type, $role_id) { $q = 'SELECT COUNT(*) FROM product WHERE visible = 1 AND (deleted = 0 OR archived = 0) AND postedby_role_id = ? AND product_type = ?'; $sth = $dbh-&#62;prepare($q); $sth-&#62;execute($role_id, $product_type); $product_count = 0; while(list($count) = $sth-&#62;fetchrow_array()) { $product_count [...]]]></description>
			<content:encoded><![CDATA[<p>Found this bit in a model class of my own.</p>
<pre class="brush: php;">static public function active_product($product_type, $role_id) {
	$q = 'SELECT COUNT(*)
                FROM product
                WHERE
                    visible = 1 AND
                    (deleted = 0 OR archived = 0) AND
                    postedby_role_id = ? AND
                    product_type = ?';

        $sth = $dbh-&gt;prepare($q);
        $sth-&gt;execute($role_id, $product_type);

        $product_count = 0;
        while(list($count) = $sth-&gt;fetchrow_array()) {
            $product_count += $count;
        }

        return $product_count;
}</pre>
<p>WTF was I smoking?</p>
]]></content:encoded>
			<wfw:commentRss>http://www.devfail.com/2008/12/29/worlds-most-unnecessary-loop/feed/</wfw:commentRss>
		<slash:comments>2</slash:comments>
		</item>
	</channel>
</rss>

