<?xml version="1.0" encoding="utf-8"?>
<feed xmlns="http://www.w3.org/2005/Atom">
    <title>the ender.com blog</title>
    <link rel="alternate" type="text/html" href="http://www.ender.com/" />
    <link rel="self" type="application/atom+xml" href="http://www.ender.com/atom.xml" />
    <id>tag:www.ender.com,2008-04-03://2</id>
    <updated>2008-07-15T04:28:35Z</updated>
    <subtitle>lamp, ajax, linux, iphone, and other fun things</subtitle>
    <generator uri="http://www.sixapart.com/movabletype/">Movable Type Open Source 4.1</generator>

<entry>
    <title>Slacker</title>
    <link rel="alternate" type="text/html" href="http://www.ender.com/2008/07/slacker.html" />
    <id>tag:www.ender.com,2008://2.106</id>

    <published>2008-07-15T04:18:24Z</published>
    <updated>2008-07-15T04:28:35Z</updated>

    <summary>I&apos;m aware I haven&apos;t posted much. That said, I&apos;m hoping to have an app I&apos;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...</summary>
    <author>
        <name>Matt</name>
        <uri>http://www.mattwallace.net/</uri>
    </author>
    
    
    <content type="html" xml:lang="en" xml:base="http://www.ender.com/">
        <![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>]]>
        
    </content>
</entry>

<entry>
    <title>Xen and the Art of Virtualization</title>
    <link rel="alternate" type="text/html" href="http://www.ender.com/2008/06/xen-and-the-art-of-virtualizat.html" />
    <id>tag:www.ender.com,2008://2.103</id>

    <published>2008-06-20T00:10:44Z</published>
    <updated>2008-06-20T02:10:05Z</updated>

    <summary>I have historically had several servers at Layered Tech. 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...</summary>
    <author>
        <name>Matt</name>
        <uri>http://www.mattwallace.net/</uri>
    </author>
    
        <category term="LAMP" scheme="http://www.sixapart.com/ns/types#category" />
    
        <category term="linux" scheme="http://www.sixapart.com/ns/types#category" />
    
    
    <content type="html" xml:lang="en" xml:base="http://www.ender.com/">
        <![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>]]>
        
    </content>
</entry>

<entry>
    <title>jQuery 1.2.6</title>
    <link rel="alternate" type="text/html" href="http://www.ender.com/2008/06/jquery-126.html" />
    <id>tag:www.ender.com,2008://2.102</id>

    <published>2008-06-10T05:17:54Z</published>
    <updated>2008-06-10T05:28:19Z</updated>

    <summary>A couple weeks ago, the jQuery team released jquery 1.2.6. jQuery is the write-once, run-anywhere a new type of javascript library. It&apos;s incredibly full of win. Favorite things in 1.2.6: Still small (minified+gzipped, 15k) Dimensions plugin - I can see...</summary>
    <author>
        <name>Matt</name>
        <uri>http://www.mattwallace.net/</uri>
    </author>
    
        <category term="AJAX" scheme="http://www.sixapart.com/ns/types#category" />
    
        <category term="Javascript" scheme="http://www.sixapart.com/ns/types#category" />
    
        <category term="jQuery" scheme="http://www.sixapart.com/ns/types#category" />
    
    
    <content type="html" xml:lang="en" xml:base="http://www.ender.com/">
        <![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>]]>
        
    </content>
</entry>

<entry>
    <title>jquery, the jquery form plugin, and detecting an ajax submit</title>
    <link rel="alternate" type="text/html" href="http://www.ender.com/2008/04/jquery-the-jquery-form-plugin.html" />
    <id>tag:www.ender.com,2008://2.91</id>

    <published>2008-04-09T02:44:46Z</published>
    <updated>2008-04-09T03:14:29Z</updated>

    <summary><![CDATA[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: function isajax() { return ((!empty($_SERVER['HTTP_X_REQUESTED_WITH'])) && $_SERVER['HTTP_X_REQUESTED_WITH'] == 'XMLHttpRequest'); } But what happens...]]></summary>
    <author>
        <name>Matt</name>
        <uri>http://www.mattwallace.net/</uri>
    </author>
    
        <category term="AJAX" scheme="http://www.sixapart.com/ns/types#category" />
    
        <category term="Javascript" scheme="http://www.sixapart.com/ns/types#category" />
    
        <category term="LAMP" scheme="http://www.sixapart.com/ns/types#category" />
    
        <category term="jQuery" scheme="http://www.sixapart.com/ns/types#category" />
    
    
    <content type="html" xml:lang="en" xml:base="http://www.ender.com/">
        <![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>]]>
        <![CDATA[<p>The jQuery form plugin supports posting uploads. However, when an upload is posted, the form plugin instantiates an iframe and submits that form, since xmlhttprequest can't be encoded for file uploads.</p>

<p>Therein lies the problem: that xmlhttprequest header will not be set.</p>

<p>I handled it with a hidden field:</p>

<blockquote class='code'>
&lt;form method='POST' action='/something.php'&gt;
  &lt;input type='hidden' name='isajaxrequest'
    id='isajaxrequest' value='0' /&gt;
  [...]
&lt;/form&gt;

</blockquote>

<p>Now you have a magic variable to check. Then, in your jquery:</p>

<blockquote class='code'>
$("#myform").ajaxForm() {
 [...]
 beforeSubmit: function (formData, jqForm, options) {
    $("#isajaxrequest").attr("value", 1);
})
 [...]
}

</blockquote>

<p>This way, if your form is submitted via iframe, $_REQUEST['isajaxrequest'] (in php parlance) will be non-zero.</p>

<p>WARNING: the isajaxrequest field will only work as presented here in the iframe; so you still have to test for the server header AND the isajaxrequest variable. Why? Because by the time the form plugin calls beforeSubmit, it has already copied the form into an object which will be used to serialize and submit it, and changes to the form do not propagate. What's interesting is, if you apply ajaxForm to a form with an input type='file', it will only use the iframe if that field is selected. So on the same form, clicking submit with the file selected will use an iframe, but clicking submit when the file field is empty will let it submit over xmlhttprequest.</p>

<p>You *can* still use beforeSubmit to set the field regardless, but you'll have to navigate the formData array, which is an array of js objects, like: <b> [ { "name": "isajaxrequest", "value": "1"}, {"name": "someotherfield", "value": "someothervalue" } ]</b></p>

<p>Not particularly something you want to iterate through if you can avoid it, although if you're concerned about a proxy stripping the xmlhttprequest header, you may want to do it anyhow.</p>]]>
    </content>
</entry>

<entry>
    <title>Event bubbling in Javascript</title>
    <link rel="alternate" type="text/html" href="http://www.ender.com/2008/04/event-bubbling-in-javascript.html" />
    <id>tag:www.ender.com,2008://2.88</id>

    <published>2008-04-04T02:55:54Z</published>
    <updated>2008-04-04T03:00:11Z</updated>

    <summary>By carefully using generic event handlers, you can handle events even with a dynamic document.</summary>
    <author>
        <name>Matt</name>
        <uri>http://www.mattwallace.net/</uri>
    </author>
    
        <category term="AJAX" scheme="http://www.sixapart.com/ns/types#category" />
    
        <category term="Javascript" scheme="http://www.sixapart.com/ns/types#category" />
    
        <category term="LAMP" scheme="http://www.sixapart.com/ns/types#category" />
    
        <category term="Web 2.0" scheme="http://www.sixapart.com/ns/types#category" />
    
        <category term="jQuery" scheme="http://www.sixapart.com/ns/types#category" />
    
    
    <content type="html" xml:lang="en" xml:base="http://www.ender.com/">
        <![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>]]>
        <![CDATA[<h3>Why use generic handlers?</h3>

<p>If you are making a dynamic document, you know that CSS settings are applied as entries are inserted. If you dynamically create a div with class="foo", and you have a ".foo" style defined in your stylesheet(s), then it will inherit it automatically.</p>

<p>If you bind to every class="foo" element on a page at some point (say, with $(".foo").bind() with <a href='http://www.jquery.com'>jquery</a>), then append more elements with that class, they do NOT automatically inherit the event binding.</p>

<h3>How to get around it</h3>

<p>To get around this shortcoming, you can bind your event handler to a higher level event. I'm going to describe it with jquery. For example, let's assume you want to check for clicks on all divs with a class "foo", and make the background color red.</p>

<p>Here's the 'old' way with jquery:</p>

<blockquote class='code'>
$(".foo").bind("click", function(e) {
  $(this).css({'backgroundColor': 'red'});
});
</blockquote>

<p>The problem is, if you add a new div into the DOM, it will not have that event binding.</p>

<p>Here's the 'new' way:</p>

<blockquote class='code'>
$(document.body).bind("click", function(e) {
  var $target = $(e.target);
  if ($target.is(".foo")) {
    $target.css({'backgroundColor': 'red'});
  }
});
</blockquote>

<p>Pretty simple, right? Actually, it is. And it's less code and less of a pain than all the code required to bind new elements coming in most likely. Here's the code at work. Elements with class foo are bound to change bgcolor to red when clicked:</p>

<blockquote>
<iframe width='500' src='http://www.ender.com/~matt/bubbleDemo.html'></iframe>
</blockquote>

<h3>What can go wrong?</h3>

<p>The major problem is events that don't bubble up. The <a href='http://en.wikipedia.org/wiki/DOM_Events'>wikipedia entry on DOM events</a> has a nice list of events with their Bubble property - among those that <b>don't</b> bubble up: load, unload, focus (which was the one that prompted me to investigate), blur, DOMNode(RemovedFrom|InsertedInto)Document, rowexit, and others.</p>

<p>Still, this is an awesome technique. The more you make your page dynamic, the more useful it becomes.</p>]]>
    </content>
</entry>

<entry>
    <title>Put this in your toolbox</title>
    <link rel="alternate" type="text/html" href="http://www.ender.com/2008/03/put-this-in-your-toolbox.html" />
    <id>tag:www.ender.com,2008://2.87</id>

    <published>2008-03-20T17:11:14Z</published>
    <updated>2008-03-20T17:13:01Z</updated>

    <summary>I&apos;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: HTML Purifier...</summary>
    <author>
        <name>Matt</name>
        <uri>http://www.mattwallace.net/</uri>
    </author>
    
        <category term="LAMP" scheme="http://www.sixapart.com/ns/types#category" />
    
        <category term="PHP" scheme="http://www.sixapart.com/ns/types#category" />
    
    
    <content type="html" xml:lang="en" xml:base="http://www.ender.com/">
        <![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>]]>
        
    </content>
</entry>

<entry>
    <title>Hello again, Hello World</title>
    <link rel="alternate" type="text/html" href="http://www.ender.com/2008/03/hello-again-hello-world.html" />
    <id>tag:www.ender.com,2008://2.83</id>

    <published>2008-03-11T04:05:42Z</published>
    <updated>2008-03-11T04:09:47Z</updated>

    <summary> Any programmer has done this one a thousand times. But this one is more fun than I remember this being before....</summary>
    <author>
        <name>Matt</name>
        <uri>http://www.mattwallace.net/</uri>
    </author>
    
    
    <content type="html" xml:lang="en" xml:base="http://www.ender.com/">
        <![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>]]>
        
    </content>
</entry>

<entry>
    <title>MT 4.1</title>
    <link rel="alternate" type="text/html" href="http://www.ender.com/2008/03/mt-41.html" />
    <id>tag:www.ender.com,2008://2.81</id>

    <published>2008-03-09T03:50:23Z</published>
    <updated>2008-03-09T03:52:05Z</updated>

    <summary>So, I&apos;ve upgraded to Moveable Type 4.1, and I&apos;m forcing commenters to use on the of the web login services (typekey, oid, etc). If that doesn&apos;t cut down on the spammers, then it&apos;s time to drop the hammer and put...</summary>
    <author>
        <name>Matt</name>
        <uri>http://www.mattwallace.net/</uri>
    </author>
    
    
    <content type="html" xml:lang="en" xml:base="http://www.ender.com/">
        <![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>]]>
        
    </content>
</entry>

<entry>
    <title>MySQL Update Evaluation Gotcha</title>
    <link rel="alternate" type="text/html" href="http://www.ender.com/2007/08/mysql-update-evaluation-gotcha.html" />
    <id>tag:www.ender.com,2007://2.66</id>

    <published>2007-08-13T23:45:21Z</published>
    <updated>2007-08-13T23:48:53Z</updated>

    <summary>If you use MySQL, note this: mysql&gt; create database test; Query OK, 1 row affected (0.01 sec) mysql&gt; use test; Database changed mysql&gt; create table foo ( -&gt; x int, -&gt; y int -&gt; ); Query OK, 0 rows affected...</summary>
    <author>
        <name>Matt</name>
        <uri>http://www.mattwallace.net/</uri>
    </author>
    
        <category term="LAMP" scheme="http://www.sixapart.com/ns/types#category" />
    
        <category term="MySQL" scheme="http://www.sixapart.com/ns/types#category" />
    
    
    <content type="html" xml:lang="en" xml:base="http://www.ender.com/">
        <![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>]]>
        
    </content>
</entry>

<entry>
    <title>using procmail and MIME::Parser to extract iphone photo attachments</title>
    <link rel="alternate" type="text/html" href="http://www.ender.com/2007/08/using-procmail-and-mimeparser.html" />
    <id>tag:www.ender.com,2007://2.65</id>

    <published>2007-08-11T23:48:00Z</published>
    <updated>2007-08-12T02:03:14Z</updated>

    <summary>I have an iPhone. I&apos;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...</summary>
    <author>
        <name>Matt</name>
        <uri>http://www.mattwallace.net/</uri>
    </author>
    
        <category term="Cool" scheme="http://www.sixapart.com/ns/types#category" />
    
        <category term="Web 2.0" scheme="http://www.sixapart.com/ns/types#category" />
    
        <category term="iPhone" scheme="http://www.sixapart.com/ns/types#category" />
    
    
    <content type="html" xml:lang="en" xml:base="http://www.ender.com/">
        <![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>]]>
        
    </content>
</entry>

<entry>
    <title>iPhone, glorious iPhone</title>
    <link rel="alternate" type="text/html" href="http://www.ender.com/2007/08/iphone-glorious-iphone.html" />
    <id>tag:www.ender.com,2007://2.63</id>

    <published>2007-08-04T05:53:40Z</published>
    <updated>2007-08-04T05:57:27Z</updated>

    <summary>i has a iphone? It&apos;s true. I&apos;m one of the converted. (Fallen?) I definitely like it so far, although I was unimpressed with battery the first day. It really should be engineered to survive one day of hard use. I...</summary>
    <author>
        <name>Matt</name>
        <uri>http://www.mattwallace.net/</uri>
    </author>
    
        <category term="iPhone" scheme="http://www.sixapart.com/ns/types#category" />
    
    
    <content type="html" xml:lang="en" xml:base="http://www.ender.com/">
        <![CDATA[<p>i has a iphone?</p>

<p>It's true. I'm one of the converted. (Fallen?)</p>

<p>I definitely like it so far, although I was unimpressed with battery the first day. It really should be engineered to survive one day of hard use. I was charging it until late last night. I watched youtube from it in bed for about 30 minutes, had a total of 14 hrs of standby, and then about 6 or so hours of use (mostly as an ipod, small bit of phone). It died while I was talking to my wife en route home.</p>

<p>Rumor has it that bluetooth, and the "prompt" wlan networks features both suck up a lot of bandwidth, so I may try to keep those off when possible. (I'm going to turn bluetooth off while driving, damnit, but I don't really need it otherwise).</p>]]>
        
    </content>
</entry>

<entry>
    <title>dojo.lang.hitch</title>
    <link rel="alternate" type="text/html" href="http://www.ender.com/2007/08/dojolanghitch.html" />
    <id>tag:www.ender.com,2007://2.62</id>

    <published>2007-08-04T05:05:58Z</published>
    <updated>2007-08-04T05:50:10Z</updated>

    <summary><![CDATA[A few weeks ago, I was wrestling with one of those things that I used to consider a major pain with javascript: meshing objects and event handling. Let's say you have some code. Sloppy, but demonstrative: &lt;html&gt; &lt;head&gt; &lt;script lanugage='Javascript'...]]></summary>
    <author>
        <name>Matt</name>
        <uri>http://www.mattwallace.net/</uri>
    </author>
    
        <category term="AJAX" scheme="http://www.sixapart.com/ns/types#category" />
    
        <category term="Javascript" scheme="http://www.sixapart.com/ns/types#category" />
    
    
    <content type="html" xml:lang="en" xml:base="http://www.ender.com/">
        <![CDATA[<p>A few weeks ago, I was wrestling with one of those things that I used to consider a major pain with javascript: meshing objects and event handling.</p>

<p>Let's say you have some code. Sloppy, but demonstrative:</p>

<blockquote><font face='courier'>

<p>&lt;html&gt;<br />
&lt;head&gt;<br />
&lt;script lanugage='Javascript' src='dojo/dojo.js'&gt;&lt;/script&gt;<br />
&lt;script&gt;<br />
dojo.require("dojo.lang.*");<br />
&lt;/script&gt;<br />
&lt;/head&gt;<br />
&lt;body&gt;<br />
&lt;div id='output' name='output'&gt;&lt;/div&gt;<br />
&lt;script language='Javascript'&gt;<br />
function foo() {<br />
  var x;<br />
  var y;<br />
  this.go = function() {document.getElementById('output').innerHTML += 'this.x is ' + this.x + '&lt;br /&gt;';}<br />
}<br />
var fooz = new foo;<br />
fooz.x = 5;<br />
document.getElementById('output').innerHTML += 'fooz.x is ' + fooz.x + '&lt;br /&gt;';<br />
<b>setTimeout(fooz.go, 300);</b><br />
&lt;/script&gt;<br />
&lt;/body&gt;<br />
&lt;/html&gt;<br />
</font></blockquote></p>

<p>What happens when you run it?</p>

<blockquote>
fooz.x is 5
this.x is undefined
</blockquote>

<p>Javascript objects do not stay instantiated when passed into setTimeout. setTimeout() is unavoidable, but I often find that when implementing behaviors which need objects, you're forced into one of two nasty choices:</p>

<ul><li>Give everything an id, and pass that id into setTimeout in order to maintain some sort of scope</li>
<li>Watch everything lose context when passing through setTimeout</li>
</ul>

<p>Not pretty choices.</p>

<p>But dojo.hang.hitch() solves that problem, gloriously. dojo.lang.hitch lets you attach a function to run IN THE SCOPE of an object.</p>

<p>Let's change the code above:</p>

<blockquote><font face='courier'>

<p>&lt;html&gt;<br />
&lt;head&gt;<br />
&lt;script lanugage='Javascript' src='dojo/dojo.js'&gt;&lt;/script&gt;<br />
&lt;script&gt;<br />
dojo.require("dojo.lang.*");<br />
&lt;/script&gt;<br />
&lt;/head&gt;<br />
&lt;body&gt;<br />
&lt;div id='output' name='output'&gt;&lt;/div&gt;<br />
&lt;script language='Javascript'&gt;<br />
function foo() {<br />
  var x;<br />
  var y;<br />
  this.go = function() {document.getElementById('output').innerHTML += 'this.x is ' + this.x + '&lt;br /&gt;';}<br />
}<br />
var fooz = new foo;<br />
fooz.x = 5;<br />
document.getElementById('output').innerHTML += 'fooz.x is ' + fooz.x + '&lt;br /&gt;';<br />
<b>setTimeout(dojo.lang.hitch(fooz, fooz.go), 300);</b><br />
&lt;/script&gt;<br />
&lt;/body&gt;<br />
&lt;/html&gt;<br />
</font><br />
</blockquote></p>

<p>Output now:</p>

<p>fooz.x is 5<br />
this.x is 5</p>

<p>Beautiful.</p>

<p>What's great is that this lets you run events on things without IDs. I dynamically instantiate a lot of elements in the DOM with document.createElement, and there's often no NEED to assign an id except for issues like this; handling events. Now, with DOJO's hitching, you can deal with your objects while preserving context through setTimeout calls.</p>

<p>Dojo is filled with gems.</p>

<p>Check out the <a href='http://dojotoolkit.org/'>Dojo Homepage</a> and this little <a href='http://developer.iamalpha.com/dojo-intro'>into to dojo</a> isn't bad either.</p>]]>
        
    </content>
</entry>

<entry>
    <title>Time for some tech and blogging</title>
    <link rel="alternate" type="text/html" href="http://www.ender.com/2007/07/time-for-some-tech-and-bloggin.html" />
    <id>tag:www.ender.com,2007://2.60</id>

    <published>2007-07-06T06:38:53Z</published>
    <updated>2007-07-06T06:46:11Z</updated>

    <summary>It&apos;s time to get some blogging going on. Yes, it&apos;s been a while. Up on the list of tech projects that need some lovin: (1) Automated invoicing for monthly payees (2) UPS automatic price acquisition through their api Longer term...</summary>
    <author>
        <name>Matt</name>
        <uri>http://www.mattwallace.net/</uri>
    </author>
    
        <category term="Notes" scheme="http://www.sixapart.com/ns/types#category" />
    
    
    <content type="html" xml:lang="en" xml:base="http://www.ender.com/">
        <![CDATA[<p>It's time to get some blogging going on. Yes, it's been a while. Up on the list of tech projects that need some lovin:</p>

<p>(1) Automated invoicing for monthly payees<br />
(2) UPS automatic price acquisition through their api</p>

<p>Longer term I'm tempted to fiddle with some sort of turbo scaffolding system. I've played a few, like cakephp, but was left wanting. I also want to dig into dojo a bit more, and possibly see what 0.9 has been adding; I like 0.4, but some things I've seen (e.g., drag n drop) are lacking (like with dnd, it uses a nasty black bar for the drop targeting rather than dynamic element repositioning).</p>]]>
        
    </content>
</entry>

<entry>
    <title>You have been pwned by a grue</title>
    <link rel="alternate" type="text/html" href="http://www.ender.com/2006/09/you-have-been-pwned-by-a-grue.html" />
    <id>tag:www.ender.com,2006://2.49</id>

    <published>2006-09-04T07:56:13Z</published>
    <updated>2006-09-04T07:57:50Z</updated>

    <summary><![CDATA[Welcome to Text-Only Counterstrike You are in a dark, outdoor map. &gt; GO NORTH You have been pwned by a grue....]]></summary>
    <author>
        <name>Matt</name>
        <uri>http://www.mattwallace.net/</uri>
    </author>
    
        <category term="Cool" scheme="http://www.sixapart.com/ns/types#category" />
    
    
    <content type="html" xml:lang="en" xml:base="http://www.ender.com/">
        <![CDATA[<p><b>Welcome to Text-Only Counterstrike</b></p>

<p>You are in a dark, outdoor map.<br />
<b>&gt;</b> GO NORTH<br />
<a href='http://xkcd.com/c91.html'>You have been pwned by a grue.</a></p>]]>
        
    </content>
</entry>

<entry>
    <title>Gotta love &apos;em</title>
    <link rel="alternate" type="text/html" href="http://www.ender.com/2006/08/gotta-love-em.html" />
    <id>tag:www.ender.com,2006://2.48</id>

    <published>2006-08-30T06:54:05Z</published>
    <updated>2006-08-30T07:03:50Z</updated>

    <summary>Cool nerds. Jeff Bezos Such an alpha nerd. He&apos;s rumored to be a crazed idea guy who can brainstorm up innovation the way most people decide what to have for lunch. The Taco Bell commercials, the bizarre business branches of...</summary>
    <author>
        <name>Matt</name>
        <uri>http://www.mattwallace.net/</uri>
    </author>
    
        <category term="Cool" scheme="http://www.sixapart.com/ns/types#category" />
    
    
    <content type="html" xml:lang="en" xml:base="http://www.ender.com/">
        <![CDATA[<p>Cool nerds.</p>

<p><b>Jeff Bezos</b></p>

<p>Such an alpha nerd. He's rumored to be a crazed idea guy who can brainstorm up innovation the way most people decide what to have for lunch. The Taco Bell commercials, the bizarre business branches of Amazon, they all just add to the mystique. I just wish he'd fight harder for patent reform.</p>

<p><b>Mark Cuban</b></p>

<p>You just have to love <a href='http://www.blogmaverick.com'>Mark Cuban</a>. Fired for closing a sale, relentless entrepreneuer, funds the EFF, looking for disruptive tech all the time... he's awesome. And his irreverent personality is the clincher. More fines than anyone in NBA history? Check. Anything he can't do? I'll leave that box blank.</p>

<p><b>Richard Branson</b></p>

<p>You just gotta love it. Self made mania, with little tentacles in so many diverse industries, you have to wonder if his prowess just comes from a deal with the devil. Music, transportation, cell phones, health clubs... this guy is awesome.</p>

<p><b>Janus Friis, Niklas Zennstrom</b></p>

<p>First, you make Kazaa. Then, because you can't buy the particular small country you wanted, you make Skype. After pocketing 2.4B from that, you're still thinking: what next? So you start making a P2P TV app. THYS? Bad. Ass. They're like a more commercialized version of Justin Frankel, on crack.</p>]]>
        
    </content>
</entry>

</feed>
