<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0"
	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/"
	xmlns:atom="http://www.w3.org/2005/Atom"
	xmlns:sy="http://purl.org/rss/1.0/modules/syndication/"
	xmlns:slash="http://purl.org/rss/1.0/modules/slash/"
	>

<channel>
	<title>yonkeltron &#187; Programming</title>
	<atom:link href="http://yonkeltron.com/tag/programming/feed/" rel="self" type="application/rss+xml" />
	<link>http://yonkeltron.com</link>
	<description>Temporary Exile</description>
	<lastBuildDate>Fri, 16 Jul 2010 18:45:41 +0000</lastBuildDate>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=3.0</generator>
		<item>
		<title>Great post about Emacs keyboard macros</title>
		<link>http://yonkeltron.com/2010/07/16/great-post-about-emacs-keyboard-macros/</link>
		<comments>http://yonkeltron.com/2010/07/16/great-post-about-emacs-keyboard-macros/#comments</comments>
		<pubDate>Fri, 16 Jul 2010 18:45:41 +0000</pubDate>
		<dc:creator>Jonathan Magen</dc:creator>
				<category><![CDATA[Uncategorized]]></category>
		<category><![CDATA[Computing]]></category>
		<category><![CDATA[emacs]]></category>
		<category><![CDATA[F/OSS]]></category>
		<category><![CDATA[Programming]]></category>

		<guid isPermaLink="false">http://yonkeltron.com/?p=675</guid>
		<description><![CDATA[I always find great stuff on the emacs-fu blog but today I read a particularly-wonderful post about Emacs keyboard macros. Like the author, I&#8217;ve been a long-time Emacs user but never really got into keyboard macros because it&#8217;s been quite easy to produce an elisp one-liner in many cases. That being said, this seems like ]]></description>
			<content:encoded><![CDATA[<p>I always find great stuff on the <a href="http://emacs-fu.blogspot.com">emacs-fu</a> blog but today I read a particularly-wonderful post about <a href="http://emacs-fu.blogspot.com/2010/07/keyboard-macros.html">Emacs keyboard macros</a>. Like the author, I&#8217;ve been a long-time Emacs user but never really got into keyboard macros because it&#8217;s been quite easy to produce an <a href="http://en.wikipedia.org/wiki/Emacs_Lisp">elisp</a> one-liner in many cases. That being said, this seems like a great time to learn so I look forward to reading more on the topic of <a href="http://www.emacswiki.org/emacs/KeyboardMacros">keyboard macros</a> as well as learning some <a href="http://www.emacswiki.org/emacs/KeyboardMacrosTricks">new tricks</a>.</p>
<p>Thanks for a great post!</p>
]]></content:encoded>
			<wfw:commentRss>http://yonkeltron.com/2010/07/16/great-post-about-emacs-keyboard-macros/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>newhaven.rb hackfest tomorrow!</title>
		<link>http://yonkeltron.com/2010/06/30/newhaven-rb-hackfest-tomorrow/</link>
		<comments>http://yonkeltron.com/2010/06/30/newhaven-rb-hackfest-tomorrow/#comments</comments>
		<pubDate>Wed, 30 Jun 2010 14:00:54 +0000</pubDate>
		<dc:creator>Jonathan Magen</dc:creator>
				<category><![CDATA[Uncategorized]]></category>
		<category><![CDATA[Computing]]></category>
		<category><![CDATA[F/OSS]]></category>
		<category><![CDATA[Programming]]></category>
		<category><![CDATA[Ruby]]></category>

		<guid isPermaLink="false">http://yonkeltron.com/?p=673</guid>
		<description><![CDATA[Tomorrow, in New Haven, CT will be the &#8220;Ruby, White and Blue&#8221; Hackfest run by newhaven.rb. We&#8217;ll be working on a few projects including the group&#8217;s site and most likely some Prawn and ScosugBot stuff. Beginners and people interested in learning are more than welcome and we hope to have some excellent projects for people ]]></description>
			<content:encoded><![CDATA[<p>Tomorrow, in New Haven, CT will be the &#8220;Ruby, White and Blue&#8221; Hackfest run by newhaven.rb. We&#8217;ll be working on a few projects including <a href="http://github.com/yonkeltron/NHV-Ruby-site">the group&#8217;s site</a> and most likely some <a href="http://github.com/sandal/prawn">Prawn</a> and <a href="http://github.com/yonkeltron/scosugbot">ScosugBot</a> stuff. Beginners and people interested in learning are more than welcome and we hope to have some excellent projects for people to get started on.</p>
<p>Fill out the <a href="http://is.gd/d9ZiB">RSVP form</a> and we&#8217;ll meet at 6pm EST at <a href="http://www.bluestatecoffee.com/">Blue State Coffee</a> on Thursday,  July 1st. Bring a computer and let&#8217;s write some code.</p>
<p><iframe width="425" height="350" frameborder="0" scrolling="no" marginheight="0" marginwidth="0" src="http://maps.google.com/maps?f=q&amp;source=s_q&amp;hl=en&amp;geocode=&amp;q=Blue+State+Coffee+-+New+Haven,+New+Haven,+CT&amp;sll=41.306075,-72.931894&amp;sspn=0.009333,0.01929&amp;ie=UTF8&amp;hq=Blue+State+Coffee+-&amp;hnear=New+Haven,+Connecticut&amp;t=h&amp;cid=8790853015135628419&amp;ll=41.319076,-72.921238&amp;spn=0.022562,0.036478&amp;z=14&amp;iwloc=A&amp;output=embed"></iframe><br /><small><a href="http://maps.google.com/maps?f=q&amp;source=embed&amp;hl=en&amp;geocode=&amp;q=Blue+State+Coffee+-+New+Haven,+New+Haven,+CT&amp;sll=41.306075,-72.931894&amp;sspn=0.009333,0.01929&amp;ie=UTF8&amp;hq=Blue+State+Coffee+-&amp;hnear=New+Haven,+Connecticut&amp;t=h&amp;cid=8790853015135628419&amp;ll=41.319076,-72.921238&amp;spn=0.022562,0.036478&amp;z=14&amp;iwloc=A" style="color:#0000FF;text-align:left">View Larger Map</a></small></p>
]]></content:encoded>
			<wfw:commentRss>http://yonkeltron.com/2010/06/30/newhaven-rb-hackfest-tomorrow/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Creating a Ruby DSL</title>
		<link>http://yonkeltron.com/2010/05/13/creating-a-ruby-dsl/</link>
		<comments>http://yonkeltron.com/2010/05/13/creating-a-ruby-dsl/#comments</comments>
		<pubDate>Fri, 14 May 2010 02:44:43 +0000</pubDate>
		<dc:creator>Jonathan Magen</dc:creator>
				<category><![CDATA[Uncategorized]]></category>
		<category><![CDATA[Computing]]></category>
		<category><![CDATA[Programming]]></category>
		<category><![CDATA[Ruby]]></category>

		<guid isPermaLink="false">http://yonkeltron.com/?p=653</guid>
		<description><![CDATA[Tons of people in the Ruby community go on and on about domain-specific languages (abbreviated DSL) and how wonderful they are. In most cases, I agree with them. I began to wonder how I could go about leveraging Ruby&#8217;s awesomely-flexible syntax to create my own DSL. To illustrate my quest, I have written this article. ]]></description>
			<content:encoded><![CDATA[<p>Tons of people in the Ruby community go on and on about <a href="http://en.wikipedia.org/wiki/Domain_Specific_Language">domain-specific languages (abbreviated DSL)</a> and how wonderful they are. In most cases, I agree with them. I began to wonder how I could go about leveraging Ruby&#8217;s awesomely-flexible syntax to create my own DSL. To illustrate my quest, I have written this article. It assumes you know Ruby. The example details are completely fictitious and just contrived enough to be interesting. I promise, the code will be the main focus and I will link/point to other resources which might be helpful to budding DSL designers like myself.</p>
<p><strong>Problem</strong></p>
<p>The Dream Castle Architectural Firm (D-CAF, among friends) wants a tool which it can use for very high-level prototyping of custom homes. They need it to be understandable by both computers and humans. It only needs to keep track of the following things:</p>
<ul>
<li>Houses &#8211; Each house has a name</li>
<li>Floors &#8211; Each house has multiple floors. Each floor has a number</li>
<li>Rooms &#8211; Each floor has multiple rooms and each room has a type</li>
</ul>
<p>The only other requirement is that the DSL be translatable to plain English so that they can show it to customers. No problem.</p>
<p><strong>Solution</strong></p>
<p>The DSL for the high-level specification of custom houses will look like the following:</p>
<pre>CustomHouse.build :home do
  floor(1) {
    room :den
    room :kitchen
  }

  floor(2) {
    room :bedroom
    room :bathroom
  }
end</pre>
<p>That&#8217;s it. You specify that a house should be built, that it has a name, some floors and each floor has some rooms. Simple, easy and 100% pure Ruby.  Notice the cunning usage of both do/end and bracket notation for defining blocks. The outer block passed to <code>CustomHouse#build</code> uses do/end syntax while the blocks passed to <code>House#floor</code> use the bracket syntax. These could easily be reversed (or combined or whatever) but it makes it look pretty and helps to visually differentiate things so that you (the developer) and the user (the architect) can things more clearly. Plus, when you print the output (calling <code>to_s</code> on the instance of <code>House</code> which gets returned), you get the following wonderful text:</p>
<pre>House named home has 2 floors.
Floor 1 has 2 rooms (den, kitchen)
Floor 2 has 2 rooms (bedroom, bathroom)</pre>
<p>It&#8217;s a small house, don&#8217;t be a wiseacre. So, how can such a DSL be built?</p>
<p><strong>Implementation</strong></p>
<p>Let&#8217;s write the implementation for this together.  First, we&#8217;re going to start of with a module named <code>CustomHouse</code>.  In Ruby, modules are just classes so we&#8217;ll define a class method called <code>build</code> which will behave like a factory method.</p>
<pre>module CustomHouse
  def self.build(name, &amp;block)
    house = House.new(name)
    house.instance_eval(&amp;block)
    return house
  end
end</pre>
<p>As you can see, the method takes two params, a name and a block. The first thing that it does is create an instance of the House class (which we have not yet defined) passing in the name parameter. Second it calls <a href="http://ruby-doc.org/core-1.8.7/classes/Object.html#M000607">instance_eval</a> on the house passing in the block. This ventures into the territory of <a href="http://en.wikipedia.org/wiki/Metaprogramming">metaprogramming</a> which is great fun but beyond the scope of this document, though I am sure others have used it for DSL construction (coincidentally, if you are interested in Ruby metaprogramming, buy <a href="http://amzn.com/1934356476">this book</a>). Suffice it to say that it executes the supplied block in the context of the House instance. Finally, the <code>CustomHouse#build</code> method returns the instance of <code>House</code>.</p>
<p>(There are those who believe that *any* type of eval is fundamentally evil. I have been taught this many times and I try to avoid using eval on an actualy string whenever possible. Still, someone with a better understanding of Ruby internals might be able to better explain if this in any better.)</p>
<p>Next, let&#8217;s define what the code for the <code>House</code> class looks like. As a note, it will be defined in the <code>CustomHouse</code> module, technically making the fully-namespaced name of the class <code>CustomHouse::House</code>.</p>
<pre>class House
  attr_accessor :name, :floors

  def initialize(name = '')
    @name = name.to_s
    @floors = []
  end

  def floor(number, &amp;block)
    fl = Floor.new(number)
    fl.instance_eval(&amp;block)
    @floors &lt; &lt; fl
  end

  def to_s
    str = "House named #{@name} has #{@floors.length} floors.\n"
    @floors.each do |f|
      str &lt;&lt; f.to_s
    end
    str
  end
end</pre>
<p>The above code should appear relatively simple. The House class has only a few methods. First, it has a constructor function which takes a name and a block, setting the name as an instance variable and another instance variable, <code>@floors</code>, which is just an empty array. Next, it has a method called <code>floor</code> which takes a number and a block. The guts of this method should look familiar to you because it mimics almost exactly the <code>build</code> factory method defined on <code>CustomHouse</code>. Finally, it has a <code>to_s</code> method because of the requirement that the DSL be translatable to plain English for clients to check out.</p>
<p>If we can just dwell for a moment on the <code>floor</code> method, notice that, it too, takes a block and uses <code>instance_eval</code>. It then adds the newly-constructed instance of <code>Floor</code> to the array in <code>@floor</code>. Let&#8217;s look at the <code>Floor</code> class now.</p>
<pre>class Floor
  attr_accessor :number, :rooms

  def initialize(number = 0)
    @number = number
    @rooms = []
  end

  def room(type)
    @rooms &lt; &lt; Room.new(type)
  end

  def to_s
    str = "Floor #{@number} has #{@rooms.length} rooms ("
    @rooms.each do |r|
      str += "#{r.type}, "
    end
    str.chop!.chop!
    str += ")\n"
    str
  end
end</pre>
<p>There shouldn&#8217;t be anything confusing about the above code as it doesn&#8217;t use any sort of block eval. In fact, the only thing left to look at is the class for <code>Room</code> which is even less impressive.</p>
<pre>class Room
  attr_reader :type

  def initialize(type)
    @type = type
  end
end</pre>
<p>That&#8217;s it. Seriously, that&#8217;s the entire implementation of the DSL. You pass a block to <code>CustomHouse#build</code> which gets executed in the context of a new instance of <code>House</code>. The block calls the <code>House#floor</code> method with a block which in turn gets executed in the context of a new instance of <code>Floor</code>. The Floor#room method adds new <code>Room</code> instances to the class and that&#8217;s basically it.</p>
<p>Here&#8217;s all the code together with the example:</p>
<pre>module CustomHouse

  def self.build(name, &amp;block)
    house = House.new(name)
    house.instance_eval(&amp;block)
    return house
  end

  class House
    attr_accessor :name, :floors

    def initialize(name = '')
      @name = name.to_s
      @floors = []
    end

    def floor(number, &amp;block)
      fl = Floor.new(number)
      fl.instance_eval(&amp;block)
      @floors &lt;&lt; fl
    end

    def to_s
      str = "House named #{@name} has #{@floors.length} floors.\n"
      @floors.each do |f|
        str &lt;&lt; f.to_s
      end
      str
    end
  end

  class Floor
    attr_accessor :number, :rooms

    def initialize(number = 0)
      @number = number
      @rooms = []
    end

    def room(type)
      @rooms &lt;&lt; Room.new(type)
    end

    def to_s
      str = "Floor #{@number} has #{@rooms.length} rooms ("
      @rooms.each do |r|
        str += "#{r.type}, "
      end
      str.chop!.chop!
      str += ")\n"
      str
    end
  end

  class Room
    attr_reader :type

    def initialize(type)
      @type = type
    end
  end
end

h = CustomHouse.build :home do
  floor(1) {
    room :den
    room :kitchen
  }

  floor(2) {
    room :bedroom
    room :bathroom
  }
end

puts h</pre>
<p>Try running it and see what happens! Then try writing other definitions for custom houses and experience the theoretical joy of the hypothetical architectural firm.</p>
<p><strong>DSL construction techniques</strong></p>
<p>For clarification and context, I&#8217;d like to share some other, smaller examples which build on this technique and demonstrate one more.</p>
<p>Behold, a DSL for feeding Pandas:</p>
<pre>Panda.feed {
  nom :bamboo
  nom :chocolate
}</pre>
<p>The implementation of this is both simple and straightforward.</p>
<pre>class Panda
  def self.feed(&amp;block)
    panda = Panda.new
    panda.instance_eval(&amp;block)
  end

  def nom(food)
    #whatever
  end
end</pre>
<p>Since the block is evaluated in the context of the new <code>Panda</code> instance, it has access to the <code>Panda#nom</code> method. For people deathly afraid of eval, there is this alternative syntax:</p>
<pre>Panda.feed do |p|
  p.nom :bamboo
  p.nom :chocolate
end</pre>
<p>Which is implemented with <code>yield</code> instead of <code>instance_eval</code> like so:</p>
<pre>class Panda
  def self.feed
    yield Panda.new
  end

  def nom(food)
    # whatever
  end
end</pre>
<p>For a wonderful and inspiring treatment of Ruby DSLs and associated patterns, see the <a href="http://mwrc2009.confreaks.com/13-mar-2009-18-10-jive-talkin-dsl-design-and-construction-jeremy-mcanally.html">most-excellent talk on the matter given by Jeremy McAnally at the 2009 Mid West Ruby Conference</a>.</p>
<p><strong>Conclusion</strong></p>
<p>DSLs are a fantastic tool which can help to simplify complicated and repetitive tasks. Ruby is very good for creating DSLs but it is not the only good tool out there. I advise you look into the creation of DSLs with Scala and, the best DSL-creation tool there ever was, Lisp Macros.</p>
<p>I am interested in improving this tutorial for the benefit of those programmers who wish to learn about DSL construction but don&#8217;t know where to start.</p>
]]></content:encoded>
			<wfw:commentRss>http://yonkeltron.com/2010/05/13/creating-a-ruby-dsl/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Building shared libraries</title>
		<link>http://yonkeltron.com/2010/04/08/building-shared-libraries/</link>
		<comments>http://yonkeltron.com/2010/04/08/building-shared-libraries/#comments</comments>
		<pubDate>Fri, 09 Apr 2010 00:12:41 +0000</pubDate>
		<dc:creator>Jonathan Magen</dc:creator>
				<category><![CDATA[Uncategorized]]></category>
		<category><![CDATA[Computing]]></category>
		<category><![CDATA[Debian]]></category>
		<category><![CDATA[F/OSS]]></category>
		<category><![CDATA[Linux]]></category>
		<category><![CDATA[Programming]]></category>

		<guid isPermaLink="false">http://yonkeltron.com/?p=631</guid>
		<description><![CDATA[Being a Debian user, I don&#8217;t make a habit of compiling things by hand and on those occasions when I do need to do so, I usually use apt-build (good article, though a bit old here). However, today I had to get a particularly odd shared library with a very specific version to match a ]]></description>
			<content:encoded><![CDATA[<p>Being a Debian user, I don&#8217;t make a habit of compiling things by hand and on those occasions when I do need to do so, I usually use apt-build (good article, though a bit old <a href="http://polishlinux.org/linux/debian/apt-build-optimize-debian/ ">here</a>). However, today I had to get a particularly odd shared library with a very specific version to match a production environment we have at work. So, I downloaded the tarball, which was quite large, and then compiled it. Which took four and a half minutes on my dual-core (1.83GHz) ThinkPad running <code>make -j 4</code> which isn&#8217;t all that slow, really.</p>
<p>Once it was completed, I looked around (grepped around) for the output file and was dismayed to discover that there weren&#8217;t any. After tinkering around for about an hour, I finally figured out that you can request shared libraries be built by providing an option to the configure script:</p>
<p><code>./configure --enable-shared</code></p>
<p>Shortly thereafter, I got the shared library version I needed and was on the road again. Just a useful tip which I hope can be of help to someone.</p>
]]></content:encoded>
			<wfw:commentRss>http://yonkeltron.com/2010/04/08/building-shared-libraries/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>HTML5 has custom data attributes</title>
		<link>http://yonkeltron.com/2010/03/25/html5-has-custom-data-attributes/</link>
		<comments>http://yonkeltron.com/2010/03/25/html5-has-custom-data-attributes/#comments</comments>
		<pubDate>Thu, 25 Mar 2010 15:16:35 +0000</pubDate>
		<dc:creator>Jonathan Magen</dc:creator>
				<category><![CDATA[Uncategorized]]></category>
		<category><![CDATA[Computing]]></category>
		<category><![CDATA[Internet]]></category>
		<category><![CDATA[JavaScript]]></category>
		<category><![CDATA[Programming]]></category>
		<category><![CDATA[Ruby]]></category>
		<category><![CDATA[Web]]></category>
		<category><![CDATA[XML]]></category>

		<guid isPermaLink="false">http://yonkeltron.com/?p=627</guid>
		<description><![CDATA[So, I know that the Microformats project has has varying degrees of success in their endeavor to embed data in HTML such that it does not violate web standards.  As John Resig pointed out, others have used things like XML namespacing in XHTML to achieve similar goals. The most notable usages of this technique are ]]></description>
			<content:encoded><![CDATA[<p>So, I know that the <a href="http://microformats.org/">Microformats</a> project has has varying degrees of success in their endeavor to embed data in HTML such that it does not violate web standards.  As <a href="http://ejohn.org/blog/html-5-data-attributes/">John Resig pointed out</a>, others have used things like XML namespacing in XHTML to achieve similar goals. The most notable usages of this technique are most likely to be found in the <a href="http://www.w3.org/TR/xhtml-rdfa-scenarios/">applications</a> of <a href="http://en.wikipedia.org/wiki/RDFa">RDFa</a>. However, when looking at the new <a href="http://blog.solnic.eu/2009/09/08/unobtrusive-javascript-helpers-in-rails-3">unobtrusive JavaScript helpers</a> in the forthcoming Rails 3, I was tipped off to the huge scope of the new data- attributes in <a href="http://html5.org/">HTML5</a>. The custom data- attributes excite me.</p>
<p>In HTML5, including any arbitrary attribute may be included in any element provided that it is prefixed with data- and doesn&#8217;t interfere with the rest of the standard. Anything. So I can do the following and have it be perfectly valid:</p>
<pre>&lt;div data-panda="bamboo"&gt; Whatever &lt;div&gt;</pre>
<p>How awesome is that?</p>
]]></content:encoded>
			<wfw:commentRss>http://yonkeltron.com/2010/03/25/html5-has-custom-data-attributes/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Rails + Merb = Rails 3</title>
		<link>http://yonkeltron.com/2010/03/17/rails-merb-rails-3/</link>
		<comments>http://yonkeltron.com/2010/03/17/rails-merb-rails-3/#comments</comments>
		<pubDate>Wed, 17 Mar 2010 14:33:42 +0000</pubDate>
		<dc:creator>Jonathan Magen</dc:creator>
				<category><![CDATA[Uncategorized]]></category>
		<category><![CDATA[Computing]]></category>
		<category><![CDATA[F/OSS]]></category>
		<category><![CDATA[Programming]]></category>
		<category><![CDATA[Ruby]]></category>
		<category><![CDATA[Web]]></category>

		<guid isPermaLink="false">http://yonkeltron.com/?p=622</guid>
		<description><![CDATA[I&#8217;m rather excited about this. Saw this talk right here. Oh, and then there&#8217;s this]]></description>
			<content:encoded><![CDATA[<p>I&#8217;m rather excited about this. Saw this talk <a href="http://www.infoq.com/presentations/katz-rails3">right here</a>.</p>
<p>Oh, and then there&#8217;s <a href="http://blog.rubybestpractices.com/posts/gregory/022-rbp-now-open.html">this</a>.</p>
]]></content:encoded>
			<wfw:commentRss>http://yonkeltron.com/2010/03/17/rails-merb-rails-3/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Neato article about NoSQL on Ars Technica</title>
		<link>http://yonkeltron.com/2010/02/24/neato-article-about-nosql-on-ars-technica/</link>
		<comments>http://yonkeltron.com/2010/02/24/neato-article-about-nosql-on-ars-technica/#comments</comments>
		<pubDate>Wed, 24 Feb 2010 15:46:28 +0000</pubDate>
		<dc:creator>Jonathan Magen</dc:creator>
				<category><![CDATA[Uncategorized]]></category>
		<category><![CDATA[Computing]]></category>
		<category><![CDATA[F/OSS]]></category>
		<category><![CDATA[Internet]]></category>
		<category><![CDATA[Programming]]></category>
		<category><![CDATA[Web]]></category>

		<guid isPermaLink="false">http://yonkeltron.com/?p=618</guid>
		<description><![CDATA[I am very excited by some of the NoSQL stuff out there and enjoyed a recent Ars Technica article. The first page is some neat background and the second page has a good overview of some NoSQL options out there. http://arstechnica.com/business/data-centers/2010/02/-since-the-rise-of.ars]]></description>
			<content:encoded><![CDATA[<p>I am very excited by some of the NoSQL stuff out there and enjoyed <a href="http://arstechnica.com/business/data-centers/2010/02/-since-the-rise-of.ars/">a recent Ars Technica article</a>. The first page is some neat background and<a href="http://arstechnica.com/business/data-centers/2010/02/-since-the-rise-of.ars/2"> the second page has a good overview </a>of some NoSQL options out there.</p>
<div id="_mcePaste" style="overflow: hidden; position: absolute; left: -10000px; top: 0px; width: 1px; height: 1px;">http://arstechnica.com/business/data-centers/2010/02/-since-the-rise-of.ars/</div>
]]></content:encoded>
			<wfw:commentRss>http://yonkeltron.com/2010/02/24/neato-article-about-nosql-on-ars-technica/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>The zen of backup theory</title>
		<link>http://yonkeltron.com/2010/02/11/the-zen-of-backup-theory/</link>
		<comments>http://yonkeltron.com/2010/02/11/the-zen-of-backup-theory/#comments</comments>
		<pubDate>Thu, 11 Feb 2010 17:33:42 +0000</pubDate>
		<dc:creator>Jonathan Magen</dc:creator>
				<category><![CDATA[Uncategorized]]></category>
		<category><![CDATA[Computing]]></category>
		<category><![CDATA[Linux]]></category>
		<category><![CDATA[Programming]]></category>
		<category><![CDATA[Security]]></category>
		<category><![CDATA[Testing]]></category>

		<guid isPermaLink="false">http://yonkeltron.com/?p=607</guid>
		<description><![CDATA[When stuck inside due to all the snow, there is no better time to consider the topic of backup. Seriously, backup is important and the issue is fascinating.  The area of backup brings together so many topics in computing. Think about it! To do backup successfully, you must deal with data transfer, data integrity validation, ]]></description>
			<content:encoded><![CDATA[<p>When stuck inside due to all the snow, there is no better time to consider the topic of backup. Seriously, backup is important and the issue is fascinating.  The area of backup brings together so many topics in computing. Think about it! To do backup successfully, you must deal with data transfer, data integrity validation, networks, distributed systems, compression and, if you&#8217;re doing it right, cryptography. It is not just computer science however, but also workflow management and that somewhat-nebulous-yet-often-referred-to thing of systems thinking.</p>
<p>I got to thinking about the topic of backups and was curious as to the state of research as well as backup tools. A great intro to so-called &#8220;backup theory&#8221; is available on the <a href="http://en.wikipedia.org/wiki/Backup">&#8216;Backup&#8217; Wikipedia article</a> and <a href="http://www.educ.umu.se/~cobian/backuptheory.htm">others have written</a> on the subject <a href="http://www.google.com/search?q=backup%20theory">(Google will verify</a> that this is true). As it turns out, advances in storage have recently offered many new opportunities for improving the way that a given backup process might work.</p>
<p>Several distributed fault-tolerant filesystems are coming along quite nicely. Though the <a href="http://labs.google.com/papers/gfs.html">Google File System</a> and the equivalent <a href="http://hadoop.apache.org/hdfs/">HDFS</a> project which is part of <a href="http://hadoop.apache.org/">Apache&#8217;s Hadoop</a> have gotten much attention, there are other options. <a href="http://www.gluster.org/">GlusterFS</a> (follow <a href="http://twitter.com/gluster">GlusterFS on Twitter</a>, perhaps?) and <a href="http://ceph.newdream.net/">Ceph</a> are two excellent examples of Free/Open Source Software projects which offer the compelling combo of fault tolerance and distributed storage. They each employ replication and have similar architectures insofar as they abstract individual machines into &#8220;chunks&#8221; or &#8220;blocks&#8221; and manage replication automatically. One interesting difference is that while GlusterFS exports filesystems &#8220;as-is&#8221; (see the docs for an explanation), Ceph exports entire block devices.</p>
<p>So then what about the theory and goals of backup? In my opinion, backing up is not enough. Having a backup plan and executing it perfectly doesn&#8217;t mean a thing if the data can&#8217;t be recovered.  (In fact this issue relates strongly to a larger discussion of reliability. Rather than focusing exclusively on total time spent in a failure state, individuals concerned with reliability would also do well to consider how fast a system can recover from those failures. If a system can be up and running again after only 5 minutes, then that system can go down 12 times before reaching an hour of downtime. If another system takes 20 minutes to rebound from a failure, then that system can only go down 3 times!) I haven&#8217;t yet gotten to thinking about the problem of restoration following failure for anything other than plain old files. For example, I backup my personal data to servers in Philadelphia and California in addition to an external hard drive in my apartment. I make careful use of  old stand-byes like <a href="http://en.wikipedia.org/wiki/Tar_%28file_format%29">tar</a>, <a href="http://en.wikipedia.org/wiki/Gzip">gzip</a> and <a href="http://en.wikipedia.org/wiki/Rsync">rsync</a> along with a checksum utility like <a href="http://en.wikipedia.org/wiki/Md5sum">md5sum</a> or, more recently, something in the <a href="http://en.wikipedia.org/wiki/Sha1sum">SHA</a> family. Plus I use the <a href="http://git-scm.com/">git</a> revision control system for code and <a href="http://joey.kitenet.net/code/etckeeper/">etckeeper</a> for config. By backing up all of my configuration data in addition to my personal files, I make it so that I can easily return a given system to a usable state, if not restoring it perfectly. I have successfully restored systems by doing little more than a reverse rsync.</p>
<p>To be fair, I just spoke about about the few systems under my personal control which constitute a small and limited case. I back up to different locations which is good practice but my local copy is certainly not sufficient for anything industrial. If the disk breaks, I&#8217;m out of luck. Considering a larger-scale system is when GlusterFS, Ceph and others would come in handy. Obviously there are a <a href="http://amzn.com/0596102461">great</a> <a href="http://amzn.com/0596001533">many</a> <a href="http://amzn.com/0471227145">books</a> <a href="http://amzn.com/1420076396">written</a> about <a href="http://amzn.com/1430226625">this topic</a> but, for the purposes of discussion, if I were to build a platform for the reliable storage of huge amounts of data, my project would look something like this&#8230;</p>
<p>First, I would round up spare computers with room for extra disks. They machines would not need to be particularly fast or possess large amounts of memory. I&#8217;m not sure of the exact hardware requirements for either GlusterFS (<a href="http://gluster.com/community/documentation/index.php/Storage_Server_Installation_and_Configuration#Hardware_Requirements">vague wiki entry</a>) or Ceph but it&#8217;s hard to imagine that they&#8217;d require huge amounts of anything but disk space. Anyway, if my organization had old desktops or something which were being replaced then they might be perfect candidates.</p>
<p>Second comes storage. It seems that at the time of this writing, one can purchase a 1TB hard disk for around US$85. Let us assume that 20 desktop machines could be procured and each had two spare disk slots. For around US$3500 (figuring 2 US$85 disks per machine and a little more for tax+shipping, etc.) one could buy 20TB of storage. Now, it&#8217;s not quite that simple as the fault-tolerance scheme in both GlusterFS and Ceph relies on replication. Assuming the accepted replication factor of 3 (a norm adhered to by the Google File System), that would reduce the 20TB storage block by a third  leaving around 6 and two thirds terabytes of fault-tolerant storage. Filesystems of this type usually require cluster control processes which (ideally, I think) reside on dedicated machines so an extra machine or two would also be required. I got a good explanation of how metadata servers work in GFS/HDFS by reading the <a href="http://hadoop.apache.org/common/docs/current/hdfs_design.html">HDFS design document</a>, actually. Metadata servers and other control processes serve similar functions. Ceph documents are very explicit about not having a single point of failure whereas GlusterFS is not quite so adamant. I need some help figuring out if GlusterFS is as fault-tolerant in that respect.</p>
<p>For under US$4000, one could theoretically build over 6TB of fault-tolerant distributed storage (provided that spare machines are plentiful, something which shouldn&#8217;t be a problem for organizations with a semi-regular hardware replacement cycle). Now, as for the usage of that storage system for backup, it&#8217;s a different piece of the discussion. I&#8217;ve seen quite a few setups where a single-but-very-large server provides networked storage to a large number of users via something like samba or NFS. In this case, the big server is usually blessed with some complicated RAID arrangement which people put entirely too much faith in. No one ever listens that RAID is not a backup strategy. Personally, I don&#8217;t believe in hardware reliability because it seems silly to spend money trying to prevent hardware from failing when you know it&#8217;s going to break (eventually) anyway. I&#8217;m not saying that RAID isn&#8217;t useful because it *is* useful and has a place. What I am saying is that it&#8217;s not backup. So if an organization has a big network storage server then where does that get backed up to? It&#8217;s hard to backup 6 TB off site but it can (certainly) be done. However, if an organization is lucky enough to have multiple buildings then a distributed storage cluster like I described earlier would be an excellent addition to the overall backup infrastructure. Putting a few machines in different buildings and using it as a place to shadow the main file server and whatever else needs to be backed up would grant an added measure of security.</p>
<p>Snow days are a good time for thinking and my backup jobs went smoothly. However, I feel as if I have begun a track of study which might yield some good results. Granted, it&#8217;s not just about the technology (<a href="http://arxiv.org/abs/cs/0412074">humans screw things up</a>) but the ability to build reliable and fault-tolerant storage systems for massive amounts of data using only commodity hardware is a huge boon to users everywhere. This concludes my backup rant.</p>
]]></content:encoded>
			<wfw:commentRss>http://yonkeltron.com/2010/02/11/the-zen-of-backup-theory/feed/</wfw:commentRss>
		<slash:comments>1</slash:comments>
		</item>
		<item>
		<title>ES5 is finally here, JavaScript geeks rejoice!</title>
		<link>http://yonkeltron.com/2009/12/15/es5-is-finally-here-javascript-geeks-rejoice/</link>
		<comments>http://yonkeltron.com/2009/12/15/es5-is-finally-here-javascript-geeks-rejoice/#comments</comments>
		<pubDate>Wed, 16 Dec 2009 01:03:56 +0000</pubDate>
		<dc:creator>Jonathan Magen</dc:creator>
				<category><![CDATA[Uncategorized]]></category>
		<category><![CDATA[Computing]]></category>
		<category><![CDATA[F/OSS]]></category>
		<category><![CDATA[JavaScript]]></category>
		<category><![CDATA[Programming]]></category>
		<category><![CDATA[Web]]></category>

		<guid isPermaLink="false">http://yonkeltron.com/?p=599</guid>
		<description><![CDATA[So, earlier this week, it was announced that ECMAScript 5 has finally been released. This is a good thing and I caught the highlights on InfoQ. The full draft is a 252 page PDF  beast of a document which covers basically about everything there is to cover. The things which strike me as interesting are ]]></description>
			<content:encoded><![CDATA[<p>So, earlier this week, it was announced that <a href="http://en.wikipedia.org/wiki/ECMAScript#ECMAScript.2C_5th_Edition">ECMAScript 5</a> has finally been released. This is a good thing and I caught the highlights on <a href="http://www.infoq.com/news/2009/12/ecmascript5">InfoQ</a>. The full draft is a <a href="http://www.ecma-international.org/publications/files/ECMA-ST/ECMA-262.pdf">252 page PDF  beast of a document</a> which covers basically about everything there is to cover. The things which strike me as interesting are the improved Array functions (like map, filter and reduce), some (finally) ways to harden Objects (in the form of freeze and seal) and <a href="http://json.org">JSON</a> in the language. The other big deal which has me excited is the availability of a strict mode which has been spoken about by <a href="http://www.youtube.com/watch?v=hQVTIJBZook">Douglas Crockford in his Google Tech Talk</a> as well in his book <a href="http://amzn.com/0596517742">JavaScript: The Good Parts</a>, which you should buy. Honestly, it makes you appreciate JavaScript so very, very much as D-Crock highlights the best and worst features of JavaScript.</p>
<p>In reality, this has been a big month for JavaScript with Google open sourcing its internal JS toolkit, <a href="http://code.google.com/closure/">Closure</a> along with much attention being paid to to projects like <a href="http://nodejs.org/">NodeJS</a> (for network stuff) and <a href="http://commonjs.org/">CommonJS</a> (for everything else).</p>
]]></content:encoded>
			<wfw:commentRss>http://yonkeltron.com/2009/12/15/es5-is-finally-here-javascript-geeks-rejoice/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Data visualization on a web page</title>
		<link>http://yonkeltron.com/2009/11/01/data-visualization-on-a-web-page/</link>
		<comments>http://yonkeltron.com/2009/11/01/data-visualization-on-a-web-page/#comments</comments>
		<pubDate>Sun, 01 Nov 2009 21:06:07 +0000</pubDate>
		<dc:creator>Jonathan Magen</dc:creator>
				<category><![CDATA[Uncategorized]]></category>
		<category><![CDATA[Computing]]></category>
		<category><![CDATA[F/OSS]]></category>
		<category><![CDATA[Internet]]></category>
		<category><![CDATA[JavaScript]]></category>
		<category><![CDATA[Programming]]></category>
		<category><![CDATA[Web]]></category>

		<guid isPermaLink="false">http://yonkeltron.com/?p=588</guid>
		<description><![CDATA[Quickie: Two of my favorite ways to get data visualized on a web page are the Google Chart API and flot, the amazing canvas-based plotting library built on top of jQuery. The Google Chart API provides a rediculously clever way to get high-quality information graphics which are generated on the back of the clearly-amazing Google ]]></description>
			<content:encoded><![CDATA[<p>Quickie: Two of my favorite ways to get data visualized on a web page are the <a href="http://code.google.com/apis/chart/">Google Chart API</a> and <a href="http://code.google.com/p/flot/">flot</a>, the amazing canvas-based plotting library built on top of <a href="http://jquery.com/">jQuery</a>.</p>
<p>The Google Chart API provides a rediculously clever way to get high-quality information graphics which are generated on the back of the clearly-amazing Google infrastructure. You just use the URL layout provided and it sort of just works. All types of charts can be created. It&#8217;s very nice if you&#8217;re willing to take the time to piece together the URLs in the proper format. There <a href="http://keith-wood.name/gChartRef.html">are</a> some <a href="http://www.maxb.net/scripts/jgcharts/include/demo/#1">abstractions</a>, though.</p>
<p>Then there&#8217;s <a href="http://code.google.com/p/flot/">flot</a> (which I&#8217;m told is Swedish for &#8220;pretty&#8221;). Flot is a library written in JavaScript on top of jQuery which produces very nice charts inside a canvas element. The <a href="http://people.iola.dk/olau/flot/examples/">demos are quite gorgeous</a> and it&#8217;s operation seems straightforward enough. As a side note, <a href="http://liftweb.net/">Lift</a> has a <a href="http://scala-tools.org/scaladocs/liftweb/1.0/net/liftweb/widgets/flot/Flot$object.html">built-in flot widget</a>.</p>
]]></content:encoded>
			<wfw:commentRss>http://yonkeltron.com/2009/11/01/data-visualization-on-a-web-page/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
	</channel>
</rss>
