<?xml version="1.0" encoding="utf-8"?>
<rss version="2.0">
    <channel>
        <title>the ender.com blog</title>
        <link>http://www.ender.com/</link>
        <description>lamp, ajax, linux, iphone, and other fun things</description>
        <language>en</language>
        <copyright>Copyright 2010</copyright>
        <lastBuildDate>Thu, 08 Oct 2009 18:20:09 -0600</lastBuildDate>
        <generator>http://www.sixapart.com/movabletype/</generator>
        <docs>http://www.rssboard.org/rss-specification</docs>
        
        <item>
            <title>MySQL Performance: # of columns vs varchars</title>
            <description><![CDATA[<p>I have long told fellow developers that trying to stick to tables that have entirely fixed width columns is good practice.</p>

<p>This tends to lead to, at the least, normalizing out text on a performance sensitive table/application.</p>

<p>Instead of:</p>

<blockquote class='code'>
CREATE TABLE foo (
  idx int(10) unsigned not null auto_increment primary key,
  productId int(10) unsigned not null,
  price decimal(7,2) not null,
  description text not null default '',
  KEY productId_idx(productId)
);
</blockquote>

<p>It might be broken up into:</p>

<blockquote class='code'>
CREATE TABLE foo (
  myInt int(10) unsigned not null auto_increment primary key,
  productId int(10) unsigned not null,
  price decimal(7,2) not null,
  KEY productId_idx(productId)
);
CREATE TABLE foo_text (
  foo int(10) unsigned not null primary key,
  text not null default ''
);
</blockquote>

<p>The idea is that if you're doing most operations with the "foo" table, you'll get much better performance without a variable width column (varchar, text, etc).</p>

<p>They used a table with a varchar(1) column, and got a massive performance hit, but only when the number of columns was large. I'd like to experiment to see if it is the number or pure width of the columns. (In short, compare something like 99xchar(3)+1 varchar(1), or 1xchar(297) + 1 varchar(1).<br />
</p>]]></description>
            <link>http://www.ender.com/2009/10/mysql-performance-of-columns-v.html</link>
            <guid>http://www.ender.com/2009/10/mysql-performance-of-columns-v.html</guid>
            
            
            <pubDate>Thu, 08 Oct 2009 18:20:09 -0600</pubDate>
        </item>
        
        <item>
            <title>MySQL NULL gotcha; or, yes, Virginia, types do matter</title>
            <description><![CDATA[<p>If you spend a lot of time dealing with languages that are loosely typed and have scalars running wild, then like me, you may be prone to doing something like this:</p>

<blockquote class='code'>
mysql> select NOW(); select GREATEST(NOW(), DATE_ADD(NOW(),INTERVAL 1 DAY));
+---------------------+
| NOW()               |
+---------------------+
| 2009-04-28 14:17:36 | 
+---------------------+
1 row in set (0.00 sec)

<p>+-------------------------------------------------+<br />
| GREATEST(NOW(), DATE_ADD(NOW(),INTERVAL 1 DAY)) |<br />
+-------------------------------------------------+<br />
| 2009-04-29 14:17:36                             | <br />
+-------------------------------------------------+<br />
1 row in set (0.00 sec)</p>

<p>mysql> select GREATEST(NULL, NOW());<br />
+-----------------------+<br />
| GREATEST(NULL, NOW()) |<br />
+-----------------------+<br />
| NULL                  | <br />
+-----------------------+<br />
1 row in set (0.00 sec)<br />
</blockquote></p>

<p>I'm glad the bug this caused had a minor impact, and this will hopefully be sufficient to slap me out of my loosely typed comfort zone for a while.<br />
</p>]]></description>
            <link>http://www.ender.com/2009/04/mysql-null-gotcha-or-yes-virgi.html</link>
            <guid>http://www.ender.com/2009/04/mysql-null-gotcha-or-yes-virgi.html</guid>
            
            
            <pubDate>Tue, 28 Apr 2009 15:15:51 -0600</pubDate>
        </item>
        
        <item>
            <title>Worth</title>
            <description><![CDATA[<p><a href='http://neopythonic.blogspot.com/'>This</a> may be worth following.</p>]]></description>
            <link>http://www.ender.com/2008/10/worth.html</link>
            <guid>http://www.ender.com/2008/10/worth.html</guid>
            
            
            <pubDate>Thu, 23 Oct 2008 00:41:57 -0600</pubDate>
        </item>
        
        <item>
            <title>Seinfeld is an appropriate Microsoft shill; Vista is a joke</title>
            <description><![CDATA[<p>I was pleased and amused at news that <a href='http://online.wsj.com/article/SB121928939429159525.html?mod=googlenews_wsj'>Seinfeld  will apparently pimp Vista</a>, which has been ravaged by issues such as <a href='http://www.tomshardware.com/reviews/xp-vs-vista,1531-11.html'>poor performance</a>, the way UAC <a href='http://msmvps.com/blogs/thenakedmvp/archive/2007/02/15/user-account-control-uac-on-vista-a-useless-feature-t.aspx'>trains users to click yes without providing real security</a>, to say nothing of how Vista <a href='http://www.electronista.com/articles/08/01/04/vista.drm.and.netflix/'>has horrible DRM</a>, which distrusts the user and <a href='http://arstechnica.com/articles/paedia/hardware/hdcp-vista.ars'>hurts consumers</a>.</p>

<p>Vista is so bad, Microsoft came up with this elaborate plan to <a href='http://www.betanews.com/article/Is_Microsofts_Mojave_Vista_experiment_backfiring_with_users/1217535233'>trick people into saying nice things about Vista</a>. It might be easy to trick a few novice users into thinking Vista looks neat when they're in a lab, but do they know about the performance issues it may have on their hardware, or the frustrating DRM? For that matter, can they navigate the small ocean of different Vista licenses to select the right one? Vista is not what you'd expect from a half-decade of development. When you spend billions upon billions of dollars on a new operating system, you'd expect more than a "<a href='http://defectivebydesign.org/'>Defective By Design</a>" piece of junk.</p>

<p>All this leads me to conclude that Seinfeld is the <b>perfect</b> spokesperson for Vista. Because Vista is a joke. Windows is the <a href='http://en.wikipedia.org/wiki/The_Smelly_Car'>Smelly Car</a> of personal computing. It makes computers stink, and Vista is just the latest horrible manifestation. </p>]]></description>
            <link>http://www.ender.com/2008/08/seinfeld-is-an-appropriate-mic.html</link>
            <guid>http://www.ender.com/2008/08/seinfeld-is-an-appropriate-mic.html</guid>
            
                <category domain="http://www.sixapart.com/ns/types#category">rants</category>
            
            
            <pubDate>Thu, 21 Aug 2008 19:44:00 -0600</pubDate>
        </item>
        
        <item>
            <title>If this is an iPhone killer, don&apos;t take out insurance yet</title>
            <description><![CDATA[<p>Seriously Wired, <a href='http://www.wired.com/gadgets/gadgetreviews/multimedia/2008/08/gallery_gadgets?slide=8&slideView=7'>what's wrong with you?</a></p>

<blockquote>The E71 looks more like a Blackberry Killer, but don't be fooled: This great white hope gives the iPhone a run for its money in a lot of different areas (yes, really).</blockquote>

<p>No, <b>not really</b>.</p>

<ul>
<li>Big, nasty keyboard</li>
<li>Display not as large as ipod, let alone iphone</li>
<li>MicroSD, but only 8GB.</li>
<li>$500 unlocked. Ouch. You're not iPhone 3.0, you know.</li>
<li>No headphone jack.</li>
</ul>

<p>So it's an iPhone killer because... uh... the battery lasts 3 days!  Yeah... because you can't do anything cool with it.</p>]]></description>
            <link>http://www.ender.com/2008/08/if-this-is-an-iphone-killer-do.html</link>
            <guid>http://www.ender.com/2008/08/if-this-is-an-iphone-killer-do.html</guid>
            
            
            <pubDate>Fri, 08 Aug 2008 00:41:08 -0600</pubDate>
        </item>
        
        <item>
            <title>Slacker</title>
            <description><![CDATA[<p>I'm aware I haven't posted much. That said, I'm hoping to have an app I've been working on for the GAE (Google App Engine) done shortly, and will post some impressions about the GAE, and Python. (Wait, do I need a new category?) </p>

<p>After that, now that Apple has opened the developer floodgates, it's time to put in some time with my Cocoa for MacOSX book, iphone dev docs, etc, and do some iphone work. I enjoy my own iphone way too much to not develop something for it. Yay open platform! I did a small app for PalmOS ages ago, never even distributed it, but just had to to do it because I loved my palm and there was a decent gcc-based toolchain.</p>

<p>I am planning to upgrade to 3g, despite battery concerns. If necessary, I will disable the 3g except when I expect to be using lots of data. I never had an issue with call quality, and don't talk enough (<100m a month on average) to care. Maybe I can figure out a way to make that hotkeyed in some way. (I'd like to have a handful of settings toggles available when you double-click home when locked, like the ipod controls)</p>

<p>I grabbed a <a href='http://svenontech.com/reviews/?p=74'>mybat external battery</a> for the iphone. We'll see how that works, but tucked in my laptop bag, hopefully that will be serviceable in the clutch when battery is low and a recharge opportunity is not coming.</p>]]></description>
            <link>http://www.ender.com/2008/07/slacker.html</link>
            <guid>http://www.ender.com/2008/07/slacker.html</guid>
            
            
            <pubDate>Mon, 14 Jul 2008 23:18:24 -0600</pubDate>
        </item>
        
        <item>
            <title>Xen and the Art of Virtualization</title>
            <description><![CDATA[<p>I have historically had several servers at <a href='http://www.layeredtech.com'>Layered Tech</a>. They recently raised their prices, and the prices for several friends who have hosted servers there. The majority of our use is low volume, experimental sorts of things, and so we decided to go in together on a larger box that we could virtualize.</p>

<p>Enter <a href='http://www.voxel.net'>Voxel</a>, who offer a $199/mo dedicated server that includes:</p>

<ul>
<li>4 GB RAM</li>
<li>Quad XEON 2Ghz</li>
<li>320GB SATA disk (which are growing more standard among these providers, but a lot of options are still IDE</li>
<li><b>SSH-accessible serial console access included</b></li>
</ul>

<p>That last one is a serious nod to their foresight and a judo chop to other providers. Layered Tech overs a KVM solution as a $30 or $35/day rental. Voxel automatically includes it.</p>

<p>Anyhow, with this beefy box, we set about setting up Xen. Voxel's support was admirable when my initial xen install broke the serial console access. It turned out my /etc/grub.conf needed a change:</p>

<blockquote class='code'>
title CentOS (2.6.18-53.1.21.el5xen)
        root (hd0,0)
        kernel /xen.gz-2.6.18-53.1.21.el5 <b>com1=9600,8n1</b>
        module /vmlinuz-2.6.18-53.1.21.el5xen ro root=LABEL=/ console=tty0 console=ttyS0,9600 panic=100
        module /initrd-2.6.18-53.1.21.el5xen.img
</blockquote>

<p>(Change in bold)</p>

<p>Without the com1= line, it defaulted to 38400.</p>

<p>Anyhow, with that done, I got to work actually setting up Xen virtual server instances. The host box (aka the Dom0) is CentOS, and so the "easy" install should be another instance of virtualized CentOS, although any variant should be usable. I tried to use virt-install, but it failed miserably.</p>

<p>First, I had issues with networking. Even when I resolved those, halfway through anaconda installing packages, the system crashed.</p>

<p>Ultimately, I settled on doing it manually using this guide to <a href='http://wiki.centos.org/HowTos/Xen/InstallingCentOSDomU'>installing CentOS DomUs on a CentOS Dom0</a>.</p>

<p>Caveats for me included the fact that my bridge was <b>virbr0</b> instead of <b>xenbr0</b>. I <b>have</b> a <b>xenbr0</b>, it just wasn't the correct bridge for RFC1918 going out...</p>

<p>Anyhow, aside from the networking problems, that went fairly smoothly. (Although the top of the guide has you selecting from i386 or x86_64, and the kickstart config just says i386, so I had to restart to correct that, since I was doing the x86_64 install.</p>

<p>Still on the agenda: getting a real IP address. Voxel offered a reasonable extra 8 IPs for $4/mo, and we'd like to ensure each VPS has its own IP address, not 192.168 addresses that translate.</p>

<p>Still, this has been a pretty fun thing so far. I've heard that Xen is what Amazon is using to provide AWS, and I've been learning a lot of new linux tools (like brctl; I'd never had a reason to do linux bridging prior to now, even though I've done it plenty with networking devices).</p>]]></description>
            <link>http://www.ender.com/2008/06/xen-and-the-art-of-virtualizat.html</link>
            <guid>http://www.ender.com/2008/06/xen-and-the-art-of-virtualizat.html</guid>
            
                <category domain="http://www.sixapart.com/ns/types#category">LAMP</category>
            
                <category domain="http://www.sixapart.com/ns/types#category">linux</category>
            
            
            <pubDate>Thu, 19 Jun 2008 19:10:44 -0600</pubDate>
        </item>
        
        <item>
            <title>jQuery 1.2.6</title>
            <description><![CDATA[<p>A couple weeks ago, the jQuery team released jquery 1.2.6.</p>

<p><a href='http://jquery.com'>jQuery</a> is <s>the write-once, run-anywhere</s> a new type of javascript library.</p>

<p>It's incredibly full of win. Favorite things in 1.2.6:</p>

<ul>
<li><b>Still small</b> (minified+gzipped, 15k)</li>
<li><b>Dimensions plugin</b> - I can see why. Dimensions was a godsend, providing totally important calls like $.position() and $.innerHeight() and whatnot. Indispensible.</li>
<li><b>makeArray</b> - <i>jQuery's internal .makeArray() method now converts any array-like object into a new array. Additionally it wraps all other objects as an array and returns the resulting set.</i>  This one is so wild, it will require further digestion, but there are plenty of possibilities</li>
</ul>

<p>I'm working on a brief introductions to jQuery I will post to go over a bunch of basic techniques; things that go a tiny bit beyond the jquery.com documentation usage.</p>]]></description>
            <link>http://www.ender.com/2008/06/jquery-126.html</link>
            <guid>http://www.ender.com/2008/06/jquery-126.html</guid>
            
                <category domain="http://www.sixapart.com/ns/types#category">AJAX</category>
            
                <category domain="http://www.sixapart.com/ns/types#category">Javascript</category>
            
                <category domain="http://www.sixapart.com/ns/types#category">jQuery</category>
            
            
            <pubDate>Tue, 10 Jun 2008 00:17:54 -0600</pubDate>
        </item>
        
        <item>
            <title>jquery, the jquery form plugin, and detecting an ajax submit</title>
            <description><![CDATA[<p>When you send a request via $.ajax, $.get, or $.post in jquery, you can test for the HTTP_X_REQUESTED_WITH header, looking for a value of 'XMLHttpRequest', a la:</p>

<blockquote class='code'>
function isajax() {
  return ((!empty($_SERVER['HTTP_X_REQUESTED_WITH'])) && 
    $_SERVER['HTTP_X_REQUESTED_WITH'] == 'XMLHttpRequest');
}

</blockquote>

<p>But what happens when you're using the <a href='http://www.malsup.com/jquery/form/'>jQuery Form plugin</a>? Normally, things work fine. Below the cut for a serious caveat!</p>]]></description>
            <link>http://www.ender.com/2008/04/jquery-the-jquery-form-plugin.html</link>
            <guid>http://www.ender.com/2008/04/jquery-the-jquery-form-plugin.html</guid>
            
                <category domain="http://www.sixapart.com/ns/types#category">AJAX</category>
            
                <category domain="http://www.sixapart.com/ns/types#category">Javascript</category>
            
                <category domain="http://www.sixapart.com/ns/types#category">LAMP</category>
            
                <category domain="http://www.sixapart.com/ns/types#category">jQuery</category>
            
            
            <pubDate>Tue, 08 Apr 2008 21:44:46 -0600</pubDate>
        </item>
        
        <item>
            <title>Event bubbling in Javascript</title>
            <description><![CDATA[<p>Today I had the opportunity to play with event bubbling and applying generic event handlers. Quick overview on handling them (with jquery!) and which events cannot be cancelled.</p>]]></description>
            <link>http://www.ender.com/2008/04/event-bubbling-in-javascript.html</link>
            <guid>http://www.ender.com/2008/04/event-bubbling-in-javascript.html</guid>
            
                <category domain="http://www.sixapart.com/ns/types#category">AJAX</category>
            
                <category domain="http://www.sixapart.com/ns/types#category">Javascript</category>
            
                <category domain="http://www.sixapart.com/ns/types#category">LAMP</category>
            
                <category domain="http://www.sixapart.com/ns/types#category">Web 2.0</category>
            
                <category domain="http://www.sixapart.com/ns/types#category">jQuery</category>
            
            
            <pubDate>Thu, 03 Apr 2008 20:55:54 -0600</pubDate>
        </item>
        
        <item>
            <title>Put this in your toolbox</title>
            <description><![CDATA[<p>I'm going to admit to not having used this yet. But having used a lot other solutions (most recently pear Safe_HTML with additional pre/post-processing), this is a breath of fresh air: <a href="http://htmlpurifier.org/">HTML Purifier</a></p>]]></description>
            <link>http://www.ender.com/2008/03/put-this-in-your-toolbox.html</link>
            <guid>http://www.ender.com/2008/03/put-this-in-your-toolbox.html</guid>
            
                <category domain="http://www.sixapart.com/ns/types#category">LAMP</category>
            
                <category domain="http://www.sixapart.com/ns/types#category">PHP</category>
            
            
            <pubDate>Thu, 20 Mar 2008 11:11:14 -0600</pubDate>
        </item>
        
        <item>
            <title>Hello again, Hello World</title>
            <description><![CDATA[<p><span class="mt-enclosure mt-enclosure-image" style="display: inline;"><img alt="hw.jpg" src="http://www.ender.com/photos/hw.jpg" width="644" height="776" class="mt-image-right" style="float: right; margin: 0 0 20px 20px;" /></span></p>

<p>Any programmer has done this one a thousand times. But this one is more fun than I remember this being before.</p>]]></description>
            <link>http://www.ender.com/2008/03/hello-again-hello-world.html</link>
            <guid>http://www.ender.com/2008/03/hello-again-hello-world.html</guid>
            
            
            <pubDate>Mon, 10 Mar 2008 22:05:42 -0600</pubDate>
        </item>
        
        <item>
            <title>MT 4.1</title>
            <description><![CDATA[<p>So, I've upgraded to Moveable Type 4.1, and I'm forcing commenters to use on the of the web login services (typekey, oid, etc). If that doesn't cut down on the spammers, then it's time to drop the hammer and put in an anti-spam plugin. But at least now that I am upgraded, getting such a plugin will be easier.</p>]]></description>
            <link>http://www.ender.com/2008/03/mt-41.html</link>
            <guid>http://www.ender.com/2008/03/mt-41.html</guid>
            
            
            <pubDate>Sat, 08 Mar 2008 21:50:23 -0600</pubDate>
        </item>
        
        <item>
            <title>MySQL Update Evaluation Gotcha</title>
            <description><![CDATA[<p>If you use MySQL, note this:</p>

<div style='background-color: #202020'><blockquote><pre>

<p>mysql> create database test;<br />
Query OK, 1 row affected (0.01 sec)</p>

<p>mysql> use test;<br />
Database changed<br />
mysql> create table foo (<br />
    -> x int,<br />
    -> y int<br />
    -> );<br />
Query OK, 0 rows affected (0.00 sec)</p>

<p>mysql> insert into foo values (1, 2);<br />
Query OK, 1 row affected (0.00 sec)</p>

<p>mysql> select * from foo;<br />
+------+------+<br />
| x    | y    |<br />
+------+------+<br />
|    1 |    2 |<br />
+------+------+<br />
1 row in set (0.00 sec)</p>

<p>mysql> update foo set x=5,y=10,x=x+y;<br />
Query OK, 1 row affected (0.00 sec)<br />
Rows matched: 1  Changed: 1  <b>Warnings: 0</b></p>

<p>mysql> select * from foo;<br />
+------+------+<br />
| x    | y    |<br />
+------+------+<br />
|   15 |   10 |<br />
+------+------+<br />
1 row in set (0.00 sec)</p>

<p>mysql><br />
</pre></blockquote></div></p>

<p>I bolded the part that bothers me. No warnings. Double-updating the same value in the same row in the same statement throws no warnings (never mind errors!).  I haven't checked the ANSI standard to see if this is mentioned, but it sure is worth noting.</p>]]></description>
            <link>http://www.ender.com/2007/08/mysql-update-evaluation-gotcha.html</link>
            <guid>http://www.ender.com/2007/08/mysql-update-evaluation-gotcha.html</guid>
            
                <category domain="http://www.sixapart.com/ns/types#category">LAMP</category>
            
                <category domain="http://www.sixapart.com/ns/types#category">MySQL</category>
            
            
            <pubDate>Mon, 13 Aug 2007 18:45:21 -0600</pubDate>
        </item>
        
        <item>
            <title>using procmail and MIME::Parser to extract iphone photo attachments</title>
            <description><![CDATA[<p>I have an iPhone. I'm finding myself very prone to snapping photos now, whereas before I was completely unlikely to tote a camera. I also discovered that Movable Type works just fine on the iPhone, I even posted an entry on my <a href='http://matt.mattwallace.net'>personal blog</a> from it while we were at the ice cream place.</p>

<p>But you know what? I want to put up a photo I just blogged. But transferring a photo via anything but email is a pain. Enter perl. I whipped up a perl script to receive iphone photo email, piped via procmail, and save the photo attachment to a path, then email back the phone address with the filename it used. Just make sure you set the path in the script to somewhere down from your DocumentRoot, and then you can immediately reference the photo with an img tag.</p>

<p>Now I can photoblog directly from the phone, which is pretty fun.</p>

<p>Requires<br />
sendmail (for the outbound msg, but I bet you could adapt any other mail program)<br />
perl<br />
MIME::Parser<br />
procmail</p>

<p>Here's the relevent part of my procmail entry (note that photoblog is an alias that goes to my user account via /etc/aliases):</p>

<div style='background-color: #202020'>
<blockquote><pre>
:0H
* ^TO.*photoblog@ender.com
|/home/matt/iphotoparse.pl
</pre></blockquote>
</div>

<p>And the code, which you can get here: <a href='http://www.ender.com/~matt/iphotoparse.pl.txt'>iphotoparse.pl</a></p>

<p>Happy photoblogging from the phone.<br />
</p>]]></description>
            <link>http://www.ender.com/2007/08/using-procmail-and-mimeparser.html</link>
            <guid>http://www.ender.com/2007/08/using-procmail-and-mimeparser.html</guid>
            
                <category domain="http://www.sixapart.com/ns/types#category">Cool</category>
            
                <category domain="http://www.sixapart.com/ns/types#category">Web 2.0</category>
            
                <category domain="http://www.sixapart.com/ns/types#category">iPhone</category>
            
            
            <pubDate>Sat, 11 Aug 2007 18:48:00 -0600</pubDate>
        </item>
        
    </channel>
</rss>
