<?xml version="1.0" encoding="UTF-8"?>
<?xml-stylesheet type="text/xsl" media="screen" href="/~d/styles/atom10full.xsl"?><?xml-stylesheet type="text/css" media="screen" href="http://feeds.feedburner.com/~d/styles/itemcontent.css"?><feed xmlns="http://www.w3.org/2005/Atom" xmlns:openSearch="http://a9.com/-/spec/opensearch/1.1/" xmlns:georss="http://www.georss.org/georss" xmlns:gd="http://schemas.google.com/g/2005" gd:etag="W/&quot;DkQBQHgyeCp7ImA9WxBaEkw.&quot;"><id>tag:blogger.com,1999:blog-33260599</id><updated>2010-03-21T16:32:31.690-07:00</updated><title>Imposterrific</title><subtitle type="html">Coding can be fun!</subtitle><link rel="http://schemas.google.com/g/2005#feed" type="application/atom+xml" href="http://blog.jeffscudder.com/feeds/posts/default" /><link rel="alternate" type="text/html" href="http://blog.jeffscudder.com/" /><link rel="next" type="application/atom+xml" href="http://www.blogger.com/feeds/33260599/posts/default?start-index=26&amp;max-results=25&amp;redirect=false&amp;v=2" /><author><name>Jeffrey Scudder</name><uri>http://www.blogger.com/profile/13002167096451875802</uri><email>noreply@blogger.com</email></author><generator version="7.00" uri="http://www.blogger.com">Blogger</generator><openSearch:totalResults>86</openSearch:totalResults><openSearch:startIndex>1</openSearch:startIndex><openSearch:itemsPerPage>25</openSearch:itemsPerPage><atom10:link xmlns:atom10="http://www.w3.org/2005/Atom" rel="self" type="application/atom+xml" href="http://feeds.feedburner.com/Imposterrific" /><feedburner:info xmlns:feedburner="http://rssnamespace.org/feedburner/ext/1.0" uri="imposterrific" /><atom10:link xmlns:atom10="http://www.w3.org/2005/Atom" rel="hub" href="http://pubsubhubbub.appspot.com/" /><entry gd:etag="W/&quot;DkYBRn8_eSp7ImA9WxBUGUU.&quot;"><id>tag:blogger.com,1999:blog-33260599.post-3898783742476646871</id><published>2010-02-08T22:51:00.001-08:00</published><updated>2010-03-07T09:49:17.141-08:00</updated><app:edited xmlns:app="http://www.w3.org/2007/app">2010-03-07T09:49:17.141-08:00</app:edited><category scheme="http://www.blogger.com/atom/ns#" term="blogger" /><category scheme="http://www.blogger.com/atom/ns#" term="css" /><title>New Blog Template</title><content type="html">With the growing popularity of mobile phones and lower resolution netbooks, a fixed width blog format is looking less and less appealing. I decided to work on a new look for this blog. The main feature I was looking for was a set of CSS rules that would allow the main content to scale with the viewer's browser window width. If the window is too narrow, the less important content on the sidebar should flow down below the main content.&lt;br /&gt;&lt;br /&gt;I began with an existing theme for Blogger, Tekka, that pushes the right sidebar down beneath the main content when the window is narrow. I then made some CSS changes to tweak the look to fit my tastes.&lt;br /&gt;&lt;br /&gt;First things first, the default fonts must go! I drew much of my inspiration from &lt;a href="http://blog.notdot.net/"&gt;Nick Johnson's blog&lt;/a&gt;, specifically the way that serif fonts are used in some places for accent while sans-serif is used for most of the content. This is a technique that I experimented with a bit in a graphic design class in college.&lt;br /&gt;&lt;br /&gt;For titles I added:&lt;pre&gt;h1, h2 {&lt;br /&gt;  ...&lt;br /&gt;  font-family: Georgia, 'Times New Roman', Times, serif;&lt;br /&gt;}&lt;br /&gt;&lt;br /&gt;h3 {&lt;br /&gt;  ...&lt;br /&gt;  font-family: Trebuchet MS, Verdana, Sans-serif;&lt;br /&gt;}&lt;/pre&gt;To change the font used for the main text in the page, I set a template variable as follows:&lt;pre&gt;&amp;lt;Variable name="bodyFont" description="Text Font"&lt;br /&gt;  type="font" &lt;br /&gt;  default="normal normal 100% 'Lucida Grande', &lt;br /&gt;    Verdana, Helvetica, sans-serif" &lt;br /&gt;  value="normal normal 100% 'Lucida Grande', &lt;br /&gt;    Verdana, Helvetica, sans-serif"&amp;gt;&lt;/pre&gt;Next I set about changing the style of the title link. You see, when someone is viewing a single post, the blog title becomes a link to the main blog page. So, the blog's title is styled like a link and I found the default link styles a bit jarring. This might seem like a minor change but so often it's the little things that matter. I set this style using&lt;pre&gt;h1 a:visited {&lt;br /&gt;  ...&lt;br /&gt;  color: #505050;&lt;br /&gt;}&lt;/pre&gt;Now that the text styling is done, the layout could use a bit of adjustment. I changed the margins on the main content to the following:&lt;pre&gt;#content-wrapper { &lt;br /&gt;  margin-top: 20px;&lt;br /&gt;  margin-$endSide: 30px;&lt;br /&gt;  margin-bottom: 30;&lt;br /&gt;  margin-$startSide: 35px;&lt;br /&gt; }&lt;/pre&gt;I removed the padding from the &lt;code&gt;h1&lt;/code&gt; title style and the date header. I also removed the style rule entirely for the description.&lt;br /&gt;&lt;br /&gt;We're nearing the end! The sidebar wasn't quite to my liking so I changed the border style. Lastly, in order to get the sidebar to flow down beneath the main content I set a minimum width. Here is the final style for the sidebar:&lt;pre&gt;#sidebar {&lt;br /&gt;  text-transform:none;&lt;br /&gt;  background-color: $sidebarBgColor;&lt;br /&gt;  color: $sidebarTextColor;&lt;br /&gt;  padding-$startSide: 20px;&lt;br /&gt;  width: 30%;&lt;br /&gt;  min-width: 215px;&lt;br /&gt;  float: $endSide;&lt;br /&gt;  font: $bodyFont;&lt;br /&gt;  border-$startSide:1px solid $mainTextColor;&lt;br /&gt;  word-wrap: break-word;&lt;br /&gt;  overflow: hidden;&lt;br /&gt;}&lt;/pre&gt;I debated about posting the whole template here, but I'm not sure that it would be very readable. If you would like the whole thing, leave a comment and I can email it to you.&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/33260599-3898783742476646871?l=blog.jeffscudder.com' alt='' /&gt;&lt;/div&gt;</content><link rel="replies" type="application/atom+xml" href="http://blog.jeffscudder.com/feeds/3898783742476646871/comments/default" title="Post Comments" /><link rel="replies" type="text/html" href="https://www.blogger.com/comment.g?blogID=33260599&amp;postID=3898783742476646871" title="1 Comments" /><link rel="edit" type="application/atom+xml" href="http://www.blogger.com/feeds/33260599/posts/default/3898783742476646871?v=2" /><link rel="self" type="application/atom+xml" href="http://www.blogger.com/feeds/33260599/posts/default/3898783742476646871?v=2" /><link rel="alternate" type="text/html" href="http://blog.jeffscudder.com/2010/02/new-blog-template.html" title="New Blog Template" /><author><name>Jeffrey Scudder</name><uri>http://www.blogger.com/profile/13002167096451875802</uri><email>noreply@blogger.com</email><gd:extendedProperty name="OpenSocialUserId" value="00750547326625434286" /></author><thr:total xmlns:thr="http://purl.org/syndication/thread/1.0">1</thr:total></entry><entry gd:etag="W/&quot;A0YMRng6eCp7ImA9WxBWFkQ.&quot;"><id>tag:blogger.com,1999:blog-33260599.post-354090936792118313</id><published>2010-01-13T23:45:00.000-08:00</published><updated>2010-02-08T23:06:27.610-08:00</updated><app:edited xmlns:app="http://www.w3.org/2007/app">2010-02-08T23:06:27.610-08:00</app:edited><category scheme="http://www.blogger.com/atom/ns#" term="q12" /><category scheme="http://www.blogger.com/atom/ns#" term="JavaScript" /><category scheme="http://www.blogger.com/atom/ns#" term="css" /><title>DOM Manipulation in JavaScript, a Utility</title><content type="html">In my latest addition to the &lt;a href="http://code.google.com/p/q12/"&gt;q12 JavaScript library&lt;/a&gt;, I have added a simple function to construct a nested document structure. I grew tired of writing repetitive and difficult to follow code like this &lt;pre&gt;var div = document.createElement('div');&lt;br /&gt;div['id'] = 'outer-div';&lt;br /&gt;var link = document.createElement('a');&lt;br /&gt;link.href = 'http://blog.jeffscudder.com';&lt;br /&gt;link.appendChild(document.createTextNode('my blog'));&lt;br /&gt;div.appendChild(link);&lt;/pre&gt;Using the new tree function this would become:&lt;pre&gt;var div = tree([&lt;br /&gt;    'div', {&lt;br /&gt;        id: 'outer-div'}, [&lt;br /&gt;      'a', {&lt;br /&gt;          href: 'http://blog.jeffscudder.com'}, [&lt;br /&gt;        'my blog']]]);&lt;/pre&gt;In the process of writing this utility function, I came across another small oddity in editing HTML using JavaScript related to the style attribute. Most HTML attributes are simple text properties, however when editing the CSS style of a node, you cannot set the full content of the style attribute. &lt;pre&gt;// You cannot do this:&lt;br /&gt;div.style = "color:red; font-weight:bold";&lt;/pre&gt;Instead, you set each sub item in the style attribute:&lt;pre&gt;// This works:&lt;br /&gt;div.style.color = 'red';&lt;br /&gt;div.style['font-weight'] = 'bold';&lt;/pre&gt;The tree function that I've written handles this nested style structure as well. Here's an example:&lt;pre&gt;['div', {&lt;br /&gt;    'id': 'foo', &lt;br /&gt;    'style': {'color': 'red', 'font-weight': 'bold'}}, &lt;br /&gt;  'This works too!']&lt;/pre&gt;Now that you have an idea of how to use this utility, here's the code. Minus the comments it's only about twenty-one lines.&lt;pre&gt;/**&lt;br /&gt; * Creates a DOM tree from a simple list.&lt;br /&gt; * The structure of the tree passed in is as follows:&lt;br /&gt; * ['elementTag', &lt;br /&gt; *      {attribute1: value,&lt;br /&gt; *       attribute2: value,&lt;br /&gt; *       style: {property1: value,&lt;br /&gt; *               property2: value}},&lt;br /&gt; *    'child text node',&lt;br /&gt; *    ['elementTag',&lt;br /&gt; *         {property: value},&lt;br /&gt; *       'grandchild text node'],&lt;br /&gt; *    'third node']&lt;br /&gt; * The above will result in a DOM node which has three child nodes, the&lt;br /&gt; * first and third will be text nodes because the values were strings.&lt;br /&gt; * The second child node will be a DOM node as well.&lt;br /&gt; *&lt;br /&gt; * @param {Array} t The tree's structure as a collection of strings, lists,&lt;br /&gt; *     and simple objects. The structure is as follows&lt;br /&gt; *     ['elementTag', {attributes}, child, child, child, ...]&lt;br /&gt; * @return {Element} Returns a new DOM element.&lt;br /&gt; */&lt;br /&gt;function tree(t) {&lt;br /&gt;  // Create the node using the tag which is first in the list.&lt;br /&gt;  var domNode = document.createElement(t[0]);&lt;br /&gt;  // Add all HTML attributes to the node.&lt;br /&gt;  for (var key in t[1]) {&lt;br /&gt;    // The style attributes get special treatment.&lt;br /&gt;    if (key == 'style') {&lt;br /&gt;      for (var styleAttribute in t[1].style) {&lt;br /&gt;        domNode.style[styleAttribute] = t[1].style[styleAttribute];&lt;br /&gt;      }&lt;br /&gt;    } else {&lt;br /&gt;      domNode[key] = t[1][key];&lt;br /&gt;    }&lt;br /&gt;  }&lt;br /&gt;  // Iterate over all child nodes, converting them to either text or HTML&lt;br /&gt;  // nodes.&lt;br /&gt;  for (var index = 2, child; child = t[index]; index++) {&lt;br /&gt;    if (typeof(child) == 'string') {&lt;br /&gt;      domNode.appendChild(document.createTextNode(child));&lt;br /&gt;    } else {&lt;br /&gt;      // Buid recursively.&lt;br /&gt;      domNode.appendChild(tree(child));&lt;br /&gt;    }&lt;br /&gt;  }&lt;br /&gt;  return domNode; &lt;br /&gt;}&lt;/pre&gt;What do you think, is there anything you would add?&lt;br /&gt;&lt;br /&gt;On a realted note, if you're interested in a more powerful templating system, you might want to try &lt;a href="&lt;br /&gt;http://code.google.com/closure/templates/"&gt;Closure Templates&lt;/a&gt; which were &lt;a href="http://googlecode.blogspot.com/2009/11/introducing-closure-tools.html"&gt;recently open sourced&lt;/a&gt;.&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/33260599-354090936792118313?l=blog.jeffscudder.com' alt='' /&gt;&lt;/div&gt;</content><link rel="replies" type="application/atom+xml" href="http://blog.jeffscudder.com/feeds/354090936792118313/comments/default" title="Post Comments" /><link rel="replies" type="text/html" href="https://www.blogger.com/comment.g?blogID=33260599&amp;postID=354090936792118313" title="1 Comments" /><link rel="edit" type="application/atom+xml" href="http://www.blogger.com/feeds/33260599/posts/default/354090936792118313?v=2" /><link rel="self" type="application/atom+xml" href="http://www.blogger.com/feeds/33260599/posts/default/354090936792118313?v=2" /><link rel="alternate" type="text/html" href="http://blog.jeffscudder.com/2010/01/dom-manipulation-in-javascript-utility.html" title="DOM Manipulation in JavaScript, a Utility" /><author><name>Jeffrey Scudder</name><uri>http://www.blogger.com/profile/13002167096451875802</uri><email>noreply@blogger.com</email><gd:extendedProperty name="OpenSocialUserId" value="00750547326625434286" /></author><thr:total xmlns:thr="http://purl.org/syndication/thread/1.0">1</thr:total></entry><entry gd:etag="W/&quot;DkUNQno8cCp7ImA9WxNUGE4.&quot;"><id>tag:blogger.com,1999:blog-33260599.post-6782376423778260654</id><published>2009-10-22T16:00:00.000-07:00</published><updated>2009-11-09T22:24:53.478-08:00</updated><app:edited xmlns:app="http://www.w3.org/2007/app">2009-11-09T22:24:53.478-08:00</app:edited><category scheme="http://www.blogger.com/atom/ns#" term="JavaScript" /><title>The joys of onKeyDown</title><content type="html">I recently found myself in need of a way to detect when a user presses enter when typing in a text input box and happened upon one of the &lt;a href="http://www.quirksmode.org/js/keys.html"&gt;quirkiest&lt;/a&gt; of browser features, key press detection in JavaScript. Searching the Internet provided a few ideas but nothing that quite fit what I was looking for, so I thought maybe I should get the word out about what I've learned.&lt;br /&gt;&lt;br /&gt;Lets assume that we have a form with an input box and we want to perform some special action when the user presses the enter key while focus is on the text input box. We begin by adding an onKeyDown event to the input box (you might also consider onKeyUp, but onKeyPress seems like it might be somewhat quirkier).&lt;pre&gt;&amp;lt;form&amp;gt;&lt;br /&gt;  &amp;lt;input type="text" id="my-input"&amp;gt;&lt;br /&gt;&amp;lt;/form&amp;gt;&lt;br /&gt;&amp;lt;div id="output"&amp;gt;&amp;lt;/div&amp;gt;&lt;br /&gt;&amp;lt;script&amp;gt;&lt;br /&gt;  document.getElementById('my-input').onkeydown = function(e) {};&lt;br /&gt;&amp;lt;script&amp;gt;&lt;/pre&gt;Now the first hurdle is that in IE, Safari, and Chrome you can access the ASCII character code for the key which was pressed in &lt;code&gt;window.event.keyCode&lt;/code&gt; but in FireFox you'll need to get the event object and look at the &lt;code&gt;which&lt;/code&gt; member.&lt;pre&gt;&amp;lt;script&amp;gt;&lt;br /&gt; document.getElementById('my-input').onkeydown = function(e) {&lt;br /&gt;   var keyCode = 0;&lt;br /&gt;   if (window &amp;amp;&amp;amp; window.event &amp;amp;&amp;amp; window.event.keyCode) {&lt;br /&gt;     keyCode = window.event.keyCode;&lt;br /&gt;   } else if (e &amp;amp;&amp;amp; e.which) {&lt;br /&gt;     keyCode = e.which;&lt;br /&gt;   } else {&lt;br /&gt;     alert('fail');&lt;br /&gt;   }&lt;br /&gt;   document.getElementById('output').innerHTML = 'You pressed ' + keyCode;&lt;br /&gt; };&lt;br /&gt;&amp;lt;script&amp;gt;&lt;/pre&gt;Now there is one gotcha with what we've written so far. Each key that we press when focus is on the desired input causes our code to be run, but the browser also performs the default behavior for that key. If our input is a simple text box, the characters pressed will show up in the text box. If the input is part of a form with a submit button, pressing enter will cause the form to be submitted. If the form is submitted then the browser is sent to a different page which in this case is not what we want.&lt;br /&gt;&lt;br /&gt;There are a few ways to prevent the key presses from also triggering the default behavior and do only our behavior. One of the simplest ways is to return false from the &lt;code&gt;onKeyDown&lt;/code&gt; function. If we change our handler to the below, characters will not show up in a text input box because our handler consumes them.&lt;pre&gt; document.getElementById('my-input').onkeydown = function(e) {&lt;br /&gt;   var keyCode = 0;&lt;br /&gt;   if (window &amp;amp;&amp;amp; window.event &amp;amp;&amp;amp; window.event.keyCode) {&lt;br /&gt;     keyCode = window.event.keyCode;&lt;br /&gt;   } else if (e &amp;amp;&amp;amp; e.which) {&lt;br /&gt;     keyCode = e.which;&lt;br /&gt;   } else {&lt;br /&gt;     alert('fail');&lt;br /&gt;   }&lt;br /&gt;   document.getElementById('output').innerHTML = 'You pressed ' + keyCode;&lt;br /&gt;   return false;&lt;br /&gt; };&lt;/pre&gt;With the above, the last key press is displayed in the output, but in most cases we probably do want the user to see the chracters they've typed showing up in the input box. We just want to prevent the form submit when the user presses the enter key. To accomplish this behavior, we can return false when we don't want the key press to propoage and return true when the default behavior should also be performed.&lt;pre&gt; document.getElementById('my-input').onkeydown = function(e) {&lt;br /&gt;   var keyCode = 0;&lt;br /&gt;   if (window &amp;amp;&amp;amp; window.event &amp;amp;&amp;amp; window.event.keyCode) {&lt;br /&gt;     keyCode = window.event.keyCode;&lt;br /&gt;   } else if (e &amp;amp;&amp;amp; e.which) {&lt;br /&gt;     keyCode = e.which;&lt;br /&gt;   } else {&lt;br /&gt;     alert('fail');&lt;br /&gt;   }&lt;br /&gt;   document.getElementById('output').innerHTML = 'You pressed ' + keyCode;&lt;br /&gt;   if (keyCode == 13) { // 13 is the key code for the enter key.&lt;br /&gt;     return false;&lt;br /&gt;   } else {&lt;br /&gt;     return true;&lt;br /&gt;   }&lt;br /&gt; };&lt;/pre&gt;There you have it, a way to detect when the enter key is pressed in our input box while also preventing the form from being submitted.&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/33260599-6782376423778260654?l=blog.jeffscudder.com' alt='' /&gt;&lt;/div&gt;</content><link rel="replies" type="application/atom+xml" href="http://blog.jeffscudder.com/feeds/6782376423778260654/comments/default" title="Post Comments" /><link rel="replies" type="text/html" href="https://www.blogger.com/comment.g?blogID=33260599&amp;postID=6782376423778260654" title="3 Comments" /><link rel="edit" type="application/atom+xml" href="http://www.blogger.com/feeds/33260599/posts/default/6782376423778260654?v=2" /><link rel="self" type="application/atom+xml" href="http://www.blogger.com/feeds/33260599/posts/default/6782376423778260654?v=2" /><link rel="alternate" type="text/html" href="http://blog.jeffscudder.com/2009/10/joys-of-onkeydown.html" title="The joys of onKeyDown" /><author><name>Jeffrey Scudder</name><uri>http://www.blogger.com/profile/13002167096451875802</uri><email>noreply@blogger.com</email><gd:extendedProperty name="OpenSocialUserId" value="00750547326625434286" /></author><thr:total xmlns:thr="http://purl.org/syndication/thread/1.0">3</thr:total></entry><entry gd:etag="W/&quot;CEEARnY_eSp7ImA9WxNXEk0.&quot;"><id>tag:blogger.com,1999:blog-33260599.post-8890003236705886325</id><published>2009-09-28T22:16:00.000-07:00</published><updated>2009-09-28T22:37:27.841-07:00</updated><app:edited xmlns:app="http://www.w3.org/2007/app">2009-09-28T22:37:27.841-07:00</app:edited><category scheme="http://www.blogger.com/atom/ns#" term="journal" /><category scheme="http://www.blogger.com/atom/ns#" term="writing" /><title>Journaling</title><content type="html">This evening I found my long lost journal. In dusting it off and cracking it open I learned that my last entry had been over a year ago. With the exception of this last year long hiatus, I've regularly kept a journal since sometime in 1999 or 2000. I've found writing my thoughts helps me crystallize them and I tend to deal with thoughts and emotions internally, mulling them for hours or days. This is one of the reasons I think I've stuck with blogging.&lt;br /&gt;&lt;br /&gt;Keeping a private journal is a completely different feeling than keeping a blog. When I write here I'm intensely (sometimes even paralyzingly) conscious of my audience. Not that it's a large one. Here I tend to focus on software related discoveries and creations. It is one creative outlet, but one decidedly different from when I journal. &lt;br /&gt;&lt;br /&gt;It was refreshing to scratch blank pages with pen, writing for an audience which understands me better than most.&lt;br /&gt;&lt;br /&gt;Okay now how many of you, when you saw the title, thought that I was going to talk about a &lt;a href="http://en.wikipedia.org/wiki/Journaling_file_system"&gt;file system&lt;/a&gt; or &lt;a href="http://labs.google.com/papers/bigtable-osdi06.pdf"&gt;database&lt;/a&gt;? :-) How about you, do you keep a private journal?&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/33260599-8890003236705886325?l=blog.jeffscudder.com' alt='' /&gt;&lt;/div&gt;</content><link rel="replies" type="application/atom+xml" href="http://blog.jeffscudder.com/feeds/8890003236705886325/comments/default" title="Post Comments" /><link rel="replies" type="text/html" href="https://www.blogger.com/comment.g?blogID=33260599&amp;postID=8890003236705886325" title="2 Comments" /><link rel="edit" type="application/atom+xml" href="http://www.blogger.com/feeds/33260599/posts/default/8890003236705886325?v=2" /><link rel="self" type="application/atom+xml" href="http://www.blogger.com/feeds/33260599/posts/default/8890003236705886325?v=2" /><link rel="alternate" type="text/html" href="http://blog.jeffscudder.com/2009/09/journaling.html" title="Journaling" /><author><name>Jeffrey Scudder</name><uri>http://www.blogger.com/profile/13002167096451875802</uri><email>noreply@blogger.com</email><gd:extendedProperty name="OpenSocialUserId" value="00750547326625434286" /></author><thr:total xmlns:thr="http://purl.org/syndication/thread/1.0">2</thr:total></entry><entry gd:etag="W/&quot;CEACRHY8eSp7ImA9WxNSE0U.&quot;"><id>tag:blogger.com,1999:blog-33260599.post-5422201680782397777</id><published>2009-08-26T23:49:00.000-07:00</published><updated>2009-08-27T07:19:25.871-07:00</updated><app:edited xmlns:app="http://www.w3.org/2007/app">2009-08-27T07:19:25.871-07:00</app:edited><category scheme="http://www.blogger.com/atom/ns#" term="JavaScript" /><category scheme="http://www.blogger.com/atom/ns#" term="matrix" /><title>A Matrix Sim in JavaScript</title><content type="html">Do you ever find yourself working on a large project with a long lead-in time before you have visible results to show? I had been frustrated by this feeling recently. I had been focusing on a personal project which will likely be a long time in the making, so I decided to pick up a short, simple, and quick project to keep things lively and fresh. So our story begins.&lt;br /&gt;&lt;br /&gt;During high school, I was wowed by the movie The Matrix. The special effects were mind blowing (for their day) and the story line was something I could really get behind (not so with the sequels, but I digress). I imagine this is how my elders felt when Star Wars was first released.&lt;br /&gt;&lt;br /&gt;One of the most memorable visuals in the movie is the code of the matrix zipping by vertically on the screen in a retro green on black. Cypher, makes a statement, which seems to be a favorite among programmers, that he no longer sees the code itself, but what it represents. He has become fluent to the point of transcendence - a geek nirvana experience.&lt;br /&gt;&lt;br /&gt;At this point in my life I had written a few moderately complex programs, mostly using Turbo C, and I thought: "Why, I could make my computer look like the matrix." It was one of the more involved programs I had written at the time and I was quite pleased with the result. I brought it in to the computer lab at school, loaded it onto all of the machines, and had the whole lab running it at once. I'm pretty sure that &lt;a href="http://twitter.com/leebenjp"&gt;Ben&lt;/a&gt;, Yed, and Roman G. remember it. Sadly I doubt the code would run on the DOS emulator that ships with Windows XP and higher. I recall vaguely that Roman ported it to Win32 or something in our high school computer science class. Now that I think about it, I guess you could say that this was my first open source experience. &lt;br /&gt;&lt;br /&gt;In thinking of something quick and easy to create with some immediate visual payoff, I decided to recreate my little DOS matrix sim, but this time in the browser. Behold: &lt;a href="http://www.jeffscudder.com/matrix"&gt;The matrix in JavaScript&lt;/a&gt;.&lt;br /&gt;&lt;br /&gt;&lt;!--&lt;a onblur="try {parent.deselectBloggerImageGracefully();} catch(e) {}" href="http://www.jeffscudder.com/matrix"&gt;&lt;img style="display:block; margin:0px auto 10px; text-align:center;cursor:pointer; cursor:hand;width: 320px; height: 257px;" src="http://4.bp.blogspot.com/_54HtFT6yBFI/SpaT_6DoTHI/AAAAAAAAAcI/gylHk_PxWWI/s320/matrix_sim.png" border="0" alt=""id="BLOGGER_PHOTO_ID_5374645931438787698" /&gt;&lt;/a&gt;--&gt;It turns out that the CSS rules needed to keep columns at a fixed width and height was actually quite complex and took longer than expected to get right. The vertical line height was still elusive in Chrome and Safari, but worked in Firefox and Opera. I don't think that this works yet in Internet Explorer. Though if past traffic is any indication, none of you would have noticed had I not said something :-)&lt;br /&gt;&lt;br /&gt;Many thanks to &lt;a href="http://scudmissile.net/"&gt;Scudmissile&lt;/a&gt; for his mighty CSS kung fu. Oh, and that whirring sound that you hear may be your CPU fan trying to take flight. Apparently rendering a vertical text flow like this using DOM manipulation, CSS, and Math.random may be a bit more processor intensive than my obsolete C code.&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/33260599-5422201680782397777?l=blog.jeffscudder.com' alt='' /&gt;&lt;/div&gt;</content><link rel="replies" type="application/atom+xml" href="http://blog.jeffscudder.com/feeds/5422201680782397777/comments/default" title="Post Comments" /><link rel="replies" type="text/html" href="https://www.blogger.com/comment.g?blogID=33260599&amp;postID=5422201680782397777" title="0 Comments" /><link rel="edit" type="application/atom+xml" href="http://www.blogger.com/feeds/33260599/posts/default/5422201680782397777?v=2" /><link rel="self" type="application/atom+xml" href="http://www.blogger.com/feeds/33260599/posts/default/5422201680782397777?v=2" /><link rel="alternate" type="text/html" href="http://blog.jeffscudder.com/2009/08/matrix-sim-in-javascript.html" title="A Matrix Sim in JavaScript" /><author><name>Jeffrey Scudder</name><uri>http://www.blogger.com/profile/13002167096451875802</uri><email>noreply@blogger.com</email><gd:extendedProperty name="OpenSocialUserId" value="00750547326625434286" /></author><media:thumbnail xmlns:media="http://search.yahoo.com/mrss/" url="http://4.bp.blogspot.com/_54HtFT6yBFI/SpaT_6DoTHI/AAAAAAAAAcI/gylHk_PxWWI/s72-c/matrix_sim.png" height="72" width="72" /><thr:total xmlns:thr="http://purl.org/syndication/thread/1.0">0</thr:total></entry><entry gd:etag="W/&quot;CkIBSXY8fyp7ImA9WxJaE0w.&quot;"><id>tag:blogger.com,1999:blog-33260599.post-4504844384194444821</id><published>2009-08-01T00:38:00.000-07:00</published><updated>2009-08-03T07:42:38.877-07:00</updated><app:edited xmlns:app="http://www.w3.org/2007/app">2009-08-03T07:42:38.877-07:00</app:edited><category scheme="http://www.blogger.com/atom/ns#" term="http" /><category scheme="http://www.blogger.com/atom/ns#" term="app engine" /><category scheme="http://www.blogger.com/atom/ns#" term="https" /><category scheme="http://www.blogger.com/atom/ns#" term="python" /><title>A Test Client for App Engine</title><content type="html">I created a &lt;a href="http://code.google.com/p/scud-cms/source/browse/#svn/trunk/app_engine_http"&gt;simple utility library&lt;/a&gt; in Python to help anyone debug their App Engine application. Many of the App Engine apps that I've seen use HTTP, HTML form posts, and the &lt;a href="http://code.google.com/appengine/docs/python/users/overview.html"&gt;Users API&lt;/a&gt; and the easiest way to test these features is to fire up the web browser and click through the web pages generated by the app.  However this can be a bit slow and repetative and it is difficult to determine exactly what is being sent over the wire (though this is greatly helped by using &lt;a href="http://www.wireshark.org/"&gt;wireshark&lt;/a&gt;, &lt;a href="http://www.fiddler2.com/fiddler2/"&gt;fiddler&lt;/a&gt;, &lt;a href="http://www.tcpdump.org/"&gt;tcpdump&lt;/a&gt;, or antoher network packet sniffing tool).&lt;br /&gt;&lt;br /&gt;Enter &lt;a href="http://code.google.com/p/scud-cms/source/browse/trunk/app_engine_http/http.py"&gt;my little App Engine HTTP module&lt;/a&gt;. It provides a simple interface for making arbitrary HTTP requests and will print the full request and response to the terminal (though you can turn the noisy printing off if you want). &lt;a href="http://code.google.com/p/scud-cms/downloads/list"&gt;Download&lt;/a&gt;, copy the &lt;code&gt;http.py&lt;/code&gt; file to you working directory and try it out in your Python interpreter.&lt;br /&gt;&lt;br /&gt;For our first demonstration, let's try to visit the Google search page. &lt;pre&gt;import http&lt;br /&gt;client = http.Client()&lt;br /&gt;resp = client.request('GET', 'http://www.google.com')&lt;/pre&gt;You should see your request and the server's response (with the HTML for the Google Search page) in your terminal window. This should work with just about any website out there.&lt;br /&gt;&lt;br /&gt;Other HTTP debugging tools can show you the request and response like this, but I find that this kind of simple Python client can be useful in writing end-to-end or integration tests which contact your App Engine app remotely. &lt;br /&gt;&lt;br /&gt;Along those lines, one of the things which standard HTTP debugging tools do not provide, is a way to sign in to an App Engine app with a Google Account so that the App Engine Users API can identify the current user.  I wrote an extremely simple app which illustrates the Users API, try it out here:&lt;br /&gt;&lt;br /&gt;&lt;a href="http://jscudtest.appspot.com/user"&gt;http://jscudtest.appspot.com/user&lt;/a&gt;&lt;br /&gt;&lt;br /&gt;After signing in, the page should simply say, "Hello &lt;em&gt;yourusername&lt;/em&gt; (&lt;em&gt;yourusername&lt;/em&gt;@&lt;em&gt;yourdomain.com&lt;/em&gt;)" You'll notice that during the sign in process, you signed in on &lt;code&gt;www.google.com/accounts&lt;/code&gt; and were asked to approve access to the app. This kind of interaction works great in a browser, but can be tricky when you are using a command line, browserless, client.&lt;br /&gt;&lt;br /&gt;It is possible however, to sign in to an App Engine app without using a browser. You can use the same technique used in  &lt;code&gt;appcfg&lt;/code&gt;, use &lt;a href="http://code.google.com/apis/accounts/docs/AuthForInstalledApps.html"&gt;ClientLogin&lt;/a&gt; and use the authorization token to obtain an app specific cookie which indicates the current user. This simple HTTP library can do this for you and all subsequent requests will use this cookie to tell the App Engine app who the current user is. Try it out by making the request to the simple user app that you visited earlier:&lt;pre&gt;import http&lt;br /&gt;client = http.Client()&lt;br /&gt;client.appengine_login('jscudtest')&lt;br /&gt;resp = client.request('GET',&lt;br /&gt;                      'http://jscudtest.appspot.com/user')&lt;br /&gt;print resp.body&lt;/pre&gt;You should see the following text displayed in the terminal:&lt;pre&gt;Hello, &lt;em&gt;yourusername&lt;/em&gt; (&lt;em&gt;yourusername&lt;/em&gt;@&lt;em&gt;yourdomain.com&lt;/em&gt;)&lt;/pre&gt;You can use the &lt;code&gt;appengine_login&lt;/code&gt; method with your own app, just change the argument to the App ID of the app you want to access. &lt;br /&gt;&lt;br /&gt;Along with simplifying access to apps which use Google Accounts, I wanted this library to simplify the process of using another feature used by many web apps: HTML form posts. Now I'm certain you've used HTML forms before, here's a simple example: &lt;br /&gt;&lt;br /&gt;&lt;a href="http://shoutout.appspot.com/"&gt;http://shoutout.appspot.com/&lt;/a&gt;&lt;br /&gt;&lt;br /&gt;The above app uses both the Users API and a simple form. As an alternative to visiting this page in the web browser, you can post your shout-out using the following:&lt;pre&gt;import http&lt;br /&gt;client = http.Client()&lt;br /&gt;client.appengine_login('shoutout')&lt;br /&gt;client.request('POST', 'http://shoutout.appspot.com/',&lt;br /&gt;    form_data={'who': raw_input('From: '),&lt;br /&gt;               'message': raw_input('Message: ')})&lt;/pre&gt;If you've even wondered what gets sent across the wire to post on a form like this, look back in your terminal to see the request from your computer and the response from the server (this is of course just the HTTP layer, wireshark will show you traffic on the IP and Ethernet layer as well). &lt;br /&gt;&lt;br /&gt;That's really all there is to it. I designed this as just a simple script to use on the command line and I wrote it in less time than it's taken me to write this blog post about it (I borrowed &lt;a href="http://code.google.com/p/gdata-python-client/source/browse/trunk/src/atom/http_core.py"&gt;atom.http_core&lt;/a&gt; from the &lt;a href="http://code.google.com/p/gdata-python-client/"&gt;gdata-python-client&lt;/a&gt; as a foundation). With some tweaks to remove the interactive (getpass and raw_input) calls and replace them with parameters, I could see this module as a utility layer in a larger, more complex, App Engine client application. If you're creating on I'd love to hear about it ;-)&lt;br /&gt;&lt;br /&gt;For more information on how the &lt;code&gt;appengine_login&lt;/code&gt; method works behind the scenes, see this presentation I gave a few months ago:&lt;br /&gt;&lt;br /&gt;&lt;iframe src="http://docs.google.com/present/embed?id=dcb4p69x_7fgnfgx28" frameborder="0" width="410" height="342"&gt;&lt;/iframe&gt;&lt;br /&gt;&lt;br /&gt;Many thanks to &lt;a href="http://twitter.com/tjohns"&gt;Trevor Johns&lt;/a&gt; and &lt;a href="http://twitter.com/nicksdjohnson"&gt;Nick Johnson&lt;/a&gt; for helping me to understand how this ClientLogin-to-cookie exchange works.&lt;br /&gt;&lt;br /&gt;I'm sure that App Engine's Java runtime users would appreciate a port of this simple library to Java, if you feel so inclined.&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/33260599-4504844384194444821?l=blog.jeffscudder.com' alt='' /&gt;&lt;/div&gt;</content><link rel="replies" type="application/atom+xml" href="http://blog.jeffscudder.com/feeds/4504844384194444821/comments/default" title="Post Comments" /><link rel="replies" type="text/html" href="https://www.blogger.com/comment.g?blogID=33260599&amp;postID=4504844384194444821" title="3 Comments" /><link rel="edit" type="application/atom+xml" href="http://www.blogger.com/feeds/33260599/posts/default/4504844384194444821?v=2" /><link rel="self" type="application/atom+xml" href="http://www.blogger.com/feeds/33260599/posts/default/4504844384194444821?v=2" /><link rel="alternate" type="text/html" href="http://blog.jeffscudder.com/2009/08/test-client-for-app-engine.html" title="A Test Client for App Engine" /><author><name>Jeffrey Scudder</name><uri>http://www.blogger.com/profile/13002167096451875802</uri><email>noreply@blogger.com</email><gd:extendedProperty name="OpenSocialUserId" value="00750547326625434286" /></author><thr:total xmlns:thr="http://purl.org/syndication/thread/1.0">3</thr:total></entry><entry gd:etag="W/&quot;C04ER3s7fCp7ImA9WxJUF08.&quot;"><id>tag:blogger.com,1999:blog-33260599.post-6992235213398099142</id><published>2009-07-14T23:01:00.000-07:00</published><updated>2009-07-15T22:25:06.504-07:00</updated><app:edited xmlns:app="http://www.w3.org/2007/app">2009-07-15T22:25:06.504-07:00</app:edited><category scheme="http://www.blogger.com/atom/ns#" term="app engine" /><category scheme="http://www.blogger.com/atom/ns#" term="cms" /><category scheme="http://www.blogger.com/atom/ns#" term="python" /><title>New version of my Dirt Simple CMS</title><content type="html">I have just uploaded "version 2" of the &lt;a href="http://code.google.com/p/scud-cms"&gt;dirt simple content management system&lt;/a&gt; which I developed &lt;a href="http://blog.jeffscudder.com/2008/08/dirt-simple-cms.html"&gt;almost a year ago&lt;/a&gt;. For those who don't recall, scud-cms is an extremely thin layer on top of App Engine with a plain text box based editor for creating web pages. The only new feature in this release is the ability to page through all of the content in your app by visiting the /content_lister page. I implemented the pagination system using "key only" queries and order-by-key which are fairly recent features in App Engine. For more potential designs to page through datastore entities, see this article on &lt;a href="http://code.google.com/appengine/articles/paging.html"&gt;pagination&lt;/a&gt;.  &lt;br /&gt;&lt;br /&gt;I was inpired to work on this in part by a comment from &lt;a href="http://jawtek.com"&gt;Jason Worley&lt;/a&gt; (&lt;a href="http://twitter.com/swirleydude"&gt;swirleydude&lt;/a&gt; on twitter) who has been using it and appears to like it quite a bit. At some point I plan to do a version 3 release which will include file uploads (great for images) just as Jason has done in &lt;a href="http://projects.jawtek.com/litecms/"&gt;his own modifications&lt;/a&gt;. Having someone use your software, enjoy it, tweak it, and build on it is rewarding in a way which is quite unique.&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/33260599-6992235213398099142?l=blog.jeffscudder.com' alt='' /&gt;&lt;/div&gt;</content><link rel="replies" type="application/atom+xml" href="http://blog.jeffscudder.com/feeds/6992235213398099142/comments/default" title="Post Comments" /><link rel="replies" type="text/html" href="https://www.blogger.com/comment.g?blogID=33260599&amp;postID=6992235213398099142" title="0 Comments" /><link rel="edit" type="application/atom+xml" href="http://www.blogger.com/feeds/33260599/posts/default/6992235213398099142?v=2" /><link rel="self" type="application/atom+xml" href="http://www.blogger.com/feeds/33260599/posts/default/6992235213398099142?v=2" /><link rel="alternate" type="text/html" href="http://blog.jeffscudder.com/2009/07/new-version-of-my-dirt-simple-cms.html" title="New version of my Dirt Simple CMS" /><author><name>Jeffrey Scudder</name><uri>http://www.blogger.com/profile/13002167096451875802</uri><email>noreply@blogger.com</email><gd:extendedProperty name="OpenSocialUserId" value="00750547326625434286" /></author><thr:total xmlns:thr="http://purl.org/syndication/thread/1.0">0</thr:total></entry><entry gd:etag="W/&quot;D08MQHsyfCp7ImA9WxJUEUw.&quot;"><id>tag:blogger.com,1999:blog-33260599.post-6586089585110584129</id><published>2009-07-07T23:01:00.000-07:00</published><updated>2009-07-08T22:04:41.594-07:00</updated><app:edited xmlns:app="http://www.w3.org/2007/app">2009-07-08T22:04:41.594-07:00</app:edited><category scheme="http://www.blogger.com/atom/ns#" term="xo laptop" /><category scheme="http://www.blogger.com/atom/ns#" term="one laptop per child" /><title>Updating my OLPC XO laptop</title><content type="html">For a few months &lt;a href="http://blog.jeffscudder.com/2008/03/xo-laptop.html"&gt;my XO laptop&lt;/a&gt; was my primary personal machine. I've &lt;a href="http://blog.jeffscudder.com/search/label/xo%20laptop"&gt;written before&lt;/a&gt; about some of my favorite features, and after a year and a half with it, my favorites are still:&lt;ul&gt;&lt;li&gt;A screen that is readable in full sunlight or glare&lt;/li&gt;&lt;li&gt;Linux&lt;/li&gt;&lt;li&gt;Long battery life&lt;/li&gt;&lt;li&gt;Runs absolutely silently, no fans or spinning hard drive&lt;/li&gt;&lt;/ul&gt;However, there were a few drawbacks. It is a bit short on ram and processing power but most of the time I'm using simple programming tools, so I don't need much. Web browsing on some sites was a bit slow though. The biggest pain point in my book was the lack of copy and paste capability. I often found myself needing to retype a lengthy command in the terminal. On other systems I would have just copied and pasted from the web browser. For a while, &lt;a href="http://blog.jeffscudder.com/2008/09/in-praise-of-screen.html"&gt;I worked around this&lt;/a&gt; by using &lt;a href="http://en.wikipedia.org/wiki/Gnu_screen"&gt;screen&lt;/a&gt;, which has a built in copy-paste buffer. &lt;br /&gt;&lt;br /&gt;It turns out, in a recent release, the OLPC team has assuaged my number one annoyance. It is now possible to copy text from any of the activities (programs) and paste into another (like the &lt;a href="http://wiki.laptop.org/go/Terminal_Activity"&gt;terminal&lt;/a&gt;). In order to use this new goodness, I needed to &lt;a href="http://wiki.laptop.org/go/Olpc-update"&gt;update my XO operating system&lt;/a&gt; from the current version (&lt;a href="http://wiki.laptop.org/go/Release_notes/656"&gt;656&lt;/a&gt;) to a newer build (&lt;a href="http://wiki.laptop.org/go/Release_notes/8.2.1"&gt;802&lt;/a&gt;). &lt;br /&gt;&lt;br /&gt;The process of updating turned out to be quite simple. If you are undertaking these same steps, please note, this does wipe out some parts of the operating system. New programs which you've installed using yum or rpm's might be erased depending on where they are installed. It looks like everything in the &lt;code&gt;/home/olpc&lt;/code&gt; directory is untouched. For complete instructions, see the &lt;a href="http://laptop.org/"&gt;laptop.org&lt;/a&gt; wiki page for &lt;a href="http://"&gt;olpc-update&lt;/a&gt;.&lt;br /&gt;&lt;br /&gt;To update, open the terminal and become root by executing &lt;pre&gt;su&lt;/pre&gt; After that, make sure that your laptop is plugged in to a source of electricity and connected to the internet as this next step involved downloading the new operating system and overwriting your existing OS. Probably not something you want to lose power during.&lt;br /&gt;&lt;br /&gt;To download and install the new OS run &lt;pre&gt;/usr/sbin/olpc-update 802&lt;/pre&gt; Once you run this your laptop will spend the next several minutes to hours downloading and installing. A few exciting status messages will appear on your screen. Things like  "Deleting old pristine version" - yikes!&lt;br /&gt;&lt;br /&gt;I've found 802 to be a significant improvement over 656. The copy paste functionality is great and the UI looks and feels cleaner. Selecting applications and switching between them is easier than it used to be. With copy and paste now firmly in place I plan to use my little green machine quite a bit more.&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/33260599-6586089585110584129?l=blog.jeffscudder.com' alt='' /&gt;&lt;/div&gt;</content><link rel="replies" type="application/atom+xml" href="http://blog.jeffscudder.com/feeds/6586089585110584129/comments/default" title="Post Comments" /><link rel="replies" type="text/html" href="https://www.blogger.com/comment.g?blogID=33260599&amp;postID=6586089585110584129" title="0 Comments" /><link rel="edit" type="application/atom+xml" href="http://www.blogger.com/feeds/33260599/posts/default/6586089585110584129?v=2" /><link rel="self" type="application/atom+xml" href="http://www.blogger.com/feeds/33260599/posts/default/6586089585110584129?v=2" /><link rel="alternate" type="text/html" href="http://blog.jeffscudder.com/2009/07/updating-my-olpc-xo-laptop.html" title="Updating my OLPC XO laptop" /><author><name>Jeffrey Scudder</name><uri>http://www.blogger.com/profile/13002167096451875802</uri><email>noreply@blogger.com</email><gd:extendedProperty name="OpenSocialUserId" value="00750547326625434286" /></author><thr:total xmlns:thr="http://purl.org/syndication/thread/1.0">0</thr:total></entry><entry gd:etag="W/&quot;DkQMRH0zfyp7ImA9WxJVEUk.&quot;"><id>tag:blogger.com,1999:blog-33260599.post-8901353907487636115</id><published>2009-06-25T14:15:00.001-07:00</published><updated>2009-06-27T16:13:05.387-07:00</updated><app:edited xmlns:app="http://www.w3.org/2007/app">2009-06-27T16:13:05.387-07:00</app:edited><category scheme="http://www.blogger.com/atom/ns#" term="currying" /><category scheme="http://www.blogger.com/atom/ns#" term="python" /><category scheme="http://www.blogger.com/atom/ns#" term="code" /><category scheme="http://www.blogger.com/atom/ns#" term="programming" /><title>Partial Function Invocation</title><content type="html">My wife tells me that I often jump into an explanation by starting at the beginning of my train of thought without giving any indication of where I'm going. It would be better if I began with the point I'm trying to make, then explain how I reched my conclusion, How am I doing so far? Oh wait, right... Here is my conclusion:&lt;br /&gt;&lt;br /&gt;Allowing a function to be partially invoked, to allow some of the arguments to be specified at different times, can allow for code which is more flexible than by just using objects or pure functions.&lt;br /&gt;&lt;br /&gt;I've been thinking about this lately as I refactored the &lt;a href="http://code.google.com/p/gdata-python-client/"&gt;gdata-python-client&lt;/a&gt; which is a library which can be used with AtomPub services. I'll spare you all the gory details, and offer a simple example of how partial function invocation might come in handy.&lt;br /&gt;&lt;br /&gt;When making a request to a remote server, you might need the following information, just for example: username, password. URL, message body, and content type. So we start out by writing a stateless function to take this information and open a connnecion to the server, format our inputs, transmit our request, and parse the response. We'll call it &lt;code&gt;post&lt;/code&gt;, and using it looks like this:&lt;pre&gt;serverResponse = post(url, data, contentType, username, &lt;br /&gt;                      password)&lt;/pre&gt;This is all well and good, but suppose the final request, as shown above, is preceeded by a whole series of function calls. Each function would need to dutifully pass along parts of the request. Say for example that the user types in their username and password long before the request is made, so these get passed as parameters to lots of functions which only receive them so they can pass them on. In addition, the username and password are almost always the same from request to request, so the same values are being passed to the post function over and over. In cases like this, we will often use an object to hold common values.&lt;pre&gt;class Requestor {&lt;br /&gt;  username&lt;br /&gt;  password&lt;br /&gt;&lt;br /&gt;  method post(url, data, conteentType) {...}&lt;br /&gt;}&lt;/pre&gt;Now our request will look like:&lt;pre&gt;client = new Requestor(username, password)&lt;br /&gt;serverResponse = client.post(url, data, contentType)&lt;/pre&gt;What we've effectively done here is specified some of the information in advance and left other pieces of information to be specified at the last minute. I would argue that this make the code better (cleaner, less chance of human error in listing lots of parameters, perhaps less data on the call stack, etc.).&lt;br /&gt;&lt;br /&gt;Now the question becomes: Did we extract the right pieces of information from the function call into the object? Suppose the code you are writing needs to use a different password for each service you are making a request to, but the content type of the data is always the same. Then it would have made more sense to design our class like this:&lt;pre&gt;class Requestor {&lt;br /&gt;  username&lt;br /&gt;  contentType&lt;br /&gt;&lt;br /&gt;  method post(url, data, password) {...}&lt;br /&gt;}&lt;/pre&gt;Since we've established that not everyone who is using our code has the same usage patterns, lets design for utimate flexibility. Every parameter can be specified either in the object, or in the function call. Also, if the object has a parameter already, we could override it by passing in that parameter when we call the method. This is not too difficult in in Python, so here is a non-pseudocode example:&lt;pre&gt;class Requestor(object):&lt;br /&gt;  &lt;br /&gt;  def __init__(self, url=None, data=None, &lt;br /&gt;               content_type=None, username=None, &lt;br /&gt;               password=None):&lt;br /&gt;    self.url = url&lt;br /&gt;    self.data = data&lt;br /&gt;    self.content_type =  content_type&lt;br /&gt;    self.username = username&lt;br /&gt;    self.password = password&lt;br /&gt;  &lt;br /&gt;  def post(self, url=None, data=None, &lt;br /&gt;           content_type=None, username=None, &lt;br /&gt;           password=None):&lt;br /&gt;    url = url or self.url&lt;br /&gt;    data = data or self.data&lt;br /&gt;    content_type = content_type or self.content_type&lt;br /&gt;    username = username or self.username&lt;br /&gt;    password = password or self.password&lt;br /&gt;    # Now we have our inputs, code to make &lt;br /&gt;    # the request starts here&lt;br /&gt;    ...&lt;/pre&gt;If you think this seems a bit excessive, I would agree. I didn't go nearly this far when designing the library that started me thinking about this. There was one request parameter in particular though &lt;a href="http://code.google.com/p/gdata-python-client/source/browse/trunk/src/atom/client.py"&gt;that does use this pattern&lt;/a&gt;. (Five points to the first person to post it in the comments. ;-) &lt;br /&gt;&lt;br /&gt;To use the above class, you would do:&lt;pre&gt;requestor = Requestor(username='...')&lt;br /&gt;requestor.password = '...'&lt;br /&gt;...&lt;br /&gt;server_response = requestor.post(url, data, content_type)&lt;/pre&gt;It will also handle our alternate usage where we want to give the password to the post method and set the content type at the object level:&lt;pre&gt;requestor = Requestor(username='...', content_type='...')&lt;br /&gt;...&lt;br /&gt;server_response = requestor.post(url, data, password='...')&lt;/pre&gt;We can even override parameters which are set in the object:&lt;pre&gt;requestor = Requestor(password='...', content_type='...')&lt;br /&gt;requestor.username = '...'&lt;br /&gt;...&lt;br /&gt;# Override the content_type, just on this request.&lt;br /&gt;server_response = requestor.post(url, data, content_type='...')&lt;/pre&gt;With the above example we end up with a lot of code just to let us specify each parameter in either the object or as a function argument. In fact, this can introduce so cases where the user forgets to specify in either, which is possible because all function arguments are now optional. Wouldn't it be better if we could instead specify some of the function parameters, pass the half-specified function call around, and fill in the ramaining values when we finally invoke. For this illustration, I'm using the following syntax to show a partial invocation, &lt;code&gt;&amp;lt; &amp;gt;&lt;/code&gt; around arguments instead of &lt;code&gt;( )&lt;/code&gt;.&lt;pre&gt;function post(url, data, contentType, username, password) {...}&lt;br /&gt;&lt;br /&gt;started = post&amp;lt;username, password&amp;gt;&lt;br /&gt;...&lt;br /&gt;serverRespense = started(url, data, contentType)&lt;/pre&gt;Recall our case from earler, what if the contentType is constant but the password is instead more variable:&lt;pre&gt;started = post&amp;lt;username, contentType&amp;gt;&lt;br /&gt;...&lt;br /&gt;serverRespense = started(url, data, password)&lt;/pre&gt;It turns out I'm not the first person to think of this pattern, not by a long shot. Functional programming often makes use of this pattern, referred to as &lt;a href="http://en.wikipedia.org/wiki/Currying"&gt;function currying&lt;/a&gt;. I found the following &lt;a href="http://www.engr.uconn.edu/~jeffm/Papers/curry.html"&gt;example for Scheme&lt;/a&gt; which also shows how easy this is in Haskell. The prototype library for JavaScript includes a &lt;a href="http://www.prototypejs.org/api/function/bind"&gt;bind function&lt;/a&gt; which can accomplish the same thing. Here's a paper on the topic in C++: (&lt;a href="http://www.osl.iu.edu/publications/prints/2001/jarvi:01:mpool.pdf"&gt;pdf&lt;/a&gt;, &lt;a href="http://www.google.com/search?q=cache:www.osl.iu.edu/publications/prints/2001/jarvi:01:mpool.pdf+http://www.osl.iu.edu/publications/prints/2001/jarvi:01:mpool.pdf&amp;cd=1"&gt;Google cache HTML&lt;/a&gt;).  I also found &lt;a href="http://www.python.org/dev/peps/pep-0309/"&gt;PEP 309&lt;/a&gt; which was a proposal for this in Python. Perhaps I should have called my Python example above: Function Currying using Classes. If you can think of other examples, I'd love to see them.&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/33260599-8901353907487636115?l=blog.jeffscudder.com' alt='' /&gt;&lt;/div&gt;</content><link rel="replies" type="application/atom+xml" href="http://blog.jeffscudder.com/feeds/8901353907487636115/comments/default" title="Post Comments" /><link rel="replies" type="text/html" href="https://www.blogger.com/comment.g?blogID=33260599&amp;postID=8901353907487636115" title="1 Comments" /><link rel="edit" type="application/atom+xml" href="http://www.blogger.com/feeds/33260599/posts/default/8901353907487636115?v=2" /><link rel="self" type="application/atom+xml" href="http://www.blogger.com/feeds/33260599/posts/default/8901353907487636115?v=2" /><link rel="alternate" type="text/html" href="http://blog.jeffscudder.com/2009/06/partial-function-invocation.html" title="Partial Function Invocation" /><author><name>Jeffrey Scudder</name><uri>http://www.blogger.com/profile/13002167096451875802</uri><email>noreply@blogger.com</email><gd:extendedProperty name="OpenSocialUserId" value="00750547326625434286" /></author><thr:total xmlns:thr="http://purl.org/syndication/thread/1.0">1</thr:total></entry><entry gd:etag="W/&quot;DkIFSX4zfyp7ImA9WxBWGEo.&quot;"><id>tag:blogger.com,1999:blog-33260599.post-6765680047314759978</id><published>2009-05-17T13:11:00.000-07:00</published><updated>2010-02-10T23:48:38.087-08:00</updated><app:edited xmlns:app="http://www.w3.org/2007/app">2010-02-10T23:48:38.087-08:00</app:edited><category scheme="http://www.blogger.com/atom/ns#" term="road trip" /><title>Recently completed: our half-US tour</title><content type="html">With stops in &lt;br /&gt;&lt;br /&gt;Auburn CA&lt;br /&gt;Reno NV&lt;br /&gt;Winnemucca NV&lt;br /&gt;Wells NV&lt;br /&gt;Metropolis NV&lt;br /&gt;Bonneville Salt Flats UT&lt;br /&gt;Salt Lake City UT&lt;br /&gt;Green River WY&lt;br /&gt;Cheyenne WY&lt;br /&gt;Denver CO&lt;br /&gt;Littleton CO&lt;br /&gt;Centennial CO &lt;br /&gt;Lincoln NE&lt;br /&gt;Omaha NE&lt;br /&gt;West Des Moines IA&lt;br /&gt;Indianola IA&lt;br /&gt;Sigourney IA&lt;br /&gt;Fairfield IA&lt;br /&gt;Hannibal MO&lt;br /&gt;Fenton MO&lt;br /&gt;Crestwood MO&lt;br /&gt;Sikeston MO&lt;br /&gt;Memphis TN&lt;br /&gt;Little Rock AR&lt;br /&gt;Texarkana AR&lt;br /&gt;Texarkana TX&lt;br /&gt;Plano TX&lt;br /&gt;Dallas TX&lt;br /&gt;Garland TX&lt;br /&gt;Wichita Falls TX&lt;br /&gt;Amarillo TX&lt;br /&gt;Albuquerque NM&lt;br /&gt;Williams AZ&lt;br /&gt;Bakersfield CA&lt;br /&gt;Plesanton CA&lt;br /&gt;Milpitas CA&lt;br /&gt;&lt;br /&gt;(Edited) Here's a map of our approximate route:&lt;br /&gt;&lt;iframe width="425" height="350" frameborder="0" scrolling="no" marginheight="0" marginwidth="0" src="http://maps.google.com/maps?f=d&amp;amp;source=s_d&amp;amp;saddr=Auburn,+CA&amp;amp;daddr=Reno+NV+to:Winnemucca+NV+to:Wells+NV+to:Salt+Lake+City+UT+to:Green+River+WY+to:Denver+CO+to:Lincoln,+Nebraska+to:Omaha+NE+to:West+Des+Moines+IA+to:Indianola+IA+to:Sigourney+IA+to:Saint+Louis,+MO+63109+to:Memphis+TN+to:Little+Rock+AR+to:Texarkana+TX+to:Dallas,+Texas+to:Wichita+Falls+TX+to:Amarillo+TX+to:Albuquerque+NM+to:Williams+AZ+to:Bakersfield,+CA+to:Pleasanton,+Alameda,+California+to:Milpitas,+Santa+Clara,+California&amp;amp;hl=en&amp;amp;geocode=FbWDUQIdZoPI-CmfpXVVKAWbgDFweCwzC7ECOQ%3BFaEsWwIdVcnb-CmdoJKSrkCZgDGH9zh0zsXFQA%3BFZ4ycQId-377-CkpnimG612ggDEmngPIY_bIjw%3BFSVQcwId9scl-Sl3j_x8ANeogDHPdw1Z07DALg%3BFcv1bQIdma1U-SntMdGIlD1ShzHKMU1IoLdTWw%3BFQCteQIdeq15-SlHjCnh4X1ahzH4TPTd16zL2A%3BFRJfXgIdgQ---SnPFx8jqoBrhzHWNoon-PSOEQ%3BFc6pbgIdMcE8-illElbKWb6WhzG53tUfm4U6Yw%3BFXZ8dQId5ipH-int_Ay1yI2ThzEEtjeuT01CRg%3BFfxqegIdHBRq-ikfHoJbih_shzGXgwrTwJaJUw%3BFeASdwIdQm1s-ikB71z1OrDuhzHkYs_KX8CiMA%3BFWCydgIdrxGB-imJ3arOMOHlhzEcEtmTY2frwg%3BFWPATAIdoDWe-imxAg0d9LXYhzF2XAlLW0BsLg%3BFd5WGAIdLPah-ilFl0PqHn7VhzH-thpgFfOT0Q%3BFXEwEgIdxcV_-imbVh-hNKHShzEXW_MNEPUFNA%3BFeUG_gEdOPJk-ilXZKDCMkE0hjFwW9thkjxYnQ%3BFYuI9AEdfWg7-ilLl0V79xlMhjGPZ0f2pJvsuQ%3BFWx7BQIdNRwh-in12mJwkiBThjEAUurvy_oGHQ%3BFe1xGQIdfy3u-SkDz0Wy1EgBhzGv0jZoHNHz0A%3BFctYFwId_6Gk-Sl7gwnT3QoihzH99tm4zvjTwA%3BFTHdGQId5RlQ-SlVpQFT6Z4yhzGGU8DNx-elHQ%3BFezAGwIdKOvn-CkNy5S5yGvqgDHIdP6YCQw2WQ%3BFd-uPgIdCVe8-ClfdbphoumPgDEWferhR2irsw%3BFTAcOwIdQNq7-CnxXXjLADOOgDEnpTqtwOFjeA&amp;amp;mra=ls&amp;amp;sll=37.09024,-105.820312&amp;amp;sspn=23.553364,34.321289&amp;amp;ie=UTF8&amp;amp;ll=37.125286,-105.820312&amp;amp;spn=9.00626,32.41499&amp;amp;output=embed"&gt;&lt;/iframe&gt;&lt;br /&gt;&lt;small&gt;&lt;a href="http://maps.google.com/maps?f=d&amp;amp;source=embed&amp;amp;saddr=Auburn,+CA&amp;amp;daddr=Reno+NV+to:Winnemucca+NV+to:Wells+NV+to:Salt+Lake+City+UT+to:Green+River+WY+to:Denver+CO+to:Lincoln,+Nebraska+to:Omaha+NE+to:West+Des+Moines+IA+to:Indianola+IA+to:Sigourney+IA+to:Saint+Louis,+MO+63109+to:Memphis+TN+to:Little+Rock+AR+to:Texarkana+TX+to:Dallas,+Texas+to:Wichita+Falls+TX+to:Amarillo+TX+to:Albuquerque+NM+to:Williams+AZ+to:Bakersfield,+CA+to:Pleasanton,+Alameda,+California+to:Milpitas,+Santa+Clara,+California&amp;amp;hl=en&amp;amp;geocode=FbWDUQIdZoPI-CmfpXVVKAWbgDFweCwzC7ECOQ%3BFaEsWwIdVcnb-CmdoJKSrkCZgDGH9zh0zsXFQA%3BFZ4ycQId-377-CkpnimG612ggDEmngPIY_bIjw%3BFSVQcwId9scl-Sl3j_x8ANeogDHPdw1Z07DALg%3BFcv1bQIdma1U-SntMdGIlD1ShzHKMU1IoLdTWw%3BFQCteQIdeq15-SlHjCnh4X1ahzH4TPTd16zL2A%3BFRJfXgIdgQ---SnPFx8jqoBrhzHWNoon-PSOEQ%3BFc6pbgIdMcE8-illElbKWb6WhzG53tUfm4U6Yw%3BFXZ8dQId5ipH-int_Ay1yI2ThzEEtjeuT01CRg%3BFfxqegIdHBRq-ikfHoJbih_shzGXgwrTwJaJUw%3BFeASdwIdQm1s-ikB71z1OrDuhzHkYs_KX8CiMA%3BFWCydgIdrxGB-imJ3arOMOHlhzEcEtmTY2frwg%3BFWPATAIdoDWe-imxAg0d9LXYhzF2XAlLW0BsLg%3BFd5WGAIdLPah-ilFl0PqHn7VhzH-thpgFfOT0Q%3BFXEwEgIdxcV_-imbVh-hNKHShzEXW_MNEPUFNA%3BFeUG_gEdOPJk-ilXZKDCMkE0hjFwW9thkjxYnQ%3BFYuI9AEdfWg7-ilLl0V79xlMhjGPZ0f2pJvsuQ%3BFWx7BQIdNRwh-in12mJwkiBThjEAUurvy_oGHQ%3BFe1xGQIdfy3u-SkDz0Wy1EgBhzGv0jZoHNHz0A%3BFctYFwId_6Gk-Sl7gwnT3QoihzH99tm4zvjTwA%3BFTHdGQId5RlQ-SlVpQFT6Z4yhzGGU8DNx-elHQ%3BFezAGwIdKOvn-CkNy5S5yGvqgDHIdP6YCQw2WQ%3BFd-uPgIdCVe8-ClfdbphoumPgDEWferhR2irsw%3BFTAcOwIdQNq7-CnxXXjLADOOgDEnpTqtwOFjeA&amp;amp;mra=ls&amp;amp;sll=37.09024,-105.820312&amp;amp;sspn=23.553364,34.321289&amp;amp;ie=UTF8&amp;amp;ll=37.125286,-105.820312&amp;amp;spn=9.00626,32.41499" style="color:#0000FF;text-align:left"&gt;View Larger Map&lt;/a&gt;&lt;/small&gt;&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/33260599-6765680047314759978?l=blog.jeffscudder.com' alt='' /&gt;&lt;/div&gt;</content><link rel="replies" type="application/atom+xml" href="http://blog.jeffscudder.com/feeds/6765680047314759978/comments/default" title="Post Comments" /><link rel="replies" type="text/html" href="https://www.blogger.com/comment.g?blogID=33260599&amp;postID=6765680047314759978" title="1 Comments" /><link rel="edit" type="application/atom+xml" href="http://www.blogger.com/feeds/33260599/posts/default/6765680047314759978?v=2" /><link rel="self" type="application/atom+xml" href="http://www.blogger.com/feeds/33260599/posts/default/6765680047314759978?v=2" /><link rel="alternate" type="text/html" href="http://blog.jeffscudder.com/2009/05/recently-completed-our-half-us-tour.html" title="Recently completed: our half-US tour" /><author><name>Jeffrey Scudder</name><uri>http://www.blogger.com/profile/13002167096451875802</uri><email>noreply@blogger.com</email><gd:extendedProperty name="OpenSocialUserId" value="00750547326625434286" /></author><thr:total xmlns:thr="http://purl.org/syndication/thread/1.0">1</thr:total></entry><entry gd:etag="W/&quot;D08GQHo_cCp7ImA9WxJRF0w.&quot;"><id>tag:blogger.com,1999:blog-33260599.post-5485765422037211950</id><published>2009-05-17T13:06:00.000-07:00</published><updated>2009-05-18T23:50:21.448-07:00</updated><app:edited xmlns:app="http://www.w3.org/2007/app">2009-05-18T23:50:21.448-07:00</app:edited><category scheme="http://www.blogger.com/atom/ns#" term="music" /><title>Anticipating "it's all crazy..."</title><content type="html">One of my favorite bands is releasing a new album tomorrow and I though I'd take a short moment to gush about it. I've been a long time admirer of &lt;a href="http://www.mewithoutyou.com/"&gt;mewithoutYou&lt;/a&gt;'s work. Their abstract poetry filled with vivid imagery combines with highly energetic rich sounds and hits a sweet-spot. Certain lines tend to resonate with me. I find "&lt;a href="http://www.last.fm/music/mewithoutYou/_/O,+Porcupine"&gt;O Porcupine&lt;/a&gt;" in particular to be moving.&lt;br /&gt;&lt;br /&gt;I like to think of myself as having broad musical tastes, but if I do tend to be critical of a song it is very often overly simplistic lyrics which I fault. I don't know that I've ever sat down and thought through why that is, perhaps another time. &lt;br /&gt;&lt;br /&gt;From listening to a few preview release tracks from this album, I don't think mewithoutYou runs any risk of that sort of problem. In fact, while listening to "the Fox, the Crow and the Cookie" I found myself pulling out the dictionary to look up the words &lt;a href="http://en.wikipedia.org/wiki/Canzonette"&gt;canzonette&lt;/a&gt;, &lt;a href="http://en.wikipedia.org/wiki/Corvidae"&gt;corvidae&lt;/a&gt;, and &lt;a href="http://wordnetweb.princeton.edu/perl/webwn?s=escadrille"&gt;escadrille&lt;/a&gt;! Some of those rhymes are absolutely majestic. I think this album may satsfy even Xirzec's bombastically erudite lexical tastes. Thanks again to Andy for introducing me to their music.&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/33260599-5485765422037211950?l=blog.jeffscudder.com' alt='' /&gt;&lt;/div&gt;</content><link rel="replies" type="application/atom+xml" href="http://blog.jeffscudder.com/feeds/5485765422037211950/comments/default" title="Post Comments" /><link rel="replies" type="text/html" href="https://www.blogger.com/comment.g?blogID=33260599&amp;postID=5485765422037211950" title="2 Comments" /><link rel="edit" type="application/atom+xml" href="http://www.blogger.com/feeds/33260599/posts/default/5485765422037211950?v=2" /><link rel="self" type="application/atom+xml" href="http://www.blogger.com/feeds/33260599/posts/default/5485765422037211950?v=2" /><link rel="alternate" type="text/html" href="http://blog.jeffscudder.com/2009/05/anticipating-its-all-crazy.html" title="Anticipating &quot;it's all crazy...&quot;" /><author><name>Jeffrey Scudder</name><uri>http://www.blogger.com/profile/13002167096451875802</uri><email>noreply@blogger.com</email><gd:extendedProperty name="OpenSocialUserId" value="00750547326625434286" /></author><thr:total xmlns:thr="http://purl.org/syndication/thread/1.0">2</thr:total></entry><entry gd:etag="W/&quot;C0QARHc6fCp7ImA9WxJSFUQ.&quot;"><id>tag:blogger.com,1999:blog-33260599.post-2570254577969295783</id><published>2009-05-05T23:16:00.000-07:00</published><updated>2009-05-05T23:29:05.914-07:00</updated><app:edited xmlns:app="http://www.w3.org/2007/app">2009-05-05T23:29:05.914-07:00</app:edited><category scheme="http://www.blogger.com/atom/ns#" term="puns" /><title>A Two Pun Day</title><content type="html">If I were a rock, I wouldn't want to be marble because I wouldn't want people to take me for granite.&lt;br /&gt;&lt;br /&gt;I told one of my good friends that I was allergic to milk and he said, "No whey!"&lt;br /&gt;&lt;br /&gt;I would estimate that I make at least two puns per week. Something someone says will just strike me at an odd angle and the pun percolates out effortlessly. The other day I thought of the above two. I'm not sure if the first is original, but we were in an elevator debating whether the stone walls were made of marble or granite and I couldn't resist. Later that day, someone mentioned cottage cheese and I thought of the second. It's a certified groaner, five out of six friends agree!&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/33260599-2570254577969295783?l=blog.jeffscudder.com' alt='' /&gt;&lt;/div&gt;</content><link rel="replies" type="application/atom+xml" href="http://blog.jeffscudder.com/feeds/2570254577969295783/comments/default" title="Post Comments" /><link rel="replies" type="text/html" href="https://www.blogger.com/comment.g?blogID=33260599&amp;postID=2570254577969295783" title="0 Comments" /><link rel="edit" type="application/atom+xml" href="http://www.blogger.com/feeds/33260599/posts/default/2570254577969295783?v=2" /><link rel="self" type="application/atom+xml" href="http://www.blogger.com/feeds/33260599/posts/default/2570254577969295783?v=2" /><link rel="alternate" type="text/html" href="http://blog.jeffscudder.com/2009/05/two-pun-day.html" title="A Two Pun Day" /><author><name>Jeffrey Scudder</name><uri>http://www.blogger.com/profile/13002167096451875802</uri><email>noreply@blogger.com</email><gd:extendedProperty name="OpenSocialUserId" value="00750547326625434286" /></author><thr:total xmlns:thr="http://purl.org/syndication/thread/1.0">0</thr:total></entry><entry gd:etag="W/&quot;A0AAQ3k4cCp7ImA9WxJTFko.&quot;"><id>tag:blogger.com,1999:blog-33260599.post-6967060481872143754</id><published>2009-03-17T23:16:00.000-07:00</published><updated>2009-04-25T10:15:42.738-07:00</updated><app:edited xmlns:app="http://www.w3.org/2007/app">2009-04-25T10:15:42.738-07:00</app:edited><category scheme="http://www.blogger.com/atom/ns#" term="laptop" /><category scheme="http://www.blogger.com/atom/ns#" term="pi day" /><title>Our New Pi Day Laptop</title><content type="html">To commemorate this year's pi day, we've christened our newly purchased laptop PiPuter. It's an Acer Aspire. We were looking for a super cheap full sized laptop with decent spects and found a good deal at the MicroCenter. Vanessa says that our computer has graduated magniu cum laude from its factory and it is currently watching us - watching, watching, always watching. &lt;a onblur="try {parent.deselectBloggerImageGracefully();} catch(e) {}" href="http://4.bp.blogspot.com/_54HtFT6yBFI/SfNDnJa2QII/AAAAAAAAAZ4/s82nZSw6cwc/s1600-h/2009-04-22+033.jpg"&gt;&lt;img style="float:right; margin:0 0 10px 10px;cursor:pointer; cursor:hand;width: 240px; height: 320px;" src="http://4.bp.blogspot.com/_54HtFT6yBFI/SfNDnJa2QII/AAAAAAAAAZ4/s82nZSw6cwc/s320/2009-04-22+033.jpg" border="0" alt=""id="BLOGGER_PHOTO_ID_5328677123931914370" /&gt;&lt;/a&gt;&lt;a onblur="try {parent.deselectBloggerImageGracefully();} catch(e) {}" href="http://4.bp.blogspot.com/_54HtFT6yBFI/SfNDeh_ggDI/AAAAAAAAAZw/1c_VsWEnTxw/s1600-h/2009-04-22+021.jpg"&gt;&lt;img style="float:right; margin:0 0 10px 10px;cursor:pointer; cursor:hand;width: 320px; height: 240px;" src="http://4.bp.blogspot.com/_54HtFT6yBFI/SfNDeh_ggDI/AAAAAAAAAZw/1c_VsWEnTxw/s320/2009-04-22+021.jpg" border="0" alt=""id="BLOGGER_PHOTO_ID_5328676975909306418" /&gt;&lt;/a&gt;&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/33260599-6967060481872143754?l=blog.jeffscudder.com' alt='' /&gt;&lt;/div&gt;</content><link rel="replies" type="application/atom+xml" href="http://blog.jeffscudder.com/feeds/6967060481872143754/comments/default" title="Post Comments" /><link rel="replies" type="text/html" href="https://www.blogger.com/comment.g?blogID=33260599&amp;postID=6967060481872143754" title="0 Comments" /><link rel="edit" type="application/atom+xml" href="http://www.blogger.com/feeds/33260599/posts/default/6967060481872143754?v=2" /><link rel="self" type="application/atom+xml" href="http://www.blogger.com/feeds/33260599/posts/default/6967060481872143754?v=2" /><link rel="alternate" type="text/html" href="http://blog.jeffscudder.com/2009/03/our-new-pi-day-laptop.html" title="Our New Pi Day Laptop" /><author><name>Jeffrey Scudder</name><uri>http://www.blogger.com/profile/13002167096451875802</uri><email>noreply@blogger.com</email><gd:extendedProperty name="OpenSocialUserId" value="00750547326625434286" /></author><media:thumbnail xmlns:media="http://search.yahoo.com/mrss/" url="http://4.bp.blogspot.com/_54HtFT6yBFI/SfNDnJa2QII/AAAAAAAAAZ4/s82nZSw6cwc/s72-c/2009-04-22+033.jpg" height="72" width="72" /><thr:total xmlns:thr="http://purl.org/syndication/thread/1.0">0</thr:total></entry><entry gd:etag="W/&quot;DkQNRXc7fSp7ImA9WxVVE0U.&quot;"><id>tag:blogger.com,1999:blog-33260599.post-2245753391273195878</id><published>2009-03-05T07:21:00.001-08:00</published><updated>2009-03-06T16:06:34.905-08:00</updated><app:edited xmlns:app="http://www.w3.org/2007/app">2009-03-06T16:06:34.905-08:00</app:edited><category scheme="http://www.blogger.com/atom/ns#" term="vicodin" /><category scheme="http://www.blogger.com/atom/ns#" term="septoplasty" /><title>Septoplasty</title><content type="html">I never dreamed that I too would be undergoing &lt;a href="http://en.wikipedia.org/wiki/Septoplasty"&gt;septoplasty&lt;/a&gt; just a few short months after &lt;a href="http://bitworking.org/news/375/Septoplasty"&gt;Joe Greogorio had his operation&lt;/a&gt;. It turns out I had a pretty severely deviated septum which likely contributed to the annual sinus infections which I have been experiencing. My allergist recommended I have this operation to straighten the inside of my nose, as my left nasal passage was almost completely blocked near the bridge of my nose. In looking for a possible sinus infection I had a CT scan of my sinuses which revealed just how severe the deviation was. By the way, looking at a slice by slice cross section of your own head is fascinating.&lt;br /&gt;&lt;br /&gt;This past Wednesday I had the surgery and I will have the stitches and splints removed next Tuesday. It's been a bit different than I expected. I anticipated some pain but, surprisingly, the part that hurts most is my upper front teeth. I also didn't expect quite so much bleeding. In any case, I'm not feeling too bad and I am looking forward to the long term benefits. Also, this has been my first experience BWOV (blogging while on &lt;a href="http://en.wikipedia.org/wiki/Vicodin"&gt;vicodin&lt;/a&gt;).&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/33260599-2245753391273195878?l=blog.jeffscudder.com' alt='' /&gt;&lt;/div&gt;</content><link rel="replies" type="application/atom+xml" href="http://blog.jeffscudder.com/feeds/2245753391273195878/comments/default" title="Post Comments" /><link rel="replies" type="text/html" href="https://www.blogger.com/comment.g?blogID=33260599&amp;postID=2245753391273195878" title="3 Comments" /><link rel="edit" type="application/atom+xml" href="http://www.blogger.com/feeds/33260599/posts/default/2245753391273195878?v=2" /><link rel="self" type="application/atom+xml" href="http://www.blogger.com/feeds/33260599/posts/default/2245753391273195878?v=2" /><link rel="alternate" type="text/html" href="http://blog.jeffscudder.com/2009/03/septoplasty.html" title="Septoplasty" /><author><name>Jeffrey Scudder</name><uri>http://www.blogger.com/profile/13002167096451875802</uri><email>noreply@blogger.com</email><gd:extendedProperty name="OpenSocialUserId" value="00750547326625434286" /></author><thr:total xmlns:thr="http://purl.org/syndication/thread/1.0">3</thr:total></entry><entry gd:etag="W/&quot;CEcFQXc5fCp7ImA9WxVVE00.&quot;"><id>tag:blogger.com,1999:blog-33260599.post-7674732341545067883</id><published>2009-03-01T21:00:00.001-08:00</published><updated>2009-03-05T17:13:30.924-08:00</updated><app:edited xmlns:app="http://www.w3.org/2007/app">2009-03-05T17:13:30.924-08:00</app:edited><category scheme="http://www.blogger.com/atom/ns#" term="headspace" /><title>Two Guys Arguing - Five Questions</title><content type="html">I noticed that my friend &lt;a href="http://twitter.com/leebenjp"&gt;Ben&lt;/a&gt; is participating in a new blog named &lt;a href="http://twoguysarguing.wordpress.com/"&gt;Two Guys Arguing&lt;/a&gt; (in addition to blogs &lt;a href="http://yardspoon.blogspot.com/"&gt;one&lt;/a&gt; &lt;a href="http://themeatsweats.blogspot.com/"&gt;two&lt;/a&gt; and &lt;a href="http://regenmytoolkit.blogspot.com/"&gt;three&lt;/a&gt; :-) and I thought I'd piggy back on a recent &lt;a href="http://twoguysarguing.wordpress.com/2009/03/01/five-questions-a-response/"&gt;ice-breaker post&lt;/a&gt;.&lt;br /&gt;&lt;blockquote&gt;&lt;ol&gt;&lt;li&gt;What are you currently hacking on?&lt;/li&gt;&lt;li&gt;What are you currently getting better at?&lt;/li&gt;&lt;li&gt;What do you do when your computer is asleep?&lt;/li&gt;&lt;li&gt;Describe that ‘big fish’ project that’s been stewing in your brain.&lt;/li&gt;&lt;li&gt;What are you gonna post about this coming week?&lt;/li&gt;&lt;/ol&gt;&lt;/blockquote&gt;&lt;br /&gt;On to the answers:&lt;ol&gt;&lt;li&gt;As a small part of my day job I'm currently working on a rewrite of significant portions of the &lt;a href="http://code.google.com/p/gdata-python-client/"&gt;gdata-python-client&lt;/a&gt; to support version two of the Google Data API protocol (check out the &lt;a href="http://code.google.com/p/gdata-python-client/source/browse/#svn/branches/v2"&gt;v2 branch&lt;/a&gt;). &lt;/li&gt;&lt;li&gt;I've been trying to focus on writing speedier unit tests. Unit testing is great, but sometimes it is necessary to write end to end tests which can take a rather long time to run. Slow tests are run less often, so I've been thinking of some ways to cache some of the more expensive pieces of these end to end tests while still preserving their utility.&lt;/li&gt;&lt;li&gt;Playing with Claire is easily one of my favorite non-computer related activities. I have a wonderful wife who keeps me company and there's nothing like relaxing with the family. Aside from the yard work, remodeling, and other house related items, I do very much enjoy playing guitar now and again. I even have a somewhat regular weekly gig.&lt;/li&gt;&lt;li&gt;I have a few side projects I like to hack on here and there in my spare time. One of them I've been thinking more about recently is a computer language I've decided to call "&lt;a href="http://code.google.com/p/headspace"&gt;Headspace&lt;/a&gt;". I wanted to try an experiment and see what the effects would be of applying &lt;a href="http://en.wikipedia.org/wiki/The_Magical_Number_Seven,_Plus_or_Minus_Two"&gt;the rule of seven&lt;/a&gt; to programming.&lt;/li&gt;&lt;li&gt;I've been planning to write a bit about the surgery I've recently undergone so stay tuned ;-)&lt;/li&gt;&lt;/ol&gt;Two Guys Arguing seems like it's off to a great start and I look forward to reading along.&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/33260599-7674732341545067883?l=blog.jeffscudder.com' alt='' /&gt;&lt;/div&gt;</content><link rel="replies" type="application/atom+xml" href="http://blog.jeffscudder.com/feeds/7674732341545067883/comments/default" title="Post Comments" /><link rel="replies" type="text/html" href="https://www.blogger.com/comment.g?blogID=33260599&amp;postID=7674732341545067883" title="3 Comments" /><link rel="edit" type="application/atom+xml" href="http://www.blogger.com/feeds/33260599/posts/default/7674732341545067883?v=2" /><link rel="self" type="application/atom+xml" href="http://www.blogger.com/feeds/33260599/posts/default/7674732341545067883?v=2" /><link rel="alternate" type="text/html" href="http://blog.jeffscudder.com/2009/03/two-guys-arguing-five-questions.html" title="Two Guys Arguing - Five Questions" /><author><name>Jeffrey Scudder</name><uri>http://www.blogger.com/profile/13002167096451875802</uri><email>noreply@blogger.com</email><gd:extendedProperty name="OpenSocialUserId" value="00750547326625434286" /></author><thr:total xmlns:thr="http://purl.org/syndication/thread/1.0">3</thr:total></entry><entry gd:etag="W/&quot;DEUMSXc8fCp7ImA9WxVWFk8.&quot;"><id>tag:blogger.com,1999:blog-33260599.post-8993787774065128940</id><published>2009-02-25T21:20:00.001-08:00</published><updated>2009-02-25T21:31:28.974-08:00</updated><app:edited xmlns:app="http://www.w3.org/2007/app">2009-02-25T21:31:28.974-08:00</app:edited><category scheme="http://www.blogger.com/atom/ns#" term="twitter" /><category scheme="http://www.blogger.com/atom/ns#" term="google" /><title>Google Tweets</title><content type="html">Earlier today, &lt;a href="http://twitter.com/google/status/1251523388"&gt;Google&lt;/a&gt; posted the following on Twitter&lt;blockquote&gt;I'm 01100110 01100101 01100101 01101100 01101001 01101110 01100111 00100000 01101100 01110101 01100011 01101011 01111001 00001010&lt;/blockquote&gt;This looks suspiciously like ASCII, so I set out to render it in a more human readable form:&lt;pre&gt;Bin       Hex ASCII&lt;br /&gt;0110 0110 66  f&lt;br /&gt;0110 0101 65  e&lt;br /&gt;0110 0101 65  e&lt;br /&gt;0110 1100 6C  l&lt;br /&gt;0110 1001 69  i&lt;br /&gt;0110 1110 6E  n&lt;br /&gt;0110 0111 67  g&lt;br /&gt;0010 0000 20    (space)&lt;br /&gt;0110 1100 6C  l&lt;br /&gt;0111 0101 75  u&lt;br /&gt;0110 0011 63  c&lt;br /&gt;0110 1011 6B  k&lt;br /&gt;0111 1001 79  y&lt;br /&gt;0000 1010 0A  \n&lt;br /&gt;&lt;/pre&gt;I doubt I'm the first to post this, but there you have it :-)&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/33260599-8993787774065128940?l=blog.jeffscudder.com' alt='' /&gt;&lt;/div&gt;</content><link rel="replies" type="application/atom+xml" href="http://blog.jeffscudder.com/feeds/8993787774065128940/comments/default" title="Post Comments" /><link rel="replies" type="text/html" href="https://www.blogger.com/comment.g?blogID=33260599&amp;postID=8993787774065128940" title="3 Comments" /><link rel="edit" type="application/atom+xml" href="http://www.blogger.com/feeds/33260599/posts/default/8993787774065128940?v=2" /><link rel="self" type="application/atom+xml" href="http://www.blogger.com/feeds/33260599/posts/default/8993787774065128940?v=2" /><link rel="alternate" type="text/html" href="http://blog.jeffscudder.com/2009/02/google-tweets.html" title="Google Tweets" /><author><name>Jeffrey Scudder</name><uri>http://www.blogger.com/profile/13002167096451875802</uri><email>noreply@blogger.com</email><gd:extendedProperty name="OpenSocialUserId" value="00750547326625434286" /></author><thr:total xmlns:thr="http://purl.org/syndication/thread/1.0">3</thr:total></entry><entry gd:etag="W/&quot;Dk8MQnczcSp7ImA9WxVXGE0.&quot;"><id>tag:blogger.com,1999:blog-33260599.post-4156704969603181070</id><published>2009-02-01T21:29:00.000-08:00</published><updated>2009-02-16T09:21:23.989-08:00</updated><app:edited xmlns:app="http://www.w3.org/2007/app">2009-02-16T09:21:23.989-08:00</app:edited><category scheme="http://www.blogger.com/atom/ns#" term="test" /><category scheme="http://www.blogger.com/atom/ns#" term="GRE" /><title>Brief Haitus</title><content type="html">I'm taking a short break from posting here to study for the &lt;a href="www.ets.org/gre/"&gt;GRE&lt;/a&gt;. I'm planning to apply to grad school in the not too distant future, and figured I should study. Apologies for the pusillanimously prosaic post.&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/33260599-4156704969603181070?l=blog.jeffscudder.com' alt='' /&gt;&lt;/div&gt;</content><link rel="replies" type="application/atom+xml" href="http://blog.jeffscudder.com/feeds/4156704969603181070/comments/default" title="Post Comments" /><link rel="replies" type="text/html" href="https://www.blogger.com/comment.g?blogID=33260599&amp;postID=4156704969603181070" title="1 Comments" /><link rel="edit" type="application/atom+xml" href="http://www.blogger.com/feeds/33260599/posts/default/4156704969603181070?v=2" /><link rel="self" type="application/atom+xml" href="http://www.blogger.com/feeds/33260599/posts/default/4156704969603181070?v=2" /><link rel="alternate" type="text/html" href="http://blog.jeffscudder.com/2009/02/brief-haitus.html" title="Brief Haitus" /><author><name>Jeffrey Scudder</name><uri>http://www.blogger.com/profile/13002167096451875802</uri><email>noreply@blogger.com</email><gd:extendedProperty name="OpenSocialUserId" value="00750547326625434286" /></author><thr:total xmlns:thr="http://purl.org/syndication/thread/1.0">1</thr:total></entry><entry gd:etag="W/&quot;DUEHQXc5eyp7ImA9WxVSGE8.&quot;"><id>tag:blogger.com,1999:blog-33260599.post-2894791340329908657</id><published>2009-01-06T18:16:00.000-08:00</published><updated>2009-01-12T22:20:30.923-08:00</updated><app:edited xmlns:app="http://www.w3.org/2007/app">2009-01-12T22:20:30.923-08:00</app:edited><category scheme="http://www.blogger.com/atom/ns#" term="guitar" /><category scheme="http://www.blogger.com/atom/ns#" term="music" /><title>Guitar Hacking</title><content type="html">In highschool, I began learning to play guitar. I took private lessons at a local music store, and although I had read sheet music for over seven years by this point (mostly while playing trombone), my teacher started me out by drawing guitar tabs. Unlike sheet music with staffs, clefs, meters, and measures, guitar tabs read like a simple map of where your fingers belong. In some cases, tabs are a picture of the neck of the guitar. For example, most books of guitar chords contain diagrams that look something like this:&lt;pre&gt;&lt;br /&gt; E A D G B e&lt;br /&gt;0___________&lt;br /&gt; | | | | | |&lt;br /&gt; | | | | | |&lt;br /&gt; | | | | | |&lt;br /&gt;1-----------&lt;br /&gt; | | | | | |&lt;br /&gt; | 2 | | | |&lt;br /&gt; | | | | | |&lt;br /&gt;2-----------&lt;br /&gt; | | | | | |&lt;br /&gt; 1 | | | | 4&lt;br /&gt; | | | | | |&lt;br /&gt;3-----------&lt;br /&gt; | | | | | |&lt;br /&gt; | | | | | |&lt;br /&gt; | | | | | |&lt;br /&gt;4-----------&lt;/pre&gt;The long vertical lines are the strings, while the horizontal lines are the frets. The lower pitched strings are on the left, while the higher pitched are on the right. Finger placement is indicated by the numbers written in the strings. The index finger is 1 and the pinky is 4. This diagram is of a G major chord and it uses three fingers, two on the third fret, and one on the second.&lt;br /&gt;&lt;br /&gt;However, you could also draw a guitar tab like this:&lt;pre&gt;&lt;br /&gt; 0       1       2       3       4&lt;br /&gt;e|-------|-------|---4---|-------|&lt;br /&gt;B|-------|-------|-------|-------|&lt;br /&gt;G|-------|-------|-------|-------|&lt;br /&gt;D|-------|-------|-------|-------|&lt;br /&gt;A|-------|---2---|-------|-------|&lt;br /&gt;E|-------|-------|---1---|-------|&lt;/pre&gt;The above looks a bit more like the neck of the guitar from the point of view of the person holding it. &lt;br /&gt;&lt;br /&gt;One great way to learn how a musician plays an unusual chord, is to look at a video or picture. In that case, you'd see the neck of the guitar reversed, like this:&lt;pre&gt; &lt;br /&gt;4       3       2       1       0&lt;br /&gt;|-------|---1---|-------|-------|E&lt;br /&gt;|-------|-------|---2---|-------|A&lt;br /&gt;|-------|-------|-------|-------|D&lt;br /&gt;|-------|-------|-------|-------|G&lt;br /&gt;|-------|-------|-------|-------|B&lt;br /&gt;|-------|---4---|-------|-------|e&lt;/pre&gt;Unless, of course, you are watching one of the many left-handed guitar players (Hendrix, McCartney, etc.) in which case, you neck would look like this:&lt;pre&gt;&lt;br /&gt; 0       1       2       3       4&lt;br /&gt;E|-------|-------|---1---|-------|&lt;br /&gt;A|-------|---2---|-------|-------|&lt;br /&gt;D|-------|-------|-------|-------|&lt;br /&gt;G|-------|-------|-------|-------|&lt;br /&gt;B|-------|-------|-------|-------|&lt;br /&gt;e|-------|-------|---4---|-------|&lt;/pre&gt;The interesting thing about learning to play guitar using tabs, is that you actually have less information to go on than with sheet music. Tabs tend to lack information about the rhythm being played, tempo, and volume which are all present in sheet music. The one thing which sheet music lacks, however, is an indication of where your fingers should go when playing a particular chord or riff. Unpacking finger placement information from a cluster of notes on a staff can be difficult enough that guitar tabs make an attractive tradeoff. It is the musical equivalent of a domain specific language.&lt;br /&gt;&lt;br /&gt;With the prevalence of recorded music which can be rewound and replayed over and over, a guitar player can often reconstruct the rythms and other necessary information by listening to the song. No longer need all information live on the page, the quick and dirty guitar hacker plays with tabs on the stand and the music in her head.&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/33260599-2894791340329908657?l=blog.jeffscudder.com' alt='' /&gt;&lt;/div&gt;</content><link rel="replies" type="application/atom+xml" href="http://blog.jeffscudder.com/feeds/2894791340329908657/comments/default" title="Post Comments" /><link rel="replies" type="text/html" href="https://www.blogger.com/comment.g?blogID=33260599&amp;postID=2894791340329908657" title="1 Comments" /><link rel="edit" type="application/atom+xml" href="http://www.blogger.com/feeds/33260599/posts/default/2894791340329908657?v=2" /><link rel="self" type="application/atom+xml" href="http://www.blogger.com/feeds/33260599/posts/default/2894791340329908657?v=2" /><link rel="alternate" type="text/html" href="http://blog.jeffscudder.com/2009/01/guitar-hacking.html" title="Guitar Hacking" /><author><name>Jeffrey Scudder</name><uri>http://www.blogger.com/profile/13002167096451875802</uri><email>noreply@blogger.com</email><gd:extendedProperty name="OpenSocialUserId" value="00750547326625434286" /></author><thr:total xmlns:thr="http://purl.org/syndication/thread/1.0">1</thr:total></entry><entry gd:etag="W/&quot;DEUDQn8yfyp7ImA9WxRbE0o.&quot;"><id>tag:blogger.com,1999:blog-33260599.post-5459319669730482646</id><published>2008-11-19T22:23:00.000-08:00</published><updated>2008-12-03T23:37:53.197-08:00</updated><app:edited xmlns:app="http://www.w3.org/2007/app">2008-12-03T23:37:53.197-08:00</app:edited><category scheme="http://www.blogger.com/atom/ns#" term="app engine" /><category scheme="http://www.blogger.com/atom/ns#" term="mashup" /><category scheme="http://www.blogger.com/atom/ns#" term="mashupcamp" /><title>Mashup Camp 8</title><content type="html">I participated in &lt;a href="http://www.mashupcamp.com/wiki/index.php/MashupCamp8DiscussionIdeas"&gt;MashupCamp8&lt;/a&gt; and created a simple &lt;a href="http://en.wikipedia.org/wiki/Mashup_(web_application_hybrid)"&gt;mashup&lt;/a&gt; in a few hours which I have now &lt;a href="http://code.google.com/p/sippycode/source/browse/#svn/trunk/mashupcamp_editor"&gt;open-sourced&lt;/a&gt;. It is a blog post editor, or article editor if you prefer, which finds key words in your text as you are writing and displays web search results for those key words next to the editor. Here's my elevator pitch:&lt;br /&gt;&lt;br /&gt;When writing an article or blog post, I'll often note places where I should add a link and go back later to add them in. Sometimes searching for good resources to link to uncovers new information which I wish I had known while I was writing the article. &lt;br /&gt;&lt;br /&gt;As I was walking around here at Mashup Camp, I saw a few web services which would allow me to do some data mining on raw text (like this blog post I'm writing) and search the web for relevant information. &lt;br /&gt;&lt;br /&gt;I created a simple Ajax editor, which is hosted on Google App Engine. It takes the article's text, sends it securely (over HTTPS) to &lt;a href="http://www.opencalais.com/"&gt;Open Calais&lt;/a&gt; which extracts key words then disambiguates, dedupes, and scores them for relevancy. Using this semantic web data from Calais, the editor then performs a web search on each of the keywords and requests results from the &lt;a href="http://developer.yahoo.com/search/boss/"&gt;Yahoo Search BOSS API&lt;/a&gt; in the JSON format. The text analysis and web search is done automatically when the editor detects that you have stopped typing. To avoid excessive and distracting search refreshes, the editor will wait between three and eight seconds before performing the search.&lt;br /&gt;&lt;br /&gt;You can try it out here: &lt;br /&gt;&lt;a href="https://sippycode.appspot.com/article_editor"&gt;https://sippycode.appspot.com/article_editor&lt;/a&gt;.&lt;br /&gt;&lt;br /&gt;Download the source code &lt;a href="http://code.google.com/p/sippycode/downloads/list?q=label:MashupCamp"&gt;here&lt;/a&gt;.&lt;br /&gt;&lt;br /&gt;This simple little mashup was &lt;a href="http://www.opencalais.com/node/9951"&gt;well received&lt;/a&gt;, and I think part of the reason is the potential for growth. The fundamental idea, is to have an environment in which relevant data is brought to you as you work. You don't even need to go info hunting, our computers can find relevant information and bring it to you automagically.&lt;br /&gt;&lt;br /&gt;For this particular mashup app, I had envisioned a few additional features, the addition of which is left as an exercise to the reader if you should so choose.&lt;ul&gt;&lt;li&gt;A WSIWYG editor to create rich HTML instead of just plain text. (I looked at tinyMCE but ran out of time.)&lt;/li&gt;&lt;li&gt;Search on combinations of keywords instead of just individual items identified by Calais.&lt;/li&gt;&lt;li&gt;Search other information sources, like news results, images, videos.&lt;/li&gt;&lt;li&gt;Search on multiple search engines. (Google has an easy to use Ajax search API, but I wanted to try something that was totally new to me.)&lt;/li&gt;&lt;/ul&gt;&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/33260599-5459319669730482646?l=blog.jeffscudder.com' alt='' /&gt;&lt;/div&gt;</content><link rel="replies" type="application/atom+xml" href="http://blog.jeffscudder.com/feeds/5459319669730482646/comments/default" title="Post Comments" /><link rel="replies" type="text/html" href="https://www.blogger.com/comment.g?blogID=33260599&amp;postID=5459319669730482646" title="5 Comments" /><link rel="edit" type="application/atom+xml" href="http://www.blogger.com/feeds/33260599/posts/default/5459319669730482646?v=2" /><link rel="self" type="application/atom+xml" href="http://www.blogger.com/feeds/33260599/posts/default/5459319669730482646?v=2" /><link rel="alternate" type="text/html" href="http://blog.jeffscudder.com/2008/11/mashup-camp-8.html" title="Mashup Camp 8" /><author><name>Jeffrey Scudder</name><uri>http://www.blogger.com/profile/13002167096451875802</uri><email>noreply@blogger.com</email><gd:extendedProperty name="OpenSocialUserId" value="00750547326625434286" /></author><thr:total xmlns:thr="http://purl.org/syndication/thread/1.0">5</thr:total></entry><entry gd:etag="W/&quot;CEYAR3Y6eip7ImA9WxRUEUs.&quot;"><id>tag:blogger.com,1999:blog-33260599.post-3166839608692563656</id><published>2008-11-11T23:19:00.001-08:00</published><updated>2008-11-19T22:22:26.812-08:00</updated><app:edited xmlns:app="http://www.w3.org/2007/app">2008-11-19T22:22:26.812-08:00</app:edited><category scheme="http://www.blogger.com/atom/ns#" term="xml" /><category scheme="http://www.blogger.com/atom/ns#" term="python" /><title>XML Library with Versioning</title><content type="html">I recently created a simple Python library for converting objects to and from XML. Code samples up front, here's how you would define some class to represent some hierarchical XML:&lt;pre&gt;class AtomFeed(XmlElement):&lt;br /&gt;  _qname = '{http://www.w3.org/2005/Atom}feed'&lt;br /&gt;  title = Title&lt;br /&gt;  entries = [Entry]&lt;br /&gt;&lt;br /&gt;class Entry(XmlElement):&lt;br /&gt;  _qname = '{http://www.w3.org/2005/Atom}entry'&lt;br /&gt;  links = [Link]&lt;br /&gt;  title = Title&lt;br /&gt;  content = Content&lt;br /&gt;&lt;br /&gt;class Link(XmlElement):&lt;br /&gt;  _qname = '{http://www.w3.org/2005/Atom}link'&lt;br /&gt;  rel = 'rel'&lt;br /&gt;  address = 'href'&lt;br /&gt;&lt;br /&gt;class Url(XmlElement):&lt;br /&gt;  _qname = '{http://www.w3.org/2005/Atom}url'&lt;br /&gt;&lt;br /&gt;class Title(XmlElement):&lt;br /&gt;  _qname = '{http://www.w3.org/2005/Atom}title'&lt;br /&gt;  title_type = 'type'&lt;/pre&gt;Now for the whys and hows.&lt;br /&gt;&lt;br /&gt;For the past few years I've been working with Web Services and most of them use XML to represent the data (though I hope JSON catches on more widely). There are some great XML libraries out there, and my library is based on one of them (ElementTree). XML parsing is certainly nothing new, so why create a new one?&lt;h4&gt;The Why&lt;/h4&gt;There are a few limitations with the XML parsing approaches I've used in Python:&lt;br /&gt;&lt;ul&gt;&lt;li&gt;XML structure isn't documented or available using &lt;code&gt;help()&lt;/code&gt;&lt;/li&gt;&lt;li&gt;No autocompete for finding elements in the XML&lt;/li&gt;&lt;li&gt;If the XML changes in a new version of the web service, my code needs to be rewritten&lt;/li&gt;&lt;li&gt;My code interacting with the XML is verbose&lt;/li&gt;&lt;br /&gt;&lt;/ul&gt;Source code can provide a wealth of information, but parsed XML doesn't have the same level of information richness as source code. Between tool tips in IDEs, auto-generated documentation, and autocomplete, having classes loaded for your XML models can bring the tree traversal logic closer to your fingertips. Many software development tools are optimized for working with predefined classes rather than generic XML objects.&lt;br /&gt;&lt;br /&gt;However, one of the biggest drawbacks to representing each type of XML element with it's own class is that you end up needing to write lots of class definitions. For this reason I've tried to make the XML class definitions as compact as possible. Specifying a simple XML class only takes two lines of code. For each type of sub-element and each XML attribute, you can add one line of code. You don't need to declare all of the elements or attributes either. The XmlElement will preserve all of the XML which it parses. If there are class members which correspond to a specified sub-element, the element will be placed in that member. Any unspecified elements will be converted to XmlElement instances. You can search over all XML elements (both anticipated members and unanticipated generic objects) using the &lt;code&gt;get_elements&lt;/code&gt; method. XML attributes are handled in a similar fashion and can be searched using &lt;code&gt;get_attributes&lt;/code&gt;.&lt;br /&gt;&lt;br /&gt;I've saved the most unique feature of this library for last: Sometimes web services change the XML definition thereby breaking your code. If it is something small like a change in XML namespace or changing a tag, it seems like such a waste to have to edit lines upon lines of code. To address this kind of problem, this XML library supports versioning. When you parse or generate XML, you can specify the version of the available rules that you'd like to use. You can use the same objects with any version of the web service.&lt;br /&gt;&lt;br /&gt;To use versioning, write a class definition with tuples containing the version specific information:&lt;pre&gt;class Control(XmlElement):&lt;br /&gt;  _qname = ('{http://purl.org/atom/app#}control', #v1&lt;br /&gt;            '{http://www.w3.org/2007/app}control') #v2&lt;br /&gt;  draft = Draft&lt;br /&gt;  uri = 'atomURI'&lt;br /&gt;  lang = 'atomLanguageTag'&lt;br /&gt;  tag = ('control_tag', 'tag') # v1, v2&lt;br /&gt;&lt;br /&gt;class Draft(XmlElement):&lt;br /&gt;  _qname = ('{http://purl.org/atom/app#}draft', &lt;br /&gt;            '{http://www.w3.org/2007/app}draft')&lt;/pre&gt;If you create an instance of the Control element like this:&lt;pre&gt;c = Control(draft=Draft('yes'), tag='test')&lt;/pre&gt;Then you can generate XML for each version like this:&lt;pre&gt;c.to_string(1)&lt;/pre&gt;returns&lt;pre&gt;&amp;lt;control xmlns="http://purl.org/atom/app#" &lt;br /&gt;    control_tag="test"&amp;gt;&lt;br /&gt;  &amp;lt;draft&amp;gt;yes&amp;lt;/draft&amp;gt;&lt;br /&gt;&amp;lt;/control&amp;gt;&lt;/pre&gt;while&lt;pre&gt;c.to_string(2)&lt;/pre&gt;returns&lt;pre&gt;&amp;lt;control xmlns="http://www.w3.org/2007/app" &lt;br /&gt;    tag="test"&amp;gt;&lt;br /&gt;  &amp;lt;draft&amp;gt;yes&amp;lt;/draft&amp;gt;&lt;br /&gt;&amp;lt;/control&amp;gt;&lt;/pre&gt;Note the difference in XML namespaces in the above. I also added an example of an attribute name which changed between versions, though "tag" doesn't actually belong in &lt;code&gt;AtomPub control&lt;/code&gt; (so don't go trying to use it m'kay).&lt;br /&gt;&lt;br /&gt;Since this library is open source, you're free to examine how it works and use it however you like. Allow me to highlight a few key points.&lt;h4&gt;The How&lt;/h4&gt;Earlier I showed how to define XML element classes which look for specific sub elements and attributes and convert them into member objects. I also mentioned that this XML library handles versioning, meaning that the same object can parse and produce different XML depending on a version parameter. Both of these are accomplished by creating class level rule sets which are built up using introspection the first time an XML conversion is attempted.&lt;br /&gt;&lt;br /&gt;In pseudo-code it works like this.&lt;pre&gt;XML --&amp;gt; object&lt;br /&gt;  - find out the desired version&lt;br /&gt;  - is there an entry for this version in _rule_set?&lt;br /&gt;  - if not, look at all XML members of this class &lt;br /&gt;      in _members&lt;br /&gt;  - create XML matching rules based on each member's type&lt;br /&gt;      (and store in _rule_set so we don't need to generate &lt;br /&gt;       the rules again)&lt;br /&gt;  - iterate over all sub-elements in the XML tree&lt;br /&gt;  - sub-elements and attributes which are in the rule set &lt;br /&gt;      are converted into the declared type&lt;br /&gt;  - sub-elements and attributes which don't fit a rule are&lt;br /&gt;      stored in _other_elements or _other_attributes&lt;/pre&gt;When generating XML the process is similar but slightly different.&lt;pre&gt;object --&amp;gt; XML&lt;br /&gt;  - create an XML tree with the tag and namespace for this &lt;br /&gt;      object given the desired version&lt;br /&gt;  - look at all members of this class in _members&lt;br /&gt;  - tell each member to attach itself to the tree using &lt;br /&gt;      it's rules for the desired version&lt;br /&gt;  - iterate through _other_elements and _other_attributes &lt;br /&gt;      and tell each to attach to the XML tree&lt;/pre&gt;Armed with the above explanation, understanding the &lt;a href="http://code.google.com/p/sippycode/source/browse/trunk/sippycode/xml/core.py"&gt;source code&lt;/a&gt; should be a bit easier.&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/33260599-3166839608692563656?l=blog.jeffscudder.com' alt='' /&gt;&lt;/div&gt;</content><link rel="replies" type="application/atom+xml" href="http://blog.jeffscudder.com/feeds/3166839608692563656/comments/default" title="Post Comments" /><link rel="replies" type="text/html" href="https://www.blogger.com/comment.g?blogID=33260599&amp;postID=3166839608692563656" title="0 Comments" /><link rel="edit" type="application/atom+xml" href="http://www.blogger.com/feeds/33260599/posts/default/3166839608692563656?v=2" /><link rel="self" type="application/atom+xml" href="http://www.blogger.com/feeds/33260599/posts/default/3166839608692563656?v=2" /><link rel="alternate" type="text/html" href="http://blog.jeffscudder.com/2008/11/xml-library-with-versioning.html" title="XML Library with Versioning" /><author><name>Jeffrey Scudder</name><uri>http://www.blogger.com/profile/13002167096451875802</uri><email>noreply@blogger.com</email><gd:extendedProperty name="OpenSocialUserId" value="00750547326625434286" /></author><thr:total xmlns:thr="http://purl.org/syndication/thread/1.0">0</thr:total></entry><entry gd:etag="W/&quot;D0EAQn8-eCp7ImA9WxRUGE0.&quot;"><id>tag:blogger.com,1999:blog-33260599.post-3506851407405291707</id><published>2008-11-05T21:47:00.001-08:00</published><updated>2008-11-27T09:07:23.150-08:00</updated><app:edited xmlns:app="http://www.w3.org/2007/app">2008-11-27T09:07:23.150-08:00</app:edited><category scheme="http://www.blogger.com/atom/ns#" term="vi" /><category scheme="http://www.blogger.com/atom/ns#" term="vim" /><category scheme="http://www.blogger.com/atom/ns#" term="style" /><title>Vim Line Length</title><content type="html">I happen to be a fan of the &lt;code&gt;vi&lt;/code&gt; text editor. I also happen to be a fan of code style guidelines. And sometimes it is very handy to know if a line in your source code has gone over eighty characters long. Some style guides still recommend a max line length of eighty characters, a tradition dating all the way back to &lt;a href="http://en.wikipedia.org/wiki/Punched_cards#IBM_80_column_punch_card_format"&gt;IBM punch cards&lt;/a&gt;, circa 1928. For an even more impressive feat of long term engineering influence look up how the size of Roman war chariots determined the size of NASA space shuttle booster rockets. But I digress.&lt;br /&gt;&lt;br /&gt;To mark the characters which are over the eighty character limit, enter the following either within &lt;code&gt;vim&lt;/code&gt; or in your &lt;code&gt;.vimrc&lt;/code&gt; file.&lt;pre&gt;:match ErrorMsg '\%&gt;80v.\+'&lt;/pre&gt;I've noticed that some blogger templates tend to display fifty-five characters in a fixed width format (as in a &lt;code&gt;&amp;lt;pre&amp;gt;&lt;/code&gt; block or &lt;code&gt;&amp;lt;code&amp;gt;&lt;/code&gt;). To edit code which I plan to post on Blogger, I sometimes turn on&lt;pre&gt;:match ErrorMsg '\%&gt;55v.\+'&lt;/pre&gt;&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/33260599-3506851407405291707?l=blog.jeffscudder.com' alt='' /&gt;&lt;/div&gt;</content><link rel="replies" type="application/atom+xml" href="http://blog.jeffscudder.com/feeds/3506851407405291707/comments/default" title="Post Comments" /><link rel="replies" type="text/html" href="https://www.blogger.com/comment.g?blogID=33260599&amp;postID=3506851407405291707" title="3 Comments" /><link rel="edit" type="application/atom+xml" href="http://www.blogger.com/feeds/33260599/posts/default/3506851407405291707?v=2" /><link rel="self" type="application/atom+xml" href="http://www.blogger.com/feeds/33260599/posts/default/3506851407405291707?v=2" /><link rel="alternate" type="text/html" href="http://blog.jeffscudder.com/2008/11/vim-line-length.html" title="Vim Line Length" /><author><name>Jeffrey Scudder</name><uri>http://www.blogger.com/profile/13002167096451875802</uri><email>noreply@blogger.com</email><gd:extendedProperty name="OpenSocialUserId" value="00750547326625434286" /></author><thr:total xmlns:thr="http://purl.org/syndication/thread/1.0">3</thr:total></entry><entry gd:etag="W/&quot;CkMAQnc_cCp7ImA9WxRXGUg.&quot;"><id>tag:blogger.com,1999:blog-33260599.post-1571859065591721543</id><published>2008-10-25T07:58:00.000-07:00</published><updated>2008-10-25T09:00:43.948-07:00</updated><app:edited xmlns:app="http://www.w3.org/2007/app">2008-10-25T09:00:43.948-07:00</app:edited><category scheme="http://www.blogger.com/atom/ns#" term="sculpture" /><category scheme="http://www.blogger.com/atom/ns#" term="android" /><title>Atom-Powered Robots Run Amok</title><content type="html">I imagine a grand total of two of my readers will recognize the title of this post. (Hint: it's from &lt;a href="http://tools.ietf.org/html/rfc5023"&gt;RFC 5023&lt;/a&gt;.) But it seemed an appropriate title for a recent addition to a local office building where some &lt;a href="http://code.google.com/android/"&gt;Android&lt;/a&gt; &lt;a href="http://source.android.com/"&gt;developers&lt;/a&gt; tend to congregate.&lt;div style="text-align:center"&gt;&lt;a onblur="try {parent.deselectBloggerImageGracefully();} catch(e) {}" href="http://3.bp.blogspot.com/_54HtFT6yBFI/SQM2NevsQvI/AAAAAAAAAQ8/VtP1059ML2w/s1600-h/IMG_0381.JPG"&gt;&lt;img style="cursor:pointer; cursor:hand;width: 400px; height: 300px;" src="http://3.bp.blogspot.com/_54HtFT6yBFI/SQM2NevsQvI/AAAAAAAAAQ8/VtP1059ML2w/s400/IMG_0381.JPG" border="0" alt=""id="BLOGGER_PHOTO_ID_5261108394918167282" /&gt;&lt;/a&gt;&lt;br /&gt;(Note the tiny t-shirt logo.)&lt;br /&gt;&lt;a onblur="try {parent.deselectBloggerImageGracefully();} catch(e) {}" href="http://2.bp.blogspot.com/_54HtFT6yBFI/SQM2OI1QOGI/AAAAAAAAARE/Ed7z1y0R2q4/s1600-h/IMG_0390.JPG"&gt;&lt;img style="cursor:pointer; cursor:hand;width: 400px; height: 300px;" src="http://2.bp.blogspot.com/_54HtFT6yBFI/SQM2OI1QOGI/AAAAAAAAARE/Ed7z1y0R2q4/s400/IMG_0390.JPG" border="0" alt=""id="BLOGGER_PHOTO_ID_5261108406215784546" /&gt;&lt;/a&gt;&lt;br /&gt;Ai luff mai Android.&lt;/div&gt;&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/33260599-1571859065591721543?l=blog.jeffscudder.com' alt='' /&gt;&lt;/div&gt;</content><link rel="replies" type="application/atom+xml" href="http://blog.jeffscudder.com/feeds/1571859065591721543/comments/default" title="Post Comments" /><link rel="replies" type="text/html" href="https://www.blogger.com/comment.g?blogID=33260599&amp;postID=1571859065591721543" title="4 Comments" /><link rel="edit" type="application/atom+xml" href="http://www.blogger.com/feeds/33260599/posts/default/1571859065591721543?v=2" /><link rel="self" type="application/atom+xml" href="http://www.blogger.com/feeds/33260599/posts/default/1571859065591721543?v=2" /><link rel="alternate" type="text/html" href="http://blog.jeffscudder.com/2008/10/atom-powered-robots-run-amok.html" title="Atom-Powered Robots Run Amok" /><author><name>Jeffrey Scudder</name><uri>http://www.blogger.com/profile/13002167096451875802</uri><email>noreply@blogger.com</email><gd:extendedProperty name="OpenSocialUserId" value="00750547326625434286" /></author><media:thumbnail xmlns:media="http://search.yahoo.com/mrss/" url="http://3.bp.blogspot.com/_54HtFT6yBFI/SQM2NevsQvI/AAAAAAAAAQ8/VtP1059ML2w/s72-c/IMG_0381.JPG" height="72" width="72" /><thr:total xmlns:thr="http://purl.org/syndication/thread/1.0">4</thr:total></entry><entry gd:etag="W/&quot;D0QHQXsyfSp7ImA9WxVXGE0.&quot;"><id>tag:blogger.com,1999:blog-33260599.post-684779978538135363</id><published>2008-10-15T23:41:00.001-07:00</published><updated>2009-02-16T09:28:50.595-08:00</updated><app:edited xmlns:app="http://www.w3.org/2007/app">2009-02-16T09:28:50.595-08:00</app:edited><category scheme="http://www.blogger.com/atom/ns#" term="open source" /><category scheme="http://www.blogger.com/atom/ns#" term="python" /><category scheme="http://www.blogger.com/atom/ns#" term="twitter" /><title>Twitter Client</title><content type="html">As a proof of concept for using the &lt;a href="http://code.google.com/p/sippycode/"&gt;sippycode HTTP library&lt;/a&gt; which I wrote about in my last post, I decided to create a simple text console client for Twitter. Download the Twitter terminal application &lt;a href="http://code.google.com/p/sippycode/downloads/list?q=label:Twitter"&gt;here&lt;/a&gt;.&lt;br /&gt;&lt;br /&gt;Twitter's RESTful API is quite simple, and I wrote an open source library for Twitter based on the sippycode HTTP library in a few minutes. Here's an example of posting a new update (&lt;a href="http://en.wikipedia.org/wiki/Twitter"&gt;tweeting&lt;/a&gt;):&lt;pre&gt;import sippycode.http.core as http_core&lt;br /&gt;import sippycode.auth.core as auth_core&lt;br /&gt;&lt;br /&gt;class TwitterClient(object):&lt;br /&gt;&lt;br /&gt;  def __init__(self, username, password):&lt;br /&gt;    self._credentials = auth_core.BasicAuth(username, &lt;br /&gt;                                            password)&lt;br /&gt;&lt;br /&gt;  def update(self, message):&lt;br /&gt;    request = http_core.HttpRequest(method='POST')&lt;br /&gt;    http_core.parse_uri(&lt;br /&gt;            'http://twitter.com/statuses/update.xml'&lt;br /&gt;        ).modify_request(request)&lt;br /&gt;    request.add_form_inputs({'status': message})&lt;br /&gt;    self._credentials.modify_request(request)&lt;br /&gt;    client = http_core.HttpClient()&lt;br /&gt;    response = client.request(request)&lt;br /&gt;    return response&lt;/pre&gt;In the above, the client sends an authenticated POST to the updates URL. Using the &lt;code&gt;TwitterClient&lt;/code&gt; in your code looks like this:&lt;pre&gt;client = TwitterClient('my-username', 'my-password')&lt;br /&gt;client.update('Try out this Twitter client: &lt;a href="http://code.google.com/p/sippycode/downloads/list?q=label:Twitter"&gt;http://oji.me/wP&lt;/a&gt;')&lt;/pre&gt;To try out this Twitter console app, unpack the download and run &lt;code&gt;sippy_twitter.py&lt;/code&gt;. With it, you can update your status on Twitter or read the updates from your friends. When reading, the client displays five updates at a time, since showing more at once would likely cause some to scroll off the top of the screen (assuming the terminal displays twenty-five lines). &lt;br /&gt;&lt;br /&gt;This simple application was designed to be a proof of concept, but it's really grown on me. Cycling through all of my friend's updates doesn't require any scrolling, and it feels snappier than the web interface. It seems like others are enjoying this terminal client too. &lt;br /&gt;&lt;br /&gt;There are quite a few ways that this client could be improved, so there's plenty of opportunity to pitch in if you are interested. I have received feature requests from friends who previewed this app, such as: support command line arguments which will allow the client to perform updates when being run from another program, show a running countdown from 140 characters as you are typing your update (could probably be done using &lt;code&gt;&lt;a href="http://www.amk.ca/python/howto/curses/"&gt;ncurses&lt;/a&gt;&lt;/code&gt;), ability to follow users, and read updates from just one user. If you'd like to participate in any of these, let me know in the comments. &lt;br /&gt;&lt;br /&gt;Fire up your terminal and give this client a try. Why not post an update to &lt;a href="http://twitter.com/jscud"&gt;@jscud&lt;/a&gt; right now?&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/33260599-684779978538135363?l=blog.jeffscudder.com' alt='' /&gt;&lt;/div&gt;</content><link rel="replies" type="application/atom+xml" href="http://blog.jeffscudder.com/feeds/684779978538135363/comments/default" title="Post Comments" /><link rel="replies" type="text/html" href="https://www.blogger.com/comment.g?blogID=33260599&amp;postID=684779978538135363" title="1 Comments" /><link rel="edit" type="application/atom+xml" href="http://www.blogger.com/feeds/33260599/posts/default/684779978538135363?v=2" /><link rel="self" type="application/atom+xml" href="http://www.blogger.com/feeds/33260599/posts/default/684779978538135363?v=2" /><link rel="alternate" type="text/html" href="http://blog.jeffscudder.com/2008/10/twitter-client.html" title="Twitter Client" /><author><name>Jeffrey Scudder</name><uri>http://www.blogger.com/profile/13002167096451875802</uri><email>noreply@blogger.com</email><gd:extendedProperty name="OpenSocialUserId" value="00750547326625434286" /></author><thr:total xmlns:thr="http://purl.org/syndication/thread/1.0">1</thr:total></entry><entry gd:etag="W/&quot;A0YCRngzeyp7ImA9WxRXEU4.&quot;"><id>tag:blogger.com,1999:blog-33260599.post-4492041656231128438</id><published>2008-10-13T21:12:00.000-07:00</published><updated>2008-10-15T23:39:27.683-07:00</updated><app:edited xmlns:app="http://www.w3.org/2007/app">2008-10-15T23:39:27.683-07:00</app:edited><category scheme="http://www.blogger.com/atom/ns#" term="open source" /><category scheme="http://www.blogger.com/atom/ns#" term="projects" /><category scheme="http://www.blogger.com/atom/ns#" term="https" /><category scheme="http://www.blogger.com/atom/ns#" term="python" /><title>An Open Source Python HTTP Client</title><content type="html">At &lt;a href="http://superhappydevhouse.org/"&gt;Super Happy Dev House&lt;/a&gt; &lt;a href="http://superhappydevhouse.org/SuperHappyDevHouse27"&gt;27&lt;/a&gt;, I made significant progress on an open source library for making HTTP requests in Python. For the past few years I've been working with web services and APIs (&lt;a href="http://en.wikipedia.org/wiki/SOAP"&gt;SOAP&lt;/a&gt;, &lt;a href="http://www.youtube.com/watch?v=YCcAE2SCQ6k"&gt;REST&lt;/a&gt; (&lt;a href="http://en.wikipedia.org/wiki/REST"&gt;wikipedia&lt;/a&gt;) - specifically &lt;a href="http://www.youtube.com/watch?v=T04fKsD56LU"&gt;AtomPub&lt;/a&gt;, etc.) and I wanted to create an HTTP library which is simple, clean, and precise. Python has a couple of great HTTP libraries already, but one of them is a bit too low level (&lt;a href="http://www.python.org/doc/lib/module-httplib.html"&gt;httplib&lt;/a&gt;) and the other is too high level (&lt;a href="http://www.python.org/doc/lib/module-urllib2.html"&gt;urllib2&lt;/a&gt;). &lt;br /&gt;&lt;br /&gt;For example, in httplib you call a method to send data as if you are writing to a file (httplib uses sockets, after all). Required HTTP headers like Content-Length are not calculated for you. You'll need to handle cookies and redirects on your own. On the plus side, you get full control of what is being sent. The higher level library, urllib2, is built on top of httplib. It adds some handy abstractions, like calculating the Content-Length, but it also has some limitations. I haven't yet been able to figure out how to perform a &lt;code&gt;PUT&lt;/code&gt; or &lt;code&gt;DELETE&lt;/code&gt; with urllib2.&lt;br /&gt;&lt;br /&gt;When making HTTP calls to web services, there are often a large number of HTTP headers, URL parameters, and components to the request. Making a request feels like making a function call in most HTTP libraries. In the past, I've wrapped these functions with successive layers containing more and more function parameters. For example, in a request to send a photo and metadata to PicasaWeb, you need to include an Authorization token, Content-Type specifying a MIME-multipart request and the multipart boundary, and a multipart payload consisting of the Atom XML describing the photo and the photo's binary data. If you add in the the ability to specify other headers and URL parameters, your function call might look like this:&lt;pre&gt;def post_photo(url, url_parameters, escape_parameters, &lt;br /&gt;               photo_mime_type, photo_file_handle, &lt;br /&gt;               photo_file_size, metadata_xml, &lt;br /&gt;               metadata_mime_type, auth_token, &lt;br /&gt;               additional_http_headers)&lt;br /&gt;...&lt;br /&gt;&lt;br /&gt;# Sets the request's Host, port, and uri. &lt;br /&gt;# Makes the request into a MIME multipart request, &lt;br /&gt;# adjusts the Content-Type and recalculates &lt;br /&gt;# Content-Length.&lt;br /&gt;# Sets the Authorization header&lt;br /&gt;post_photo('http://picasaweb.google.com/data/'&lt;br /&gt;           'feed/api/user/userID/albumid/albumID', None, &lt;br /&gt;           False, 'image/jpeg', photo_file, photo_size, &lt;br /&gt;           atom_xml, 'application/atom-xml', &lt;br /&gt;           client_login_token, None)&lt;/pre&gt;To use the above, you have to gather all of the information in one place, and make the function call. There are cases where you want a design like the above. &lt;br /&gt;&lt;br /&gt;However, more and more I think of ways the program could be more cleanly structured if this information could be compartmentalized. This new library relies on an &lt;code&gt;HttpRequest&lt;/code&gt; object which various parts of the program modify. Once all of the modifications have been applied, the fully constructed request is passed to an HttpClient which communicates with the server using httplib or urlfetch if you happen to be on Google App Engine. (Support for more HTTP libraries is certainly possible.)&lt;br /&gt;&lt;br /&gt;The photo posting example from above could look something like this. Keep in mind that these steps could be carried out in a different order in different segments of code.&lt;pre&gt;photo_post = HttpRequest(method='POST')&lt;br /&gt;# Sets the Authorization header&lt;br /&gt;client_login_token.modify_request(photo_post)&lt;br /&gt;# Adds to the body and calculated Content-Length, &lt;br /&gt;# sets the Content-Type.&lt;br /&gt;photo_post.add_body_part(atom_xml, &lt;br /&gt;    'application/atom+xml')&lt;br /&gt;# Makes the request into a MIME multipart request, &lt;br /&gt;# adjusts the Content-Type and recalculates &lt;br /&gt;# Content-Length.&lt;br /&gt;photo_post.add_body_part(photo_file, 'image/jpeg', &lt;br /&gt;    photo_size)&lt;br /&gt;# Sets the request's Host, port, and uri. &lt;br /&gt;parse_uri('http://picasaweb.google.com/data/'&lt;br /&gt;          'feed/api/user/userID/albumid/albumID'&lt;br /&gt;          ).modify_request(photo_post)&lt;/pre&gt;In fact, the above code could make up the body of the &lt;code&gt;post_photo&lt;/code&gt; function described in the first code snippet.&lt;br /&gt;&lt;br /&gt;I created an &lt;a href="http://code.google.com/p/sippycode/"&gt;open source project&lt;/a&gt; for this and other small projects called &lt;code&gt;&lt;a href="http://code.google.com/p/sippycode/source/browse/#svn/trunk/sippycode/http"&gt;sippycode&lt;/a&gt;&lt;/code&gt; (a play on sippy cup). This is a place where code can grow up.&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/33260599-4492041656231128438?l=blog.jeffscudder.com' alt='' /&gt;&lt;/div&gt;</content><link rel="replies" type="application/atom+xml" href="http://blog.jeffscudder.com/feeds/4492041656231128438/comments/default" title="Post Comments" /><link rel="replies" type="text/html" href="https://www.blogger.com/comment.g?blogID=33260599&amp;postID=4492041656231128438" title="0 Comments" /><link rel="edit" type="application/atom+xml" href="http://www.blogger.com/feeds/33260599/posts/default/4492041656231128438?v=2" /><link rel="self" type="application/atom+xml" href="http://www.blogger.com/feeds/33260599/posts/default/4492041656231128438?v=2" /><link rel="alternate" type="text/html" href="http://blog.jeffscudder.com/2008/10/open-source-python-http-client.html" title="An Open Source Python HTTP Client" /><author><name>Jeffrey Scudder</name><uri>http://www.blogger.com/profile/13002167096451875802</uri><email>noreply@blogger.com</email><gd:extendedProperty name="OpenSocialUserId" value="00750547326625434286" /></author><thr:total xmlns:thr="http://purl.org/syndication/thread/1.0">0</thr:total></entry><entry gd:etag="W/&quot;AkUGQX05cSp7ImA9WxRQEUU.&quot;"><id>tag:blogger.com,1999:blog-33260599.post-7827211925586951346</id><published>2008-09-28T23:11:00.001-07:00</published><updated>2008-10-04T23:30:20.329-07:00</updated><app:edited xmlns:app="http://www.w3.org/2007/app">2008-10-04T23:30:20.329-07:00</app:edited><category scheme="http://www.blogger.com/atom/ns#" term="open source" /><category scheme="http://www.blogger.com/atom/ns#" term="xo laptop" /><category scheme="http://www.blogger.com/atom/ns#" term="screen" /><title>In Praise of screen</title><content type="html">I've used &lt;a href="http://en.wikipedia.org/wiki/Gnu_screen"&gt;screen&lt;/a&gt; for a few years now, but I only recently learned about one of its highly helpful features. As I was using my &lt;a href="http://laptop.org/"&gt;XO laptop&lt;/a&gt; in text only mode (&lt;code&gt;ctrl-alt-fn-2&lt;/code&gt;), I was using screen to simulate multiple terminals, and I needed to copy and paste text between them. In the past, I've usually used screen when &lt;a href="http://en.wikipedia.org/wiki/Ssh"&gt;ssh&lt;/a&gt;-ing into a machine, and &lt;a href="http://www.chiark.greenend.org.uk/~sgtatham/putty/"&gt;putty&lt;/a&gt; (my ssh client of choice) provided copy and paste, so I had never needed screen's system. &lt;br /&gt;&lt;br /&gt;It turns out, screen's built-in, cross-window copy-paste system is a breeze to use. Press &lt;code&gt;ctrl-a [&lt;/code&gt; to enter copy mode, press &lt;code&gt;enter&lt;/code&gt; to mark the start point and &lt;code&gt;enter&lt;/code&gt; again to mark the end point. You have now copied the text. Switch to the desired window, and paste in the text using &lt;code&gt;ctrl-a ]&lt;/code&gt;.&lt;br /&gt;&lt;br /&gt;This feature is especially handy in the XO laptop, where I've never been able to figure out how to copy and paste in the &lt;a href="http://wiki.laptop.org/go/Terminal"&gt;Terminal Activity&lt;/a&gt;.&lt;br /&gt;&lt;br /&gt;For me, screen's most useful feature has been the ability to detach and reattach to a session which continues to run on the server. If I lose my ssh connection, all of my processes continue to run, and I can reattach to my screen session as if nothing ever happened.&lt;br /&gt;&lt;br /&gt;Screen can be difficult to understand if you've never seen it in action, so I recommend watching &lt;a href="http://fosswire.com/video/729"&gt;this video&lt;/a&gt;. You can also learn more in &lt;a href=" http://www.kuro5hin.org/story/2004/3/9/16838/14935"&gt;this tutorial&lt;/a&gt;.&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/33260599-7827211925586951346?l=blog.jeffscudder.com' alt='' /&gt;&lt;/div&gt;</content><link rel="replies" type="application/atom+xml" href="http://blog.jeffscudder.com/feeds/7827211925586951346/comments/default" title="Post Comments" /><link rel="replies" type="text/html" href="https://www.blogger.com/comment.g?blogID=33260599&amp;postID=7827211925586951346" title="0 Comments" /><link rel="edit" type="application/atom+xml" href="http://www.blogger.com/feeds/33260599/posts/default/7827211925586951346?v=2" /><link rel="self" type="application/atom+xml" href="http://www.blogger.com/feeds/33260599/posts/default/7827211925586951346?v=2" /><link rel="alternate" type="text/html" href="http://blog.jeffscudder.com/2008/09/in-praise-of-screen.html" title="In Praise of screen" /><author><name>Jeffrey Scudder</name><uri>http://www.blogger.com/profile/13002167096451875802</uri><email>noreply@blogger.com</email><gd:extendedProperty name="OpenSocialUserId" value="00750547326625434286" /></author><thr:total xmlns:thr="http://purl.org/syndication/thread/1.0">0</thr:total></entry></feed>
