<?xml version="1.0" encoding="UTF-8"?>
<?xml-stylesheet type="text/xsl" media="screen" href="/~d/styles/rss2full.xsl"?><?xml-stylesheet type="text/css" media="screen" href="http://feeds.feedburner.com/~d/styles/itemcontent.css"?><!-- generator="wordpress/2.2.1" --><rss xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:wfw="http://wellformedweb.org/CommentAPI/" xmlns:dc="http://purl.org/dc/elements/1.1/" version="2.0">

<channel>
	<title>larrytheliquid</title>
	<link>http://larrytheliquid.com</link>
	<description>iconoclasm in virtue of phase transitions</description>
	<pubDate>Tue, 13 Oct 2009 08:58:42 +0000</pubDate>
	<generator>http://wordpress.org/?v=2.2.1</generator>
	<language>en</language>
			<atom10:link xmlns:atom10="http://www.w3.org/2005/Atom" rel="self" href="http://feeds.feedburner.com/Larrytheliquid" type="application/rss+xml" /><atom10:link xmlns:atom10="http://www.w3.org/2005/Atom" rel="hub" href="http://pubsubhubbub.appspot.com" /><item>
		<title>new blog: lemmatheultimate</title>
		<link>http://larrytheliquid.com/2009/10/13/new-blog-lemmatheultimate/</link>
		<comments>http://larrytheliquid.com/2009/10/13/new-blog-lemmatheultimate/#comments</comments>
		<pubDate>Tue, 13 Oct 2009 08:57:02 +0000</pubDate>
		<dc:creator>larrytheliquid</dc:creator>
		
		<category><![CDATA[Uncategorized]]></category>

		<guid isPermaLink="false">http://larrytheliquid.com/2009/10/13/new-blog-lemmatheultimate/</guid>
		<description><![CDATA[I only post occasionally here anyway (so the frequency will probably not change)&#8230;. however I am starting a new blog over at lemmatheultimate.com. The bandwidth of posts there will be much higher than here (see its description for why), and the topic is exploring the world of reliable software (using more rigor than you may [...]]]></description>
			<content:encoded><![CDATA[<p>I only post occasionally here anyway (so the frequency will probably not change)&#8230;. however I am starting a new blog over at <a href="http://lemmatheultimate.com">lemmatheultimate.com</a>. The bandwidth of posts there will be much higher than here (see its description for why), and the topic is exploring the world of reliable software (using more rigor than you may be thinking).</p>
]]></content:encoded>
			<wfw:commentRss>http://larrytheliquid.com/2009/10/13/new-blog-lemmatheultimate/feed/</wfw:commentRss>
		</item>
		<item>
		<title>Developing micro-architectures in web apps and services</title>
		<link>http://larrytheliquid.com/2009/07/14/developing-micro-architectures-in-web-apps-and-services/</link>
		<comments>http://larrytheliquid.com/2009/07/14/developing-micro-architectures-in-web-apps-and-services/#comments</comments>
		<pubDate>Tue, 14 Jul 2009 08:21:40 +0000</pubDate>
		<dc:creator>larrytheliquid</dc:creator>
		
		<category><![CDATA[REST]]></category>

		<category><![CDATA[Elegance]]></category>

		<category><![CDATA[Web]]></category>

		<category><![CDATA[Design]]></category>

		<category><![CDATA[Ruby on Rails]]></category>

		<category><![CDATA[Ruby]]></category>

		<category><![CDATA[Uncategorized]]></category>

		<guid isPermaLink="false">http://larrytheliquid.com/2009/07/14/developing-micro-architectures-in-web-apps-and-services/</guid>
		<description><![CDATA[Note: the following article is in the context of the Ruby community and makes many Ruby-specific references, but the principles discussed are generally language-agnostic.
Intro
By now the benefits provided by macro-architecture in the context of web applications and web services via frameworks like Rails are well-understood and do not need to be re-explained. Changes in Rails [...]]]></description>
			<content:encoded><![CDATA[<p><em>Note: the following article is in the context of the Ruby community and makes many Ruby-specific references, but the principles discussed are generally language-agnostic.</em></p>
<h2>Intro</h2>
<p>By now the benefits provided by macro-architecture in the context of web applications and web services via frameworks like Rails are well-understood and do not need to be re-explained. Changes in Rails and the introduction of ActiveResource have also contributed to the current acceptance of REST&#8217;ful principles as being beneficial in web apps.</p>
<p>However, one area that has been gaining more support in the community but has not been directly examined is that of micro-architectures. For the sake of this article I am defining a micro-architecture as a REST&#8217;ful web applications or service that is composed of several self-contained services communicated with over HTTP. Herein the general benefits of micro-architectures, as well as when and how to effectively move to them, well be discussed.</p>
<h2>Test-driving the public interface</h2>
<p>As with most software, begin TDD-style with tests first. I recommend outside-in style development, with heavy emphasis on the &#8220;outside&#8221; and little on the &#8220;in&#8221;. In other words, favor integration tests over unit tests. For example, in typical software development your goal might be the algorithmic transformation of some data set. In this case you would start out with some example base cases of how your library works, and implement them in the red-green-refactor cycle. If the implementation starts becoming too complicated then introduce some unit tests to help you manage complexity. However, remember that the purpose of the api is just to get the integration tests to pass, and any extra unit tests just make refactoring more difficult. Thus, unit tests (and even more extremely, mocking) are only a result of necessity due to complexity or test-suite run time savings.</p>
<p>The analogy in the web app/service world to our algorithmic transform library then would be to use integration tests at the highest level possible, namely through the http api. For a web application (something consumed by a human in a browser) use <a href="http://github.com/brynary/webrat/tree/master">webrat</a> so that you can exercise the same navigation and data-submission structure that users do in the browser in html. For testing web services (consumed programmatically as apis, mostly simple xml or json serialization formats), I recommend testing with <a href="http://github.com/brynary/rack-test/tree/master">rack-test</a>.</p>
<p>One common and valid argument against micro-architectures is that they are a bit complicated to setup automated tests for, although I think this is beginning to change. Either way both webrat and rack-test can be used to test rack-based applications in-memory. It is advised to start this way to avoid setup pains.</p>
<p>Once you have your tests passing you can easily convert them to shoot real http requests at servers rather than in-memory rack-object interface testing. You have many options here for webrat, including mechanize if you want to go headless and selenium if you want to spawn up a real browser. I recommend going headless, at least during development so you don&#8217;t slow down your feedback loop. If you are using rack-test then something to look out for is <a href="http://github.com/halorgium/rack-client/tree/master">rack-client</a>. Although the library isn&#8217;t mature yet, it offers a single line of code change to go from in-memory rack-test to http-based rack-test. Since webrat has a rack-test adapter, it could also be used with rack-client instead of mechanize. First get your in-memory tests passing, then write up some rackup .ru files to manually spawn servers with, and then convert the tests to http with the methods described above. After that is done, you can automate the spawning servers with your testing framework&#8217;s equivalent of RSpec before(:all) and after(:all).</p>
<h2>Development guidelines</h2>
<p>I will assume that we are building some single web app or service to be hosted at some top-level domain (e.g. facebook, google, etc). As such, the customer will be facing an api that from the outside looks like a macro-architecture, where many things are possible in a somewhat complicated service. The opposite would be many Amazon AWS-style mini services like S3, SimpleDB, EC2, etc, but these kind of public micro-services are not too common.</p>
<p>So, once again we start building our public macro-service. Because such services have growth and complexity in mind, it&#8217;s a good idea to use a larger framework like Rails or Merb with enough conventions and organization to handle that complexity. It is easier to develop an entire macro-service with a macro-architecture, putting all of your controllers, models, views, etc in the same codebase to makeup your resources. In contrast separating code out into isolated internal micro-services takes some work, in the same way that organizing a pile of legos into piles of common color is harder than throwing everything into a single pile.</p>
<p>Additionally, while setting up http-level integration testing by forking a process in before(:all) and killing it in after(:all) is manageable, doing the same with several internal services consumed by one main one is a bit more complicated to setup. Nonetheless, it is still advisable to manually do this until some nice library pops up that can handle expressing these connections and spawning/tearing down servers from them elegantly.</p>
<p>You should design your macro-architecture in a way that makes separating out micro-services easy. In other words, think about how whatever part of your app that you are building could be backed by some service that stands on its own (e.g. a blog post comments controller could be backed by a generic annotation service that accepts a uri to some resource, as well as annotation text and author information). Get your tests passing this way against your integration-level macro-service api. Note that you don&#8217;t have to test the micro-service api, that is the fun part of refactoring (but if necessary due to complexity, be sure to add tests&#8230; use the same discretion between integration, unit, and mock tests as used in the simple algorithmic transform example above).</p>
<p>The reason why you should think about the internal-service that could comprise your macro-service is to avoid sharing code between this part and the rest of the application. If you haven&#8217;t noticed already this article is really about taking classic established software principles and applying to the world of web apps. In this case we want high cohesion and loose coupling between code in various parts of our public macro-service api. This is a good practice in general, and as long as you maintain it in a slightly stricter fashion than normal then it will make extracting a micro-service possible. Also when I avoid code sharing, that doesn&#8217;t prevent you from extracting common utility code into shared gems, just stay away from sharing business logic code that will eventually make refactoring a service out unbearable.</p>
<h2>Being pragmatic</h2>
<p>Note that I am not saying that you should always follow this practice of avoiding code reuse and thinking about how to make public-api resources independent for each part of your application. Software development is a constant rearrangement of where complexity resides, whether it be in a specific, isolated, and visible portion of code, or whether it lies in the complex relationships between too many abstractions. Therefore, as always use discretion as to what makes sense to keep in the internal macro-architecture of the public macro-service, and what should be split off into internal micro-services. What I am saying is that you should be aware of when you reuse code across resources and consciously make the decision to do so. Just try to think about whether or not a resource could easily explode in complexity (making the encapsulation of the complex service worth it), or whether it could easily become a performance bottleneck (making isolated performance monitoring worth it). Those two reasons, separating out complexity via encapsulation, and performance monitoring, are the big motivators for creating a micro-architecture.</p>
<p>In any case, if you&#8217;ve identified a resource that is a good candidate for becoming a micro-service, and has already been tested implicitly via the public macro-service api, then there is a convenient middle ground to take. Rack and its notion of middleware, in addition to bigger frameworks supporting it with things like Rails Metal, make this middle ground possible. I generally like using a class that inherits from Sinatra::Base as a micro-service, as the api does not contrain your resource design like bigger frameworks with more conventions do, and keeping the amount of files and directories to a minimum is possible. Sinatra provides just enough sugar to make building a Rack-middleware a pleasant experience (although the Rails 3.0 internals are shaping up to be flexible enough to be used in a very similar way, so watch for that as well). By creating your resource as a middleware service you more explicitly mark it as code to be isolated from the rest of the internal macro-architecture, but because of Rack you get the benefit of being able to test the entire public macro-service in one process. Doing this during the development phase of your application prevents you from being barred down by setting up the integration-testing infrastructure for running several rack-apps pulled out of the middleware stack but still consumed by the main application. In fact, if the separation is just for organization encapsulation purposes then feel free to deploy your monolithic app with the micro-services as middleware. However, if you have micro-services that were separated due to performance concerns that need to be monitored then be sure to pull them out and integration test them before your public deployment.</p>
<h2>Common criticisms</h2>
<p>The most common criticism that I have not addressed when it comes to using all these micro services is complexity introduced by latency issues when dealing with many http apis. To deal with this transparently and most elegantly, I recommend Ruby 1.9 + <a href="http://github.com/espace/neverblock/tree/master">Neverblock</a>. Other options include manual event handling with <a href="http://github.com/eventmachine/em-http-request/tree/master">em-http-request</a>, or explicit thread-based latency hiding with something like &#8220;need_later&#8221; futures in <a href="http://github.com/larrytheliquid/dataflow/tree/master">Dataflow</a>.</p>
<p>Another common criticism is the complexity increased in an application because of all the new moving parts, which is indeed a problem and should be weighed against the two major motivations. Notably though, with the clear boundaries introduced via the separate applications, you can catch exceptions if one micro-service is not responding and handle error messages on the specific page that uses it. Compare this to a monolithic architecture, where partial system availability is much more difficult to design.</p>
<h2>Final remarks</h2>
<p><em>Please note that for simplicity I have been implying a ratio of one public api resource to one internal micro-service, but in reality a single micro service could be used in part by many public api resources, and a single public api resource could make use of several internal micro-services.</em></p>
<p>This concludes my summary of how to effectively manage and take advantage of an internal micro-service architecture. Micro-services are still in their young and &#8220;hip&#8221; stages compared to their macro counterparts, so expect best practices regarding them to evolve as we collectively gain experience. I think the general advice in this post is sane though, so hopefully it can serve as a reference to people not yet familiar with the topic. As always, comments/criticism welcome.</p>
<h3>Benefits</h3>
<p><em>For brevity I tried to not cover specific benefits of micro-architecture within the two major categories of encapsulation and performance monitoring isolation. Here is a list that I will update if anyone has more suggestions in the comments.</em></p>
<ul>
<li>library/gem dependency isolation</li>
<li>choosing appropriately different servers for services (e.g. passenger vs thin)</li>
<li>partial-site functioning when isolated services are down and error handling is in place</li>
<li>full http reverse-proxy caching via <a href="http://en.wikipedia.org/wiki/Edge_Side_Includes">ESI</a> pulling in bits from disparate services</li>
</ul>
]]></content:encoded>
			<wfw:commentRss>http://larrytheliquid.com/2009/07/14/developing-micro-architectures-in-web-apps-and-services/feed/</wfw:commentRss>
		</item>
		<item>
		<title>Presenting Clojure with a Gitorial</title>
		<link>http://larrytheliquid.com/2009/03/02/presenting-clojure-with-a-gitorial/</link>
		<comments>http://larrytheliquid.com/2009/03/02/presenting-clojure-with-a-gitorial/#comments</comments>
		<pubDate>Mon, 02 Mar 2009 07:25:09 +0000</pubDate>
		<dc:creator>larrytheliquid</dc:creator>
		
		<category><![CDATA[Presentation]]></category>

		<category><![CDATA[Clojure]]></category>

		<category><![CDATA[Git]]></category>

		<category><![CDATA[REST]]></category>

		<category><![CDATA[Web]]></category>

		<category><![CDATA[Productivity]]></category>

		<category><![CDATA[Blogging]]></category>

		<category><![CDATA[Feeds]]></category>

		<guid isPermaLink="false">http://larrytheliquid.com/2009/03/02/presenting-clojure-with-a-gitorial/</guid>
		<description><![CDATA[Here are the slides to the Clojure presentation I gave last week for the OrlandoJUG. Initially I was planning giving a comprehensive overview of the language, but the content ended up being long and mostly rehashed information already available online. Such a presentation would have also probably been too much to take in for one [...]]]></description>
			<content:encoded><![CDATA[<p><a href="http://github.com/larrytheliquid/buzzer" title="GitHub Mascot on white"><img src="http://larrytheliquid.com/wp-content/uploads/2009/03/github_mascot1.thumbnail.png" alt="GitHub Mascot on white" align="left" hspace="10" /></a>Here are the <a href="http://www.slideshare.net/larrytheliquid/clojure-an-overview">slides to the Clojure presentation</a> I gave last week for the <a href="http://www.codetown.us/group/orlandojug">OrlandoJUG</a>. Initially I was planning giving a <a href="http://www.codetown.us/events/orlandojug-1">comprehensive overview of the language</a>, but the content ended up being long and mostly rehashed information already available online. Such a presentation would have also probably been too much to take in for one sitting.</p>
<p>Instead, I came up with an experimental tutorial-style format. The core of the presentation was explaining a gradually built Clojure library with TDD. The experimental part was that this presentation was captured in the Git revision control system. Every commit has a commit message that explains the &#8220;next slide&#8221; of the presentation. People can then view diffs between commits to quickly see what changed.</p>
<p>GitHub was used as the presentation medium. First you go to the <a href="http://github.com/larrytheliquid/buzzer">library page</a>, then click the <a href="http://github.com/larrytheliquid/buzzer/commits">commits tab</a>, and finally click the &#8220;Older&#8221; link at the bottom to get to the first revision. For each revision you can click the title to see the commit message, and see a nice colored diff of the changes. For small commits the diff is enough and you can explain what happened right there. For larger changes it&#8217;s easier to click the filename in the diff to get the new file by itself, including syntax highlighting.</p>
<p>Because the &#8220;presentation&#8221; is on GitHub, people can view it when they get home again even if they don&#8217;t know how to use Git. However, one really powerful feature is exclusive to Git users. Once the repository has been downloaded, you are able to check out any particular revision. Because the library has passing tests at every commit (unless otherwise noted), you are able to create a branch and play with the code with the backing of tests.</p>
<p>Some other nice perks are that Git allows commit message and revision history editing. This allows you to write a &#8220;shitty first draft&#8221; quickly and not worry about getting the presentation-intended commit history perfect the first time around. Another cool thing is that presentations like this can be collaboratively improved through GitHub forks and merges.</p>
<p>The end result is a toy library accessible through a webservice, logging api hits in a separate thread, producing and consuming JSON, and integration tested through localhost over HTTP. Note that only the later commits have long messages with better explanations more suitable to a web audience. This is because I didn&#8217;t really know what I was on to at the beginning of the &#8220;Gitorial experiment&#8221;, and was planning on doing most of the explaining &#8220;on stage&#8221;.</p>
<p>This whole thing reminds me of the whole &#8220;unintended innovation&#8221; thing that keeps happening with Twitter (or even on GitHub itself with things like <a href="http://github.com/raganwald/homoiconic">Reg&#8217;s Homoiconic blog</a>). One could even imagine gradually built public Gitorials where the GitHub RSS feed is announced early for people to subscribe to. After that an Internet-full of people could &#8220;watch&#8221; the presentaiton unfold day by day in their feed reader.</p>
<p>Anyway, I talked to some people in the audience later and have only had positive feedback on the presentation format thus far. I loved it personally and plan to make more presentations in this style in the future.</p>
]]></content:encoded>
			<wfw:commentRss>http://larrytheliquid.com/2009/03/02/presenting-clojure-with-a-gitorial/feed/</wfw:commentRss>
		</item>
		<item>
		<title>Learn to Cry by writing parse trees in Ruby</title>
		<link>http://larrytheliquid.com/2008/06/05/learn-to-cry-by-writing-parse-trees-in-ruby/</link>
		<comments>http://larrytheliquid.com/2008/06/05/learn-to-cry-by-writing-parse-trees-in-ruby/#comments</comments>
		<pubDate>Thu, 05 Jun 2008 05:44:04 +0000</pubDate>
		<dc:creator>larrytheliquid</dc:creator>
		
		<category><![CDATA[Elegance]]></category>

		<category><![CDATA[Ruby]]></category>

		<guid isPermaLink="false">http://larrytheliquid.com/2008/06/05/learn-to-cry-by-writing-parse-trees-in-ruby/</guid>
		<description><![CDATA[Cry is a Ruby library that provides a nice object oriented way to create, transfer, and manipulate frozen parse trees. The idea behind the name is that you end up writing in parse tree format, in a syntax more verbose than CLOS&#8230; hence &#8220;Cry&#8221; =) In reality Cry would mainly be used in meta-programming though, [...]]]></description>
			<content:encoded><![CDATA[<p><a href="http://github.com/larrytheliquid/cry/tree/master" title="Cry"><img src="http://larrytheliquid.com/wp-content/uploads/2008/06/cry.thumbnail.jpg" title="Cry" alt="Cry" align="left" hspace="10" /></a><a href="http://github.com/larrytheliquid/cry/tree/master">Cry</a> is a Ruby library that provides a nice object oriented way to create, transfer, and manipulate frozen parse trees. The idea behind the name is that you end up writing in parse tree format, in a syntax more verbose than <a href="http://en.wikipedia.org/wiki/Common_Lisp_Object_System">CLOS</a>&#8230; hence &#8220;Cry&#8221; =) In reality Cry would mainly be used in meta-programming though, and is designed to have a simple &amp; consistent api.</p>
<p>Let&#8217;s say we have an instance of an &#8220;Account&#8221; class stored in the local variable &#8220;acnt&#8221;. It has a &#8220;withdraw&#8221; method that takes an &#8220;amount&#8221; parameter.</p>
<p>In Ruby you would normally call this method like so:</p>
<p><code>acnt.withdraw(50)</code></p>
<p>In Common Lisp&#8217;s CLOS you would do it like this:</p>
<p><code>(withdraw acnt 50)</code></p>
<p>Notice that because CLOS deals with objects, the second parameter is the instance of the class that the method will be called on. Cry copies this parameter order in its parse trees:</p>
<p><code>Cry::ParseTree.new(:withdraw, acnt, 50).evaluate</code></p>
<p>In Ruby classes are just instances of the &#8220;Class&#8221; class. Thus, the syntax for class methods remains the same:</p>
<p><code>Cry::ParseTree.new(:sqrt, Math, 16).evaluate # =&gt; 4.0</code></p>
<p>Another neat thing is that the parse tree instances are not evaluated until you call the evaluate method. This lets you pass them around, similar in concept to Procs (aka lambdas.)</p>
<p><code>parse_tree = Cry::ParseTree.new(:+, Cry::ParseTree.new(:*, 2, 3), Cry::ParseTree.new(:/, 16, 2)) # =&gt; (:+, (:*, 2, 3), (:/, 16, 2))<br />
parse_tree.evaluate # =&gt; 14</code></p>
<p><a href="http://larrytheliquid.com/wp-content/uploads/2008/06/cry-parse-tree.png" title="Cry::ParseTree"><img src="http://larrytheliquid.com/wp-content/uploads/2008/06/cry-parse-tree.thumbnail.png" title="Cry::ParseTree" alt="Cry::ParseTree" align="left" /></a>Notice that the object and any of the parameters can each be parse trees as well (and even those can continue recursively nesting parse trees with their respective objects and parameters.)</p>
<p>There are also convenient getter methods for our parse tree components:</p>
<p><code>parse_tree.node_method # =&gt; :+<br />
parse_tree.node_object # =&gt; (:*, 2, 3)<br />
parse_tree.node_arguments # =&gt; [(:/, 16, 2)]</code></p>
<p>Similarly, there are setters that could be used like this:</p>
<p><code>parse_tree.node_object = parse_tree.node_object.evaluate # =&gt; 6<br />
parse_tree.node_arguments = parse_tree.node_arguments.map{|p| p.evaluate } # =&gt; 8<br />
parse_tree.evaluate # =&gt; 14</code></p>
<p>The previous example takes components of our parse tree and evaluates them separately, then sets the results back. This opens up possibilities for having a very deeply nested parse tree, and evaluating certain sections in parallel.</p>
<p>In traditional Ruby the above can be explicitly written like so:</p>
<p><code>2.*(3).+(16./(2)) # =&gt; 16</code></p>
<p>The big difference is that this would be evaluated immediately, whereas you can delay and manipulate the whole structure by using a parse tree.</p>
<p>We previously used setter methods to manually evaluate the parse trees for the object and arguments. However, we could also change something, such as the object:</p>
<p><code>parse_tree.node_object = 5<br />
parse_tree.evaluate # =&gt; 40</code></p>
<p>Or, we could change every part of the parse tree:</p>
<p><code>parse_tree.node_method = :new<br />
parse_tree.node_object = Array<br />
parse_tree.node_arguments = [5, 9]<br />
parse_tree.evaluate # =&gt; [9, 9, 9, 9, 9]</code></p>
<p>Certain methods are defined with blocks, for these simply pass in a Proc as the last argument:</p>
<p><code># Traditional Ruby<br />
[1, 2, 3].inject(2) {|sum, i| sum + i } # =&gt; 8</code></p>
<p><code> # Cry::ParseTree Ruby<br />
parse_tree = Cry::ParseTree.new(:inject, [1, 2, 3], 2, lambda{|sum, i| sum + i })<br />
parse_tree.evaluate # =&gt; 8</code></p>
<p>Cry::ParseTree extends from Array, and internally stores the method, object, and arguments in that order respectively. Knowing this, we could have done the following to switch out the block to be used for our parse tree:</p>
<p><code>old_block = parse_tree.pop<br />
parse_tree.push lambda{|product, i| product * i }<br />
parse_tree.evaluate # =&gt; 12</code></p>
<p>We have access to all methods Array does, so this would work too:</p>
<p><code>parse_tree.each {|p| puts p.inspect }<br />
:inject<br />
[1, 2, 3]<br />
2<br />
#&lt;Proc:0x0005526c@(irb):67&gt;<br />
=&gt; (:inject, [1, 2, 3], 2, #&lt;Proc:0x0005526c@(irb):67&gt;)</code></p>
<p>That about wraps things up. If you would like to follow development, or fork/contribute to the project, you can find <a href="http://github.com/larrytheliquid/cry/tree/master">Cry on github</a>. Even if you just wonder if something will work, feel free to try out your Ruby parse tree masterpieces by adding funky ones as tests.</p>
<p>In case anyone is interested, I made this so I could have an easy datastructure to manipulate when dealing with <a href="http://en.wikipedia.org/wiki/Genetic_programming">Genetic Programming</a> algorithms. I&#8217;m working on an interesting project that involves them, and will be sure to put it on github and make a post when it&#8217;s ready.</p>
]]></content:encoded>
			<wfw:commentRss>http://larrytheliquid.com/2008/06/05/learn-to-cry-by-writing-parse-trees-in-ruby/feed/</wfw:commentRss>
		</item>
		<item>
		<title>Compiling Git and git-svn on OSX Tiger</title>
		<link>http://larrytheliquid.com/2007/12/29/compiling-git-and-git-svn-on-osx-tiger/</link>
		<comments>http://larrytheliquid.com/2007/12/29/compiling-git-and-git-svn-on-osx-tiger/#comments</comments>
		<pubDate>Sat, 29 Dec 2007 23:24:22 +0000</pubDate>
		<dc:creator>larrytheliquid</dc:creator>
		
		<category><![CDATA[Uncategorized]]></category>

		<guid isPermaLink="false">http://larrytheliquid.com/2007/12/29/compiling-git-and-git-svn-on-osx-tiger/</guid>
		<description><![CDATA[Getting Git to work properly with a package manager is pretty easy, but after having been through package version hell I only compile things now.
While compiling is normally an easy configure/make/install cycle, you do get the occasional dependency hell. Unfortunately, Git on Tiger is one such situation.
The following worked for me to get Git, Git&#8217;s [...]]]></description>
			<content:encoded><![CDATA[<p><a href="http://git.or.cz/"><img src="/images/gitit.jpg" align="left" hspace="10" /></a>Getting Git to work properly with a package manager is pretty easy, but after having been through package version hell I only compile things now.</p>
<p>While compiling is normally an easy configure/make/install cycle, you do get the occasional dependency hell. Unfortunately, Git on Tiger is one such situation.</p>
<p>The following worked for me to get Git, Git&#8217;s man pages, and git-svn working on OSX Tiger.</p>
<p>First cd to wherever you keep your source files (remember to adjust this path in all the following instructions if yours is different):</p>
<pre>cd /usr/local/src</pre>
<p>Next lets install an XML parser dependency, Git, and it&#8217;s man pages:</p>
<pre>
curl -O http://surfnet.dl.sourceforge.net/sourceforge/expat/expat-2.0.1.tar.gz
tar xvzf expat-2.0.1.tar.gz
cd expat-2.0.1
./configure --prefix=/usr/local
make
sudo make install
cd..

curl -O http://kernel.org/pub/software/scm/git/git-1.5.3.7.tar.gz
tar xvzf git-1.5.3.7.tar.gz
cd git-1.5.3.7
./configure --prefix=/usr/local
make
sudo make install
cd ..

curl -O http://www.kernel.org/pub/software/scm/git/git-manpages-1.5.3.7.tar.bz2
sudo tar xjv -C /usr/local/man -f git-manpages-1.5.3.7.tar.bz2</pre>
<p>Add the following environment variable to whatever file your shell uses (<code>.bash_profile</code> for BASH):</p>
<pre>
export MANPATH="/usr/local/man:$MANPATH"</pre>
<p>Whew, you now have Git! One cool thing it comes with is <code>git-svn</code>, which let&#8217;s you work with existing Subversion repositories. Unfortunately this does not work immediately on Tiger, and you might get an error like <code>Can't locate SVN/Core.pm in @INC</code> when trying to use it. Aw shucks&#8230; brave on to use git-svn soon!</p>
<p>First find your existing Subversion source directory, and compile some Perl modules you probably skipped originally:</p>
<pre>
cd /usr/local/src/subversion-1.4.3
make swig-pl
make check-swig-pl
sudo make install-swig-pl</pre>
<p>At this point you can use git-svn, except when dealing with an authenticated repository. The error will look like this <code>Can't locate Term/ReadKey.pm in @INC</code>, but we can fix that too. We will now connect to Perl&#8217;s CPAN (if this is your first time, just answer the questions it asks&#8230; I mostly hit enter or typed &#8220;yes&#8221; for everything) and then install something necessary to take your authentication credentials input from the command line:</p>
<pre>
perl -MCPAN -e shell
install Term::ReadKey
exit</pre>
<p>Tada, after quite a journey you are ready to start moving away from Subversion with Git and finally achieve branching nirvana! Let me know if you have any problems in the comments.</p>
<p>Many thanks to <a href="http://blog.kineticweb.com/articles/search?q=svn">Justin Reagor</a> and <a href="http://www.felocity.org/blog/article/git_svn_on_osx/">Rudolf Heuser</a> for their tips.</p>
]]></content:encoded>
			<wfw:commentRss>http://larrytheliquid.com/2007/12/29/compiling-git-and-git-svn-on-osx-tiger/feed/</wfw:commentRss>
		</item>
		<item>
		<title>InlineBBQ Queue service</title>
		<link>http://larrytheliquid.com/2007/12/21/inlinebbq-queue-service/</link>
		<comments>http://larrytheliquid.com/2007/12/21/inlinebbq-queue-service/#comments</comments>
		<pubDate>Fri, 21 Dec 2007 08:17:21 +0000</pubDate>
		<dc:creator>larrytheliquid</dc:creator>
		
		<category><![CDATA[Elegance]]></category>

		<category><![CDATA[Ruby]]></category>

		<guid isPermaLink="false">http://larrytheliquid.com/2007/12/21/inlinebbq-queue-service/</guid>
		<description><![CDATA[I was reading TopFunky&#8217;s great post on various queue&#8217;s that you can use with Ruby, and came across Rick Olson&#8217;s particularly amazing BBQ Queue service.
Being immediately inspired, I wrote a complementary version, the InlineBBQ Queue service.
Expect an MIT license on this sucker soon once it goes through at least 2 more production applications.
As mentioned in [...]]]></description>
			<content:encoded><![CDATA[<p><a href="http://pastie.caboo.se/pastes/131232"><img src="/images/omgwtfbbq.jpg" align="left" height="240" hspace="10" width="178" /></a>I was reading TopFunky&#8217;s great post on <a href="http://nubyonrails.com/articles/about-this-blog-beanstalk-messaging-queue">various queue&#8217;s that you can use with Ruby</a>, and came across Rick Olson&#8217;s particularly amazing <a href="http://pastie.textmate.org/private/vxqxcvv40omkrhvnzp6a">BBQ Queue service</a>.</p>
<p>Being immediately inspired, I wrote a complementary version, the <a href="http://pastie.caboo.se/pastes/131232">InlineBBQ Queue service</a>.</p>
<p>Expect an MIT license on this sucker soon once it goes through at least 2 more production applications.</p>
<p>As mentioned in the comments, I&#8217;m in the middle of implementing the service for Rubinius, JRuby, and IronRuby too&#8230;. &#8220;rbx&#8221; and &#8220;jruby&#8221; are just proving much harder to type than &#8220;ruby&#8221;.</p>
<p>Note: This is a joke =p</p>
]]></content:encoded>
			<wfw:commentRss>http://larrytheliquid.com/2007/12/21/inlinebbq-queue-service/feed/</wfw:commentRss>
		</item>
		<item>
		<title>class DuckTyping &lt; InterfacePolymorphism &lt; UniformInterface</title>
		<link>http://larrytheliquid.com/2007/12/18/class-ducktyping-interfacepolymorphism-uniforminterface/</link>
		<comments>http://larrytheliquid.com/2007/12/18/class-ducktyping-interfacepolymorphism-uniforminterface/#comments</comments>
		<pubDate>Tue, 18 Dec 2007 08:01:21 +0000</pubDate>
		<dc:creator>larrytheliquid</dc:creator>
		
		<category><![CDATA[Elegance]]></category>

		<category><![CDATA[REST]]></category>

		<category><![CDATA[Ruby]]></category>

		<guid isPermaLink="false">http://larrytheliquid.com/2007/12/18/class-ducktyping-interfacepolymorphism-uniforminterface/</guid>
		<description><![CDATA[I really like the concept of the Uniform Interface. One of my favorite things to do is spend hours on my whiteboard  (and sometimes days) fiddling with ideas that express what I consider to be elegance. This ranges from macroscopic elegance (ie: the architecture level) to microscopic elegance (ie: the function/method level). Somewhere in [...]]]></description>
			<content:encoded><![CDATA[<p><img src="/images/self-respond-to-rest.jpg" title="self.respond_to? " alt="self.respond_to? " align="left" hspace="10" />I really like the concept of the Uniform Interface. One of my favorite things to do is spend hours on my whiteboard  (and sometimes days) fiddling with ideas that express what I consider to be elegance. This ranges from macroscopic elegance (ie: the architecture level) to microscopic elegance (ie: the function/method level). Somewhere in the middle lies my fascination with sets, my favorite topic in Discrete Mathematics.</p>
<p>I think one of the reasons I like the Uniform Interface so much is that it groups things together into a set (all things that respond to the same method or methods), which lets you conjure up powerful abstractions at any point in the macroscopic to microscopic elegance scale.</p>
<p>One reason I like REST is because of its HTTP implementation&#8217;s Uniform Interface, the most common request methods being CREATE, UPDATE, PUT, DELETE, and HEAD. Programs using MapReduce also use a Common Interface for both the map and reduce functions&#8230; and there are many, many more examples.</p>
<p>The difference between the Uniform Interface and Interface Polymorphism is subtle. The Uniform Interface is more general (ie: applying to REST, which is a service), whereas Interface Polymorphism specifically applies to programming. Thus, Interface Polymorphism is a specific kind of Uniform Interface.</p>
<p>The term &#8220;Duck Typing&#8221; is mentioned in Ruby circles sometimes, and it&#8217;s mostly just another name for Interface Polymorphism. This is probably because Ruby has no such thing as an interface. Java on the other hand does, which is how I learned about the concept first. In Java, if a class implements an interface then it absolutely has to define the interfaces methods in its class definition. In Ruby, duck typed methods simply have to be defined by the time an object is called (even if they weren&#8217;t there during the objects initial class declaration, or even during the objects initialization). Notice I used the word &#8220;object&#8221;, but don&#8217;t forget that in Ruby a class represented through a constant is an object too. So, the only difference is that Duck Typing is more often used when talking about dynamically adding Interface Polymorphic methods.</p>
<p>Let&#8217;s sum it all up with a Ruby class definition and some inheritance.<br />
<code><br />
class DuckTyping &lt; InterfacePolymorphism &lt; UniformInterface<br />
end<br />
</code></p>
]]></content:encoded>
			<wfw:commentRss>http://larrytheliquid.com/2007/12/18/class-ducktyping-interfacepolymorphism-uniforminterface/feed/</wfw:commentRss>
		</item>
		<item>
		<title>Intro to Rails (using v. 2.0)</title>
		<link>http://larrytheliquid.com/2007/12/07/intro-to-rails-using-v-20/</link>
		<comments>http://larrytheliquid.com/2007/12/07/intro-to-rails-using-v-20/#comments</comments>
		<pubDate>Fri, 07 Dec 2007 11:38:36 +0000</pubDate>
		<dc:creator>larrytheliquid</dc:creator>
		
		<category><![CDATA[REST]]></category>

		<category><![CDATA[Web]]></category>

		<category><![CDATA[Ruby]]></category>

		<category><![CDATA[Ruby on Rails]]></category>

		<guid isPermaLink="false">http://larrytheliquid.com/2007/12/07/intro-to-rails-using-v-20/</guid>
		<description><![CDATA[
As some of you know, when I&#8217;m not working I&#8217;m taking classes in Information Systems at UCF. One of the classes I took this semester was Web Systems II, which is essentially a server-side course that focuses on ASP.NET development.
One particular assignment was creating a &#8220;Category Code Manager&#8221;, which I had never heard of previously. [...]]]></description>
			<content:encoded><![CDATA[<p><a href="http://larrytheliquid.com/screencasts/RailsIntro-CCM.zip"><img src="http://farm2.static.flickr.com/1388/1074975852_d0e8cd7f24_o.jpg" title="larrytheliquid LOVES Ruby on Rails" alt="Larry LOVES Ruby on Rails" align="left" hspace="10" /></a></p>
<p>As some of you know, when I&#8217;m not working I&#8217;m taking classes in Information Systems at UCF. One of the classes I took this semester was Web Systems II, which is essentially a server-side course that focuses on ASP.NET development.</p>
<p>One particular assignment was creating a &#8220;Category Code Manager&#8221;, which I had never heard of previously. I think the professor made the term up, but the concept is simple nonetheless. There are categories (ie: fruits) that each can have many codes (ie: apples, oranges). I think the purpose of the assignment was to get used to working with foreign keys, and building dynamic drop downs as a tool to display this sort of relationship. Another gotcha is that the categories can have parent categories.</p>
<p>The class had a participation grade that I must have overlooked&#8230; Needless to say that didn&#8217;t bode well for me, so I created this <strong><a href="http://larrytheliquid.com/screencasts/RailsIntro-CCM.zip">screencast as an introduction to Ruby on Rails (beginner level) using the new Rails 2.0</a></strong> (final source code included.) I tried to follow best practices where possible (ie: TDD), and covered the topics of:</p>
<ul>
<li>Database agnosticism &amp; environments</li>
<li>Using rake to create databases, and to run</li>
<li>Scaffold generator</li>
<li>has_many &amp; belongs_to relationships within ActiveRecord</li>
<li>The interactive Rails console</li>
<li>The new integration of the ruby debugger, and a drop of live metaprogramming</li>
<li>Test Driven Development with Test::Unit</li>
<li>Intro to REST&#8217;ful architecture within Rails</li>
</ul>
<p>But, I left some things out to avoid making the screencast even longer, and avoid it being confusing for beginners. Just so you all know, some changes I would have made include:</p>
<ul>
<li>Create some helper methods for things like populating the select tags</li>
<li>Use nested routing (I did this first, but renaming all the named routes, having to explain the routing, etc made this too complex for a beginner video)</li>
<li>Use <a href="http://rspec.rubyforge.org/">RSpec</a> for testing (RSpec&#8217;s scaffold uses mocks and stubs, which are just a little too much to explain when already introducing all of Rails and testing)</li>
<li>Use a REST&#8217;ful abstraction plugin (we developed an internal one at work, but unfortunately we haven&#8217;t been able to open source it yet&#8230; until then check out <a href="http://mr.hamptoncatlin.com/">make_resourceful</a>)</li>
<li>Use the <a href="http://work.onemanswalk.com/2007/3/6/object-mother-in-rails">ObjectMother</a> pattern for creating objects during tests</li>
</ul>
<p>Enjoy the <a href="http://larrytheliquid.com/screencasts/RailsIntro-CCM.zip">screencast</a>!</p>
]]></content:encoded>
			<wfw:commentRss>http://larrytheliquid.com/2007/12/07/intro-to-rails-using-v-20/feed/</wfw:commentRss>
		</item>
		<item>
		<title>Rails controllers are proper resources</title>
		<link>http://larrytheliquid.com/2007/08/09/rails-controllers-are-proper-resources/</link>
		<comments>http://larrytheliquid.com/2007/08/09/rails-controllers-are-proper-resources/#comments</comments>
		<pubDate>Thu, 09 Aug 2007 06:27:39 +0000</pubDate>
		<dc:creator>larrytheliquid</dc:creator>
		
		<category><![CDATA[REST]]></category>

		<category><![CDATA[Ruby on Rails]]></category>

		<guid isPermaLink="false">http://larrytheliquid.com/2007/08/09/rails-controllers-are-proper-resources/</guid>
		<description><![CDATA[I&#8217;ve been doing a lot with REST and ROA on and off the job lately (mainly with Eric and Dray, who still does not have a blog.)
The way Rails implements resources is through Controller classes. One thing that came up yesterday, was the argument that the implementation is improper due to the inclusion of both [...]]]></description>
			<content:encoded><![CDATA[<p>I&#8217;ve been doing a lot with <a href="http://en.wikipedia.org/wiki/Representational_State_Transfer">REST</a> and <a href="http://en.wikipedia.org/wiki/Resource_oriented_architecture">ROA</a> on and off the job lately (mainly with <a href="http://www.last100meters.com/">Eric</a> and Dray, who <em>still</em> does not have a blog.)</p>
<p>The way Rails implements resources is through Controller classes. One thing that came up yesterday, was the argument that the implementation is improper due to the inclusion of both an index and a show action in one Controller. In REST, a resource can be its own entity (ie: an apple), or a collection of of entities (ie: a fruits resource composed of apples, grapes, oranges, etc.) At first glance, the challenge to Rails Controllers seems to stand because a GET to the <code>index</code> action returns a collection of resources, whereas a GET to the <code>show</code> action just returns one resource.</p>
<p>Upon closer inspection though, you&#8217;ll see that the confusion comes from focusing on Controller actions. What should really be looked at is the resource (the controller), and how those two requests are addressed (the <a href="http://en.wikipedia.org/wiki/Uniform_Resource_Identifier">URI</a>.) Firstly, notice what kind of resource we have&#8230; it&#8217;s a <code>fruits</code> resource. Next, look at the URI, it is <code>/fruits</code>.</p>
<p>Now that we&#8217;ve established that our <code>FruitsController</code> represents a plural resource (a collection of fruit resources), we can move on to explaining the confusion that the index and show actions introduce. A request to <code>/fruits</code> will return all of our fruits. But, the world has many fruits and we don&#8217;t want to request them all. Instead, we will fire a GET at <code>/fruits?page=2?limit=10</code>. Although most of you will recognize this as simple pagination, in ROA it is known as the concept of <code>addressibiliy</code> to indicate state in the URI.</p>
<p>Here&#8217;s where the confusion is cleared: a request to <code>/fruits/1337</code> is not requesting a singular resource (in this case a cherry, the most elite of all fruits.) Instead, it is requesting a collection resource (fruits) but using addressibility to indicate state. It is okay to use the URI in REST different ways for addressiblity, because REST is a style and does not have a specification for addressing via URI&#8217;s. For example, another way of getting to <code>/fruits/1337</code> might be <code>/fruits/?page=1337?limit=1</code>.</p>
<p>As a closing note, even though we used the <code>fruits</code> resource collection here and addressed cherry, we could have done it differently still. If you really wanted a singular cherry resource, you can do so in <code>routes.rb</code> by replacing <code>map.resources :fruits</code> with <code>map.resource :cherry</code> (notice that &#8220;resource&#8221; is singular.) This would map to a singular CherryController to implement the resource. You could access it with a get request to <code>/cherry</code>, which would map to the <code>show</code> action (in this case the index, or list, action does not make sense because cherry is singular.)</p>
]]></content:encoded>
			<wfw:commentRss>http://larrytheliquid.com/2007/08/09/rails-controllers-are-proper-resources/feed/</wfw:commentRss>
		</item>
		<item>
		<title>[TV] Jimbo Wales on Future of the Internet</title>
		<link>http://larrytheliquid.com/2007/07/28/tv-jimbo-wales-on-future-of-the-internet/</link>
		<comments>http://larrytheliquid.com/2007/07/28/tv-jimbo-wales-on-future-of-the-internet/#comments</comments>
		<pubDate>Sat, 28 Jul 2007 18:00:24 +0000</pubDate>
		<dc:creator>larrytheliquid</dc:creator>
		
		<category><![CDATA[Web]]></category>

		<guid isPermaLink="false">http://larrytheliquid.com/2007/07/28/tv-jimbo-wales-on-future-of-the-internet/</guid>
		<description><![CDATA[Jimbo Wales, founder of Wikipedia, will be speaking tonight at 8 P.M. on C-SPAN. The topic is the &#8220;Future of the Internet&#8220;, and one of the more interesting things that will be discussed is Wikia&#8217;s new wiki-based search engine being worked on.
With my recent involvement in trying to promote BarCampOrlando, seeing this kind of content [...]]]></description>
			<content:encoded><![CDATA[<p><a href="http://en.wikipedia.org/wiki/Jimbo_Whales">Jimbo Wales, founder of Wikipedia,</a> will be speaking tonight at 8 P.M. on C-SPAN. The topic is the &#8220;<a href="http://inside.c-spanarchives.org:8080/cspan/cspan.csp?command=dprogram&amp;record=555240789">Future of the Internet</a>&#8220;, and one of the more interesting things that will be discussed is <a href="http://search.wikia.com/wiki/Search_Wikia">Wikia&#8217;s new wiki-based search engine</a> being worked on.</p>
<p>With my recent involvement in trying to promote <a href="http://www.barcamporlando.org/">BarCampOrlando</a>, seeing this kind of content on T.V. and especially in politics is a very pleasant surprise. I came across this flipping through channels and landing on C-SPAN right as the text blurb about Jimbo flashed by. They were talking about the <a href="http://inside.c-spanarchives.org:8080/cspan/cspan.csp?command=dprogram&amp;record=555410408">Baghdad Embassy Contruction</a> and mentioned a word that sounded very close to BarCamp&#8230; so I was REALLY excited for a second there =p I also recently sent out a personal email to Jimbo asking him for any involvement whatsoever in BarCampOrlando, since he lives in St. Pete, Florida and was quoted in the local Orlando Sentinel complaining about the lack of BarCamps and unconferences in the area.</p>
]]></content:encoded>
			<wfw:commentRss>http://larrytheliquid.com/2007/07/28/tv-jimbo-wales-on-future-of-the-internet/feed/</wfw:commentRss>
		</item>
	</channel>
</rss><!-- Dynamic Page Served (once) in 0.314 seconds -->
