<?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>Adam DiCarlo&#039;s Blog &#187; Programming</title>
	<atom:link href="http://adamdicarlo.com/category/programming/feed/" rel="self" type="application/rss+xml" />
	<link>http://adamdicarlo.com</link>
	<description>Programming, Linux, music, woodworking....</description>
	<lastBuildDate>Thu, 12 Nov 2009 21:26:33 +0000</lastBuildDate>
	<generator>http://wordpress.org/?v=2.8.2</generator>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
			<item>
		<title>Canvas/JavaScript scrolling tile-map demo</title>
		<link>http://adamdicarlo.com/2009/11/12/canvas-javascript-scrolling-tile-map-demo/</link>
		<comments>http://adamdicarlo.com/2009/11/12/canvas-javascript-scrolling-tile-map-demo/#comments</comments>
		<pubDate>Thu, 12 Nov 2009 21:18:27 +0000</pubDate>
		<dc:creator>adam</dc:creator>
				<category><![CDATA[Programming]]></category>
		<category><![CDATA[canvas tag]]></category>
		<category><![CDATA[JavaScript]]></category>
		<category><![CDATA[tilemap]]></category>
		<category><![CDATA[web game programming]]></category>

		<guid isPermaLink="false">http://adamdicarlo.com/?p=195</guid>
		<description><![CDATA[
$(document).ready(function () { init(); })


      canvas { border: 2px solid black; }

Here&#8217;s something I did for fun in May as a proof of concept. It uses JavaScript and the canvas tag to render a Super Mario Brothers style tile-map with background. Try it in Firefox 3.5+, Safari 4+, or Chrome/Chromium.
Do [...]]]></description>
			<content:encoded><![CDATA[<p><script type="text/javascript" src="http://bikko.org/practice/canvas/d/canvas.text.js"></script><script type="text/javascript" src="http://bikko.org/practice/canvas/d/game.js"></script><script type="text/javascript" src="http://adamdicarlo.com/js/jquery-1.3.2.js"></script><script type="text/javascript">
$(document).ready(function () { init(); })
</script></p>
<style type="text/css">
      canvas { border: 2px solid black; }
</style>
<p>Here&#8217;s something I did for fun in May as a proof of concept. It uses JavaScript and the canvas tag to render a Super Mario Brothers style tile-map with background. Try it in Firefox 3.5+, Safari 4+, or Chrome/Chromium.<br />
<canvas id="my_canvas" width="0" height="0"></canvas><br /><button onclick="toggleScroll();">Do Some Scrolling!</button> or arrow keys to move view<br /><a href="javascript:viewSmall();">small</a> | <a href="javascript:viewMedium();">medium</a> | <a href="javascript:viewLarge();">large</a></p>
]]></content:encoded>
			<wfw:commentRss>http://adamdicarlo.com/2009/11/12/canvas-javascript-scrolling-tile-map-demo/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Tried out Expression Engine 1.6.8</title>
		<link>http://adamdicarlo.com/2009/09/18/tried-out-expression-engine-1-6-8/</link>
		<comments>http://adamdicarlo.com/2009/09/18/tried-out-expression-engine-1-6-8/#comments</comments>
		<pubDate>Fri, 18 Sep 2009 16:00:14 +0000</pubDate>
		<dc:creator>adam</dc:creator>
				<category><![CDATA[Programming]]></category>

		<guid isPermaLink="false">http://adamdicarlo.com/?p=167</guid>
		<description><![CDATA[I tried the Expression Engine (freely-downloadable Core edition) CMS. I didn&#8217;t much care for it; though it might be useful if you want to store many different (complete) HTML pages in a database and have an interface to edit them with. That&#8217;s not however exactly what I think a &#8220;content management system&#8221; should be; that&#8217;s [...]]]></description>
			<content:encoded><![CDATA[<p>I tried the <a href="http://expressionengine.com">Expression Engine</a> (freely-downloadable Core edition) CMS. I didn&#8217;t much care for it; though it might be useful if you want to store many different (complete) HTML pages in a database and have an interface to edit them with. That&#8217;s not however exactly what I think a &#8220;content management system&#8221; should be; that&#8217;s more of a markup management system.</p>
<p>I just didn&#8217;t find the system inspiring; as a user, it&#8217;s hard to pinpoint why, specifically, beyond saying that the administrative interface seemed unintuitive. As a developer and systems administrator I was also pretty disturbed when I looked at the source of the installation script: 4168 lines of PHP, nearly all global-scope code, with MySQL queries, HTML, and CSS interspersed along the way.</p>
<p>Generally, I don&#8217;t trust software that I would hate to have to maintain. It goes beyond code simply looking pretty; readability is important. Given <a href="http://en.wikipedia.org/wiki/The_Magical_Number_Seven,_Plus_or_Minus_Two">The Magical Number Seven, Plus or Minus Two</a> concept, it&#8217;s easy to see why 20 line functions with a handful of local variables are much easier to maintain and debug&mdash;and to <em>proactively</em> spot bugs in&mdash;than something that is essentially a 4000 line function.</p>
<p>The system&#8217;s core code looks to be written more modularly, but it&#8217;s obviously not as flexible as Drupal. It doesn&#8217;t appear to have much database abstraction (it only supports MySQL), nor a form API. Beyond the fact that you can edit the HTML of pages (but not blog entries?) on your site directly in the administrative interface, I&#8217;m not sure why this system claims to be the most flexible thing ever.</p>
<p>I told the installer to use no table prefix, but it still prefixed the tables with &#8220;exp_&#8221;. Apparently it didn&#8217;t like a blank prefix, but it didn&#8217;t complain, either. There is code to let the system work with a different table prefix, but it&#8217;s a dirty hack that involves at least one regular expression to be run for every query. From Expression Engine&#8217;s database query function (<em>system/core/db/db.mysql.php</em>):</p>
<div class="codecolorer-container php " style="overflow:auto;white-space:nowrap;border: 1px solid #9F9F9F;width:475px;"><div class="php codecolorer" style="padding:5px;font:normal 12px/1.4em Monaco, Lucida Console, monospace;white-space:nowrap"><span style="color: #666666; font-style: italic;">// Verify table prefix and replace if necessary.</span><br />
<br />
<span style="color: #b1b100;">if</span> <span style="color: #009900;">&#40;</span><span style="color: #000088;">$this</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">prefix</span> <span style="color: #339933;">!=</span> <span style="color: #000088;">$this</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">exp_prefix</span><span style="color: #009900;">&#41;</span><br />
<span style="color: #009900;">&#123;</span><br />
&nbsp; &nbsp; <span style="color: #000088;">$sql</span> <span style="color: #339933;">=</span> <a href="http://www.php.net/preg_replace"><span style="color: #990000;">preg_replace</span></a><span style="color: #009900;">&#40;</span><span style="color: #0000ff;">&quot;/(\W)&quot;</span><span style="color: #339933;">.</span><span style="color: #000088;">$this</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">exp_prefix</span><span style="color: #339933;">.</span><span style="color: #0000ff;">&quot;(\S+?)/&quot;</span><span style="color: #339933;">,</span> <span style="color: #0000ff;">&quot;<span style="color: #000099; font-weight: bold;">\\</span>1&quot;</span><span style="color: #339933;">.</span><span style="color: #000088;">$this</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">prefix</span><span style="color: #339933;">.</span><span style="color: #0000ff;">&quot;<span style="color: #000099; font-weight: bold;">\\</span>2&quot;</span><span style="color: #339933;">,</span> <span style="color: #000088;">$sql</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span><br />
<br />
&nbsp; &nbsp; <span style="color: #666666; font-style: italic;">// If the custom prefix includes 'exp_' the above can sometimes cause partial doubling.</span><br />
&nbsp; &nbsp; <span style="color: #666666; font-style: italic;">// This is a quick fix to prevent this from causing errors in 1.x.</span><br />
&nbsp; &nbsp; <span style="color: #b1b100;">if</span> <span style="color: #009900;">&#40;</span><a href="http://www.php.net/strncmp"><span style="color: #990000;">strncmp</span></a><span style="color: #009900;">&#40;</span><span style="color: #000088;">$this</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">prefix</span><span style="color: #339933;">,</span> <span style="color: #0000ff;">'exp_'</span><span style="color: #339933;">,</span> 4<span style="color: #009900;">&#41;</span> <span style="color: #339933;">==</span> 0<span style="color: #009900;">&#41;</span><br />
&nbsp; &nbsp; <span style="color: #009900;">&#123;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #000088;">$sql</span> <span style="color: #339933;">=</span> <a href="http://www.php.net/str_replace"><span style="color: #990000;">str_replace</span></a><span style="color: #009900;">&#40;</span><span style="color: #000088;">$this</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">prefix</span><span style="color: #339933;">.</span><a href="http://www.php.net/str_replace"><span style="color: #990000;">str_replace</span></a><span style="color: #009900;">&#40;</span><span style="color: #0000ff;">'exp_'</span><span style="color: #339933;">,</span> <span style="color: #0000ff;">''</span><span style="color: #339933;">,</span> <span style="color: #000088;">$this</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">prefix</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;">prefix</span><span style="color: #339933;">,</span> <span style="color: #000088;">$sql</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span><br />
&nbsp; &nbsp; <span style="color: #009900;">&#125;</span><br />
<span style="color: #009900;">&#125;</span></div></div>
<p>I&#8217;m quite curious whether that regex substitution will break database fields with names like &#8220;exp_points.&#8221;</p>
<p>And, come to think of it, that <code class="codecolorer text "><span class="text">strncmp()</span></code> call could be a bug; the comment says &#8220;if the prefix includes&#8221; but <code class="codecolorer text "><span class="text">strncmp()</span></code> only checks the beginning of the string. Shouldn&#8217;t it be a call to <code class="codecolorer text "><span class="text">strpos()</span></code> instead?</p>
<p>On a more positive note, looking under the hood of other systems, like this one, helps me appreciate Drupal even more. Drupal really sets a high standard; once you&#8217;ve worked with it, especially if you&#8217;ve looked under the hood or done any module coding, it&#8217;s hard not to appreciate its well-thought out design and engineering. The <a href="http://api.drupal.org/api/group/form_api/6">FormAPI</a> has particularly spoiled me rotten.</p>
]]></content:encoded>
			<wfw:commentRss>http://adamdicarlo.com/2009/09/18/tried-out-expression-engine-1-6-8/feed/</wfw:commentRss>
		<slash:comments>1</slash:comments>
		</item>
		<item>
		<title>Secret (Tiny) Message Encoder</title>
		<link>http://adamdicarlo.com/2009/05/22/secret-message-encoder/</link>
		<comments>http://adamdicarlo.com/2009/05/22/secret-message-encoder/#comments</comments>
		<pubDate>Fri, 22 May 2009 08:40:02 +0000</pubDate>
		<dc:creator>adam</dc:creator>
				<category><![CDATA[Programming]]></category>
		<category><![CDATA[canvas tag]]></category>
		<category><![CDATA[JavaScript]]></category>

		<guid isPermaLink="false">http://adamdicarlo.com/?p=47</guid>
		<description><![CDATA[Having seen the smallest readable bitmap typeface (3&#215;3 pixels per character), I decided to hack up a small JavaScript/canvas web app for fun so people could try it without having to install a TTF file.

Source: Wikipedia, under the GNU Free Documentation license.
Then, the &#8220;secret message&#8221; idea struck, so I made the &#8220;secret&#8221; message encoder. (Warning: [...]]]></description>
			<content:encoded><![CDATA[<p>Having seen the smallest readable bitmap typeface (3&#215;3 pixels per character), I decided to hack up a <a href="http://bikko.org/practice/3x3/index.php">small JavaScript/canvas web app</a> for fun so people could try it without having to install a TTF file.</p>
<p><img src="http://bikko.org/practice/3x3/3x3.gif" alt="Smallest readable typeface (3x3 pixels per character)" /><br />
<span class="caption">Source: <a href="http://en.wikipedia.org/wiki/File:3x3.gif">Wikipedia</a>, under the GNU Free Documentation license.</span></p>
<p>Then, the &#8220;secret message&#8221; idea struck, so I made the <a href="http://bikko.org/practice/3x3/encode.php">&#8220;secret&#8221; message encoder</a>. (Warning: Only tested with Firefox 3. It also requires the canvas tag and doesn&#8217;t yet work in Safari.)</p>
<p>You type in a message and it will give you a link you can send to someone to view their <span class="tooltip" title="Not really.">super-encrypted</span> message.</p>
<p>Always great to find an excuse to play around with &lt;canvas&gt;!</p>
]]></content:encoded>
			<wfw:commentRss>http://adamdicarlo.com/2009/05/22/secret-message-encoder/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
	</channel>
</rss>
