<?xml version="1.0" encoding="UTF-8"?>
<rss xmlns:dc="http://purl.org/dc/elements/1.1/" version="2.0"><channel><atom:link rel="hub" href="http://tumblr.superfeedr.com/" xmlns:atom="http://www.w3.org/2005/Atom"/><description>Ben Coe is a software developer based in SF. He currently hacks up a storm at @attachmentsme His interests include climbing, coding, and being awesome.</description><title>Codes from the Underground</title><generator>Tumblr (3.0; @bencoe)</generator><link>http://www.benjamincoe.com/</link><item><title>Objective-C Designing With Blocks</title><description>&lt;p&gt;I recently started doing some Objective-C development at work. Coming from a Ruby/Python/JavaScript background, I was stoked to see that Objective-C had support for blocks.&lt;/p&gt;
&lt;p&gt;Here’s &lt;a href="http://ios-blog.co.uk/iphone-development-tutorials/programming-with-blocks-an-overview/" title="Programming With Blocks, an Overview" target="_blank"&gt;a great tutorial on the subject&lt;/a&gt;.&lt;/p&gt;
&lt;p&gt;Closures are a wonderful way to handle the complexities surrounding asynchrounous I/O. Ask any Node.js nerd, they’ll attest to this fact.&lt;/p&gt;
&lt;p&gt;I’ve been leaning on blocks heavily while building libraries for handling I/O in Objective-C. The approach I use is as follows:&lt;/p&gt;
&lt;ul&gt;&lt;li&gt;I create a delegate class that interacts with the foundation frameworks.&lt;/li&gt;
&lt;li&gt;The methods of the API exposed by the delegate accept blocks, and invoke the blocks when a series of asynchrounous actions has reached a terminal point.&lt;/li&gt;
&lt;li&gt;The class interacting with the library does not need to worry about the intermediate actions being taken by the delegate, it just trusts that its block will be invoked with the appropriate response.&lt;/li&gt;
&lt;/ul&gt;&lt;p&gt;As an example of this methodology in action, here’s an asynchrounous IMAP client I’ve been working on:&lt;/p&gt;
&lt;p&gt;&lt;a href="https://github.com/bcoe/IMAPClient"&gt;https://github.com/bcoe/IMAPClient&lt;/a&gt;&lt;/p&gt;
&lt;p&gt;The IMAP class itself is an &lt;strong&gt;&lt;em&gt;NSStreamDelegate&lt;/em&gt;&lt;/strong&gt;. When a user invokes an IMAP command, a block is provided. The delegate methods handle the specifics surrounding the asynchrounous I/O. Once an operation eventually completes, the block is invoked. Here’s the code that handles running a command:&lt;/p&gt;
&lt;script src="https://gist.github.com/1614864.js?file=command.m"&gt;&lt;/script&gt;&lt;p&gt;An individual consuming the library need not worry about these specifics. They simply provide the block and trust that it will eventually be invoked with the appropriate response. Ultimately, a series of IMAP commands takes on a form resembling this:&lt;/p&gt;
&lt;script src="https://gist.github.com/1614869.js?file=imap.m"&gt;&lt;/script&gt;&lt;p&gt;cool, eh?&lt;/p&gt;
&lt;p&gt;In the same vein, here’s what an API call looks like to an OAuth HTTP framework I’ve been working on:&lt;/p&gt;
&lt;script src="https://gist.github.com/1614887.js?file=http.m"&gt;&lt;/script&gt;&lt;p&gt;I find this is a great way to decompose asynchrounous problems. It’s been working great for us at Attachments.me, as we build out our iOS stack.&lt;/p&gt;
&lt;p&gt;— Ben (&lt;a href="http://twitter.com/#/benjamincoe" title="@benjamincoe"&gt;@benjamincoe&lt;/a&gt;)&lt;/p&gt;</description><link>http://www.benjamincoe.com/post/15891802388</link><guid>http://www.benjamincoe.com/post/15891802388</guid><pubDate>Sun, 15 Jan 2012 12:25:59 -0500</pubDate></item><item><title>SMTP Server Cage Match </title><description>&lt;p&gt;&lt;span class="s1"&gt;Last week I released smtproutes: &lt;/span&gt;A simple, Sinatra inspired, SMTP routing server.&lt;/p&gt;
&lt;p class="p1"&gt;&lt;a href="http://www.benjamincoe.com/post/13375872364/what-if-smtp-and-sinatra-had-a-baby" title="What if SMTP and Sinatra Had a Baby?" target="_blank"&gt;Read &lt;em&gt;What if SMTP and Sinatra Had a Baby?&lt;/em&gt;&lt;/a&gt;&lt;/p&gt;
&lt;p class="p1"&gt;Out of curiosity, I wanted to benchmark smtproutes vs. some other libraries that one might use for building SMTP-backed-web-services.&lt;/p&gt;
&lt;p class="p3"&gt;In this post I compare the performance of:&lt;/p&gt;
&lt;ul&gt;&lt;li&gt;smtproutes (&lt;a href="https://github.com/bcoe/smtproutes"&gt;https://github.com/bcoe/smtproutes&lt;/a&gt;)&lt;/li&gt;
&lt;li&gt;Lamson (&lt;a href="http://lamsonproject.org/"&gt;http://lamsonproject.org/&lt;/a&gt;)&lt;/li&gt;
&lt;li&gt;Pymilter (&lt;a href="http://bmsi.com/python/milter.html"&gt;http://bmsi.com/python/milter.html&lt;/a&gt;)&lt;/li&gt;
&lt;/ul&gt;&lt;blockquote&gt;
&lt;p&gt;“Three approaches to SMTP scripting enter, one approach to scripting SMTP leaves!”&lt;/p&gt;
&lt;/blockquote&gt;
&lt;p class="p3"&gt;&lt;strong&gt;The Test&lt;/strong&gt;&lt;/p&gt;
&lt;p class="p3"&gt;I was interested in seeing the number of messages that each server could process per second, under various loads.&lt;/p&gt;
&lt;ul&gt;&lt;li&gt;I created a mailing script which repeatedly mailed an 8kb message for the first benchmark and an 88kb message for the second, testing how each server dealt with small and relatively large email messages respectively.&lt;/li&gt;
&lt;li&gt;I created a mail processing script for each of the servers. This received the messages and kept a running total of the number processed per second.&lt;/li&gt;
&lt;li&gt;I tested each mail server with 1, 4, 8, and 16 concurrent mailing scripts, to simulate various loads on the server.&lt;/li&gt;
&lt;li&gt;All the benchmarks were run in an Ubuntu Maverick VMware Image, on my Intel Core 2 Duo 2.26Ghz Macbook Pro.&lt;/li&gt;
&lt;/ul&gt;&lt;p class="p3"&gt;&lt;strong&gt;The Results&lt;/strong&gt;&lt;/p&gt;
&lt;p class="p4"&gt;&lt;img alt="Benchmarks for 8KB Message" height="400" src="https://github.com/bcoe/smtproutes/raw/master/examples/benchmarking/8kmessage.png" width="500"/&gt;&lt;/p&gt;
&lt;p class="p4"&gt;&lt;img alt="Benchmarks 88kb Message" height="400" src="https://github.com/bcoe/smtproutes/raw/2fd383afc87f87e664e52c398507eb539a43f7ab/examples/benchmarking/88kmessage.png" width="500"/&gt;&lt;/p&gt;
&lt;p class="p3"&gt;&lt;strong&gt;Conclusions&lt;/strong&gt;&lt;/p&gt;
&lt;p class="p3"&gt;Pymilter is painfully slow. Why? there’s a lot of OS level overhead that comes with receiving email via sendmail. I’m sure a Unix guru could configure sendmail in such a way that Pymilter performs much more admirably (I’m not that Guru).&lt;/p&gt;
&lt;p class="p3"&gt;Lamson is fast, it outperforms smtproutes when there are a small number of concurrent connections (a single SMTP connection sending a lot of messages to the server).&lt;/p&gt;
&lt;p class="p3"&gt;smtproutes, which uses an underlying process pool, excels when there are many concurrent connections to the server. With 16 concurrent mail scripts running, it more than doubles Lamson’s throughput.&lt;/p&gt;
&lt;p class="p3"&gt;&lt;strong&gt;So What?&lt;/strong&gt;&lt;/p&gt;
&lt;p class="p3"&gt;The performance of Lamson and smtproutes helps validate the argument I’ve been putting forward in my last few blog posts (&lt;a href="http://www.benjamincoe.com/post/12753680108/writing-a-secure-smtp-server-in-python" title="Writing a Secure SMTP Server in Python" target="_blank"&gt;Writing a Secure SMTP Server in Python&lt;/a&gt;, &lt;a href="http://www.benjamincoe.com/post/13375872364/what-if-smtp-and-sinatra-had-a-baby" title="What if SMTP and Sinatra Had a Baby" target="_blank"&gt;What if SMTP and Sinatra Had a Baby?&lt;/a&gt;):&lt;/p&gt;
&lt;p class="p3"&gt;Running a lightweight SMTP server, independent of all the standard underpinnings of a captital ‘E’ email server, makes a ton of sense for a wide variety of applications that can be built using Email as a Service (&lt;span&gt;EaaS, yep I’m going to keep using this horrible acronym).&lt;/span&gt;&lt;/p&gt;
&lt;p class="p3"&gt;— Ben (&lt;a href="https://twitter.com/#/benjamincoe" title="@benjamincoe"&gt;@benjamincoe&lt;/a&gt;)&lt;/p&gt;</description><link>http://www.benjamincoe.com/post/13733519311</link><guid>http://www.benjamincoe.com/post/13733519311</guid><pubDate>Sun, 04 Dec 2011 12:22:01 -0500</pubDate></item><item><title>What if SMTP and Sinatra Had a Baby?</title><description>&lt;p&gt;Recently I’ve published several posts on the topic of composing software services on top of email. Why this recent obsession?&lt;/p&gt;
&lt;ul&gt;&lt;li&gt;People understand the paradigm of email. For some, my grandfather being a prime example, email is their main motivation for having a computer.&lt;/li&gt;
&lt;li&gt;Email is everywhere. It’s cross-platform, cross-device, cross-demographic. It’s estimated that there are nearly two billion email users.&lt;/li&gt;
&lt;li&gt; We’ve only scratched the surface of the types of applications that can be built, using Email as a Service (EaaS, yep worst acronym ever).&lt;/li&gt;
&lt;/ul&gt;&lt;p&gt;It’s this last point that gets me the most excited — and I’m literally so excited I’m yelling as I type right now.&lt;/p&gt;
&lt;p&gt;&lt;strong&gt;The Problem&lt;/strong&gt;&lt;/p&gt;
&lt;p&gt;Imagine if every time I wanted to rough out a website I had to spin up a whole J2EE stack, gross. In a similar vein, to compose a service on top of email, why should I have to run painful middleware? Quoting the ubuntu community website:&lt;/p&gt;
&lt;blockquote&gt;
&lt;p&gt;&lt;em&gt;“Setting up an email server is a difficult process involving a number of different programs”&lt;/em&gt; &lt;strong&gt;yikes!&lt;/strong&gt;&lt;/p&gt;
&lt;/blockquote&gt;
&lt;p&gt;If only there were a better way!&lt;/p&gt;
&lt;p&gt;&lt;strong&gt;The Solution (smtproutes)&lt;/strong&gt;&lt;/p&gt;
&lt;p&gt;smtproutes is what you’d get if Sinatra and SMTP had a baby. It’s not an email server with a capital&lt;em&gt; S&lt;/em&gt;. smtproutes is a lightweight framework for rapidly prototyping web-services on top of SMTP.&lt;/p&gt;
&lt;p&gt;Suppose I wanted to create an email service which lets you subscribe and unsubscribe to a mailing list. Here’s how we’d build this service using the smtproutes framework:&lt;/p&gt;
&lt;blockquote&gt;
&lt;p&gt;&lt;strong&gt;easy_install smtproutes&lt;/strong&gt;&lt;/p&gt;
&lt;/blockquote&gt;
&lt;script src="https://gist.github.com/1396666.js?file=mailing-list.py"&gt;&lt;/script&gt;&lt;p&gt;If the &lt;strong&gt;route&lt;/strong&gt; regular expression is matched by the &lt;em&gt;To: &lt;/em&gt;field of an inbound email message, the corresponding method will be executed.&lt;/p&gt;
&lt;p&gt;In this example:&lt;/p&gt;
&lt;ul&gt;&lt;li&gt;mailing &lt;em&gt;subscribe-username@example.com&lt;/em&gt; will add the user, identified by &lt;em&gt;username&lt;/em&gt; in the regular expression, to the subscribers collection.&lt;/li&gt;
&lt;li&gt;mailing &lt;em&gt;unsubscribe@example.com&lt;/em&gt; will remove the user.&lt;/li&gt;
&lt;/ul&gt;&lt;p&gt;It’s my hope that smtproutes can be a valuable tool for helping developers rapidly compose applications on top of SMTP. You can checkout some of its more advanced features, and contribute here:&lt;/p&gt;
&lt;p&gt;&lt;a href="https://github.com/bcoe/smtproutes"&gt;https://github.com/bcoe/smtproutes&lt;/a&gt;&lt;/p&gt;
&lt;p&gt;— Ben (&lt;a href="https://twitter.com/#/benjamincoe" title="@benjamincoe"&gt;@benjamincoe&lt;/a&gt;)&lt;/p&gt;</description><link>http://www.benjamincoe.com/post/13375872364</link><guid>http://www.benjamincoe.com/post/13375872364</guid><pubDate>Sat, 26 Nov 2011 20:33:00 -0500</pubDate></item><item><title>Writing a Secure SMTP Server in Python</title><description>&lt;p&gt;&lt;strong&gt;Email as a Platform&lt;/strong&gt;&lt;/p&gt;
&lt;p&gt;Some startups are beginning to see existing email protocols as a rich platform to develop applications on top of. This is cool, email is an incredible tool for communication and I don’t think it has ever been fully utilized. Hell, even my mom knows her email address (and she thinks I fix printers for a living). &lt;/p&gt;
&lt;p&gt;Here’s a list of some companies doing some awesome stuff with email protocols:&lt;/p&gt;
&lt;ul&gt;&lt;li&gt;posterous.com&lt;/li&gt;
&lt;li&gt;fiesta.cc&lt;/li&gt;
&lt;li&gt;mailgun.net&lt;/li&gt;
&lt;li&gt;attachments.me &lt;strong&gt;*cough*&lt;/strong&gt;&lt;/li&gt;
&lt;/ul&gt;&lt;p&gt;&lt;strong&gt;Building an Application on SMTP&lt;/strong&gt;&lt;/p&gt;
&lt;p&gt;There are a million options for quickly getting an HTTP-based web application off the ground. The options available for building  applications on top of SMTP/IMAP/POP aren’t quite as mature (or, as the case might be, simply don’t exist).&lt;/p&gt;
&lt;p&gt;Python, being the swiss army knife of programming languages, has an SMTP server in its standard libraries:&lt;/p&gt;
&lt;p&gt;&lt;a href="http://docs.python.org/library/smtpd.html"&gt;http://docs.python.org/library/smtpd.html&lt;/a&gt;&lt;/p&gt;
&lt;p&gt;I’ve been using this as a starting point for rapidly developing applications on top of SMTP. Having said that, it was missing some features I wanted:&lt;/p&gt;
&lt;ul&gt;&lt;li&gt;There was no SSL support.&lt;/li&gt;
&lt;li&gt;The library dealt somewhat poorly with multiple concurrent requests.&lt;/li&gt;
&lt;li&gt;The library does not support AUTH.&lt;/li&gt;
&lt;/ul&gt;&lt;p&gt;&lt;strong&gt;Secure SMTPD&lt;/strong&gt;&lt;/p&gt;
&lt;p&gt;I have started a project that subclasses &lt;em&gt;smtpd.py&lt;/em&gt; and adds support for SSL and AUTH. I have also changed the way in which new connections are handled (they are now forked), making the main process block less.&lt;/p&gt;
&lt;p&gt;Other than that, Secure-SMTPD works pretty much exactly the same way as the standard library:&lt;/p&gt;
&lt;p&gt;&lt;strong&gt;easy_install secure-smtpd&lt;/strong&gt;&lt;/p&gt;
&lt;p&gt;&lt;strong&gt;SSL SMTP Server&lt;/strong&gt;&lt;/p&gt;
&lt;script src="https://gist.github.com/1362671.js?file=server.py"&gt;&lt;/script&gt;&lt;p&gt;&lt;strong&gt;SSL SMTP Client&lt;/strong&gt;&lt;/p&gt;
&lt;script src="https://gist.github.com/1362673.js?file=client.py"&gt;&lt;/script&gt;&lt;p&gt;You can find and contribute to the project here:&lt;/p&gt;
&lt;p&gt;&lt;a href="https://github.com/bcoe/secure-smtpd"&gt;https://github.com/bcoe/secure-smtpd&lt;/a&gt;&lt;/p&gt;
&lt;p&gt;My goal is to create something that can act as a good foundation for rapidly prototyping rich SMTP-based applications that are: secure, fast, and simple.&lt;/p&gt;
&lt;p&gt;— Ben (&lt;a title="@benjamincoe" href="http://twitter.com/#/benjamincoe"&gt;@benjamincoe&lt;/a&gt;)&lt;/p&gt;</description><link>http://www.benjamincoe.com/post/12753680108</link><guid>http://www.benjamincoe.com/post/12753680108</guid><pubDate>Sun, 13 Nov 2011 15:57:00 -0500</pubDate></item><item><title>Building Your First Node.js Library</title><description>&lt;p&gt;I’ve been playing with Node.js since its early days. One of my favourite hacking experiences was the first Node Knockout Competition (what a fun language!)&lt;/p&gt;
&lt;p class="p1"&gt;What has really impressed me, is how quickly the community has matured. Taking into account the conventions that have grown up around Node.js development, I thought I’d write a post targeted at helping people get their first library out the door.&lt;/p&gt;
&lt;p class="p1"&gt;&lt;strong&gt;Structuring your Library&lt;/strong&gt;&lt;/p&gt;
&lt;p class="p1"&gt;The root directory of your library should have a structure resembling this:&lt;/p&gt;
&lt;script src="https://gist.github.com/1224234.js?file=directory-structure.txt"&gt;&lt;/script&gt;&lt;p class="p1"&gt;I’ll go over each of the important parts:&lt;/p&gt;
&lt;p class="p1"&gt;&lt;strong&gt;The lib/ directory&lt;/strong&gt;&lt;/p&gt;
&lt;p class="p1"&gt;I like my code to be very explicit, for this reason I tend to have most of my code in logically named files under &lt;em&gt;lib&lt;/em&gt;, e.g., my &lt;em&gt;Person&lt;/em&gt; library might consist of a&lt;em&gt; head.js&lt;/em&gt; file, a &lt;em&gt;torso.js&lt;/em&gt; file, and an &lt;em&gt;arm.js &lt;/em&gt;file. &lt;/p&gt;
&lt;p class="p1"&gt;index.js represents the main entry point of the library, and has responsibilities similar to &lt;em&gt;__init__.py&lt;/em&gt; in Python. It pulls the namespace together. An example helps I think:&lt;/p&gt;
&lt;script src="https://gist.github.com/1224243.js?file=index.js"&gt;&lt;/script&gt;&lt;p class="p1"&gt;&lt;strong&gt;The exports object&lt;/strong&gt;&lt;/p&gt;
&lt;p class="p1"&gt;Speaking of namespaces, there’s an exports object available in each of your library files. Anything placed on the exports array is exposed to the outside world. When you &lt;em&gt;require(‘class.js’) &lt;/em&gt;you gain access to &lt;em&gt;class.js’ &lt;/em&gt;exports object.&lt;/p&gt;
&lt;script src="https://gist.github.com/1224250.js?file=exports.js"&gt;&lt;/script&gt;&lt;p class="p1"&gt;When we &lt;em&gt;require()&lt;/em&gt; the above file, we can see that the &lt;em&gt;Foo &lt;/em&gt;and &lt;em&gt;Bar&lt;/em&gt; classes are exposed:&lt;/p&gt;
&lt;script src="https://gist.github.com/1224253.js?file=import.txt"&gt;&lt;/script&gt;&lt;p class="p1"&gt;I try to keep what I punch onto the exports object to a minimum. Generally one class per library file.&lt;/p&gt;
&lt;p class="p1"&gt;&lt;strong&gt;Testing&lt;/strong&gt;&lt;/p&gt;
&lt;p class="p1"&gt;Do a bit of a literature review, and find out which testing framework you’d like to use.&lt;/p&gt;
&lt;p class="p2"&gt;Recently I’ve been using a really light-weight approach:&lt;/p&gt;
&lt;ul&gt;&lt;li&gt;I use Node.js’ built in assert module for performing assertions: &lt;a title="Assert API" target="_blank" href="http://nodejs.org/docs/v0.3.1/api/assert.html"&gt;&lt;a href="http://nodejs.org/docs/v0.3.1/api/assert.html"&gt;http://nodejs.org/docs/v0.3.1/api/assert.html&lt;/a&gt;&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;I expose all the tests in an object with semantically named keys:&lt;/li&gt;
&lt;/ul&gt;&lt;script src="https://gist.github.com/1224255.js?file=test.js"&gt;&lt;/script&gt;&lt;ul&gt;&lt;li&gt;I expose a &lt;em&gt;finished() &lt;/em&gt;callback which is used to move the tests forward, and can be called from deep within an asynchrounous stack of logic.&lt;/li&gt;
&lt;li&gt;Finally, you simply run my tests by typing: &lt;em&gt;node test/index.js&lt;/em&gt;&lt;/li&gt;
&lt;/ul&gt;&lt;p class="p1"&gt;&lt;strong&gt;TDD is Your Friend&lt;/strong&gt;&lt;/p&gt;
&lt;p class="p1"&gt;People complain about JavaScript being a pain in the ass to test, in principal I’ll agree. &lt;/p&gt;
&lt;p class="p1"&gt;It’s really annoying to take an existing JavaScript library and get it under test. It’s so easy, a few closures deep, to introduce hard to test dependencies and sideeffects. &lt;/p&gt;
&lt;p class="p2"&gt;Having said this, I find that if you use a TDD approach to building your libraries, from the ground up, you tease apart these problems from the start.&lt;/p&gt;
&lt;p class="p1"&gt;&lt;strong&gt;Creating Your API&lt;/strong&gt;&lt;/p&gt;
&lt;p class="p1"&gt;A library isn’t a good library, without a clean API. There are a few conventions used in the Node.js that are worth sticking to:&lt;/p&gt;
&lt;ul&gt;&lt;li&gt;asynchrounous calls tend to accept a callback of the form &lt;em&gt;function(err, result)&lt;/em&gt;. This allows errors occurring deep in an asynchronous set of operations, to bubble up to the application implementing your library.&lt;/li&gt;
&lt;li&gt;optional function arguments make for a much cleaner API. You very often see this form:&lt;em&gt; function(doc, options [optional], callback [optional)]&lt;/em&gt;. Where the callback might occur in place of any of the arguments. This is nice for someone using your library, but can be a pain to implement over and over again. I’ve built a library for dealing with this:&lt;/li&gt;
&lt;/ul&gt;&lt;p&gt;&lt;strong&gt;Contribute to Sexy-Args Here: &lt;/strong&gt;&lt;a title="Sexy-Args" target="_blank" href="https://github.com/bcoe/node-sexy-args"&gt;&lt;a href="https://github.com/bcoe/node-sexy-args"&gt;https://github.com/bcoe/node-sexy-args&lt;/a&gt;&lt;/a&gt;&lt;/p&gt;
&lt;ul&gt;&lt;li&gt;Finally, write a clean descriptive interface, as you would in any language. Naming is everything! name methods well, name classes well, name your library well.&lt;/li&gt;
&lt;/ul&gt;&lt;p class="p1"&gt;&lt;strong&gt;Publishing Your Library&lt;/strong&gt;&lt;/p&gt;
&lt;p class="p1"&gt;You’ve made a killer Node.js library, and you’re ready to share it with the outside world. Here’s what you’re going to want to do:&lt;/p&gt;
&lt;ul&gt;&lt;li&gt;Create clean descriptive documentation, and examples as needed.&lt;/li&gt;
&lt;li&gt;Throw everything up on Github. This is going to be your best bet for getting other people to contribute.&lt;/li&gt;
&lt;li&gt;Update your &lt;em&gt;package.json&lt;/em&gt;. This describes your library to a package manager. Most of the keys are pretty self explanatory. Most importantly make sure that &lt;em&gt;lib&lt;/em&gt; points to your &lt;em&gt;lib&lt;/em&gt; folder, and that &lt;em&gt;main&lt;/em&gt; points to your &lt;em&gt;lib/index&lt;/em&gt; file.&lt;/li&gt;
&lt;/ul&gt;&lt;script src="https://gist.github.com/1224277.js?file=package.json"&gt;&lt;/script&gt;&lt;p class="p1"&gt;Now install NPM and publish your package:&lt;/p&gt;
&lt;ul&gt;&lt;li&gt;Follow the instructions here, to install NPM: &lt;a title="Install NPM" target="_blank" href="https://github.com/isaacs/npm"&gt;&lt;a href="https://github.com/isaacs/npm"&gt;https://github.com/isaacs/npm&lt;/a&gt;&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;Now, from your packages root directory, do something resembling this:&lt;/li&gt;
&lt;/ul&gt;&lt;script src="https://gist.github.com/1224280.js?file=npm.txt"&gt;&lt;/script&gt;&lt;ul&gt;&lt;li&gt;Finally, hop on a computer that has NPM installed. install your newly published library &lt;em&gt;npm install library&lt;/em&gt;. Hop in a &lt;em&gt;node&lt;/em&gt; terminal, and make sure everything works as advertised (push point releases until this is the case).&lt;/li&gt;
&lt;/ul&gt;&lt;p class="p1"&gt;&lt;strong&gt;Promote Your Library&lt;/strong&gt;&lt;/p&gt;
&lt;p class="p3"&gt;Now that you’ve built something awesome for the Node.js community, don’t be shy to promote the hell out of it. People can’t benefit from what they don’t know about.&lt;/p&gt;
&lt;p class="p4"&gt;To help in this process, I built this recently:&lt;/p&gt;
&lt;p class="p4"&gt;NPM-Tweets: &lt;a title="NPM-Tweets" target="_blank" href="https://github.com/bcoe/npm-tweets"&gt;&lt;a href="https://github.com/bcoe/npm-tweets"&gt;https://github.com/bcoe/npm-tweets&lt;/a&gt;&lt;/a&gt; (&lt;a title="nodenpm" target="_blank" href="http://twitter.com/#/nodenpm"&gt;@nodenpm&lt;/a&gt;)&lt;/p&gt;
&lt;p class="p3"&gt;I hope some people found this useful,&lt;/p&gt;
&lt;p class="p3"&gt;— Benjamin Coe (&lt;a title="@benjamincoe" target="_blank" href="http://twitter.com/#!/benjamincoe"&gt;@benjamincoe&lt;/a&gt;)&lt;/p&gt;</description><link>http://www.benjamincoe.com/post/10326713013</link><guid>http://www.benjamincoe.com/post/10326713013</guid><pubDate>Sat, 17 Sep 2011 15:44:00 -0400</pubDate></item><item><title>Attachments.Me: A Sexy DSL for JavaScript Arguments</title><description>&lt;a href="http://blog.attachments.me/post/10135604738"&gt;Attachments.Me: A Sexy DSL for JavaScript Arguments&lt;/a&gt;: &lt;p&gt;&lt;a href="http://blog.attachments.me/post/10135604738"&gt;attachmentsme&lt;/a&gt;:&lt;/p&gt;
&lt;blockquote&gt;
&lt;p&gt;I was working on one of my Node.js libraries and noticed I was doing something silly:&lt;/p&gt;
&lt;p&gt;&lt;strong&gt;Karait (&lt;a href="https://github.com/bcoe/karait"&gt;&lt;a href="https://github.com/bcoe/karait"&gt;https://github.com/bcoe/karait&lt;/a&gt;&lt;/a&gt;)&lt;/strong&gt;&lt;/p&gt;
&lt;script src="https://gist.github.com/1212220.js?file=example-karait.js"&gt;&lt;/script&gt;&lt;p&gt;There’s a lot of ritual around dealing with optional arguments and default parameters!&lt;/p&gt;
&lt;p&gt;I did a little literature review, and found this problem was pretty…&lt;/p&gt;
&lt;/blockquote&gt;</description><link>http://www.benjamincoe.com/post/10139491408</link><guid>http://www.benjamincoe.com/post/10139491408</guid><pubDate>Mon, 12 Sep 2011 18:19:18 -0400</pubDate></item><item><title>Attachments.Me: Designing for Asynchronous Behaviour in ElasticSearch</title><description>&lt;a href="http://blog.attachments.me/post/9276751024"&gt;Attachments.Me: Designing for Asynchronous Behaviour in ElasticSearch&lt;/a&gt;: &lt;p&gt;&lt;a href="http://blog.attachments.me/post/9276751024"&gt;attachmentsme&lt;/a&gt;:&lt;/p&gt;
&lt;blockquote&gt;

&lt;p class="p1"&gt;Let me preface this article by saying that I am relatively new to ElasticSearch. If anything I say is grossly inaccurate, please feel free to yell at me in the comments.&lt;/p&gt;
&lt;p class="p1"&gt;ElasticSearch is a great abstraction on top of Lucene:&lt;/p&gt;
&lt;ul&gt;&lt;li&gt;It handles index replication and sharding.&lt;/li&gt;
&lt;li&gt;Indexes documents very…&lt;/li&gt;
&lt;/ul&gt;&lt;/blockquote&gt;</description><link>http://www.benjamincoe.com/post/9277319836</link><guid>http://www.benjamincoe.com/post/9277319836</guid><pubDate>Mon, 22 Aug 2011 22:30:11 -0400</pubDate></item><item><title>Ben Coe, Now in HD: Episode 1</title><description>&lt;iframe width="400" height="300" src="http://www.youtube.com/embed/RnS85NfdoKQ?wmode=transparent&amp;autohide=1&amp;egm=0&amp;hd=1&amp;iv_load_policy=3&amp;modestbranding=1&amp;rel=0&amp;showinfo=0&amp;showsearch=0" frameborder="0" allowfullscreen&gt;&lt;/iframe&gt;&lt;br/&gt;&lt;br/&gt;&lt;p&gt;Ben Coe, Now in HD: Episode 1&lt;/p&gt;</description><link>http://www.benjamincoe.com/post/7474911878</link><guid>http://www.benjamincoe.com/post/7474911878</guid><pubDate>Sun, 10 Jul 2011 21:19:07 -0400</pubDate></item><item><title>Why I Hate Ruby (Or, at least, some common practices of its developers*)</title><description>&lt;p&gt;&lt;p class="p1"&gt;Let me preface this post by saying, I don’t hate Ruby the language as a whole. It has an elegant syntax and I enjoy working with it (some of my best friends are Ruby developers!). What I do hate are some of the bad habits adopted by its development community.&lt;/p&gt;
&lt;p class="p1"&gt;I will begin with a story. This past week, I have been setting up &lt;a title="elasticsearch" target="_blank" href="http://www.elasticsearch.org/"&gt;elasticsearch&lt;/a&gt; as a full text search solution for &lt;a target="_blank" href="http://attachments.me"&gt;attachments.me&lt;/a&gt;. Here’s the play-by-play.&lt;/p&gt;
&lt;p class="p1"&gt;&lt;strong&gt;Java&lt;/strong&gt;&lt;/p&gt;
&lt;p class="p1"&gt;I got the Java development environment for elasticsearch up and running. This way, if need be, I can submit patches to the elasticsearch community. It’s using a tool called &lt;a title="Gradle" target="_blank" href="http://www.gradle.org/"&gt;Gradle&lt;/a&gt; for dependency management and, for once, getting all the Java dependencies installed didn’t have me tearing my hair out.&lt;/p&gt;
&lt;p class="p1"&gt;&lt;strong&gt;Python&lt;/strong&gt; &lt;/p&gt;
&lt;p class="p1"&gt; I installed &lt;a title="Pyes" target="_blank" href="https://github.com/aparo/pyes"&gt;pyes&lt;/a&gt;, a Python client for elasticsearch. This also went very smoothly.&lt;/p&gt;
&lt;p class="p1"&gt;&lt;strong&gt;Ruby&lt;/strong&gt;&lt;/p&gt;
&lt;p class="p1"&gt;Now it was time to install a Ruby client. The library &lt;a title="Tire" target="_blank" href="https://github.com/karmi/tire"&gt;Tire&lt;/a&gt; was the most popular solution, so I went with this. All the unit tests passed, and it seemed like a safe move to add Tire to our Gemfile. The next day the code was deployed and it proceeded to crash our production environment. &lt;/p&gt;
&lt;p class="p1"&gt;Why? Because Tire relied on &lt;a title="Yajl-Ruby" target="_blank" href="https://rubygems.org/gems/yajl-ruby"&gt;yajl-ruby&lt;/a&gt; which punched the &lt;em&gt;to_json()&lt;/em&gt; method on classes with a method incompatible with &lt;em&gt;ActiveSupport&lt;/em&gt; (which also punched the same method onto classes). It gets better, in &lt;em&gt;irb&lt;/em&gt; I happened to be including the &lt;em&gt;JSON&lt;/em&gt; gem, this library expected a &lt;em&gt;to_json()&lt;/em&gt; serialization method incompatible with both &lt;em&gt;yajl/json&lt;/em&gt; and &lt;em&gt;ActiveSupport&lt;/em&gt;. The situation is so bat-shit-crazy that there’s even a &lt;a title="Multi_Json" target="_blank" href="http://rubygems.org/gems/multi_json"&gt;multi_json&lt;/a&gt; library, to provide cross-compatibility between these gems (note that this gem does not fix the serialization incompatibility).&lt;/p&gt;
&lt;p class="p1"&gt;Is the problem that there are so many JSON libraries? Not really, although this is a bit crazy. The problem is that each of the JSON libraries is mucking with the class methods.&lt;/p&gt;
&lt;p class="p2"&gt;I’m a big JavaScript groupie. Like Ruby, JavaScript is a very malleable language.  It might arguably be a bit too malleable. Early in its history, it got a reputation for its ability to turn into an unmaintainable mess. If there’s one rule that saved JavaScript, it’s this &lt;em&gt;“thou shalt not touch the global scope.”  &lt;/em&gt;Well written JavaScript libraries take this commandment to heart and, as a rule, tend to only introduce one variable into global scope.&lt;/p&gt;
&lt;p class="p2"&gt;Punching methods onto classes is cool, but it pollutes scope and can cause major issues like those I had with &lt;em&gt;to_json()&lt;/em&gt;. I think that modifying things high up in the inheritance hierarchy, as a side-effect of a require statement is, in many ways, much worse than leaking things into the global scope in JavaScript — it causes bizarre hard to track down bugs, when two libraries are contending for the same method on a class.&lt;/p&gt;
&lt;p class="p1"&gt;Do I actually hate Ruby? no. Ruby developers just need to learn from languages like JavaScript and adopt conventions which pollute scope less. That way, novice Ruby developers can utilize the language while setting off less land mines.&lt;/p&gt;
&lt;p class="p1"&gt;— Ben (&lt;a target="_blank" href="http://twitter.com/benjamincoe"&gt;@benjamincoe&lt;/a&gt;)&lt;/p&gt;
&lt;p class="p1"&gt;&lt;em&gt;* It has come to my attention that, as I do not actually hate the Ruby language as a whole, this article’s original title “Why I hate Ruby” was confusing for various individuals (many of whom did not realize what was happening in time, and erroneously read a sentence or two of the article). I have amended the title, and have lashed myself in penance.&lt;/em&gt;&lt;/p&gt;&lt;/p&gt;</description><link>http://www.benjamincoe.com/post/6234388028</link><guid>http://www.benjamincoe.com/post/6234388028</guid><pubDate>Sun, 05 Jun 2011 21:40:00 -0400</pubDate></item><item><title>Attachments.Me: Pytoad: A Hoptoad Notifier for Python </title><description>&lt;a href="http://attachmentsme.tumblr.com/post/5650060316"&gt;Attachments.Me: Pytoad: A Hoptoad Notifier for Python &lt;/a&gt;: &lt;p&gt;&lt;a href="http://attachmentsme.tumblr.com/post/5650060316"&gt;attachmentsme&lt;/a&gt;:&lt;/p&gt;
&lt;blockquote&gt;
&lt;p class="p1"&gt;We’ve recently started using &lt;a title="Hoptoad" target="_blank" href="http://www.hoptoadapp.com"&gt;Hoptoad&lt;/a&gt; for monitoring exceptions in our JavaScript and Rails code. Hoptoad is a web-service for centrally aggregating exceptions. We find it helps us much more proactively hunt down and fix bugs (getting annoying emails is a really good motivator).&lt;/p&gt;
&lt;p class="p1"&gt;Python is…&lt;/p&gt;
&lt;/blockquote&gt;</description><link>http://www.benjamincoe.com/post/5650689442</link><guid>http://www.benjamincoe.com/post/5650689442</guid><pubDate>Thu, 19 May 2011 19:07:35 -0400</pubDate></item><item><title>My Company is Hiring</title><description>&lt;a href="http://attachmentsme.tumblr.com/post/4208554686/looking-for-our-other-half"&gt;My Company is Hiring&lt;/a&gt;</description><link>http://www.benjamincoe.com/post/4324137096</link><guid>http://www.benjamincoe.com/post/4324137096</guid><pubDate>Sun, 03 Apr 2011 19:13:42 -0400</pubDate></item><item><title>Attachments.me Searches Your Gmail Attachments by Filename and Content</title><description>&lt;a href="http://ca.lifehacker.com/5767059/attachmentsme-searches-your-gmail-attachments-by-filename-and-content-and-weve-got-invites"&gt;Attachments.me Searches Your Gmail Attachments by Filename and Content&lt;/a&gt;</description><link>http://www.benjamincoe.com/post/3465232030</link><guid>http://www.benjamincoe.com/post/3465232030</guid><pubDate>Wed, 23 Feb 2011 11:19:00 -0500</pubDate></item><item><title>Attachments.me Puts A Visual, Social Spin On Email Attachment Search</title><description>&lt;a href="http://techcrunch.com/2011/02/17/attachments-me/"&gt;Attachments.me Puts A Visual, Social Spin On Email Attachment Search&lt;/a&gt;</description><link>http://www.benjamincoe.com/post/3356754144</link><guid>http://www.benjamincoe.com/post/3356754144</guid><pubDate>Thu, 17 Feb 2011 22:52:43 -0500</pubDate></item><item><title>Securing Mongodb Behind Nginx</title><description>&lt;a href="http://attachmentsme.tumblr.com/post/2658871266/securing-mongodb-behind-nginx"&gt;Securing Mongodb Behind Nginx&lt;/a&gt;</description><link>http://www.benjamincoe.com/post/2659062726</link><guid>http://www.benjamincoe.com/post/2659062726</guid><pubDate>Sat, 08 Jan 2011 19:08:36 -0500</pubDate></item><item><title>Endtable, an ORM for CouchDB on Node.JS</title><description>&lt;p&gt;Two important facts about me: I hate relational-databases, and I absolutely love Node.JS (I would have its JavaScript babies).&lt;br/&gt;&lt;br/&gt;Why do I hate relational-databases? it comes down to the way they’re usually used:&lt;br/&gt;&lt;br/&gt;If I am modeling an automobile, I really don’t care that it can be stored in and retrieved from my garage. Furthermore, my garage really shouldn’t care about the attributes of the cars being stored within it.&lt;br/&gt;&lt;br/&gt;The ORMs that I have worked with have generally felt too tightly coupled to the persistence mechanism underneath them.&lt;br/&gt;&lt;br/&gt;Back when I was developing the MMO HackWars, I was a fairly green developer:&lt;/p&gt;
&lt;ul&gt;&lt;li&gt;Having grown up developing games in C, I thought of objects as things that stuck around for a while, e.g., a player shooting at alien objects as they darted around the screen.&lt;/li&gt;
&lt;li&gt;Coming from a strong OOP background, I had an object-centric view of software development, not a data-centric view.&lt;/li&gt;
&lt;/ul&gt;&lt;p&gt;I made the following design decisions for HackWars based on these facts:&lt;/p&gt;
&lt;ul&gt;&lt;li&gt;MySQL was used purely as a key/value store. I just wanted a place to serialize my models to. &lt;/li&gt;
&lt;li&gt;Saving was abstracted away from the domain model and overseen by a central thread. I think this decision related to my not thinking of an application in terms of a request/response paradigm. &lt;/li&gt;
&lt;/ul&gt;&lt;p&gt;It was a bit of a shift for me when I started doing professional web-development. The design approaches prevalent in the space (and encouraged by frameworks like Rails) did not really jive with my way of thinking about software design. I think this might be why I took to doing a lot of front-end JavaScript work. The type of design you do in browser-side JavaScript is actually shockingly close to what I was used to from game development.&lt;br/&gt;&lt;br/&gt;Enter Node.JS. I recently saw a talk by Ryan Dahl, the creator of Node.JS. In a nutshell, he said it works “the way you feel things should”. In a similar vein, I’ve been working on an Object Mapper for CouchDB/Node.js that works the way I feel persisting data should. It’s modeled after the approach I used for my MMO:&lt;/p&gt;
&lt;ul&gt;&lt;li&gt;Models are just dumped directly to CouchDB.&lt;/li&gt;
&lt;li&gt;Relationships, validations, schemas, etc., are all implicit in the domain model, not imposed by the database.&lt;/li&gt;
&lt;li&gt;Saving is performed asynchronously and automatically. You’re always interacting with a cached version of an object, with the understanding that it will save occasionally — this is freaking fast, and works well for domains like games.&lt;/li&gt;
&lt;/ul&gt;&lt;p&gt;Without further adieu, I present to you, Endtable:&lt;br/&gt;&lt;br/&gt;You can install it either from github or NPM:&lt;/p&gt;
&lt;blockquote&gt;
&lt;p&gt;&lt;strong&gt;git clone &lt;a href="https://github.com/bcoe/endtable.git"&gt;https://github.com/bcoe/endtable.git&lt;/a&gt;&lt;/strong&gt;&lt;/p&gt;
&lt;/blockquote&gt;
&lt;p&gt;or,&lt;/p&gt;
&lt;blockquote&gt;
&lt;p&gt;&lt;strong&gt;npm install endtable&lt;/strong&gt;&lt;/p&gt;
&lt;/blockquote&gt;
&lt;p&gt;First you create an engine for connecting to CouchDB:
&lt;script src="https://gist.github.com/711287.js?file=engine.js"&gt;&lt;/script&gt;&lt;/p&gt;
&lt;p&gt;You then define the Plain-Old-JavaScript-Objects that you’ll be using:
&lt;script src="https://gist.github.com/711290.js?file=pojo.js"&gt;&lt;/script&gt;&lt;strong&gt;type&lt;/strong&gt; is a reserved word in endtable that is used when permanent views are being auto-generated.&lt;br/&gt;&lt;br/&gt;You can now create some objects:&lt;/p&gt;

&lt;script src="https://gist.github.com/711295.js?file=create-object.js"&gt;&lt;/script&gt;&lt;p&gt;As changes are made to the endtable objects, they will be automatically persisted.&lt;br/&gt;&lt;br/&gt;You can retrieve objects from CouchDB using the following syntax, views will be created on the fly:&lt;/p&gt;
&lt;script src="https://gist.github.com/711298.js?file=load.js"&gt;&lt;/script&gt;&lt;p&gt;&lt;br/&gt;There you have it, Endtable is in its primordial stages, but I’m pretty happy with how it’s looking so far. Feedback is greatly appreciated.&lt;/p&gt;</description><link>http://www.benjamincoe.com/post/1656130884</link><guid>http://www.benjamincoe.com/post/1656130884</guid><pubDate>Tue, 23 Nov 2010 00:35:00 -0500</pubDate></item><item><title>Writing Clean Maintainable JavaScript</title><description>&lt;a href="http://developers.freshbooks.com/blog/view/writing_clean_maintainable_javascript/"&gt;Writing Clean Maintainable JavaScript&lt;/a&gt;: &lt;p&gt;Some helpful tips for writing clean, maintainable, and easily testable, JavaScript.&lt;/p&gt;</description><link>http://www.benjamincoe.com/post/1582651615</link><guid>http://www.benjamincoe.com/post/1582651615</guid><pubDate>Mon, 15 Nov 2010 13:39:00 -0500</pubDate></item><item><title>Unit Testing in the Cloud with Node</title><description>&lt;p&gt;I’ve been running on little sleep this weekend, why? It’s the Node.JS Knockout:&lt;/p&gt;
&lt;blockquote&gt;
&lt;p&gt;Node.js Knockout is a coding contest inspired by Rails Rumble. The rules are simple: teams of up to 4 have 48-hours to build any node.js-based web project they can imagine.&lt;/p&gt;
&lt;/blockquote&gt;
&lt;p&gt;I have been hacking away on an entry for this competition with help from my friends &lt;a title="@bentlegen" target="_self" href="http://twitter.com/bentlegen"&gt;Ben Vinegar&lt;/a&gt; and &lt;a title="@designsense" target="_blank" href="http://twitter.com/designsense"&gt;Jaco Joubert&lt;/a&gt;. Our project:&lt;/p&gt;
&lt;p&gt;&lt;strong&gt;&lt;img alt="CloudQ" src="http://i204.photobucket.com/albums/bb91/benjamincoe/Picture4.png" height="265" width="450"/&gt;&lt;/strong&gt;&lt;/p&gt;
&lt;p&gt;&lt;br/&gt;Running on a server-side mock-browser, a secured sandbox, WebHooks, and a lot of elbow-greese, CloudQ runs your client-side JavaScript on the server, so you don’t have to.&lt;/p&gt;
&lt;ul&gt;&lt;li&gt;In the root of a public Github repo put a folder named ‘test’.&lt;/li&gt;
&lt;li&gt;Place your JavaScript QUnit tests in this folder and a file named ‘index.html’ that points to them. For an example, see &lt;a title="Schedgy" target="_blank" href="http://github.com/bcoe/schedgy"&gt;this repo&lt;/a&gt;.&lt;/li&gt;
&lt;li&gt;Go to &lt;a title="CloudQ" target="_blank" href="http://nko-team-discovery-channel.heroku.com/"&gt;CloudQ&lt;/a&gt; and enter the path to the root of your Github project (for the repo above I’d enter ‘http://github.com/bcoe/schedgy’).&lt;/li&gt;
&lt;/ul&gt;&lt;p&gt;CloudQ executes the tests it finds in index.html directly off of your Github account. But wait, there’s more, you can setup a commit-hook on Github. CloudQ will tweet when one of your builds fails, just follow us &lt;a title="CloudQ" target="_blank" href="http://twitter.com/CloudQunit"&gt;@CloudQunit&lt;/a&gt;.&lt;/p&gt;
&lt;p&gt;We’re hoping some JavaScript hackers will help us test our service before the competition ends today, please give me a shout if you’re interested.&lt;br/&gt;&lt;br/&gt;&lt;strong&gt;Here’s some Important Information:&lt;/strong&gt;&lt;/p&gt;
&lt;p&gt;&lt;em&gt;A repo setup to use CloudQ:&lt;/em&gt;&lt;/p&gt;
&lt;p&gt;&lt;a title="Repo" target="_blank" href="http://github.com/bcoe/schedgy"&gt;&lt;a href="http://github.com/bcoe/schedgy"&gt;http://github.com/bcoe/schedgy&lt;/a&gt;&lt;/a&gt;&lt;/p&gt;
&lt;p&gt;&lt;em&gt;CloudQ is hosted here:&lt;/em&gt;&lt;/p&gt;
&lt;p&gt;&lt;a title="CloudQ" target="_blank" href="http://nko-team-discovery-channel.heroku.com/"&gt;&lt;a href="http://nko-team-discovery-channel.heroku.com/"&gt;http://nko-team-discovery-channel.heroku.com/&lt;/a&gt;&lt;/a&gt;&lt;/p&gt;
&lt;p&gt;I’ll write a thorough follow-up post after the competition, but here’s some quick thoughts while I’m in the thick of things:&lt;/p&gt;
&lt;ul&gt;&lt;li&gt;Node is getting fairly mature, building CloudQ was a pleasure compared to work I was doing on Node a few months ago.&lt;/li&gt;
&lt;li&gt;For certain classes of problems, e.g. WebHooks, asynchronous design is very elegant, Node lends itself beautifully to it.&lt;/li&gt;
&lt;li&gt;Competing in this competition was a really fun way to hone my skills. If you’ve never tried out a hacking competition, give it a shot.&lt;/li&gt;
&lt;/ul&gt;</description><link>http://www.benjamincoe.com/post/1029880698</link><guid>http://www.benjamincoe.com/post/1029880698</guid><pubDate>Sun, 29 Aug 2010 03:37:00 -0400</pubDate></item><item><title>Porting Smarty to Twig with PEGs</title><description>&lt;a href="http://developers.freshbooks.com/blog/view/Porting_Smarty_to_Twig_with_PEGs/"&gt;Porting Smarty to Twig with PEGs&lt;/a&gt;</description><link>http://www.benjamincoe.com/post/1005309686</link><guid>http://www.benjamincoe.com/post/1005309686</guid><pubDate>Tue, 24 Aug 2010 17:46:51 -0400</pubDate></item><item><title>Niagara Glen 2010</title><description>&lt;p&gt;This long weekend I went on a great two day trip to Niagara Glen to climb with my friend Christian. My hotel was in Grimsby, “The Gateway to Niagara”, so getting to climbing was a manageable drive away, but next time I’ll probably shoot for a hotel closer to the Glen.&lt;/p&gt;
&lt;p&gt;I finally bought a crash-pad for this trip, which was awesome (more things to fall on).&lt;/p&gt;
&lt;p&gt;&lt;img alt="Crash Pad" src="http://i204.photobucket.com/albums/bb91/benjamincoe/IMG_0085.jpg" height="665" width="500"/&gt;&lt;/p&gt;
&lt;p&gt;My fancy new crash-pad — and Christian’s 1984 Saab.&lt;/p&gt;
&lt;p&gt;&lt;img alt="Easy Problem" src="http://i204.photobucket.com/albums/bb91/benjamincoe/IMG_0083.jpg" height="665" width="500"/&gt;&lt;/p&gt;
&lt;p&gt;Me awkwardly trying to look at a camera on an easy climb I did on my first day.&lt;/p&gt;
&lt;p&gt;&lt;img alt="Roof Problem" src="http://i204.photobucket.com/albums/bb91/benjamincoe/IMG_0100.jpg" height="665" width="500"/&gt;&lt;/p&gt;
&lt;p&gt;Me mid throw on a fairly hard roof problem that Christian and I were working on Sunday.&lt;/p&gt;
&lt;p&gt;&lt;img alt="Roof Problem" src="http://i204.photobucket.com/albums/bb91/benjamincoe/IMG_0101.jpg" height="665" width="500"/&gt;&lt;/p&gt;
&lt;p&gt;The move after that sick throw.&lt;/p&gt;
&lt;p&gt;&lt;img alt="Roof Problem" src="http://i204.photobucket.com/albums/bb91/benjamincoe/IMG_0097.jpg" height="375" width="500"/&gt;&lt;/p&gt;
&lt;p&gt;Christian climbed too.&lt;/p&gt;
&lt;p&gt;All and all, a great way to spend a long weekend.&lt;/p&gt;</description><link>http://www.benjamincoe.com/post/890538106</link><guid>http://www.benjamincoe.com/post/890538106</guid><pubDate>Sun, 01 Aug 2010 19:37:05 -0400</pubDate></item><item><title>JavaScript, Comet, and RabbitMQ Fun</title><description>&lt;p&gt;I’ve been kicking around the idea of making a sequel to HackWars, the game I created as a hobby in university. Many of the problems facing the original game were technological. Even though we had lots of coders willing to help out, it was difficult to bring people up to speed, iterating was brutal, and the whole beast was/is pretty tipsy.&lt;/p&gt;
&lt;p&gt;My plan: Develop a game with similar play mechanics but with much more scalable and manageable architecture:&lt;/p&gt;
&lt;ul&gt;&lt;li&gt;A key/value store, such as Redis, for saving player information.&lt;/li&gt;
&lt;li&gt;RabbitMQ for message passing and parallelization.&lt;/li&gt;
&lt;li&gt;JavaScript/CSS/HTML for the view (I sure as hell won’t miss Applets).&lt;/li&gt;
&lt;/ul&gt;&lt;p&gt;To test my plan, I recently started mucking with using Comet in association with RabbitMQ. The results were pretty cool, I thought I’d share them.&lt;/p&gt;
&lt;p&gt;&lt;strong&gt;The Client Side&lt;br/&gt;&lt;/strong&gt;&lt;/p&gt;
&lt;p&gt;Comet is a buzz word that describes web-applications that operate based on messages pushed from the server, rather than the more common, “are we there yet?”, pull-based architecture.&lt;/p&gt;
&lt;blockquote&gt;
&lt;p&gt;&lt;span class="searchword0"&gt;Orbited&lt;/span&gt; provides a pure JavaScript/HTML  socket in the browser.&lt;/p&gt;
&lt;/blockquote&gt;
&lt;p&gt;I implemented a push-based architecture using orbited. Orbited creates a connection to a server that you proceed to keep open as long as possible, you allow orbited to re-connect when necessary. Here’s the nitty-gritty:&lt;/p&gt;
&lt;ol&gt;&lt;li&gt;You create a configuration file that routes the orbited socket to the Comet server. My configuration file routes all connections made to the orbited server to a server I run on port 9000.&lt;br/&gt;&lt;pre&gt;&lt;span class="k"&gt;[access]&lt;br/&gt;&lt;/span&gt;&lt;span class="err"&gt;*&lt;/span&gt; &lt;span class="err"&gt;-&gt;&lt;/span&gt; &lt;span class="err"&gt;localhost:9000&lt;/span&gt;&lt;/pre&gt;
&lt;/li&gt;
&lt;li&gt;Using the orbited JavaScript libraries, you open a socket to port 9000.&lt;/li&gt;
&lt;/ol&gt;&lt;p&gt;I have started building a JavaScript library for handling messages to and from the Comet server. Outbound messages simply use jQuery and &lt;strong&gt;$.ajax()&lt;/strong&gt; to post to a light-weight HTTP controller. Inbound messages arrive via the persistent connection opened by Orbited.&lt;/p&gt;
&lt;script src="http://gist.github.com/485420.js?file=orbited.js"&gt;&lt;/script&gt;&lt;p&gt;&lt;strong&gt;The Server Side&lt;/strong&gt;&lt;/p&gt;
&lt;p&gt;There are three parts to the server-side architecture:&lt;/p&gt;
&lt;p&gt;A CherryPy server handles inbound messages and dispatches them to RabbitMQ — potentially this might be a user chatting, clicking somewhere in the GUI, whatever:&lt;/p&gt;
&lt;script src="http://gist.github.com/485413.js?file=cherrypy-server.py"&gt;&lt;/script&gt;&lt;p&gt;The Comet server listens for inbound connections from Orbited on port 9000, and proceeds to spawn the connection off into its own thread:&lt;/p&gt;
&lt;script src="http://gist.github.com/485408.js?file=comet-server.py"&gt;&lt;/script&gt;&lt;p&gt;Finally, the thread listens on RabbitMQ for messages intended for a given user. These are dispatched to the client’s browser, via the open socket.&lt;/p&gt;
&lt;script src="http://gist.github.com/485405.js?file=amqp-thread.py"&gt;&lt;/script&gt;&lt;p&gt;The code is pretty rough, but I’m pretty happy with how things are working.&lt;/p&gt;
&lt;p&gt;I can’t wait to build out this architecture more, hopefully into a fairly addictive game — at which point I can move to the Caribbean, and live on my spoils.&lt;/p&gt;</description><link>http://www.benjamincoe.com/post/843088167</link><guid>http://www.benjamincoe.com/post/843088167</guid><pubDate>Wed, 21 Jul 2010 22:08:00 -0400</pubDate><category>JavaScript</category><category>Python</category><category>Orbited</category><category>Comet</category><category>RabbitMQ</category></item></channel></rss>

