<?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"?><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/" 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/" xmlns:feedburner="http://rssnamespace.org/feedburner/ext/1.0" version="2.0">

<channel>
	<title>X-Combinator</title>
	
	<link>http://www.xcombinator.com</link>
	<description>making the human scalable</description>
	<lastBuildDate>Fri, 18 Dec 2009 18:08:17 +0000</lastBuildDate>
	
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
			<atom10:link xmlns:atom10="http://www.w3.org/2005/Atom" rel="self" type="application/rss+xml" href="http://feeds.feedburner.com/xcombinator" /><feedburner:info uri="xcombinator" /><atom10:link xmlns:atom10="http://www.w3.org/2005/Atom" rel="hub" href="http://pubsubhubbub.appspot.com/" /><item>
		<title>Cascading, TF-IDF, and BufferedSum (Part 1)</title>
		<link>http://feedproxy.google.com/~r/xcombinator/~3/Rm6ltLmDFMM/</link>
		<comments>http://www.xcombinator.com/2009/12/18/cascading-tf-idf-and-bufferedsum-part-1/#comments</comments>
		<pubDate>Fri, 18 Dec 2009 18:08:17 +0000</pubDate>
		<dc:creator>Nate Murray</dc:creator>
				<category><![CDATA[cascading]]></category>
		<category><![CDATA[hadoop]]></category>
		<category><![CDATA[programming]]></category>

		<guid isPermaLink="false">http://www.xcombinator.com/?p=188</guid>
		<description><![CDATA[Introduction
A common technique in MapReduce is to input a group of records, calculate a value from that group, and emit each record with the new value attached. While this is easy to do in raw MR jobs, the solution in Cascading is not very obvious. This tutorial introduces a new operation to Cascading called BufferedSum. [...]]]></description>
			<content:encoded><![CDATA[<h2>Introduction</h2>
<p>A common technique in MapReduce is to input a group of records, calculate a value from that group, and emit each record with the new value attached. While this is easy to do in raw MR jobs, the solution in Cascading is not very obvious. This tutorial introduces a new operation to Cascading called <code>BufferedSum</code>. <code>BufferedSum</code> allows us to calculate values from a group of tuples and emit the group value to individual tuples in a scalable way.</p>
<p>Describing the operation of <code>BufferedSum</code> is clearer when discussed in concrete terms, so let&#8217;s work with an example.</p>
<h2>Example</h2>
<p>When dealing with large amounts of documents in Hadoop, its common to have each input file to contain many documents. Our input file in this case will contain two documents:</p>

<div class="wp_syntax"><div class="code"><pre class="java" style="font-family:monospace;">a.<span style="color: #006633;">txt</span>\thello world world
b.<span style="color: #006633;">txt</span>\tgoodbye goodbye world</pre></div></div>

<p>Lets say we want to calculate <a href="http://en.wikipedia.org/wiki/Tf‚Äìidf">tf-idf</a> for these documents.  One of the first values we need is the count of the occurrence particular term within each document. </p>
<p>First, we will split each line into <code>(document_id, body)</code> pairs:  </p>

<div class="wp_syntax"><div class="code"><pre class="java" style="font-family:monospace;">  pipe <span style="color: #339933;">=</span> <span style="color: #000000; font-weight: bold;">new</span> Each<span style="color: #009900;">&#40;</span>pipe, 
      <span style="color: #000000; font-weight: bold;">new</span> Fields<span style="color: #009900;">&#40;</span><span style="color: #0000ff;">&quot;line&quot;</span><span style="color: #009900;">&#41;</span>, 
      <span style="color: #000000; font-weight: bold;">new</span> RegexSplitter<span style="color: #009900;">&#40;</span><span style="color: #000000; font-weight: bold;">new</span> Fields<span style="color: #009900;">&#40;</span><span style="color: #0000ff;">&quot;document_id&quot;</span>, <span style="color: #0000ff;">&quot;body&quot;</span><span style="color: #009900;">&#41;</span>, <span style="color: #0000ff;">&quot;<span style="color: #000099; font-weight: bold;">\t</span>&quot;</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span></pre></div></div>

<p>From there we &#8220;tokenize&#8221; the document and extract each term:</p>

<div class="wp_syntax"><div class="code"><pre class="java" style="font-family:monospace;">  pipe <span style="color: #339933;">=</span> <span style="color: #000000; font-weight: bold;">new</span> Each<span style="color: #009900;">&#40;</span>pipe, <span style="color: #666666; font-style: italic;">// tokenize words by space</span>
      <span style="color: #000000; font-weight: bold;">new</span> Fields<span style="color: #009900;">&#40;</span><span style="color: #0000ff;">&quot;body&quot;</span><span style="color: #009900;">&#41;</span>,
      <span style="color: #000000; font-weight: bold;">new</span> RegexSplitGenerator<span style="color: #009900;">&#40;</span><span style="color: #000000; font-weight: bold;">new</span> Fields<span style="color: #009900;">&#40;</span><span style="color: #0000ff;">&quot;term&quot;</span><span style="color: #009900;">&#41;</span>, <span style="color: #0000ff;">&quot;<span style="color: #000099; font-weight: bold;">\\</span>s+&quot;</span><span style="color: #009900;">&#41;</span>, 
      <span style="color: #000000; font-weight: bold;">new</span> Fields<span style="color: #009900;">&#40;</span><span style="color: #0000ff;">&quot;document_id&quot;</span>, <span style="color: #0000ff;">&quot;term&quot;</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span></pre></div></div>

<p>Now our tuple stream is the following:</p>

<div class="wp_syntax"><div class="code"><pre class="java" style="font-family:monospace;">a.<span style="color: #006633;">txt</span> hello
a.<span style="color: #006633;">txt</span> world
a.<span style="color: #006633;">txt</span> world
b.<span style="color: #006633;">txt</span> goodbye
b.<span style="color: #006633;">txt</span> goodbye
b.<span style="color: #006633;">txt</span> world</pre></div></div>

<h2>Count of <code>term</code> in <code>document_id</code></h2>
<p>We now have <code>(document_id, term)</code> and we want to calculate <code>(document_id, term, term_count_in_document)</code>. With Cascading, this is easy, simply group by <code>document_id</code> and <code>term</code> and use the <code>Count()</code> function:</p>

<div class="wp_syntax"><div class="code"><pre class="java" style="font-family:monospace;">  <span style="color: #666666; font-style: italic;">// count how many times `term` appears in `document_id`</span>
  pipe <span style="color: #339933;">=</span> <span style="color: #000000; font-weight: bold;">new</span> GroupBy<span style="color: #009900;">&#40;</span>pipe, <span style="color: #000000; font-weight: bold;">new</span> Fields<span style="color: #009900;">&#40;</span><span style="color: #0000ff;">&quot;document_id&quot;</span>, <span style="color: #0000ff;">&quot;term&quot;</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
  pipe <span style="color: #339933;">=</span> <span style="color: #000000; font-weight: bold;">new</span> Every<span style="color: #009900;">&#40;</span>pipe, 
      <span style="color: #000000; font-weight: bold;">new</span> Fields<span style="color: #009900;">&#40;</span><span style="color: #0000ff;">&quot;term&quot;</span><span style="color: #009900;">&#41;</span>, 
      <span style="color: #000000; font-weight: bold;">new</span> Count<span style="color: #009900;">&#40;</span><span style="color: #000000; font-weight: bold;">new</span> Fields<span style="color: #009900;">&#40;</span><span style="color: #0000ff;">&quot;term_count_in_document&quot;</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#41;</span>, 
      <span style="color: #000000; font-weight: bold;">new</span> Fields<span style="color: #009900;">&#40;</span><span style="color: #0000ff;">&quot;document_id&quot;</span>, <span style="color: #0000ff;">&quot;term&quot;</span>, <span style="color: #0000ff;">&quot;term_count_in_document&quot;</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span></pre></div></div>

<h2>Calculating <code>total_terms_in_document</code></h2>
<p>So far, so good. Up to this point Cascading has provided everything we need.  However, next we want to get the total terms within each document and keep the tuples we have calculated thus far. Put another way, we have an input of <code>(document_id, term, term_count_in_document)</code> and we want to emit <code>(document_id, term, term_count_in_document, total_terms_in_document)</code> </p>
<p>Our first instinct might be to use <code>GroupBy()</code> and <code>Count()</code> like before. But there is a catch: <code>Every</code> operations emit the operator result with the <em>group tuple</em> (see the <a href="http://www.cascading.org/userguide/html/ch03s02.html#N20228">Each and Every Pipes</a> in the Cascading User Guide). </p>
<p>This means if we group by <code>document_id</code> and <code>Sum()</code> the <code>total_terms_in_document</code> we will emit <code>(document_id, total_terms_in_document)</code>.  The number in <code>total_terms_in_document</code> will be accurate, but we lose our <code>term</code> and <code>term_count_in_document</code>. </p>
<p>If we try to save our other fields by grouping on all three of them <code>(document_id, term, term_count_in_document)</code> then we&#8217;ve &#8220;over-grouped&#8221; and every &#8220;group&#8221; is a single tuple (the input tuple) and we won&#8217;t get the count of terms in the document as a whole. <code>BufferedSum</code> was created to solve this problem. </p>
<h2><code>BufferedSum</code></h2>
<p><code>BufferedSum</code> takes as its input three things:</p>
<ul>
<li>The name of the <code>Field</code> to output</li>
<li>The name of the <code>Field</code> to sum</li>
<li>The other <code>Fields</code> to &#8220;pull through&#8221; the operation</li>
</ul>
<p>Here is how we can use <code>BufferedSum</code> to achieve the desired effect:</p>

<div class="wp_syntax"><div class="code"><pre class="java" style="font-family:monospace;"><span style="color: #666666; font-style: italic;">// input: (document_id, term, term_count_in_document)</span>
<span style="color: #666666; font-style: italic;">// emits: (document_id, term, term_count_in_document, total_terms_in_document) </span>
pipe <span style="color: #339933;">=</span> <span style="color: #000000; font-weight: bold;">new</span> GroupBy<span style="color: #009900;">&#40;</span>pipe, <span style="color: #000000; font-weight: bold;">new</span> Fields<span style="color: #009900;">&#40;</span><span style="color: #0000ff;">&quot;document_id&quot;</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
pipe <span style="color: #339933;">=</span> <span style="color: #000000; font-weight: bold;">new</span> Every<span style="color: #009900;">&#40;</span>pipe, 
    <span style="color: #000000; font-weight: bold;">new</span> BufferedSum<span style="color: #009900;">&#40;</span><span style="color: #000000; font-weight: bold;">new</span> Fields<span style="color: #009900;">&#40;</span><span style="color: #0000ff;">&quot;total_terms_in_document&quot;</span><span style="color: #009900;">&#41;</span>, 
                    <span style="color: #000000; font-weight: bold;">new</span> Fields<span style="color: #009900;">&#40;</span><span style="color: #0000ff;">&quot;term_count_in_document&quot;</span><span style="color: #009900;">&#41;</span>,
                    <span style="color: #000000; font-weight: bold;">new</span> Fields<span style="color: #009900;">&#40;</span><span style="color: #0000ff;">&quot;document_id&quot;</span>, <span style="color: #0000ff;">&quot;term&quot;</span>, <span style="color: #0000ff;">&quot;term_count_in_document&quot;</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#41;</span>, 
    Fields.<span style="color: #006633;">SWAP</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span></pre></div></div>

<blockquote>
<p>Note: the output selector <code>Fields.SWAP</code> is critical due to Cascading tuple selection.</p>
</blockquote>
<h2>Memory considerations</h2>
<p>One thing to be careful of when using <code>BufferedSum</code> is to try and keep your groups small enough to fit in memory. However, this is not a requirement.  <code>BufferedSum</code> uses Cascading&#8217;s <code>SpillableTupleList</code> which will spill to the HDFS if it grows too large. That said, spilling is an expensive operation and should be avoided if possible.</p>
<h2>Summary</h2>
<p><code>BufferedSum</code> is a widely useful operation when dealing with sums in Cascading.  In Part 2 we will use <code>BufferedSum</code> and Cascading to finish calculating tf-idf.</p>
<h2>The Code</h2>

<div class="wp_syntax"><div class="code"><pre class="java" style="font-family:monospace;"><span style="color: #000000; font-weight: bold;">package</span> <span style="color: #006699;">com.xcombinator.cascading.operations.buffers</span><span style="color: #339933;">;</span>
<span style="color: #000000; font-weight: bold;">import</span> <span style="color: #006699;">cascading.flow.FlowProcess</span><span style="color: #339933;">;</span>
<span style="color: #000000; font-weight: bold;">import</span> <span style="color: #006699;">cascading.operation.BaseOperation</span><span style="color: #339933;">;</span>
<span style="color: #000000; font-weight: bold;">import</span> <span style="color: #006699;">cascading.operation.Buffer</span><span style="color: #339933;">;</span>
<span style="color: #000000; font-weight: bold;">import</span> <span style="color: #006699;">cascading.operation.BufferCall</span><span style="color: #339933;">;</span>
<span style="color: #000000; font-weight: bold;">import</span> <span style="color: #006699;">cascading.tuple.Fields</span><span style="color: #339933;">;</span>
<span style="color: #000000; font-weight: bold;">import</span> <span style="color: #006699;">cascading.tuple.Tuple</span><span style="color: #339933;">;</span>
<span style="color: #000000; font-weight: bold;">import</span> <span style="color: #006699;">cascading.tuple.TupleEntry</span><span style="color: #339933;">;</span>
<span style="color: #000000; font-weight: bold;">import</span> <span style="color: #006699;">cascading.tuple.SpillableTupleList</span><span style="color: #339933;">;</span>
&nbsp;
<span style="color: #000000; font-weight: bold;">import</span> <span style="color: #006699;">java.util.Iterator</span><span style="color: #339933;">;</span>
&nbsp;
<span style="color: #008000; font-style: italic; font-weight: bold;">/**
 * BufferedSum sums a value for every Tuple in a Group and emits every input
 * Tuple with the sum appended.
 * &lt;p/&gt;
 * 
 * 
 * EXAMPLE:
 *
 * {@code 
 *
 * // input: (document_id, term, term_count_in_document)
 * // emits: (document_id, term, term_count_in_document, total_terms_in_document) 
 *
 *     pipe = new GroupBy(pipe, new Fields(&quot;document_id&quot;));
 *     pipe = new Every(pipe, 
 *         new BufferedSum(new Fields(&quot;total_terms_in_document&quot;), 
 *                        new Fields(&quot;term_count_in_document&quot;),
 *                        new Fields(&quot;document_id&quot;, &quot;term&quot;, &quot;term_count_in_document&quot;)), 
 *         Fields.SWAP);
 * }
 *
 * @see BufferedSum
 * 
 */</span>
&nbsp;
<span style="color: #000000; font-weight: bold;">public</span> <span style="color: #000000; font-weight: bold;">class</span> BufferedSum <span style="color: #000000; font-weight: bold;">extends</span> BaseOperation <span style="color: #000000; font-weight: bold;">implements</span> Buffer
  <span style="color: #009900;">&#123;</span>
  <span style="color: #000000; font-weight: bold;">private</span> <span style="color: #003399;">Double</span> sum<span style="color: #339933;">;</span>
  <span style="color: #000000; font-weight: bold;">private</span> SpillableTupleList list<span style="color: #339933;">;</span>
  <span style="color: #000000; font-weight: bold;">private</span> Fields extrasSelector<span style="color: #339933;">;</span>
  <span style="color: #000000; font-weight: bold;">private</span> Fields fieldToSum<span style="color: #339933;">;</span>
&nbsp;
  <span style="color: #008000; font-style: italic; font-weight: bold;">/**
   * Returns a BufferedSum Buffer Operation. 
   *
   * @param emittedSumFieldName a {@link Fields} naming the field to emit the sum value
   * @param fieldToSum          a {@link Fields} naming the field to sum
   * @param extrasSelector      a {@link Fields} naming the other fields to &quot;pull through&quot;. These fields *must* be of the same order and size as the input Tuple
   */</span>
  <span style="color: #000000; font-weight: bold;">public</span> BufferedSum<span style="color: #009900;">&#40;</span> Fields emittedSumFieldName, Fields fieldToSum, Fields extrasSelector <span style="color: #009900;">&#41;</span>
    <span style="color: #009900;">&#123;</span>
    <span style="color: #000000; font-weight: bold;">super</span><span style="color: #009900;">&#40;</span> extrasSelector.<span style="color: #006633;">append</span><span style="color: #009900;">&#40;</span> emittedSumFieldName <span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
    <span style="color: #000000; font-weight: bold;">this</span>.<span style="color: #006633;">extrasSelector</span> <span style="color: #339933;">=</span> extrasSelector<span style="color: #339933;">;</span>
    <span style="color: #000000; font-weight: bold;">this</span>.<span style="color: #006633;">fieldToSum</span> <span style="color: #339933;">=</span> fieldToSum<span style="color: #339933;">;</span>
    <span style="color: #009900;">&#125;</span>
&nbsp;
  <span style="color: #000000; font-weight: bold;">public</span> <span style="color: #000066; font-weight: bold;">void</span> operate<span style="color: #009900;">&#40;</span> FlowProcess flowProcess, BufferCall bufferCall <span style="color: #009900;">&#41;</span>
    <span style="color: #009900;">&#123;</span>
    Iterator<span style="color: #339933;">&lt;</span>TupleEntry<span style="color: #339933;">&gt;</span> iterator <span style="color: #339933;">=</span> bufferCall.<span style="color: #006633;">getArgumentsIterator</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
    sum <span style="color: #339933;">=</span> 0.0D<span style="color: #339933;">;</span>
    list <span style="color: #339933;">=</span> <span style="color: #000000; font-weight: bold;">new</span> SpillableTupleList<span style="color: #009900;">&#40;</span> <span style="color: #cc66cc;">10000</span> <span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
&nbsp;
    <span style="color: #000000; font-weight: bold;">while</span><span style="color: #009900;">&#40;</span> iterator.<span style="color: #006633;">hasNext</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#41;</span>
      <span style="color: #009900;">&#123;</span>
      TupleEntry arguments <span style="color: #339933;">=</span> iterator.<span style="color: #006633;">next</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span> <span style="color: #666666; font-style: italic;">// must be called</span>
      sum <span style="color: #339933;">+=</span> arguments.<span style="color: #006633;">getDouble</span><span style="color: #009900;">&#40;</span> <span style="color: #000000; font-weight: bold;">this</span>.<span style="color: #006633;">fieldToSum</span>.<span style="color: #006633;">get</span><span style="color: #009900;">&#40;</span><span style="color: #cc66cc;">0</span><span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
      list.<span style="color: #006633;">add</span><span style="color: #009900;">&#40;</span> arguments.<span style="color: #006633;">getTuple</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
      <span style="color: #009900;">&#125;</span>
&nbsp;
    <span style="color: #000000; font-weight: bold;">for</span><span style="color: #009900;">&#40;</span> Tuple tuple <span style="color: #339933;">:</span> list <span style="color: #009900;">&#41;</span>
      <span style="color: #009900;">&#123;</span>
      bufferCall.<span style="color: #006633;">getOutputCollector</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span>.<span style="color: #006633;">add</span><span style="color: #009900;">&#40;</span> tuple.<span style="color: #006633;">append</span><span style="color: #009900;">&#40;</span> <span style="color: #000000; font-weight: bold;">new</span> Tuple<span style="color: #009900;">&#40;</span> sum <span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
      <span style="color: #009900;">&#125;</span>
&nbsp;
    <span style="color: #009900;">&#125;</span>
  <span style="color: #009900;">&#125;</span></pre></div></div>

<p>Share:</p>
<p>	<a rel="nofollow"  href="http://delicious.com/post?url=http%3A%2F%2Fwww.xcombinator.com%2F2009%2F12%2F18%2Fcascading-tf-idf-and-bufferedsum-part-1%2F&amp;title=Cascading%2C%20TF-IDF%2C%20and%20BufferedSum%20%28Part%201%29&amp;notes=Introduction%0D%0A%0D%0AA%20common%20technique%20in%20MapReduce%20is%20to%20input%20a%20group%20of%20records%2C%20calculate%20a%20value%20from%20that%20group%2C%20and%20emit%20each%20record%20with%20the%20new%20value%20attached.%20While%20this%20is%20easy%20to%20do%20in%20raw%20MR%20jobs%2C%20the%20solution%20in%20Cascading%20is%20not%20very%20obviou" title="del.icio.us"><img src="http://www.xcombinator.com/wp-content/plugins/sociable/images/delicious.png" title="del.icio.us" alt="del.icio.us" class="sociable-hovers" /></a><br />
	<a rel="nofollow"  href="http://reddit.com/submit?url=http%3A%2F%2Fwww.xcombinator.com%2F2009%2F12%2F18%2Fcascading-tf-idf-and-bufferedsum-part-1%2F&amp;title=Cascading%2C%20TF-IDF%2C%20and%20BufferedSum%20%28Part%201%29" title="Reddit"><img src="http://www.xcombinator.com/wp-content/plugins/sociable/images/reddit.png" title="Reddit" alt="Reddit" class="sociable-hovers" /></a><br />
	<a rel="nofollow"  href="http://technorati.com/faves?add=http%3A%2F%2Fwww.xcombinator.com%2F2009%2F12%2F18%2Fcascading-tf-idf-and-bufferedsum-part-1%2F" title="Technorati"><img src="http://www.xcombinator.com/wp-content/plugins/sociable/images/technorati.png" title="Technorati" alt="Technorati" class="sociable-hovers" /></a><br />
	<a rel="nofollow"  href="http://twitter.com/home?status=Cascading%2C%20TF-IDF%2C%20and%20BufferedSum%20%28Part%201%29%20-%20http%3A%2F%2Fwww.xcombinator.com%2F2009%2F12%2F18%2Fcascading-tf-idf-and-bufferedsum-part-1%2F" title="Twitter"><img src="http://www.xcombinator.com/wp-content/plugins/sociable/images/twitter.png" title="Twitter" alt="Twitter" class="sociable-hovers" /></a><br />
	<a rel="nofollow"  href="http://www.facebook.com/share.php?u=http%3A%2F%2Fwww.xcombinator.com%2F2009%2F12%2F18%2Fcascading-tf-idf-and-bufferedsum-part-1%2F&amp;t=Cascading%2C%20TF-IDF%2C%20and%20BufferedSum%20%28Part%201%29" title="Facebook"><img src="http://www.xcombinator.com/wp-content/plugins/sociable/images/facebook.png" title="Facebook" alt="Facebook" class="sociable-hovers" /></a><br />
	<a rel="nofollow"  href="http://www.google.com/bookmarks/mark?op=edit&amp;bkmk=http%3A%2F%2Fwww.xcombinator.com%2F2009%2F12%2F18%2Fcascading-tf-idf-and-bufferedsum-part-1%2F&amp;title=Cascading%2C%20TF-IDF%2C%20and%20BufferedSum%20%28Part%201%29&amp;annotation=Introduction%0D%0A%0D%0AA%20common%20technique%20in%20MapReduce%20is%20to%20input%20a%20group%20of%20records%2C%20calculate%20a%20value%20from%20that%20group%2C%20and%20emit%20each%20record%20with%20the%20new%20value%20attached.%20While%20this%20is%20easy%20to%20do%20in%20raw%20MR%20jobs%2C%20the%20solution%20in%20Cascading%20is%20not%20very%20obviou" title="Google Bookmarks"><img src="http://www.xcombinator.com/wp-content/plugins/sociable/images/googlebookmark.png" title="Google Bookmarks" alt="Google Bookmarks" class="sociable-hovers" /></a><br />
	<a rel="nofollow"  href="http://news.ycombinator.com/submitlink?u=http%3A%2F%2Fwww.xcombinator.com%2F2009%2F12%2F18%2Fcascading-tf-idf-and-bufferedsum-part-1%2F&amp;t=Cascading%2C%20TF-IDF%2C%20and%20BufferedSum%20%28Part%201%29" title="HackerNews"><img src="http://www.xcombinator.com/wp-content/plugins/sociable/images/hackernews.png" title="HackerNews" alt="HackerNews" class="sociable-hovers" /></a><br />
	<a rel="nofollow"  href="http://www.printfriendly.com/print?url=http%3A%2F%2Fwww.xcombinator.com%2F2009%2F12%2F18%2Fcascading-tf-idf-and-bufferedsum-part-1%2F&amp;partner=sociable" title="PDF"><img src="http://www.xcombinator.com/wp-content/plugins/sociable/images/pdf.png" title="PDF" alt="PDF" class="sociable-hovers" /></a><br />
	<a rel="nofollow"  href="http://www.xcombinator.com/feed/" title="RSS"><img src="http://www.xcombinator.com/wp-content/plugins/sociable/images/rss.png" title="RSS" alt="RSS" class="sociable-hovers" /></a></p>
<p><br/><br/></p>
]]></content:encoded>
			<wfw:commentRss>http://www.xcombinator.com/2009/12/18/cascading-tf-idf-and-bufferedsum-part-1/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		<feedburner:origLink>http://www.xcombinator.com/2009/12/18/cascading-tf-idf-and-bufferedsum-part-1/</feedburner:origLink></item>
		<item>
		<title>How to use Cascading with Hadoop Streaming</title>
		<link>http://feedproxy.google.com/~r/xcombinator/~3/3NyHyyvudHw/</link>
		<comments>http://www.xcombinator.com/2009/11/18/how-to-use-cascading-with-hadoop-streaming/#comments</comments>
		<pubDate>Wed, 18 Nov 2009 19:45:46 +0000</pubDate>
		<dc:creator>Nate Murray</dc:creator>
				<category><![CDATA[programming]]></category>

		<guid isPermaLink="false">http://www.xcombinator.com/?p=152</guid>
		<description><![CDATA[Last time we talked about how to use a raw MapReduce job in Cascading. Now we are going to up the ante by using Hadoop Streaming as a Flow in Cascading. In this example, we hook a python streaming job into a Cascade.
Its pretty easy once you know how to do it: 

Create a JobConf [...]]]></description>
			<content:encoded><![CDATA[<p><a href="http://www.xcombinator.com/2009/11/11/how-to-use-a-raw-mapreduce-job-in-cascading/">Last time</a> we talked about how to use a raw MapReduce job in Cascading. Now we are going to up the ante by using Hadoop Streaming as a Flow in Cascading. In this example, we hook a python streaming job into a Cascade.</p>
<p>Its pretty easy once you know how to do it: </p>
<ul>
<li>Create a JobConf that defines the parameters for the streaming job</li>
<li>Send up the <code>hadoop-*-streaming.jar</code> with your cascading job by putting it in your <code>jar</code></li>
<li>Send up the scripts (python, in this case) by using the <code>-file</code> option</li>
<li>Send up any other dependencies, corpora, etc. by using the <code>-file</code>, <code>-cacheFile</code>, or <code>-cacheArchive</code> options (See the <a href="http://hadoop.apache.org/common/docs/r0.20.0/streaming.html">Hadoop Streaming</a> page for more details)</li>
</ul>
<h2>Resources</h2>
<h3>NLTK</h3>
<p>To generate the <code>nltkandyaml.mod</code> zip file do the following:</p>
<pre><code># download nltk and unzip
cd nltk
zip -r nltkandyaml.zip nltk yaml
mv nltkandyaml.zip nltkandyaml.mod
</code></pre>
<p>Note that this technique is taken from <a href="http://www.cloudera.com/node/48">Cloudera</a></p>
<h3>WordNet</h3>
<p>The WordNet zip file needs to be flat. e.g. don&#8217;t zip up the files with a subdirectory. You could create this file like so:</p>
<pre><code># download and unzip the wordnet corpus
cd wordnet
zip -r ../wordnet-flat.zip *
</code></pre>
<h2>Streaming Script</h2>
<p>In python, we&#8217;ll be using <code>zipimport.zipimporter</code> to import the <code>nltk</code> libraries from a zip file. In Hadoop 0.20.0, Hadoop didn&#8217;t decompress our <code>wordnet-flat.zip</code> file automatically (but we&#8217;ve heard reports that it will, but I&#8217;m not sure which versions). For us the <code>.zip</code> file was placed in <code>lib</code> relative to the <code>pwd</code> of the script.  This allowed us to keep the WordNet corpus as a zip and read it in that format.</p>

<div class="wp_syntax"><div class="code"><pre class="python" style="font-family:monospace;">wn = WordNetCorpusReader<span style="color: black;">&#40;</span>nltk.<span style="color: black;">data</span>.<span style="color: black;">find</span><span style="color: black;">&#40;</span><span style="color: #483d8b;">'lib/wordnet-flat.zip'</span><span style="color: black;">&#41;</span><span style="color: black;">&#41;</span></pre></div></div>

<p>(In this code we&#8217;re not using the python reducer.)</p>

<div class="wp_syntax"><div class="code"><pre class="python" style="font-family:monospace;"><span style="color: #808080; font-style: italic;">#!/usr/bin/env python </span>
<span style="color: #ff7700;font-weight:bold;">import</span> <span style="color: #dc143c;">os</span>
<span style="color: #ff7700;font-weight:bold;">import</span> <span style="color: #dc143c;">re</span>
<span style="color: #ff7700;font-weight:bold;">import</span> <span style="color: #dc143c;">sys</span>
<span style="color: #ff7700;font-weight:bold;">import</span> <span style="color: #dc143c;">zipimport</span>
&nbsp;
importer = <span style="color: #dc143c;">zipimport</span>.<span style="color: black;">zipimporter</span><span style="color: black;">&#40;</span><span style="color: #483d8b;">'nltkandyaml.mod'</span><span style="color: black;">&#41;</span>
yaml = importer.<span style="color: black;">load_module</span><span style="color: black;">&#40;</span><span style="color: #483d8b;">'yaml'</span><span style="color: black;">&#41;</span>
nltk = importer.<span style="color: black;">load_module</span><span style="color: black;">&#40;</span><span style="color: #483d8b;">'nltk'</span><span style="color: black;">&#41;</span>
punct = <span style="color: #dc143c;">re</span>.<span style="color: #008000;">compile</span><span style="color: black;">&#40;</span><span style="color: #483d8b;">'[^<span style="color: #000099; font-weight: bold;">\w</span><span style="color: #000099; font-weight: bold;">\s</span>]+'</span><span style="color: black;">&#41;</span>
&nbsp;
<span style="color: #ff7700;font-weight:bold;">from</span> nltk.<span style="color: black;">corpus</span>.<span style="color: black;">reader</span> <span style="color: #ff7700;font-weight:bold;">import</span> wordnet
<span style="color: #ff7700;font-weight:bold;">from</span> nltk.<span style="color: black;">corpus</span>.<span style="color: black;">reader</span> <span style="color: #ff7700;font-weight:bold;">import</span> WordNetCorpusReader
&nbsp;
nltk.<span style="color: black;">data</span>.<span style="color: black;">path</span> += <span style="color: black;">&#91;</span><span style="color: #483d8b;">&quot;.&quot;</span><span style="color: black;">&#93;</span>
wn = WordNetCorpusReader<span style="color: black;">&#40;</span>nltk.<span style="color: black;">data</span>.<span style="color: black;">find</span><span style="color: black;">&#40;</span><span style="color: #483d8b;">'lib/wordnet-flat.zip'</span><span style="color: black;">&#41;</span><span style="color: black;">&#41;</span>
&nbsp;
<span style="color: #ff7700;font-weight:bold;">def</span> mapper<span style="color: black;">&#40;</span>args<span style="color: black;">&#41;</span>:
  line = <span style="color: #dc143c;">sys</span>.<span style="color: black;">stdin</span>.<span style="color: #dc143c;">readline</span><span style="color: black;">&#40;</span><span style="color: black;">&#41;</span><span style="color: #66cc66;">;</span>
  <span style="color: #ff7700;font-weight:bold;">try</span>:
    <span style="color: #ff7700;font-weight:bold;">while</span> line:
      line = line.<span style="color: black;">strip</span><span style="color: black;">&#40;</span><span style="color: black;">&#41;</span>
      word = line
      all_synonyms = <span style="color: black;">&#91;</span><span style="color: black;">&#93;</span>
&nbsp;
      string_synsets = wn.<span style="color: black;">synsets</span><span style="color: black;">&#40;</span>word<span style="color: black;">&#41;</span>
&nbsp;
      <span style="color: #ff7700;font-weight:bold;">for</span> synset <span style="color: #ff7700;font-weight:bold;">in</span> string_synsets:
        synonyms = <span style="color: black;">&#91;</span>lemma.<span style="color: black;">name</span> <span style="color: #ff7700;font-weight:bold;">for</span> lemma <span style="color: #ff7700;font-weight:bold;">in</span> wn.<span style="color: black;">synset</span><span style="color: black;">&#40;</span>synset.<span style="color: black;">name</span><span style="color: black;">&#41;</span>.<span style="color: black;">lemmas</span><span style="color: black;">&#93;</span>
        synonyms.<span style="color: black;">pop</span><span style="color: black;">&#40;</span><span style="color: #ff4500;">0</span><span style="color: black;">&#41;</span>
        <span style="color: #ff7700;font-weight:bold;">for</span> synonym <span style="color: #ff7700;font-weight:bold;">in</span> synonyms:
          synonym = <span style="color: #dc143c;">re</span>.<span style="color: black;">sub</span><span style="color: black;">&#40;</span><span style="color: #483d8b;">&quot;_&quot;</span>, <span style="color: #483d8b;">&quot; &quot;</span>, synonym<span style="color: black;">&#41;</span>
          all_synonyms.<span style="color: black;">append</span><span style="color: black;">&#40;</span>synonym<span style="color: black;">&#41;</span> 
&nbsp;
      <span style="color: #ff7700;font-weight:bold;">print</span> <span style="color: #483d8b;">&quot;<span style="color: #000099; font-weight: bold;">\t</span>&quot;</span>.<span style="color: black;">join</span><span style="color: black;">&#40;</span><span style="color: black;">&#91;</span>word, <span style="color: #483d8b;">','</span>.<span style="color: black;">join</span><span style="color: black;">&#40;</span>all_synonyms<span style="color: black;">&#41;</span><span style="color: black;">&#93;</span><span style="color: black;">&#41;</span>
      line = <span style="color: #dc143c;">sys</span>.<span style="color: black;">stdin</span>.<span style="color: #dc143c;">readline</span><span style="color: black;">&#40;</span><span style="color: black;">&#41;</span>
  <span style="color: #ff7700;font-weight:bold;">except</span> <span style="color: #483d8b;">&quot;end of file&quot;</span>:
    <span style="color: #ff7700;font-weight:bold;">return</span> <span style="color: #008000;">None</span>
&nbsp;
<span style="color: #808080; font-style: italic;"># we're not using this, but we could</span>
<span style="color: #ff7700;font-weight:bold;">def</span> reducer<span style="color: black;">&#40;</span>args<span style="color: black;">&#41;</span>:
  <span style="color: #ff7700;font-weight:bold;">for</span> line <span style="color: #ff7700;font-weight:bold;">in</span> <span style="color: #dc143c;">sys</span>.<span style="color: black;">stdin</span>:
    line = line.<span style="color: black;">strip</span><span style="color: black;">&#40;</span><span style="color: black;">&#41;</span>
    <span style="color: #ff7700;font-weight:bold;">print</span> line
&nbsp;
<span style="color: #ff7700;font-weight:bold;">if</span> __name__ == <span style="color: #483d8b;">&quot;__main__&quot;</span>:
  <span style="color: #ff7700;font-weight:bold;">if</span> <span style="color: #dc143c;">sys</span>.<span style="color: black;">argv</span><span style="color: black;">&#91;</span><span style="color: #ff4500;">1</span><span style="color: black;">&#93;</span> == <span style="color: #483d8b;">&quot;mapper&quot;</span>:
    mapper<span style="color: black;">&#40;</span><span style="color: #dc143c;">sys</span>.<span style="color: black;">argv</span><span style="color: black;">&#91;</span><span style="color: #ff4500;">2</span>:<span style="color: black;">&#93;</span><span style="color: black;">&#41;</span>
  <span style="color: #ff7700;font-weight:bold;">elif</span> <span style="color: #dc143c;">sys</span>.<span style="color: black;">argv</span><span style="color: black;">&#91;</span><span style="color: #ff4500;">1</span><span style="color: black;">&#93;</span> == <span style="color: #483d8b;">&quot;reducer&quot;</span>:
    reducer<span style="color: black;">&#40;</span><span style="color: #dc143c;">sys</span>.<span style="color: black;">argv</span><span style="color: black;">&#91;</span><span style="color: #ff4500;">2</span>:<span style="color: black;">&#93;</span><span style="color: black;">&#41;</span></pre></div></div>

<h2>Cascading Code</h2>
<p>Here&#8217;s the bulk of the code that will achieve the effect we want. Like last time, we&#8217;re using two intermediate taps as the input and output of the streaming job. Also, we&#8217;re just using TextLine files for simplicity.  If you don&#8217;t want the intermediate files hanging around, look at the comments towards the bottom for some example code on how to remove the files when the job is finished running. </p>

<div class="wp_syntax"><div class="code"><pre class="java" style="font-family:monospace;"><span style="color: #000000; font-weight: bold;">package</span> <span style="color: #006699;">com.xcombinator.hadoopjobs.cascadingstreamingtest</span><span style="color: #339933;">;</span>
&nbsp;
<span style="color: #000000; font-weight: bold;">import</span> <span style="color: #006699;">cascading.cascade.*</span><span style="color: #339933;">;</span>
<span style="color: #000000; font-weight: bold;">import</span> <span style="color: #006699;">cascading.flow.Flow</span><span style="color: #339933;">;</span>
<span style="color: #000000; font-weight: bold;">import</span> <span style="color: #006699;">cascading.flow.FlowConnector</span><span style="color: #339933;">;</span>
<span style="color: #000000; font-weight: bold;">import</span> <span style="color: #006699;">cascading.flow.MapReduceFlow</span><span style="color: #339933;">;</span>
<span style="color: #000000; font-weight: bold;">import</span> <span style="color: #006699;">cascading.operation.aggregator.Count</span><span style="color: #339933;">;</span>
<span style="color: #000000; font-weight: bold;">import</span> <span style="color: #006699;">cascading.operation.regex.*</span><span style="color: #339933;">;</span>
<span style="color: #000000; font-weight: bold;">import</span> <span style="color: #006699;">cascading.pipe.*</span><span style="color: #339933;">;</span>
<span style="color: #000000; font-weight: bold;">import</span> <span style="color: #006699;">cascading.scheme.*</span><span style="color: #339933;">;</span>
<span style="color: #000000; font-weight: bold;">import</span> <span style="color: #006699;">cascading.tap.*</span><span style="color: #339933;">;</span>
<span style="color: #000000; font-weight: bold;">import</span> <span style="color: #006699;">cascading.tuple.Fields</span><span style="color: #339933;">;</span>
<span style="color: #000000; font-weight: bold;">import</span> <span style="color: #006699;">cascading.operation.Identity</span><span style="color: #339933;">;</span>
<span style="color: #000000; font-weight: bold;">import</span> <span style="color: #006699;">java.util.Properties</span><span style="color: #339933;">;</span>
<span style="color: #000000; font-weight: bold;">import</span> <span style="color: #006699;">org.apache.hadoop.conf.Configuration</span><span style="color: #339933;">;</span>
<span style="color: #000000; font-weight: bold;">import</span> <span style="color: #006699;">org.apache.hadoop.conf.Configured</span><span style="color: #339933;">;</span>
<span style="color: #000000; font-weight: bold;">import</span> <span style="color: #006699;">org.apache.hadoop.io.LongWritable</span><span style="color: #339933;">;</span>
<span style="color: #000000; font-weight: bold;">import</span> <span style="color: #006699;">org.apache.hadoop.io.Text</span><span style="color: #339933;">;</span>
<span style="color: #000000; font-weight: bold;">import</span> <span style="color: #006699;">org.apache.hadoop.mapred.FileInputFormat</span><span style="color: #339933;">;</span>
<span style="color: #000000; font-weight: bold;">import</span> <span style="color: #006699;">org.apache.hadoop.mapred.FileOutputFormat</span><span style="color: #339933;">;</span>
<span style="color: #000000; font-weight: bold;">import</span> <span style="color: #006699;">org.apache.hadoop.mapred.JobConf</span><span style="color: #339933;">;</span>
<span style="color: #000000; font-weight: bold;">import</span> <span style="color: #006699;">org.apache.hadoop.mapred.TextInputFormat</span><span style="color: #339933;">;</span>
<span style="color: #000000; font-weight: bold;">import</span> <span style="color: #006699;">org.apache.hadoop.mapred.TextOutputFormat</span><span style="color: #339933;">;</span>
<span style="color: #000000; font-weight: bold;">import</span> <span style="color: #006699;">org.apache.hadoop.mapred.lib.IdentityMapper</span><span style="color: #339933;">;</span>
<span style="color: #000000; font-weight: bold;">import</span> <span style="color: #006699;">org.apache.hadoop.mapred.lib.IdentityReducer</span><span style="color: #339933;">;</span>
<span style="color: #000000; font-weight: bold;">import</span> <span style="color: #006699;">org.apache.hadoop.util.Tool</span><span style="color: #339933;">;</span>
<span style="color: #000000; font-weight: bold;">import</span> <span style="color: #006699;">org.apache.hadoop.util.ToolRunner</span><span style="color: #339933;">;</span>
<span style="color: #000000; font-weight: bold;">import</span> <span style="color: #006699;">org.apache.log4j.Logger</span><span style="color: #339933;">;</span>
<span style="color: #000000; font-weight: bold;">import</span> <span style="color: #006699;">cascading.operation.Debug</span><span style="color: #339933;">;</span>
<span style="color: #000000; font-weight: bold;">import</span> <span style="color: #006699;">org.apache.hadoop.streaming.StreamJob</span><span style="color: #339933;">;</span>
<span style="color: #000000; font-weight: bold;">import</span> <span style="color: #006699;">java.io.IOException</span><span style="color: #339933;">;</span>
&nbsp;
<span style="color: #008000; font-style: italic; font-weight: bold;">/**
 * An example file to use a Hadoop Streaming job in cascading
 */</span>
<span style="color: #000000; font-weight: bold;">public</span> <span style="color: #000000; font-weight: bold;">class</span> Main <span style="color: #000000; font-weight: bold;">extends</span> Configured <span style="color: #000000; font-weight: bold;">implements</span> Tool
  <span style="color: #009900;">&#123;</span>
  <span style="color: #000000; font-weight: bold;">private</span> <span style="color: #000000; font-weight: bold;">static</span> <span style="color: #000000; font-weight: bold;">final</span> Logger LOG <span style="color: #339933;">=</span> Logger.<span style="color: #006633;">getLogger</span><span style="color: #009900;">&#40;</span> Main.<span style="color: #000000; font-weight: bold;">class</span> <span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
&nbsp;
  <span style="color: #000000; font-weight: bold;">public</span> <span style="color: #000066; font-weight: bold;">int</span> run<span style="color: #009900;">&#40;</span><span style="color: #003399;">String</span><span style="color: #009900;">&#91;</span><span style="color: #009900;">&#93;</span> args<span style="color: #009900;">&#41;</span>
  <span style="color: #009900;">&#123;</span>
    JobConf conf <span style="color: #339933;">=</span> <span style="color: #000000; font-weight: bold;">new</span> JobConf<span style="color: #009900;">&#40;</span>getConf<span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span>, <span style="color: #000000; font-weight: bold;">this</span>.<span style="color: #006633;">getClass</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
    <span style="color: #003399;">Properties</span> properties <span style="color: #339933;">=</span> <span style="color: #000000; font-weight: bold;">new</span> <span style="color: #003399;">Properties</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
    FlowConnector.<span style="color: #006633;">setApplicationJarClass</span><span style="color: #009900;">&#40;</span>properties, <span style="color: #000000; font-weight: bold;">this</span>.<span style="color: #006633;">getClass</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
&nbsp;
    CascadeConnector cascadeConnector <span style="color: #339933;">=</span> <span style="color: #000000; font-weight: bold;">new</span> CascadeConnector<span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
    FlowConnector flowConnector <span style="color: #339933;">=</span> <span style="color: #000000; font-weight: bold;">new</span> FlowConnector<span style="color: #009900;">&#40;</span>properties<span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
&nbsp;
    <span style="color: #003399;">String</span> inputPath  <span style="color: #339933;">=</span> args<span style="color: #009900;">&#91;</span><span style="color: #cc66cc;">0</span><span style="color: #009900;">&#93;</span><span style="color: #339933;">;</span>
    <span style="color: #003399;">String</span> outputPath <span style="color: #339933;">=</span> args<span style="color: #009900;">&#91;</span><span style="color: #cc66cc;">1</span><span style="color: #009900;">&#93;</span><span style="color: #339933;">;</span>
    <span style="color: #003399;">String</span> intermediatePath1 <span style="color: #339933;">=</span> args<span style="color: #009900;">&#91;</span><span style="color: #cc66cc;">1</span><span style="color: #009900;">&#93;</span> <span style="color: #339933;">+</span> <span style="color: #0000ff;">&quot;-mr-input&quot;</span><span style="color: #339933;">;</span>
    <span style="color: #003399;">String</span> intermediatePath2 <span style="color: #339933;">=</span> args<span style="color: #009900;">&#91;</span><span style="color: #cc66cc;">1</span><span style="color: #009900;">&#93;</span> <span style="color: #339933;">+</span> <span style="color: #0000ff;">&quot;-mr-output&quot;</span><span style="color: #339933;">;</span>
&nbsp;
    Scheme textLineScheme <span style="color: #339933;">=</span> <span style="color: #000000; font-weight: bold;">new</span> TextLine<span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
&nbsp;
    Tap sourceTap <span style="color: #339933;">=</span> <span style="color: #000000; font-weight: bold;">new</span> Hfs<span style="color: #009900;">&#40;</span>textLineScheme, inputPath<span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
    Tap intermediateTap1 <span style="color: #339933;">=</span> <span style="color: #000000; font-weight: bold;">new</span> Hfs<span style="color: #009900;">&#40;</span>textLineScheme, intermediatePath1<span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
    Tap intermediateTap2 <span style="color: #339933;">=</span> <span style="color: #000000; font-weight: bold;">new</span> Hfs<span style="color: #009900;">&#40;</span>textLineScheme, intermediatePath2<span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
    Tap sinkTap   <span style="color: #339933;">=</span> <span style="color: #000000; font-weight: bold;">new</span> Hfs<span style="color: #009900;">&#40;</span>textLineScheme, outputPath<span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
&nbsp;
    <span style="color: #666666; font-style: italic;">// create our first flow, sink to the intermediateTap</span>
    Pipe wsPipe <span style="color: #339933;">=</span> <span style="color: #000000; font-weight: bold;">new</span> Each<span style="color: #009900;">&#40;</span><span style="color: #0000ff;">&quot;wordsplit&quot;</span>, 
        <span style="color: #000000; font-weight: bold;">new</span> Fields<span style="color: #009900;">&#40;</span><span style="color: #0000ff;">&quot;line&quot;</span><span style="color: #009900;">&#41;</span>, 
        <span style="color: #000000; font-weight: bold;">new</span> RegexSplitGenerator<span style="color: #009900;">&#40;</span><span style="color: #000000; font-weight: bold;">new</span> Fields<span style="color: #009900;">&#40;</span><span style="color: #0000ff;">&quot;word&quot;</span><span style="color: #009900;">&#41;</span>, <span style="color: #0000ff;">&quot;<span style="color: #000099; font-weight: bold;">\\</span>s+&quot;</span><span style="color: #009900;">&#41;</span>, 
        <span style="color: #000000; font-weight: bold;">new</span> Fields<span style="color: #009900;">&#40;</span><span style="color: #0000ff;">&quot;word&quot;</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
&nbsp;
    Flow parsedLogFlow <span style="color: #339933;">=</span> flowConnector.<span style="color: #006633;">connect</span><span style="color: #009900;">&#40;</span>sourceTap, intermediateTap1, wsPipe<span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
&nbsp;
    <span style="color: #666666; font-style: italic;">// Create a pipe and set our mr job for it </span>
    Pipe importPipe <span style="color: #339933;">=</span> <span style="color: #000000; font-weight: bold;">new</span> Pipe<span style="color: #009900;">&#40;</span><span style="color: #0000ff;">&quot;mr pipe&quot;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
    Flow mrFlow<span style="color: #339933;">;</span>
&nbsp;
    <span style="color: #000000; font-weight: bold;">try</span> <span style="color: #009900;">&#123;</span>
      JobConf streamConf <span style="color: #339933;">=</span> StreamJob.<span style="color: #006633;">createJob</span><span style="color: #009900;">&#40;</span> <span style="color: #000000; font-weight: bold;">new</span> <span style="color: #003399;">String</span><span style="color: #009900;">&#91;</span><span style="color: #009900;">&#93;</span><span style="color: #009900;">&#123;</span>
          <span style="color: #0000ff;">&quot;-input&quot;</span>, intermediateTap1.<span style="color: #006633;">getPath</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span>.<span style="color: #006633;">toString</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span>, 
          <span style="color: #0000ff;">&quot;-output&quot;</span>, intermediateTap2.<span style="color: #006633;">getPath</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span>.<span style="color: #006633;">toString</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span>,
&nbsp;
          <span style="color: #666666; font-style: italic;">// straight unix</span>
          <span style="color: #666666; font-style: italic;">// &quot;-mapper&quot;, &quot;/bin/cat&quot;,</span>
          <span style="color: #666666; font-style: italic;">// &quot;-reducer&quot;, &quot;/usr/bin/wc&quot;</span>
&nbsp;
          <span style="color: #666666; font-style: italic;">// ruby</span>
          <span style="color: #666666; font-style: italic;">// &quot;-mapper&quot;, &quot;src/main/ruby/word_count_mapper.rb&quot;,</span>
          <span style="color: #666666; font-style: italic;">// &quot;-reducer&quot;, &quot;src/main/ruby/word_count_reducer.rb&quot;,</span>
          <span style="color: #666666; font-style: italic;">// &quot;-file&quot;, &quot;src/main/ruby/word_count_mapper.rb&quot;,</span>
          <span style="color: #666666; font-style: italic;">// &quot;-file&quot;, &quot;src/main/ruby/word_count_reducer.rb&quot;</span>
&nbsp;
          <span style="color: #666666; font-style: italic;">// python</span>
          <span style="color: #0000ff;">&quot;-mapper&quot;</span>, <span style="color: #0000ff;">&quot;python synsets.py mapper&quot;</span>,
          <span style="color: #0000ff;">&quot;-reducer&quot;</span>, <span style="color: #0000ff;">&quot;org.apache.hadoop.mapred.lib.IdentityReducer&quot;</span>,
          <span style="color: #0000ff;">&quot;-file&quot;</span>, <span style="color: #0000ff;">&quot;src/main/python/synsets.py&quot;</span>,
          <span style="color: #0000ff;">&quot;-file&quot;</span>, <span style="color: #0000ff;">&quot;resources/nltkandyaml.mod&quot;</span>,
          <span style="color: #0000ff;">&quot;-file&quot;</span>, <span style="color: #0000ff;">&quot;resources/lib/wordnet-flat.zip&quot;</span>,
          <span style="color: #009900;">&#125;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
      mrFlow <span style="color: #339933;">=</span> <span style="color: #000000; font-weight: bold;">new</span> MapReduceFlow<span style="color: #009900;">&#40;</span><span style="color: #0000ff;">&quot;streaming flow&quot;</span>, streamConf, intermediateTap1,
        intermediateTap2, <span style="color: #000066; font-weight: bold;">false</span>, <span style="color: #000066; font-weight: bold;">true</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
    <span style="color: #009900;">&#125;</span> <span style="color: #000000; font-weight: bold;">catch</span><span style="color: #009900;">&#40;</span><span style="color: #003399;">IOException</span> ioe<span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
       ioe.<span style="color: #006633;">printStackTrace</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
       <span style="color: #003399;">System</span>.<span style="color: #006633;">exit</span><span style="color: #009900;">&#40;</span><span style="color: #cc66cc;">1</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
       <span style="color: #000000; font-weight: bold;">return</span> <span style="color: #cc66cc;">1</span><span style="color: #339933;">;</span>
    <span style="color: #009900;">&#125;</span>
&nbsp;
    <span style="color: #666666; font-style: italic;">// create our third &quot;regular&quot; cascading pipe. this is a bit contrived, but</span>
    <span style="color: #666666; font-style: italic;">// the idea is substitute all 'e's with 'x's. it's just here to show how to</span>
    <span style="color: #666666; font-style: italic;">// take the input of a streaming job back into cascading</span>
    Pipe subPipe <span style="color: #339933;">=</span> <span style="color: #000000; font-weight: bold;">new</span> Pipe<span style="color: #009900;">&#40;</span><span style="color: #0000ff;">&quot;subber&quot;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
    subPipe <span style="color: #339933;">=</span> <span style="color: #000000; font-weight: bold;">new</span> Each<span style="color: #009900;">&#40;</span>subPipe,
        <span style="color: #000000; font-weight: bold;">new</span> Fields<span style="color: #009900;">&#40;</span><span style="color: #0000ff;">&quot;line&quot;</span><span style="color: #009900;">&#41;</span>,
        <span style="color: #000000; font-weight: bold;">new</span> RegexReplace<span style="color: #009900;">&#40;</span><span style="color: #000000; font-weight: bold;">new</span> Fields<span style="color: #009900;">&#40;</span><span style="color: #0000ff;">&quot;linx&quot;</span><span style="color: #009900;">&#41;</span>, <span style="color: #0000ff;">&quot;e&quot;</span>, <span style="color: #0000ff;">&quot;x&quot;</span>, <span style="color: #000066; font-weight: bold;">true</span><span style="color: #009900;">&#41;</span>,
        <span style="color: #000000; font-weight: bold;">new</span> Fields<span style="color: #009900;">&#40;</span><span style="color: #0000ff;">&quot;linx&quot;</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
    Flow subFlow <span style="color: #339933;">=</span> flowConnector.<span style="color: #006633;">connect</span><span style="color: #009900;">&#40;</span>intermediateTap2, sinkTap, subPipe<span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
&nbsp;
    Cascade cascade <span style="color: #339933;">=</span> cascadeConnector.<span style="color: #006633;">connect</span><span style="color: #009900;">&#40;</span>parsedLogFlow, mrFlow, subFlow<span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
    cascade.<span style="color: #006633;">complete</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
&nbsp;
    <span style="color: #666666; font-style: italic;">// to get rid of the intermediate files you could do this:</span>
    <span style="color: #666666; font-style: italic;">// Path tmp = tap.getPath();</span>
    <span style="color: #666666; font-style: italic;">// FileSystem fs = tmp.getFileSystem(conf);</span>
    <span style="color: #666666; font-style: italic;">// fs.delete(tmp, true);</span>
&nbsp;
    <span style="color: #000000; font-weight: bold;">return</span> <span style="color: #cc66cc;">0</span><span style="color: #339933;">;</span>
  <span style="color: #009900;">&#125;</span>
&nbsp;
  <span style="color: #000000; font-weight: bold;">public</span> <span style="color: #000000; font-weight: bold;">static</span> <span style="color: #000066; font-weight: bold;">void</span> main<span style="color: #009900;">&#40;</span><span style="color: #003399;">String</span><span style="color: #009900;">&#91;</span><span style="color: #009900;">&#93;</span> args<span style="color: #009900;">&#41;</span> <span style="color: #000000; font-weight: bold;">throws</span> <span style="color: #003399;">Exception</span> 
  <span style="color: #009900;">&#123;</span>
    <span style="color: #000066; font-weight: bold;">int</span> res <span style="color: #339933;">=</span> ToolRunner.<span style="color: #006633;">run</span><span style="color: #009900;">&#40;</span><span style="color: #000000; font-weight: bold;">new</span> Configuration<span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span>, <span style="color: #000000; font-weight: bold;">new</span> Main<span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span>, args<span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
    <span style="color: #003399;">System</span>.<span style="color: #006633;">exit</span><span style="color: #009900;">&#40;</span>res<span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
  <span style="color: #009900;">&#125;</span>
&nbsp;
  <span style="color: #009900;">&#125;</span></pre></div></div>

<p>Share:</p>
<p>	<a rel="nofollow"  href="http://delicious.com/post?url=http%3A%2F%2Fwww.xcombinator.com%2F2009%2F11%2F18%2Fhow-to-use-cascading-with-hadoop-streaming%2F&amp;title=How%20to%20use%20Cascading%20with%20Hadoop%20Streaming&amp;notes=Last%20time%20we%20talked%20about%20how%20to%20use%20a%20raw%20MapReduce%20job%20in%20Cascading.%20Now%20we%20are%20going%20to%20up%20the%20ante%20by%20using%20Hadoop%20Streaming%20as%20a%20Flow%20in%20Cascading.%20In%20this%20example%2C%20we%20hook%20a%20python%20streaming%20job%20into%20a%20Cascade.%0D%0A%0D%0AIts%20pretty%20easy%20once%20you%20know%20" title="del.icio.us"><img src="http://www.xcombinator.com/wp-content/plugins/sociable/images/delicious.png" title="del.icio.us" alt="del.icio.us" class="sociable-hovers" /></a><br />
	<a rel="nofollow"  href="http://reddit.com/submit?url=http%3A%2F%2Fwww.xcombinator.com%2F2009%2F11%2F18%2Fhow-to-use-cascading-with-hadoop-streaming%2F&amp;title=How%20to%20use%20Cascading%20with%20Hadoop%20Streaming" title="Reddit"><img src="http://www.xcombinator.com/wp-content/plugins/sociable/images/reddit.png" title="Reddit" alt="Reddit" class="sociable-hovers" /></a><br />
	<a rel="nofollow"  href="http://technorati.com/faves?add=http%3A%2F%2Fwww.xcombinator.com%2F2009%2F11%2F18%2Fhow-to-use-cascading-with-hadoop-streaming%2F" title="Technorati"><img src="http://www.xcombinator.com/wp-content/plugins/sociable/images/technorati.png" title="Technorati" alt="Technorati" class="sociable-hovers" /></a><br />
	<a rel="nofollow"  href="http://twitter.com/home?status=How%20to%20use%20Cascading%20with%20Hadoop%20Streaming%20-%20http%3A%2F%2Fwww.xcombinator.com%2F2009%2F11%2F18%2Fhow-to-use-cascading-with-hadoop-streaming%2F" title="Twitter"><img src="http://www.xcombinator.com/wp-content/plugins/sociable/images/twitter.png" title="Twitter" alt="Twitter" class="sociable-hovers" /></a><br />
	<a rel="nofollow"  href="http://www.facebook.com/share.php?u=http%3A%2F%2Fwww.xcombinator.com%2F2009%2F11%2F18%2Fhow-to-use-cascading-with-hadoop-streaming%2F&amp;t=How%20to%20use%20Cascading%20with%20Hadoop%20Streaming" title="Facebook"><img src="http://www.xcombinator.com/wp-content/plugins/sociable/images/facebook.png" title="Facebook" alt="Facebook" class="sociable-hovers" /></a><br />
	<a rel="nofollow"  href="http://www.google.com/bookmarks/mark?op=edit&amp;bkmk=http%3A%2F%2Fwww.xcombinator.com%2F2009%2F11%2F18%2Fhow-to-use-cascading-with-hadoop-streaming%2F&amp;title=How%20to%20use%20Cascading%20with%20Hadoop%20Streaming&amp;annotation=Last%20time%20we%20talked%20about%20how%20to%20use%20a%20raw%20MapReduce%20job%20in%20Cascading.%20Now%20we%20are%20going%20to%20up%20the%20ante%20by%20using%20Hadoop%20Streaming%20as%20a%20Flow%20in%20Cascading.%20In%20this%20example%2C%20we%20hook%20a%20python%20streaming%20job%20into%20a%20Cascade.%0D%0A%0D%0AIts%20pretty%20easy%20once%20you%20know%20" title="Google Bookmarks"><img src="http://www.xcombinator.com/wp-content/plugins/sociable/images/googlebookmark.png" title="Google Bookmarks" alt="Google Bookmarks" class="sociable-hovers" /></a><br />
	<a rel="nofollow"  href="http://news.ycombinator.com/submitlink?u=http%3A%2F%2Fwww.xcombinator.com%2F2009%2F11%2F18%2Fhow-to-use-cascading-with-hadoop-streaming%2F&amp;t=How%20to%20use%20Cascading%20with%20Hadoop%20Streaming" title="HackerNews"><img src="http://www.xcombinator.com/wp-content/plugins/sociable/images/hackernews.png" title="HackerNews" alt="HackerNews" class="sociable-hovers" /></a><br />
	<a rel="nofollow"  href="http://www.printfriendly.com/print?url=http%3A%2F%2Fwww.xcombinator.com%2F2009%2F11%2F18%2Fhow-to-use-cascading-with-hadoop-streaming%2F&amp;partner=sociable" title="PDF"><img src="http://www.xcombinator.com/wp-content/plugins/sociable/images/pdf.png" title="PDF" alt="PDF" class="sociable-hovers" /></a><br />
	<a rel="nofollow"  href="http://www.xcombinator.com/feed/" title="RSS"><img src="http://www.xcombinator.com/wp-content/plugins/sociable/images/rss.png" title="RSS" alt="RSS" class="sociable-hovers" /></a></p>
<p><br/><br/></p>
]]></content:encoded>
			<wfw:commentRss>http://www.xcombinator.com/2009/11/18/how-to-use-cascading-with-hadoop-streaming/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		<feedburner:origLink>http://www.xcombinator.com/2009/11/18/how-to-use-cascading-with-hadoop-streaming/</feedburner:origLink></item>
		<item>
		<title>Interval – a ruby library for musical interval arithmetic</title>
		<link>http://feedproxy.google.com/~r/xcombinator/~3/a2BRQO16lac/</link>
		<comments>http://www.xcombinator.com/2009/11/17/interval-a-ruby-library-for-musical-interval-arithmetic/#comments</comments>
		<pubDate>Tue, 17 Nov 2009 16:43:45 +0000</pubDate>
		<dc:creator>Nate Murray</dc:creator>
				<category><![CDATA[music]]></category>
		<category><![CDATA[ruby]]></category>

		<guid isPermaLink="false">http://www.xcombinator.com/?p=144</guid>
		<description><![CDATA[Interval
interval is a tiny library that provides simple musical note pitch and interval arithmetic. It is intended to do one thing: given a pitch add (or subtract) an interval and give the resulting pitch.
Observe:

p = Interval::Pitch.from_string&#40;&#34;c&#34;&#41;
i = Interval::Interval.from_string&#40;&#34;M3&#34;&#41;
p2 = p + i
p2.to_short_name # =&#62; &#34;e&#34;
&#160;
i.to_s # =&#62; &#34;Major Third&#34;
&#160;
i2 = Interval::Interval.from_string&#40;&#34;p5&#34;&#41;
i2.to_s # =&#62; &#34;Perfect Fifth&#34;
&#160;
&#40;p2 [...]]]></description>
			<content:encoded><![CDATA[<h1>Interval</h1>
<p><code>interval</code> is a tiny library that provides simple musical note pitch and interval arithmetic. It is intended to do one thing: given a pitch add (or subtract) an interval and give the resulting pitch.</p>
<p>Observe:</p>

<div class="wp_syntax"><div class="code"><pre class="ruby" style="font-family:monospace;"><span style="color:#CC0066; font-weight:bold;">p</span> = <span style="color:#6666ff; font-weight:bold;">Interval::Pitch</span>.<span style="color:#9900CC;">from_string</span><span style="color:#006600; font-weight:bold;">&#40;</span><span style="color:#996600;">&quot;c&quot;</span><span style="color:#006600; font-weight:bold;">&#41;</span>
i = <span style="color:#6666ff; font-weight:bold;">Interval::Interval</span>.<span style="color:#9900CC;">from_string</span><span style="color:#006600; font-weight:bold;">&#40;</span><span style="color:#996600;">&quot;M3&quot;</span><span style="color:#006600; font-weight:bold;">&#41;</span>
p2 = <span style="color:#CC0066; font-weight:bold;">p</span> <span style="color:#006600; font-weight:bold;">+</span> i
p2.<span style="color:#9900CC;">to_short_name</span> <span style="color:#008000; font-style:italic;"># =&gt; &quot;e&quot;</span>
&nbsp;
i.<span style="color:#9900CC;">to_s</span> <span style="color:#008000; font-style:italic;"># =&gt; &quot;Major Third&quot;</span>
&nbsp;
i2 = <span style="color:#6666ff; font-weight:bold;">Interval::Interval</span>.<span style="color:#9900CC;">from_string</span><span style="color:#006600; font-weight:bold;">&#40;</span><span style="color:#996600;">&quot;p5&quot;</span><span style="color:#006600; font-weight:bold;">&#41;</span>
i2.<span style="color:#9900CC;">to_s</span> <span style="color:#008000; font-style:italic;"># =&gt; &quot;Perfect Fifth&quot;</span>
&nbsp;
<span style="color:#006600; font-weight:bold;">&#40;</span>p2 <span style="color:#006600; font-weight:bold;">-</span> i2<span style="color:#006600; font-weight:bold;">&#41;</span>.<span style="color:#9900CC;">to_s</span> <span style="color:#008000; font-style:italic;"># =&gt; &quot;a&quot;</span></pre></div></div>

<h1>Interval Quiz</h1>
<p><code>interval</code> was written primarily for learning intervals. <code>interval-quiz</code> is a gem that depends on <code>interval</code> that provides a command-line quiz. Here&#8217;s the output of an <code>interval-quiz</code> session:</p>
<pre><code>$ interval-quiz
Here are the intervals:
unison  p1        a1
second  m2 M2  d2 a2
third   m3 M3  d3 a3
fourth  p4     d4 a4
fifth   d5 p5  d5 a5
sixth   m6 M6  d6 a6
seventh m7 M7  d7 a7
octave  p8     d8
enter the intervals you want (or a blank line to quit):
M3
p5

["M3", "p5"]
1. above
2. below
3. both
do you want to be quizzed on intervals above, below, or both?  3
what is a major third below f# ? d
correct!
what is a major third above g# 1/1 (100%)? b#
correct!
what is a major third below b 2/2 (100%)? g
correct!
what is a perfect fifth below eb 3/3 (100%)? a
wrong. the answer is ab
what is a perfect fifth below c# 3/4 (75%)? d
wrong. the answer is f#
</code></pre>
<h1>Installing</h1>
<pre><code>gem install interval interval-quiz
</code></pre>
<h1>Source</h1>
<p><a href="http://github.com/jashmenn/interval">http://github.com/jashmenn/interval</a><br />
<a href="http://github.com/jashmenn/interval-quiz">http://github.com/jashmenn/interval-quiz</a></p>
<p>Share:</p>
<p>	<a rel="nofollow"  href="http://delicious.com/post?url=http%3A%2F%2Fwww.xcombinator.com%2F2009%2F11%2F17%2Finterval-a-ruby-library-for-musical-interval-arithmetic%2F&amp;title=Interval%20-%20a%20ruby%20library%20for%20musical%20interval%20arithmetic&amp;notes=Interval%0D%0A%0D%0Ainterval%20is%20a%20tiny%20library%20that%20provides%20simple%20musical%20note%20pitch%20and%20interval%20arithmetic.%20It%20is%20intended%20to%20do%20one%20thing%3A%20given%20a%20pitch%20add%20%28or%20subtract%29%20an%20interval%20and%20give%20the%20resulting%20pitch.%0D%0A%0D%0AObserve%3A%0D%0A%0D%0Ap%20%3D%20Interval%3A%3APitch.from_" title="del.icio.us"><img src="http://www.xcombinator.com/wp-content/plugins/sociable/images/delicious.png" title="del.icio.us" alt="del.icio.us" class="sociable-hovers" /></a><br />
	<a rel="nofollow"  href="http://reddit.com/submit?url=http%3A%2F%2Fwww.xcombinator.com%2F2009%2F11%2F17%2Finterval-a-ruby-library-for-musical-interval-arithmetic%2F&amp;title=Interval%20-%20a%20ruby%20library%20for%20musical%20interval%20arithmetic" title="Reddit"><img src="http://www.xcombinator.com/wp-content/plugins/sociable/images/reddit.png" title="Reddit" alt="Reddit" class="sociable-hovers" /></a><br />
	<a rel="nofollow"  href="http://technorati.com/faves?add=http%3A%2F%2Fwww.xcombinator.com%2F2009%2F11%2F17%2Finterval-a-ruby-library-for-musical-interval-arithmetic%2F" title="Technorati"><img src="http://www.xcombinator.com/wp-content/plugins/sociable/images/technorati.png" title="Technorati" alt="Technorati" class="sociable-hovers" /></a><br />
	<a rel="nofollow"  href="http://twitter.com/home?status=Interval%20-%20a%20ruby%20library%20for%20musical%20interval%20arithmetic%20-%20http%3A%2F%2Fwww.xcombinator.com%2F2009%2F11%2F17%2Finterval-a-ruby-library-for-musical-interval-arithmetic%2F" title="Twitter"><img src="http://www.xcombinator.com/wp-content/plugins/sociable/images/twitter.png" title="Twitter" alt="Twitter" class="sociable-hovers" /></a><br />
	<a rel="nofollow"  href="http://www.facebook.com/share.php?u=http%3A%2F%2Fwww.xcombinator.com%2F2009%2F11%2F17%2Finterval-a-ruby-library-for-musical-interval-arithmetic%2F&amp;t=Interval%20-%20a%20ruby%20library%20for%20musical%20interval%20arithmetic" title="Facebook"><img src="http://www.xcombinator.com/wp-content/plugins/sociable/images/facebook.png" title="Facebook" alt="Facebook" class="sociable-hovers" /></a><br />
	<a rel="nofollow"  href="http://www.google.com/bookmarks/mark?op=edit&amp;bkmk=http%3A%2F%2Fwww.xcombinator.com%2F2009%2F11%2F17%2Finterval-a-ruby-library-for-musical-interval-arithmetic%2F&amp;title=Interval%20-%20a%20ruby%20library%20for%20musical%20interval%20arithmetic&amp;annotation=Interval%0D%0A%0D%0Ainterval%20is%20a%20tiny%20library%20that%20provides%20simple%20musical%20note%20pitch%20and%20interval%20arithmetic.%20It%20is%20intended%20to%20do%20one%20thing%3A%20given%20a%20pitch%20add%20%28or%20subtract%29%20an%20interval%20and%20give%20the%20resulting%20pitch.%0D%0A%0D%0AObserve%3A%0D%0A%0D%0Ap%20%3D%20Interval%3A%3APitch.from_" title="Google Bookmarks"><img src="http://www.xcombinator.com/wp-content/plugins/sociable/images/googlebookmark.png" title="Google Bookmarks" alt="Google Bookmarks" class="sociable-hovers" /></a><br />
	<a rel="nofollow"  href="http://news.ycombinator.com/submitlink?u=http%3A%2F%2Fwww.xcombinator.com%2F2009%2F11%2F17%2Finterval-a-ruby-library-for-musical-interval-arithmetic%2F&amp;t=Interval%20-%20a%20ruby%20library%20for%20musical%20interval%20arithmetic" title="HackerNews"><img src="http://www.xcombinator.com/wp-content/plugins/sociable/images/hackernews.png" title="HackerNews" alt="HackerNews" class="sociable-hovers" /></a><br />
	<a rel="nofollow"  href="http://www.printfriendly.com/print?url=http%3A%2F%2Fwww.xcombinator.com%2F2009%2F11%2F17%2Finterval-a-ruby-library-for-musical-interval-arithmetic%2F&amp;partner=sociable" title="PDF"><img src="http://www.xcombinator.com/wp-content/plugins/sociable/images/pdf.png" title="PDF" alt="PDF" class="sociable-hovers" /></a><br />
	<a rel="nofollow"  href="http://www.xcombinator.com/feed/" title="RSS"><img src="http://www.xcombinator.com/wp-content/plugins/sociable/images/rss.png" title="RSS" alt="RSS" class="sociable-hovers" /></a></p>
<p><br/><br/></p>
]]></content:encoded>
			<wfw:commentRss>http://www.xcombinator.com/2009/11/17/interval-a-ruby-library-for-musical-interval-arithmetic/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		<feedburner:origLink>http://www.xcombinator.com/2009/11/17/interval-a-ruby-library-for-musical-interval-arithmetic/</feedburner:origLink></item>
		<item>
		<title>Slides for “Introduction to Cascading” Presentation</title>
		<link>http://feedproxy.google.com/~r/xcombinator/~3/p2xgRuMDDY4/</link>
		<comments>http://www.xcombinator.com/2009/11/13/slides-for-introduction-to-cascading-presentation/#comments</comments>
		<pubDate>Sat, 14 Nov 2009 00:57:39 +0000</pubDate>
		<dc:creator>Nate Murray</dc:creator>
				<category><![CDATA[programming]]></category>

		<guid isPermaLink="false">http://www.xcombinator.com/?p=140</guid>
		<description><![CDATA[This week I gave an introductory presentation to Cascading. These are the slides from that presentation.
Intro To Cascading
View more documents from Nate Murray.

Share:
	
	
	
	
	
	
	
	
	

]]></description>
			<content:encoded><![CDATA[<p>This week I gave an introductory presentation to <a href="http://www.cascading.org">Cascading</a>. These are the slides from that presentation.</p>
<div style="width:425px;text-align:left" id="__ss_2487571"><a style="font:14px Helvetica,Arial,Sans-serif;display:block;margin:12px 0 3px 0;text-decoration:underline;" href="http://www.slideshare.net/jashmenn/intro-to-cascading" title="Intro To Cascading">Intro To Cascading</a><object style="margin:0px" width="425" height="355"><param name="movie" value="http://static.slidesharecdn.com/swf/ssplayer2.swf?doc=intro-to-cascading-091112163237-phpapp01&#038;rel=0&#038;stripped_title=intro-to-cascading" /><param name="allowFullScreen" value="true"/><param name="allowScriptAccess" value="always"/><embed src="http://static.slidesharecdn.com/swf/ssplayer2.swf?doc=intro-to-cascading-091112163237-phpapp01&#038;rel=0&#038;stripped_title=intro-to-cascading" type="application/x-shockwave-flash" allowscriptaccess="always" allowfullscreen="true" width="425" height="355"></embed></object></p>
<div style="font-size:11px;font-family:tahoma,arial;height:26px;padding-top:2px;">View more <a style="text-decoration:underline;" href="http://www.slideshare.net/">documents</a> from <a style="text-decoration:underline;" href="http://www.slideshare.net/jashmenn">Nate Murray</a>.</div>
</div>
<p>Share:</p>
<p>	<a rel="nofollow"  href="http://delicious.com/post?url=http%3A%2F%2Fwww.xcombinator.com%2F2009%2F11%2F13%2Fslides-for-introduction-to-cascading-presentation%2F&amp;title=Slides%20for%20%22Introduction%20to%20Cascading%22%20Presentation&amp;notes=This%20week%20I%20gave%20an%20introductory%20presentation%20to%20Cascading.%20These%20are%20the%20slides%20from%20that%20presentation.%0D%0A%0D%0AIntro%20To%20CascadingView%20more%20documents%20from%20Nate%20Murray." title="del.icio.us"><img src="http://www.xcombinator.com/wp-content/plugins/sociable/images/delicious.png" title="del.icio.us" alt="del.icio.us" class="sociable-hovers" /></a><br />
	<a rel="nofollow"  href="http://reddit.com/submit?url=http%3A%2F%2Fwww.xcombinator.com%2F2009%2F11%2F13%2Fslides-for-introduction-to-cascading-presentation%2F&amp;title=Slides%20for%20%22Introduction%20to%20Cascading%22%20Presentation" title="Reddit"><img src="http://www.xcombinator.com/wp-content/plugins/sociable/images/reddit.png" title="Reddit" alt="Reddit" class="sociable-hovers" /></a><br />
	<a rel="nofollow"  href="http://technorati.com/faves?add=http%3A%2F%2Fwww.xcombinator.com%2F2009%2F11%2F13%2Fslides-for-introduction-to-cascading-presentation%2F" title="Technorati"><img src="http://www.xcombinator.com/wp-content/plugins/sociable/images/technorati.png" title="Technorati" alt="Technorati" class="sociable-hovers" /></a><br />
	<a rel="nofollow"  href="http://twitter.com/home?status=Slides%20for%20%22Introduction%20to%20Cascading%22%20Presentation%20-%20http%3A%2F%2Fwww.xcombinator.com%2F2009%2F11%2F13%2Fslides-for-introduction-to-cascading-presentation%2F" title="Twitter"><img src="http://www.xcombinator.com/wp-content/plugins/sociable/images/twitter.png" title="Twitter" alt="Twitter" class="sociable-hovers" /></a><br />
	<a rel="nofollow"  href="http://www.facebook.com/share.php?u=http%3A%2F%2Fwww.xcombinator.com%2F2009%2F11%2F13%2Fslides-for-introduction-to-cascading-presentation%2F&amp;t=Slides%20for%20%22Introduction%20to%20Cascading%22%20Presentation" title="Facebook"><img src="http://www.xcombinator.com/wp-content/plugins/sociable/images/facebook.png" title="Facebook" alt="Facebook" class="sociable-hovers" /></a><br />
	<a rel="nofollow"  href="http://www.google.com/bookmarks/mark?op=edit&amp;bkmk=http%3A%2F%2Fwww.xcombinator.com%2F2009%2F11%2F13%2Fslides-for-introduction-to-cascading-presentation%2F&amp;title=Slides%20for%20%22Introduction%20to%20Cascading%22%20Presentation&amp;annotation=This%20week%20I%20gave%20an%20introductory%20presentation%20to%20Cascading.%20These%20are%20the%20slides%20from%20that%20presentation.%0D%0A%0D%0AIntro%20To%20CascadingView%20more%20documents%20from%20Nate%20Murray." title="Google Bookmarks"><img src="http://www.xcombinator.com/wp-content/plugins/sociable/images/googlebookmark.png" title="Google Bookmarks" alt="Google Bookmarks" class="sociable-hovers" /></a><br />
	<a rel="nofollow"  href="http://news.ycombinator.com/submitlink?u=http%3A%2F%2Fwww.xcombinator.com%2F2009%2F11%2F13%2Fslides-for-introduction-to-cascading-presentation%2F&amp;t=Slides%20for%20%22Introduction%20to%20Cascading%22%20Presentation" title="HackerNews"><img src="http://www.xcombinator.com/wp-content/plugins/sociable/images/hackernews.png" title="HackerNews" alt="HackerNews" class="sociable-hovers" /></a><br />
	<a rel="nofollow"  href="http://www.printfriendly.com/print?url=http%3A%2F%2Fwww.xcombinator.com%2F2009%2F11%2F13%2Fslides-for-introduction-to-cascading-presentation%2F&amp;partner=sociable" title="PDF"><img src="http://www.xcombinator.com/wp-content/plugins/sociable/images/pdf.png" title="PDF" alt="PDF" class="sociable-hovers" /></a><br />
	<a rel="nofollow"  href="http://www.xcombinator.com/feed/" title="RSS"><img src="http://www.xcombinator.com/wp-content/plugins/sociable/images/rss.png" title="RSS" alt="RSS" class="sociable-hovers" /></a></p>
<p><br/><br/></p>
]]></content:encoded>
			<wfw:commentRss>http://www.xcombinator.com/2009/11/13/slides-for-introduction-to-cascading-presentation/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		<feedburner:origLink>http://www.xcombinator.com/2009/11/13/slides-for-introduction-to-cascading-presentation/</feedburner:origLink></item>
		<item>
		<title>How to use a raw MapReduce job in Cascading</title>
		<link>http://feedproxy.google.com/~r/xcombinator/~3/HC23im3CdN4/</link>
		<comments>http://www.xcombinator.com/2009/11/11/how-to-use-a-raw-mapreduce-job-in-cascading/#comments</comments>
		<pubDate>Wed, 11 Nov 2009 22:31:18 +0000</pubDate>
		<dc:creator>Nate Murray</dc:creator>
				<category><![CDATA[cascading]]></category>
		<category><![CDATA[hadoop]]></category>
		<category><![CDATA[java]]></category>

		<guid isPermaLink="false">http://xcombinator.local/?p=135</guid>
		<description><![CDATA[Cascading is a great abstraction over MapReduce.
However, sometimes you may have code for an existing MapReduce job or want to drop directly to Hadoop for efficiency. Even if you&#8217;re using raw MapReduce jobs, Cascading can still be useful in planning the overall data pipeline. 
The code below is an example of how to use a [...]]]></description>
			<content:encoded><![CDATA[<p><a href="http://www.cascading.org/">Cascading</a> is a great abstraction over MapReduce.</p>
<p>However, sometimes you may have code for an existing MapReduce job or want to drop directly to Hadoop for efficiency. Even if you&#8217;re using raw MapReduce jobs, Cascading can still be useful in planning the overall data pipeline. </p>
<p>The code below is an example of how to use a raw MapReduce job in a Cascade. The main thing to take away is that we are creating intermediate sinks and sources and relying on Cascading to schedule the flows in the correct order.</p>
<blockquote class="normal">
<p>NOTE: this code below depends on commit <a href="http://github.com/jashmenn/cascading/commit/f0dd84cd89da70c326e7285034e982c33d2d7388">f0dd84cd</a> which is a patch to MapReduceFlow.java that allows you to specifically set the Taps for a MapReduceFlow. I&#8217;ve contacted Chris about integrating this into the trunk. </p>
<p>Also note this patch applies to the branch <code>wip-1.1</code> and later.</p>
</blockquote>

<div class="wp_syntax"><div class="code"><pre class="java" style="font-family:monospace;"><span style="color: #000000; font-weight: bold;">package</span> <span style="color: #006699;">com.xcombinator.hadoopjobs.mapreducetest</span><span style="color: #339933;">;</span>
&nbsp;
<span style="color: #000000; font-weight: bold;">import</span> <span style="color: #006699;">cascading.cascade.*</span><span style="color: #339933;">;</span>
<span style="color: #000000; font-weight: bold;">import</span> <span style="color: #006699;">cascading.flow.Flow</span><span style="color: #339933;">;</span>
<span style="color: #000000; font-weight: bold;">import</span> <span style="color: #006699;">cascading.flow.FlowConnector</span><span style="color: #339933;">;</span>
<span style="color: #000000; font-weight: bold;">import</span> <span style="color: #006699;">cascading.flow.MapReduceFlow</span><span style="color: #339933;">;</span>
<span style="color: #000000; font-weight: bold;">import</span> <span style="color: #006699;">cascading.operation.aggregator.Count</span><span style="color: #339933;">;</span>
<span style="color: #000000; font-weight: bold;">import</span> <span style="color: #006699;">cascading.operation.regex.*</span><span style="color: #339933;">;</span>
<span style="color: #000000; font-weight: bold;">import</span> <span style="color: #006699;">cascading.pipe.*</span><span style="color: #339933;">;</span>
<span style="color: #000000; font-weight: bold;">import</span> <span style="color: #006699;">cascading.scheme.*</span><span style="color: #339933;">;</span>
<span style="color: #000000; font-weight: bold;">import</span> <span style="color: #006699;">cascading.tap.*</span><span style="color: #339933;">;</span>
<span style="color: #000000; font-weight: bold;">import</span> <span style="color: #006699;">cascading.tuple.Fields</span><span style="color: #339933;">;</span>
<span style="color: #000000; font-weight: bold;">import</span> <span style="color: #006699;">cascading.operation.Identity</span><span style="color: #339933;">;</span>
<span style="color: #000000; font-weight: bold;">import</span> <span style="color: #006699;">java.util.Properties</span><span style="color: #339933;">;</span>
<span style="color: #000000; font-weight: bold;">import</span> <span style="color: #006699;">org.apache.hadoop.conf.Configuration</span><span style="color: #339933;">;</span>
<span style="color: #000000; font-weight: bold;">import</span> <span style="color: #006699;">org.apache.hadoop.conf.Configured</span><span style="color: #339933;">;</span>
<span style="color: #000000; font-weight: bold;">import</span> <span style="color: #006699;">org.apache.hadoop.io.LongWritable</span><span style="color: #339933;">;</span>
<span style="color: #000000; font-weight: bold;">import</span> <span style="color: #006699;">org.apache.hadoop.io.Text</span><span style="color: #339933;">;</span>
<span style="color: #000000; font-weight: bold;">import</span> <span style="color: #006699;">org.apache.hadoop.mapred.FileInputFormat</span><span style="color: #339933;">;</span>
<span style="color: #000000; font-weight: bold;">import</span> <span style="color: #006699;">org.apache.hadoop.mapred.FileOutputFormat</span><span style="color: #339933;">;</span>
<span style="color: #000000; font-weight: bold;">import</span> <span style="color: #006699;">org.apache.hadoop.mapred.JobConf</span><span style="color: #339933;">;</span>
<span style="color: #000000; font-weight: bold;">import</span> <span style="color: #006699;">org.apache.hadoop.mapred.TextInputFormat</span><span style="color: #339933;">;</span>
<span style="color: #000000; font-weight: bold;">import</span> <span style="color: #006699;">org.apache.hadoop.mapred.TextOutputFormat</span><span style="color: #339933;">;</span>
<span style="color: #000000; font-weight: bold;">import</span> <span style="color: #006699;">org.apache.hadoop.mapred.lib.IdentityMapper</span><span style="color: #339933;">;</span>
<span style="color: #000000; font-weight: bold;">import</span> <span style="color: #006699;">org.apache.hadoop.mapred.lib.IdentityReducer</span><span style="color: #339933;">;</span>
<span style="color: #000000; font-weight: bold;">import</span> <span style="color: #006699;">org.apache.hadoop.util.Tool</span><span style="color: #339933;">;</span>
<span style="color: #000000; font-weight: bold;">import</span> <span style="color: #006699;">org.apache.hadoop.util.ToolRunner</span><span style="color: #339933;">;</span>
<span style="color: #000000; font-weight: bold;">import</span> <span style="color: #006699;">org.apache.log4j.Logger</span><span style="color: #339933;">;</span>
<span style="color: #000000; font-weight: bold;">import</span> <span style="color: #006699;">cascading.operation.Debug</span><span style="color: #339933;">;</span>
&nbsp;
<span style="color: #000000; font-weight: bold;">import</span> <span style="color: #006699;">org.apache.hadoop.mapred.KeyValueTextInputFormat</span><span style="color: #339933;">;</span>
&nbsp;
<span style="color: #008000; font-style: italic; font-weight: bold;">/**
 * An example file to use a raw MapReduce job in cascading
 */</span>
<span style="color: #000000; font-weight: bold;">public</span> <span style="color: #000000; font-weight: bold;">class</span> Main <span style="color: #000000; font-weight: bold;">extends</span> Configured <span style="color: #000000; font-weight: bold;">implements</span> Tool
  <span style="color: #009900;">&#123;</span>
  <span style="color: #000000; font-weight: bold;">private</span> <span style="color: #000000; font-weight: bold;">static</span> <span style="color: #000000; font-weight: bold;">final</span> Logger LOG <span style="color: #339933;">=</span> Logger.<span style="color: #006633;">getLogger</span><span style="color: #009900;">&#40;</span> Main.<span style="color: #000000; font-weight: bold;">class</span> <span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
&nbsp;
  <span style="color: #000000; font-weight: bold;">public</span> <span style="color: #000066; font-weight: bold;">int</span> run<span style="color: #009900;">&#40;</span><span style="color: #003399;">String</span><span style="color: #009900;">&#91;</span><span style="color: #009900;">&#93;</span> args<span style="color: #009900;">&#41;</span>
  <span style="color: #009900;">&#123;</span>
    JobConf conf <span style="color: #339933;">=</span> <span style="color: #000000; font-weight: bold;">new</span> JobConf<span style="color: #009900;">&#40;</span>getConf<span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span>, <span style="color: #000000; font-weight: bold;">this</span>.<span style="color: #006633;">getClass</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
    <span style="color: #003399;">Properties</span> properties <span style="color: #339933;">=</span> <span style="color: #000000; font-weight: bold;">new</span> <span style="color: #003399;">Properties</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
    FlowConnector.<span style="color: #006633;">setApplicationJarClass</span><span style="color: #009900;">&#40;</span>properties, <span style="color: #000000; font-weight: bold;">this</span>.<span style="color: #006633;">getClass</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
&nbsp;
    CascadeConnector cascadeConnector <span style="color: #339933;">=</span> <span style="color: #000000; font-weight: bold;">new</span> CascadeConnector<span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
    FlowConnector flowConnector <span style="color: #339933;">=</span> <span style="color: #000000; font-weight: bold;">new</span> FlowConnector<span style="color: #009900;">&#40;</span>properties<span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
&nbsp;
    <span style="color: #003399;">String</span> inputPath  <span style="color: #339933;">=</span> args<span style="color: #009900;">&#91;</span><span style="color: #cc66cc;">0</span><span style="color: #009900;">&#93;</span><span style="color: #339933;">;</span>
    <span style="color: #003399;">String</span> outputPath <span style="color: #339933;">=</span> args<span style="color: #009900;">&#91;</span><span style="color: #cc66cc;">1</span><span style="color: #009900;">&#93;</span><span style="color: #339933;">;</span>
    <span style="color: #003399;">String</span> intermediatePath1 <span style="color: #339933;">=</span> args<span style="color: #009900;">&#91;</span><span style="color: #cc66cc;">1</span><span style="color: #009900;">&#93;</span> <span style="color: #339933;">+</span> <span style="color: #0000ff;">&quot;-mr-input&quot;</span><span style="color: #339933;">;</span>
    <span style="color: #003399;">String</span> intermediatePath2 <span style="color: #339933;">=</span> args<span style="color: #009900;">&#91;</span><span style="color: #cc66cc;">1</span><span style="color: #009900;">&#93;</span> <span style="color: #339933;">+</span> <span style="color: #0000ff;">&quot;-mr-output&quot;</span><span style="color: #339933;">;</span>
&nbsp;
    Scheme textLineScheme <span style="color: #339933;">=</span> <span style="color: #000000; font-weight: bold;">new</span> TextLine<span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
&nbsp;
    Tap sourceTap <span style="color: #339933;">=</span> <span style="color: #000000; font-weight: bold;">new</span> Hfs<span style="color: #009900;">&#40;</span>textLineScheme, inputPath<span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
    Tap intermediateTap1 <span style="color: #339933;">=</span> <span style="color: #000000; font-weight: bold;">new</span> Hfs<span style="color: #009900;">&#40;</span><span style="color: #000000; font-weight: bold;">new</span> TextLine<span style="color: #009900;">&#40;</span><span style="color: #000000; font-weight: bold;">new</span> Fields<span style="color: #009900;">&#40;</span><span style="color: #0000ff;">&quot;line&quot;</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#41;</span>, intermediatePath1<span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
    Tap intermediateTap2 <span style="color: #339933;">=</span> <span style="color: #000000; font-weight: bold;">new</span> Hfs<span style="color: #009900;">&#40;</span>textLineScheme, intermediatePath2<span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
    Tap sinkTap   <span style="color: #339933;">=</span> <span style="color: #000000; font-weight: bold;">new</span> Hfs<span style="color: #009900;">&#40;</span>textLineScheme, outputPath<span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
&nbsp;
    <span style="color: #666666; font-style: italic;">// create our first flow, sink to the intermediateTap</span>
    Pipe wsPipe <span style="color: #339933;">=</span> <span style="color: #000000; font-weight: bold;">new</span> Each<span style="color: #009900;">&#40;</span><span style="color: #0000ff;">&quot;wordsplit&quot;</span>, 
        <span style="color: #000000; font-weight: bold;">new</span> Fields<span style="color: #009900;">&#40;</span><span style="color: #0000ff;">&quot;line&quot;</span><span style="color: #009900;">&#41;</span>, 
        <span style="color: #000000; font-weight: bold;">new</span> RegexSplitGenerator<span style="color: #009900;">&#40;</span><span style="color: #000000; font-weight: bold;">new</span> Fields<span style="color: #009900;">&#40;</span><span style="color: #0000ff;">&quot;word&quot;</span><span style="color: #009900;">&#41;</span>, <span style="color: #0000ff;">&quot;<span style="color: #000099; font-weight: bold;">\\</span>s+&quot;</span><span style="color: #009900;">&#41;</span>, 
        <span style="color: #000000; font-weight: bold;">new</span> Fields<span style="color: #009900;">&#40;</span><span style="color: #0000ff;">&quot;word&quot;</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
&nbsp;
    Flow parsedLogFlow <span style="color: #339933;">=</span> flowConnector.<span style="color: #006633;">connect</span><span style="color: #009900;">&#40;</span>sourceTap, intermediateTap1, wsPipe<span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
&nbsp;
    <span style="color: #666666; font-style: italic;">// Create a pipe and set our mr job for it </span>
    Pipe importPipe <span style="color: #339933;">=</span> <span style="color: #000000; font-weight: bold;">new</span> Pipe<span style="color: #009900;">&#40;</span><span style="color: #0000ff;">&quot;mr pipe&quot;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
&nbsp;
    JobConf mrconf <span style="color: #339933;">=</span> <span style="color: #000000; font-weight: bold;">new</span> JobConf<span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
    mrconf.<span style="color: #006633;">setJobName</span><span style="color: #009900;">&#40;</span><span style="color: #0000ff;">&quot;custom mr&quot;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
&nbsp;
    mrconf.<span style="color: #006633;">setOutputKeyClass</span><span style="color: #009900;">&#40;</span>LongWritable.<span style="color: #000000; font-weight: bold;">class</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
    mrconf.<span style="color: #006633;">setOutputValueClass</span><span style="color: #009900;">&#40;</span>Text.<span style="color: #000000; font-weight: bold;">class</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
&nbsp;
    <span style="color: #666666; font-style: italic;">// the IdentityMapper, in this case, will actually output the key, which is</span>
    <span style="color: #666666; font-style: italic;">// a long of offset in bytes. Not what we'd usually want, but we'll leave</span>
    <span style="color: #666666; font-style: italic;">// it in for now.</span>
    mrconf.<span style="color: #006633;">setMapperClass</span><span style="color: #009900;">&#40;</span>IdentityMapper.<span style="color: #000000; font-weight: bold;">class</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
    mrconf.<span style="color: #006633;">setReducerClass</span><span style="color: #009900;">&#40;</span>IdentityReducer.<span style="color: #000000; font-weight: bold;">class</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
&nbsp;
    <span style="color: #666666; font-style: italic;">// note that your input is straight text-lines. This means in a real mr job</span>
    <span style="color: #666666; font-style: italic;">// you'd most likely need to split the line by some convention</span>
    TextInputFormat format <span style="color: #339933;">=</span> <span style="color: #000000; font-weight: bold;">new</span> TextInputFormat<span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
    format.<span style="color: #006633;">configure</span><span style="color: #009900;">&#40;</span>mrconf<span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
&nbsp;
    <span style="color: #666666; font-style: italic;">// NOTE: this is both here and in the MapReduceFlow below</span>
    FileInputFormat.<span style="color: #006633;">setInputPaths</span><span style="color: #009900;">&#40;</span>mrconf, intermediateTap1.<span style="color: #006633;">getPath</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>  
    FileOutputFormat.<span style="color: #006633;">setOutputPath</span><span style="color: #009900;">&#40;</span>mrconf, intermediateTap2.<span style="color: #006633;">getPath</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span> <span style="color: #666666; font-style: italic;">// likewise</span>
&nbsp;
    <span style="color: #666666; font-style: italic;">// create our second flow, this one is for the mrjob. Notice source and sink taps</span>
    Flow mrFlow <span style="color: #339933;">=</span> <span style="color: #000000; font-weight: bold;">new</span> MapReduceFlow<span style="color: #009900;">&#40;</span><span style="color: #0000ff;">&quot;mrflow&quot;</span>, 
      mrconf, intermediateTap1, intermediateTap2, <span style="color: #000066; font-weight: bold;">false</span>, <span style="color: #000066; font-weight: bold;">true</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
&nbsp;
    <span style="color: #666666; font-style: italic;">// create our third &quot;regular&quot; cascading pipe</span>
    Pipe countPipe <span style="color: #339933;">=</span> <span style="color: #000000; font-weight: bold;">new</span> Pipe<span style="color: #009900;">&#40;</span><span style="color: #0000ff;">&quot;count&quot;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
&nbsp;
    <span style="color: #666666; font-style: italic;">// b/c our IdentityMapper is emitting long of offset in the line, just</span>
    <span style="color: #666666; font-style: italic;">// strip that out. You wouldn't have to do this if you had a smarter Mapper</span>
    <span style="color: #666666; font-style: italic;">// class.</span>
    countPipe <span style="color: #339933;">=</span> <span style="color: #000000; font-weight: bold;">new</span> Each<span style="color: #009900;">&#40;</span>countPipe, 
        <span style="color: #000000; font-weight: bold;">new</span> Fields<span style="color: #009900;">&#40;</span><span style="color: #0000ff;">&quot;line&quot;</span><span style="color: #009900;">&#41;</span>, 
        <span style="color: #000000; font-weight: bold;">new</span> RegexParser<span style="color: #009900;">&#40;</span><span style="color: #000000; font-weight: bold;">new</span> Fields<span style="color: #009900;">&#40;</span><span style="color: #0000ff;">&quot;word&quot;</span><span style="color: #009900;">&#41;</span>, <span style="color: #0000ff;">&quot;.*?<span style="color: #000099; font-weight: bold;">\\</span>t(.*)&quot;</span><span style="color: #009900;">&#41;</span>, 
        <span style="color: #000000; font-weight: bold;">new</span> Fields<span style="color: #009900;">&#40;</span><span style="color: #0000ff;">&quot;word&quot;</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
&nbsp;
    countPipe <span style="color: #339933;">=</span> <span style="color: #000000; font-weight: bold;">new</span> GroupBy<span style="color: #009900;">&#40;</span>countPipe, <span style="color: #000000; font-weight: bold;">new</span> Fields<span style="color: #009900;">&#40;</span><span style="color: #0000ff;">&quot;word&quot;</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
    countPipe <span style="color: #339933;">=</span> <span style="color: #000000; font-weight: bold;">new</span> Every<span style="color: #009900;">&#40;</span>countPipe, <span style="color: #000000; font-weight: bold;">new</span> Count<span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span>, <span style="color: #000000; font-weight: bold;">new</span> Fields<span style="color: #009900;">&#40;</span><span style="color: #0000ff;">&quot;count&quot;</span>, <span style="color: #0000ff;">&quot;word&quot;</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
&nbsp;
    <span style="color: #666666; font-style: italic;">// create the flow for the last count pipe</span>
    Flow countFlow <span style="color: #339933;">=</span> flowConnector.<span style="color: #006633;">connect</span><span style="color: #009900;">&#40;</span>intermediateTap2, sinkTap, countPipe<span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
&nbsp;
    Cascade cascade <span style="color: #339933;">=</span> cascadeConnector.<span style="color: #006633;">connect</span><span style="color: #009900;">&#40;</span>parsedLogFlow, mrFlow, countFlow<span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
    cascade.<span style="color: #006633;">complete</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
&nbsp;
    <span style="color: #666666; font-style: italic;">// if you want to get rid of the intermediate files you </span>
    <span style="color: #666666; font-style: italic;">// could do something like the following here:</span>
    <span style="color: #666666; font-style: italic;">// Path tmp = tap.getPath();</span>
    <span style="color: #666666; font-style: italic;">// FileSystem fs = tmp.getFileSystem(conf);</span>
    <span style="color: #666666; font-style: italic;">// fs.delete(tmp, true);</span>
&nbsp;
    <span style="color: #000000; font-weight: bold;">return</span> <span style="color: #cc66cc;">0</span><span style="color: #339933;">;</span>
  <span style="color: #009900;">&#125;</span>
&nbsp;
  <span style="color: #000000; font-weight: bold;">public</span> <span style="color: #000000; font-weight: bold;">static</span> <span style="color: #000066; font-weight: bold;">void</span> main<span style="color: #009900;">&#40;</span><span style="color: #003399;">String</span><span style="color: #009900;">&#91;</span><span style="color: #009900;">&#93;</span> args<span style="color: #009900;">&#41;</span> <span style="color: #000000; font-weight: bold;">throws</span> <span style="color: #003399;">Exception</span> 
  <span style="color: #009900;">&#123;</span>
    <span style="color: #000066; font-weight: bold;">int</span> res <span style="color: #339933;">=</span> ToolRunner.<span style="color: #006633;">run</span><span style="color: #009900;">&#40;</span><span style="color: #000000; font-weight: bold;">new</span> Configuration<span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span>, <span style="color: #000000; font-weight: bold;">new</span> Main<span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span>, args<span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
    <span style="color: #003399;">System</span>.<span style="color: #006633;">exit</span><span style="color: #009900;">&#40;</span>res<span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
  <span style="color: #009900;">&#125;</span>
&nbsp;
  <span style="color: #009900;">&#125;</span></pre></div></div>

<p>Share:</p>
<p>	<a rel="nofollow"  href="http://delicious.com/post?url=http%3A%2F%2Fwww.xcombinator.com%2F2009%2F11%2F11%2Fhow-to-use-a-raw-mapreduce-job-in-cascading%2F&amp;title=How%20to%20use%20a%20raw%20MapReduce%20job%20in%20Cascading&amp;notes=Cascading%20is%20a%20great%20abstraction%20over%20MapReduce.%0D%0A%0D%0AHowever%2C%20sometimes%20you%20may%20have%20code%20for%20an%20existing%20MapReduce%20job%20or%20want%20to%20drop%20directly%20to%20Hadoop%20for%20efficiency.%20Even%20if%20you%27re%20using%20raw%20MapReduce%20jobs%2C%20Cascading%20can%20still%20be%20useful%20in%20planni" title="del.icio.us"><img src="http://www.xcombinator.com/wp-content/plugins/sociable/images/delicious.png" title="del.icio.us" alt="del.icio.us" class="sociable-hovers" /></a><br />
	<a rel="nofollow"  href="http://reddit.com/submit?url=http%3A%2F%2Fwww.xcombinator.com%2F2009%2F11%2F11%2Fhow-to-use-a-raw-mapreduce-job-in-cascading%2F&amp;title=How%20to%20use%20a%20raw%20MapReduce%20job%20in%20Cascading" title="Reddit"><img src="http://www.xcombinator.com/wp-content/plugins/sociable/images/reddit.png" title="Reddit" alt="Reddit" class="sociable-hovers" /></a><br />
	<a rel="nofollow"  href="http://technorati.com/faves?add=http%3A%2F%2Fwww.xcombinator.com%2F2009%2F11%2F11%2Fhow-to-use-a-raw-mapreduce-job-in-cascading%2F" title="Technorati"><img src="http://www.xcombinator.com/wp-content/plugins/sociable/images/technorati.png" title="Technorati" alt="Technorati" class="sociable-hovers" /></a><br />
	<a rel="nofollow"  href="http://twitter.com/home?status=How%20to%20use%20a%20raw%20MapReduce%20job%20in%20Cascading%20-%20http%3A%2F%2Fwww.xcombinator.com%2F2009%2F11%2F11%2Fhow-to-use-a-raw-mapreduce-job-in-cascading%2F" title="Twitter"><img src="http://www.xcombinator.com/wp-content/plugins/sociable/images/twitter.png" title="Twitter" alt="Twitter" class="sociable-hovers" /></a><br />
	<a rel="nofollow"  href="http://www.facebook.com/share.php?u=http%3A%2F%2Fwww.xcombinator.com%2F2009%2F11%2F11%2Fhow-to-use-a-raw-mapreduce-job-in-cascading%2F&amp;t=How%20to%20use%20a%20raw%20MapReduce%20job%20in%20Cascading" title="Facebook"><img src="http://www.xcombinator.com/wp-content/plugins/sociable/images/facebook.png" title="Facebook" alt="Facebook" class="sociable-hovers" /></a><br />
	<a rel="nofollow"  href="http://www.google.com/bookmarks/mark?op=edit&amp;bkmk=http%3A%2F%2Fwww.xcombinator.com%2F2009%2F11%2F11%2Fhow-to-use-a-raw-mapreduce-job-in-cascading%2F&amp;title=How%20to%20use%20a%20raw%20MapReduce%20job%20in%20Cascading&amp;annotation=Cascading%20is%20a%20great%20abstraction%20over%20MapReduce.%0D%0A%0D%0AHowever%2C%20sometimes%20you%20may%20have%20code%20for%20an%20existing%20MapReduce%20job%20or%20want%20to%20drop%20directly%20to%20Hadoop%20for%20efficiency.%20Even%20if%20you%27re%20using%20raw%20MapReduce%20jobs%2C%20Cascading%20can%20still%20be%20useful%20in%20planni" title="Google Bookmarks"><img src="http://www.xcombinator.com/wp-content/plugins/sociable/images/googlebookmark.png" title="Google Bookmarks" alt="Google Bookmarks" class="sociable-hovers" /></a><br />
	<a rel="nofollow"  href="http://news.ycombinator.com/submitlink?u=http%3A%2F%2Fwww.xcombinator.com%2F2009%2F11%2F11%2Fhow-to-use-a-raw-mapreduce-job-in-cascading%2F&amp;t=How%20to%20use%20a%20raw%20MapReduce%20job%20in%20Cascading" title="HackerNews"><img src="http://www.xcombinator.com/wp-content/plugins/sociable/images/hackernews.png" title="HackerNews" alt="HackerNews" class="sociable-hovers" /></a><br />
	<a rel="nofollow"  href="http://www.printfriendly.com/print?url=http%3A%2F%2Fwww.xcombinator.com%2F2009%2F11%2F11%2Fhow-to-use-a-raw-mapreduce-job-in-cascading%2F&amp;partner=sociable" title="PDF"><img src="http://www.xcombinator.com/wp-content/plugins/sociable/images/pdf.png" title="PDF" alt="PDF" class="sociable-hovers" /></a><br />
	<a rel="nofollow"  href="http://www.xcombinator.com/feed/" title="RSS"><img src="http://www.xcombinator.com/wp-content/plugins/sociable/images/rss.png" title="RSS" alt="RSS" class="sociable-hovers" /></a></p>
<p><br/><br/></p>
]]></content:encoded>
			<wfw:commentRss>http://www.xcombinator.com/2009/11/11/how-to-use-a-raw-mapreduce-job-in-cascading/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		<feedburner:origLink>http://www.xcombinator.com/2009/11/11/how-to-use-a-raw-mapreduce-job-in-cascading/</feedburner:origLink></item>
		<item>
		<title>install enchant dictionaries</title>
		<link>http://feedproxy.google.com/~r/xcombinator/~3/MvHF6pcFA9g/</link>
		<comments>http://www.xcombinator.com/2009/11/11/install-enchant-dictionaries/#comments</comments>
		<pubDate>Wed, 11 Nov 2009 22:29:57 +0000</pubDate>
		<dc:creator>Nate Murray</dc:creator>
				<category><![CDATA[shell]]></category>
		<category><![CDATA[sysadmin]]></category>

		<guid isPermaLink="false">http://xcombinator.local/?p=133</guid>
		<description><![CDATA[I had a bit of a hard time getting enchant installed with dictionaries on Mac OS X. Here&#8217;s how to do it:

sudo port install enchant # you'll need MacPorts 1.8.* for this

Then download the dictionaries from the OpenOffice wiki.
Next, place the files in ~/.enchant like so:


$ tree .enchant/
.enchant/
`-- myspell
    &#124;-- en_US.aff
  [...]]]></description>
			<content:encoded><![CDATA[<p>I had a bit of a hard time getting enchant installed with dictionaries on Mac OS X. Here&#8217;s how to do it:</p>
<p><code><br />
sudo port install enchant # you'll need MacPorts 1.8.* for this<br />
</code></p>
<p>Then download the dictionaries from the <a href="http://wiki.services.openoffice.org/wiki/Dictionaries">OpenOffice wiki</a>.</p>
<p>Next, place the files in <code>~/.enchant</code> like so:</p>
<p><code></p>
<pre>
$ tree .enchant/
.enchant/
`-- myspell
    |-- en_US.aff
    `-- en_US.dic
</pre>
<p></code></p>
<p><b>UPDATE</b><br />
You can also set the path to where you want to keep the dictionaries when you compile <code>enchant</code> by passing the <code>--with-myspell-dir</code> option to <code>configure</code> (or <code>aspell</code>, <code>hspell</code> etc).</p>
<p>Share:</p>
<p>	<a rel="nofollow"  href="http://delicious.com/post?url=http%3A%2F%2Fwww.xcombinator.com%2F2009%2F11%2F11%2Finstall-enchant-dictionaries%2F&amp;title=install%20enchant%20dictionaries&amp;notes=I%20had%20a%20bit%20of%20a%20hard%20time%20getting%20enchant%20installed%20with%20dictionaries%20on%20Mac%20OS%20X.%20Here%27s%20how%20to%20do%20it%3A%0D%0A%0D%0A%0D%0Asudo%20port%20install%20enchant%20%23%20you%27ll%20need%20MacPorts%201.8.%2A%20for%20this%0D%0A%0D%0A%0D%0AThen%20download%20the%20dictionaries%20from%20the%20OpenOffice%20wiki.%0D%0A%0D%0ANext%2C%20place" title="del.icio.us"><img src="http://www.xcombinator.com/wp-content/plugins/sociable/images/delicious.png" title="del.icio.us" alt="del.icio.us" class="sociable-hovers" /></a><br />
	<a rel="nofollow"  href="http://reddit.com/submit?url=http%3A%2F%2Fwww.xcombinator.com%2F2009%2F11%2F11%2Finstall-enchant-dictionaries%2F&amp;title=install%20enchant%20dictionaries" title="Reddit"><img src="http://www.xcombinator.com/wp-content/plugins/sociable/images/reddit.png" title="Reddit" alt="Reddit" class="sociable-hovers" /></a><br />
	<a rel="nofollow"  href="http://technorati.com/faves?add=http%3A%2F%2Fwww.xcombinator.com%2F2009%2F11%2F11%2Finstall-enchant-dictionaries%2F" title="Technorati"><img src="http://www.xcombinator.com/wp-content/plugins/sociable/images/technorati.png" title="Technorati" alt="Technorati" class="sociable-hovers" /></a><br />
	<a rel="nofollow"  href="http://twitter.com/home?status=install%20enchant%20dictionaries%20-%20http%3A%2F%2Fwww.xcombinator.com%2F2009%2F11%2F11%2Finstall-enchant-dictionaries%2F" title="Twitter"><img src="http://www.xcombinator.com/wp-content/plugins/sociable/images/twitter.png" title="Twitter" alt="Twitter" class="sociable-hovers" /></a><br />
	<a rel="nofollow"  href="http://www.facebook.com/share.php?u=http%3A%2F%2Fwww.xcombinator.com%2F2009%2F11%2F11%2Finstall-enchant-dictionaries%2F&amp;t=install%20enchant%20dictionaries" title="Facebook"><img src="http://www.xcombinator.com/wp-content/plugins/sociable/images/facebook.png" title="Facebook" alt="Facebook" class="sociable-hovers" /></a><br />
	<a rel="nofollow"  href="http://www.google.com/bookmarks/mark?op=edit&amp;bkmk=http%3A%2F%2Fwww.xcombinator.com%2F2009%2F11%2F11%2Finstall-enchant-dictionaries%2F&amp;title=install%20enchant%20dictionaries&amp;annotation=I%20had%20a%20bit%20of%20a%20hard%20time%20getting%20enchant%20installed%20with%20dictionaries%20on%20Mac%20OS%20X.%20Here%27s%20how%20to%20do%20it%3A%0D%0A%0D%0A%0D%0Asudo%20port%20install%20enchant%20%23%20you%27ll%20need%20MacPorts%201.8.%2A%20for%20this%0D%0A%0D%0A%0D%0AThen%20download%20the%20dictionaries%20from%20the%20OpenOffice%20wiki.%0D%0A%0D%0ANext%2C%20place" title="Google Bookmarks"><img src="http://www.xcombinator.com/wp-content/plugins/sociable/images/googlebookmark.png" title="Google Bookmarks" alt="Google Bookmarks" class="sociable-hovers" /></a><br />
	<a rel="nofollow"  href="http://news.ycombinator.com/submitlink?u=http%3A%2F%2Fwww.xcombinator.com%2F2009%2F11%2F11%2Finstall-enchant-dictionaries%2F&amp;t=install%20enchant%20dictionaries" title="HackerNews"><img src="http://www.xcombinator.com/wp-content/plugins/sociable/images/hackernews.png" title="HackerNews" alt="HackerNews" class="sociable-hovers" /></a><br />
	<a rel="nofollow"  href="http://www.printfriendly.com/print?url=http%3A%2F%2Fwww.xcombinator.com%2F2009%2F11%2F11%2Finstall-enchant-dictionaries%2F&amp;partner=sociable" title="PDF"><img src="http://www.xcombinator.com/wp-content/plugins/sociable/images/pdf.png" title="PDF" alt="PDF" class="sociable-hovers" /></a><br />
	<a rel="nofollow"  href="http://www.xcombinator.com/feed/" title="RSS"><img src="http://www.xcombinator.com/wp-content/plugins/sociable/images/rss.png" title="RSS" alt="RSS" class="sociable-hovers" /></a></p>
<p><br/><br/></p>
]]></content:encoded>
			<wfw:commentRss>http://www.xcombinator.com/2009/11/11/install-enchant-dictionaries/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		<feedburner:origLink>http://www.xcombinator.com/2009/11/11/install-enchant-dictionaries/</feedburner:origLink></item>
		<item>
		<title>testing erlang gen_server with gen_server_mock</title>
		<link>http://feedproxy.google.com/~r/xcombinator/~3/t960H_b54BI/</link>
		<comments>http://www.xcombinator.com/2009/08/11/testing-erlang-gen_server-with-gen_server_mock/#comments</comments>
		<pubDate>Tue, 11 Aug 2009 15:42:49 +0000</pubDate>
		<dc:creator>Nate Murray</dc:creator>
				<category><![CDATA[programming]]></category>

		<guid isPermaLink="false">http://www.xcombinator.com/2009/08/11/testing-erlang-gen_server-with-gen_server_mock/</guid>
		<description><![CDATA[Testing by synchronous pattern matching
Testing multi-process erlang gen_servers can be tricky. Typically one relies simply on pattern matching to verify that the response matches what you would expect.

&#123;expected, Response&#125; = gen_server:call&#40;Pid, hi&#41;.

As long as the gen_server call hi returns expected as the first element of the tuple, then the tests pass.
The technique is also the [...]]]></description>
			<content:encoded><![CDATA[<h2>Testing by synchronous pattern matching</h2>
<p>Testing multi-process erlang gen_servers can be tricky. Typically one relies simply on pattern matching to verify that the response matches what you would expect.</p>

<div class="wp_syntax"><div class="code"><pre class="erlang" style="font-family:monospace;"><span style="color: #109ab8;">&#123;</span>expected<span style="color: #6bb810;">,</span> <span style="color: #45b3e6;">Response</span><span style="color: #109ab8;">&#125;</span> <span style="color: #014ea4;">=</span> <span style="color: #ff4e18;">gen_server</span>:<span style="color: #ff3c00;">call</span><span style="color: #109ab8;">&#40;</span><span style="color: #45b3e6;">Pid</span><span style="color: #6bb810;">,</span> hi<span style="color: #109ab8;">&#41;</span><span style="color: #6bb810;">.</span></pre></div></div>

<p>As long as the <code>gen_server</code> call <code>hi</code> returns <code>expected</code> as the first element of the tuple, then the tests pass.</p>
<p>The technique is also the same when building client-server code where both client and server are <code>gen_server</code>s. The common case is to simply test one side at a time; test the response of all client calls and then (independently) test the responses of the server calls.</p>
<h2>What about asynchronous <code>cast</code>?</h2>
<p><code>gen_server:call</code> is convenient because it is synchronous and returns a value.<br />
<code>gen_server:cast</code>, on the other hand, is asynchronous and always returns the atom <code>ok</code>. This can make <code>cast</code>s difficult to test.</p>
<p><code>gen_server_mock</code> is a library to mock <code>gen_server</code> processes that expect specific, ordered sets of messages. It allows you to unit test <code>gen_server</code>s by verifying they are receiving the expected set of messages.</p>
<h2>Example 1</h2>

<div class="wp_syntax"><div class="code"><pre class="erlang" style="font-family:monospace;">     <span style="color: #109ab8;">&#123;</span>ok<span style="color: #6bb810;">,</span> <span style="color: #45b3e6;">Mock</span><span style="color: #109ab8;">&#125;</span> <span style="color: #014ea4;">=</span> gen_server_mock:<span style="color: #ff3c00;">new</span><span style="color: #109ab8;">&#40;</span><span style="color: #109ab8;">&#41;</span><span style="color: #6bb810;">,</span>
     gen_server_mock:<span style="color: #ff3c00;">expect</span><span style="color: #109ab8;">&#40;</span><span style="color: #45b3e6;">Mock</span><span style="color: #6bb810;">,</span> call<span style="color: #6bb810;">,</span> <span style="color: #ff3c00;">fun</span><span style="color: #109ab8;">&#40;</span><span style="color: #109ab8;">&#123;</span>foo<span style="color: #6bb810;">,</span> hi<span style="color: #109ab8;">&#125;</span><span style="color: #6bb810;">,</span> <span style="color: #45b3e6;">_From</span><span style="color: #6bb810;">,</span> <span style="color: #45b3e6;">_State</span><span style="color: #109ab8;">&#41;</span> <span style="color: #6bb810;">-&gt;</span> <span style="color: #006600;">ok</span> <span style="color: #186895;">end</span><span style="color: #109ab8;">&#41;</span><span style="color: #6bb810;">,</span>
     gen_server_mock:<span style="color: #ff3c00;">expect_call</span><span style="color: #109ab8;">&#40;</span><span style="color: #45b3e6;">Mock</span><span style="color: #6bb810;">,</span> <span style="color: #ff3c00;">fun</span><span style="color: #109ab8;">&#40;</span><span style="color: #109ab8;">&#123;</span>bar<span style="color: #6bb810;">,</span> bye<span style="color: #109ab8;">&#125;</span><span style="color: #6bb810;">,</span> <span style="color: #45b3e6;">_From</span><span style="color: #6bb810;">,</span> <span style="color: #45b3e6;">_State</span><span style="color: #109ab8;">&#41;</span> <span style="color: #6bb810;">-&gt;</span> <span style="color: #006600;">ok</span> <span style="color: #186895;">end</span><span style="color: #109ab8;">&#41;</span><span style="color: #6bb810;">,</span>
&nbsp;
     ok <span style="color: #014ea4;">=</span> <span style="color: #ff4e18;">gen_server</span>:<span style="color: #ff3c00;">call</span><span style="color: #109ab8;">&#40;</span><span style="color: #45b3e6;">Mock</span><span style="color: #6bb810;">,</span> <span style="color: #109ab8;">&#123;</span>foo<span style="color: #6bb810;">,</span> hi<span style="color: #109ab8;">&#125;</span><span style="color: #109ab8;">&#41;</span><span style="color: #6bb810;">,</span>  
     ok <span style="color: #014ea4;">=</span> <span style="color: #ff4e18;">gen_server</span>:<span style="color: #ff3c00;">call</span><span style="color: #109ab8;">&#40;</span><span style="color: #45b3e6;">Mock</span><span style="color: #6bb810;">,</span> <span style="color: #109ab8;">&#123;</span>bar<span style="color: #6bb810;">,</span> bye<span style="color: #109ab8;">&#125;</span><span style="color: #109ab8;">&#41;</span><span style="color: #6bb810;">,</span>  
&nbsp;
     ok <span style="color: #014ea4;">=</span> gen_server_mock:<span style="color: #ff3c00;">assert_expectations</span><span style="color: #109ab8;">&#40;</span><span style="color: #45b3e6;">Mock</span><span style="color: #109ab8;">&#41;</span></pre></div></div>

<p>This <code>Mock</code> expects two <code>call</code>s: <code>{foo, hi}</code> and <code>{bar, bye}</code>. Since <code>Mock</code> receives both of these messages, <code>assert_expectations</code> does not raise any errors.</p>
<h2>What is verified</h2>
<p><code>gen_server_mock:assert_expectations(Mock)</code> verifies that:</p>
<ol>
<li>all expected messages were received</li>
<li>no messages were received that were not expected</li>
</ol>
<p>You can catch the <code>exit</code> by using the following:</p>

<div class="wp_syntax"><div class="code"><pre class="erlang" style="font-family:monospace;">     <span style="color: #45b3e6;">Result</span> <span style="color: #014ea4;">=</span> <span style="color: #186895;">try</span> gen_server_mock:<span style="color: #ff3c00;">assert_expectations</span><span style="color: #109ab8;">&#40;</span><span style="color: #45b3e6;">Mock</span><span style="color: #109ab8;">&#41;</span>
     <span style="color: #186895;">catch</span>
         exit:<span style="color: #006600;">Exception</span> <span style="color: #6bb810;">-&gt;</span> <span style="color: #45b3e6;">Exception</span>
     <span style="color: #186895;">end</span><span style="color: #6bb810;">,</span>
     <span style="color: #666666; font-style: italic;">% etc...</span></pre></div></div>

<h2>Example 2</h2>

<div class="wp_syntax"><div class="code"><pre class="erlang" style="font-family:monospace;">     <span style="color: #109ab8;">&#123;</span>ok<span style="color: #6bb810;">,</span> <span style="color: #45b3e6;">Mock</span><span style="color: #109ab8;">&#125;</span> <span style="color: #014ea4;">=</span> gen_server_mock:<span style="color: #ff3c00;">new</span><span style="color: #109ab8;">&#40;</span><span style="color: #109ab8;">&#41;</span><span style="color: #6bb810;">,</span>
&nbsp;
     gen_server_mock:<span style="color: #ff3c00;">expect_call</span><span style="color: #109ab8;">&#40;</span><span style="color: #45b3e6;">Mock</span><span style="color: #6bb810;">,</span> <span style="color: #ff3c00;">fun</span><span style="color: #109ab8;">&#40;</span>one<span style="color: #6bb810;">,</span>  <span style="color: #45b3e6;">_From</span><span style="color: #6bb810;">,</span> <span style="color: #45b3e6;">_State</span><span style="color: #109ab8;">&#41;</span>            <span style="color: #6bb810;">-&gt;</span> <span style="color: #006600;">ok</span> <span style="color: #186895;">end</span><span style="color: #109ab8;">&#41;</span><span style="color: #6bb810;">,</span>
     gen_server_mock:<span style="color: #ff3c00;">expect_call</span><span style="color: #109ab8;">&#40;</span><span style="color: #45b3e6;">Mock</span><span style="color: #6bb810;">,</span> <span style="color: #ff3c00;">fun</span><span style="color: #109ab8;">&#40;</span>two<span style="color: #6bb810;">,</span>  <span style="color: #45b3e6;">_From</span><span style="color: #6bb810;">,</span>  <span style="color: #45b3e6;">State</span><span style="color: #109ab8;">&#41;</span>            <span style="color: #6bb810;">-&gt;</span> <span style="color: #109ab8;">&#123;</span>ok<span style="color: #6bb810;">,</span> <span style="color: #45b3e6;">State</span><span style="color: #109ab8;">&#125;</span> <span style="color: #186895;">end</span><span style="color: #109ab8;">&#41;</span><span style="color: #6bb810;">,</span>
     gen_server_mock:<span style="color: #ff3c00;">expect_call</span><span style="color: #109ab8;">&#40;</span><span style="color: #45b3e6;">Mock</span><span style="color: #6bb810;">,</span> <span style="color: #ff3c00;">fun</span><span style="color: #109ab8;">&#40;</span>three<span style="color: #6bb810;">,</span> <span style="color: #45b3e6;">_From</span><span style="color: #6bb810;">,</span>  <span style="color: #45b3e6;">State</span><span style="color: #109ab8;">&#41;</span>           <span style="color: #6bb810;">-&gt;</span> <span style="color: #109ab8;">&#123;</span>ok<span style="color: #6bb810;">,</span> good<span style="color: #6bb810;">,</span> <span style="color: #45b3e6;">State</span><span style="color: #109ab8;">&#125;</span> <span style="color: #186895;">end</span><span style="color: #109ab8;">&#41;</span><span style="color: #6bb810;">,</span>
     gen_server_mock:<span style="color: #ff3c00;">expect_call</span><span style="color: #109ab8;">&#40;</span><span style="color: #45b3e6;">Mock</span><span style="color: #6bb810;">,</span> <span style="color: #ff3c00;">fun</span><span style="color: #109ab8;">&#40;</span><span style="color: #109ab8;">&#123;</span>echo<span style="color: #6bb810;">,</span> <span style="color: #45b3e6;">Response</span><span style="color: #109ab8;">&#125;</span><span style="color: #6bb810;">,</span> <span style="color: #45b3e6;">_From</span><span style="color: #6bb810;">,</span> <span style="color: #45b3e6;">State</span><span style="color: #109ab8;">&#41;</span> <span style="color: #6bb810;">-&gt;</span> <span style="color: #109ab8;">&#123;</span>ok<span style="color: #6bb810;">,</span> <span style="color: #45b3e6;">Response</span><span style="color: #6bb810;">,</span> <span style="color: #45b3e6;">State</span><span style="color: #109ab8;">&#125;</span> <span style="color: #186895;">end</span><span style="color: #109ab8;">&#41;</span><span style="color: #6bb810;">,</span>
     gen_server_mock:<span style="color: #ff3c00;">expect_cast</span><span style="color: #109ab8;">&#40;</span><span style="color: #45b3e6;">Mock</span><span style="color: #6bb810;">,</span> <span style="color: #ff3c00;">fun</span><span style="color: #109ab8;">&#40;</span>fish<span style="color: #6bb810;">,</span> <span style="color: #45b3e6;">State</span><span style="color: #109ab8;">&#41;</span> <span style="color: #6bb810;">-&gt;</span> <span style="color: #109ab8;">&#123;</span>ok<span style="color: #6bb810;">,</span> <span style="color: #45b3e6;">State</span><span style="color: #109ab8;">&#125;</span> <span style="color: #186895;">end</span><span style="color: #109ab8;">&#41;</span><span style="color: #6bb810;">,</span>
     gen_server_mock:<span style="color: #ff3c00;">expect_info</span><span style="color: #109ab8;">&#40;</span><span style="color: #45b3e6;">Mock</span><span style="color: #6bb810;">,</span> <span style="color: #ff3c00;">fun</span><span style="color: #109ab8;">&#40;</span>cat<span style="color: #6bb810;">,</span>  <span style="color: #45b3e6;">State</span><span style="color: #109ab8;">&#41;</span> <span style="color: #6bb810;">-&gt;</span> <span style="color: #109ab8;">&#123;</span>ok<span style="color: #6bb810;">,</span> <span style="color: #45b3e6;">State</span><span style="color: #109ab8;">&#125;</span> <span style="color: #186895;">end</span><span style="color: #109ab8;">&#41;</span><span style="color: #6bb810;">,</span>
&nbsp;
     ok <span style="color: #014ea4;">=</span> <span style="color: #ff4e18;">gen_server</span>:<span style="color: #ff3c00;">call</span><span style="color: #109ab8;">&#40;</span><span style="color: #45b3e6;">Mock</span><span style="color: #6bb810;">,</span> one<span style="color: #109ab8;">&#41;</span><span style="color: #6bb810;">,</span>
     ok <span style="color: #014ea4;">=</span> <span style="color: #ff4e18;">gen_server</span>:<span style="color: #ff3c00;">call</span><span style="color: #109ab8;">&#40;</span><span style="color: #45b3e6;">Mock</span><span style="color: #6bb810;">,</span> two<span style="color: #109ab8;">&#41;</span><span style="color: #6bb810;">,</span>
     good <span style="color: #014ea4;">=</span> <span style="color: #ff4e18;">gen_server</span>:<span style="color: #ff3c00;">call</span><span style="color: #109ab8;">&#40;</span><span style="color: #45b3e6;">Mock</span><span style="color: #6bb810;">,</span> three<span style="color: #109ab8;">&#41;</span><span style="color: #6bb810;">,</span>
     tree <span style="color: #014ea4;">=</span> <span style="color: #ff4e18;">gen_server</span>:<span style="color: #ff3c00;">call</span><span style="color: #109ab8;">&#40;</span><span style="color: #45b3e6;">Mock</span><span style="color: #6bb810;">,</span> <span style="color: #109ab8;">&#123;</span>echo<span style="color: #6bb810;">,</span> tree<span style="color: #109ab8;">&#125;</span><span style="color: #109ab8;">&#41;</span><span style="color: #6bb810;">,</span>
     ok <span style="color: #014ea4;">=</span> <span style="color: #ff4e18;">gen_server</span>:<span style="color: #ff3c00;">cast</span><span style="color: #109ab8;">&#40;</span><span style="color: #45b3e6;">Mock</span><span style="color: #6bb810;">,</span> fish<span style="color: #109ab8;">&#41;</span><span style="color: #6bb810;">,</span>
     <span style="color: #45b3e6;">Mock</span> <span style="color: #014ea4;">!</span> cat<span style="color: #6bb810;">,</span>
&nbsp;
     gen_server_mock:<span style="color: #ff3c00;">assert_expectations</span><span style="color: #109ab8;">&#40;</span><span style="color: #45b3e6;">Mock</span><span style="color: #109ab8;">&#41;</span></pre></div></div>

<p>Currently three types of messages are supported: <code>call</code>, <code>cast</code>, and <code>info</code>.</p>
<p>The signature of the <code>fun</code> of each expectation is the same as the corresponding<br />
<code>gen_server:handle_*</code>. So the <code>fun</code> for <code>expect_call</code> has the same signature as <code>handle_call</code>: <code>fun(Request, From, State)</code>. See <code>man gen_server</code> for more information.</p>
<p>However, the return value of the <code>fun</code> <em>must</em> be one of:</p>

<div class="wp_syntax"><div class="code"><pre class="erlang" style="font-family:monospace;">    ok |                  
    <span style="color: #109ab8;">&#123;</span>ok<span style="color: #6bb810;">,</span> <span style="color: #45b3e6;">NewState</span><span style="color: #109ab8;">&#125;</span> |
    <span style="color: #109ab8;">&#123;</span>ok<span style="color: #6bb810;">,</span> <span style="color: #45b3e6;">ResponseValue</span><span style="color: #6bb810;">,</span> <span style="color: #45b3e6;">NewState</span><span style="color: #109ab8;">&#125;</span> |</pre></div></div>

<p>Anything else will be an error. Note that you can change the state of your <code>Mock</code> by returning <code>NewState</code>.</p>
<p>Arbitrary, non-<code>gen_server</code> messages are handled with <code>expect_info</code>, e.g. <code>Mock ! cat</code> fulfills the <code>expect_info</code> in the example above.</p>
<h2>References</h2>
<ul>
<li><a href="http://github.com/jashmenn/gen_server_mock">Github Repo</a> (Patches readily accepted)</li>
<li>Work inspired by <a href="http://erlang.org/pipermail/erlang-questions/2008-April/034140.html">this post</a></li>
<li><a href="http://martinfowler.com/articles/mocksArentStubs.html">Mocks Aren&#8217;t Stubs</a></li>
</ul>
<p>Share:</p>
<p>	<a rel="nofollow"  href="http://delicious.com/post?url=http%3A%2F%2Fwww.xcombinator.com%2F2009%2F08%2F11%2Ftesting-erlang-gen_server-with-gen_server_mock%2F&amp;title=testing%20erlang%20gen_server%20with%20gen_server_mock&amp;notes=Testing%20by%20synchronous%20pattern%20matching%20%0D%0A%20%0D%0ATesting%20multi-process%20erlang%20gen_servers%20can%20be%20tricky.%20Typically%20one%20relies%20simply%20on%20pattern%20matching%20to%20verify%20that%20the%20response%20matches%20what%20you%20would%20expect.%20%0D%0A%20%0D%0A%0D%0A%7Bexpected%2C%20Response%7D%20%3D%20gen_server%3Ac" title="del.icio.us"><img src="http://www.xcombinator.com/wp-content/plugins/sociable/images/delicious.png" title="del.icio.us" alt="del.icio.us" class="sociable-hovers" /></a><br />
	<a rel="nofollow"  href="http://reddit.com/submit?url=http%3A%2F%2Fwww.xcombinator.com%2F2009%2F08%2F11%2Ftesting-erlang-gen_server-with-gen_server_mock%2F&amp;title=testing%20erlang%20gen_server%20with%20gen_server_mock" title="Reddit"><img src="http://www.xcombinator.com/wp-content/plugins/sociable/images/reddit.png" title="Reddit" alt="Reddit" class="sociable-hovers" /></a><br />
	<a rel="nofollow"  href="http://technorati.com/faves?add=http%3A%2F%2Fwww.xcombinator.com%2F2009%2F08%2F11%2Ftesting-erlang-gen_server-with-gen_server_mock%2F" title="Technorati"><img src="http://www.xcombinator.com/wp-content/plugins/sociable/images/technorati.png" title="Technorati" alt="Technorati" class="sociable-hovers" /></a><br />
	<a rel="nofollow"  href="http://twitter.com/home?status=testing%20erlang%20gen_server%20with%20gen_server_mock%20-%20http%3A%2F%2Fwww.xcombinator.com%2F2009%2F08%2F11%2Ftesting-erlang-gen_server-with-gen_server_mock%2F" title="Twitter"><img src="http://www.xcombinator.com/wp-content/plugins/sociable/images/twitter.png" title="Twitter" alt="Twitter" class="sociable-hovers" /></a><br />
	<a rel="nofollow"  href="http://www.facebook.com/share.php?u=http%3A%2F%2Fwww.xcombinator.com%2F2009%2F08%2F11%2Ftesting-erlang-gen_server-with-gen_server_mock%2F&amp;t=testing%20erlang%20gen_server%20with%20gen_server_mock" title="Facebook"><img src="http://www.xcombinator.com/wp-content/plugins/sociable/images/facebook.png" title="Facebook" alt="Facebook" class="sociable-hovers" /></a><br />
	<a rel="nofollow"  href="http://www.google.com/bookmarks/mark?op=edit&amp;bkmk=http%3A%2F%2Fwww.xcombinator.com%2F2009%2F08%2F11%2Ftesting-erlang-gen_server-with-gen_server_mock%2F&amp;title=testing%20erlang%20gen_server%20with%20gen_server_mock&amp;annotation=Testing%20by%20synchronous%20pattern%20matching%20%0D%0A%20%0D%0ATesting%20multi-process%20erlang%20gen_servers%20can%20be%20tricky.%20Typically%20one%20relies%20simply%20on%20pattern%20matching%20to%20verify%20that%20the%20response%20matches%20what%20you%20would%20expect.%20%0D%0A%20%0D%0A%0D%0A%7Bexpected%2C%20Response%7D%20%3D%20gen_server%3Ac" title="Google Bookmarks"><img src="http://www.xcombinator.com/wp-content/plugins/sociable/images/googlebookmark.png" title="Google Bookmarks" alt="Google Bookmarks" class="sociable-hovers" /></a><br />
	<a rel="nofollow"  href="http://news.ycombinator.com/submitlink?u=http%3A%2F%2Fwww.xcombinator.com%2F2009%2F08%2F11%2Ftesting-erlang-gen_server-with-gen_server_mock%2F&amp;t=testing%20erlang%20gen_server%20with%20gen_server_mock" title="HackerNews"><img src="http://www.xcombinator.com/wp-content/plugins/sociable/images/hackernews.png" title="HackerNews" alt="HackerNews" class="sociable-hovers" /></a><br />
	<a rel="nofollow"  href="http://www.printfriendly.com/print?url=http%3A%2F%2Fwww.xcombinator.com%2F2009%2F08%2F11%2Ftesting-erlang-gen_server-with-gen_server_mock%2F&amp;partner=sociable" title="PDF"><img src="http://www.xcombinator.com/wp-content/plugins/sociable/images/pdf.png" title="PDF" alt="PDF" class="sociable-hovers" /></a><br />
	<a rel="nofollow"  href="http://www.xcombinator.com/feed/" title="RSS"><img src="http://www.xcombinator.com/wp-content/plugins/sociable/images/rss.png" title="RSS" alt="RSS" class="sociable-hovers" /></a></p>
<p><br/><br/></p>
]]></content:encoded>
			<wfw:commentRss>http://www.xcombinator.com/2009/08/11/testing-erlang-gen_server-with-gen_server_mock/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		<feedburner:origLink>http://www.xcombinator.com/2009/08/11/testing-erlang-gen_server-with-gen_server_mock/</feedburner:origLink></item>
		<item>
		<title>rough cut: erlang code coverage with rake</title>
		<link>http://feedproxy.google.com/~r/xcombinator/~3/iZfmJveORb8/</link>
		<comments>http://www.xcombinator.com/2009/08/05/rough-cut-erlang-code-coverage-with-rake/#comments</comments>
		<pubDate>Wed, 05 Aug 2009 16:32:13 +0000</pubDate>
		<dc:creator>Nate Murray</dc:creator>
				<category><![CDATA[erlang]]></category>
		<category><![CDATA[tips]]></category>

		<guid isPermaLink="false">http://www.xcombinator.com/2009/08/05/rough-cut-erlang-code-coverage-with-rake/</guid>
		<description><![CDATA[Here&#8217;s a quick, ugly version of how to get erlang code coverage using rake. This is a rough first draft and the gist below doesn&#8217;t include all the needed dependencies. To see the rest of the Rakefile, checkout skelerl.

Share:
	
	
	
	
	
	
	
	
	

]]></description>
			<content:encoded><![CDATA[<p>Here&#8217;s a quick, ugly version of how to get erlang code coverage using rake. This is a rough first draft and the gist below doesn&#8217;t include all the needed dependencies. To see the rest of the Rakefile, checkout <a href="http://github.com/jashmenn/skelerl/blob/b4f64f6ab9ddf3e444aab2e5f2342ac056459469/tasks/build.rake">skelerl</a>.</p>
<p><script src="http://gist.github.com/162794.js"></script></p>
<p>Share:</p>
<p>	<a rel="nofollow"  href="http://delicious.com/post?url=http%3A%2F%2Fwww.xcombinator.com%2F2009%2F08%2F05%2Frough-cut-erlang-code-coverage-with-rake%2F&amp;title=rough%20cut%3A%20erlang%20code%20coverage%20with%20rake&amp;notes=Here%27s%20a%20quick%2C%20ugly%20version%20of%20how%20to%20get%20erlang%20code%20coverage%20using%20rake.%20This%20is%20a%20rough%20first%20draft%20and%20the%20gist%20below%20doesn%27t%20include%20all%20the%20needed%20dependencies.%20To%20see%20the%20rest%20of%20the%20Rakefile%2C%20checkout%20skelerl.%0D%0A%0D%0A" title="del.icio.us"><img src="http://www.xcombinator.com/wp-content/plugins/sociable/images/delicious.png" title="del.icio.us" alt="del.icio.us" class="sociable-hovers" /></a><br />
	<a rel="nofollow"  href="http://reddit.com/submit?url=http%3A%2F%2Fwww.xcombinator.com%2F2009%2F08%2F05%2Frough-cut-erlang-code-coverage-with-rake%2F&amp;title=rough%20cut%3A%20erlang%20code%20coverage%20with%20rake" title="Reddit"><img src="http://www.xcombinator.com/wp-content/plugins/sociable/images/reddit.png" title="Reddit" alt="Reddit" class="sociable-hovers" /></a><br />
	<a rel="nofollow"  href="http://technorati.com/faves?add=http%3A%2F%2Fwww.xcombinator.com%2F2009%2F08%2F05%2Frough-cut-erlang-code-coverage-with-rake%2F" title="Technorati"><img src="http://www.xcombinator.com/wp-content/plugins/sociable/images/technorati.png" title="Technorati" alt="Technorati" class="sociable-hovers" /></a><br />
	<a rel="nofollow"  href="http://twitter.com/home?status=rough%20cut%3A%20erlang%20code%20coverage%20with%20rake%20-%20http%3A%2F%2Fwww.xcombinator.com%2F2009%2F08%2F05%2Frough-cut-erlang-code-coverage-with-rake%2F" title="Twitter"><img src="http://www.xcombinator.com/wp-content/plugins/sociable/images/twitter.png" title="Twitter" alt="Twitter" class="sociable-hovers" /></a><br />
	<a rel="nofollow"  href="http://www.facebook.com/share.php?u=http%3A%2F%2Fwww.xcombinator.com%2F2009%2F08%2F05%2Frough-cut-erlang-code-coverage-with-rake%2F&amp;t=rough%20cut%3A%20erlang%20code%20coverage%20with%20rake" title="Facebook"><img src="http://www.xcombinator.com/wp-content/plugins/sociable/images/facebook.png" title="Facebook" alt="Facebook" class="sociable-hovers" /></a><br />
	<a rel="nofollow"  href="http://www.google.com/bookmarks/mark?op=edit&amp;bkmk=http%3A%2F%2Fwww.xcombinator.com%2F2009%2F08%2F05%2Frough-cut-erlang-code-coverage-with-rake%2F&amp;title=rough%20cut%3A%20erlang%20code%20coverage%20with%20rake&amp;annotation=Here%27s%20a%20quick%2C%20ugly%20version%20of%20how%20to%20get%20erlang%20code%20coverage%20using%20rake.%20This%20is%20a%20rough%20first%20draft%20and%20the%20gist%20below%20doesn%27t%20include%20all%20the%20needed%20dependencies.%20To%20see%20the%20rest%20of%20the%20Rakefile%2C%20checkout%20skelerl.%0D%0A%0D%0A" title="Google Bookmarks"><img src="http://www.xcombinator.com/wp-content/plugins/sociable/images/googlebookmark.png" title="Google Bookmarks" alt="Google Bookmarks" class="sociable-hovers" /></a><br />
	<a rel="nofollow"  href="http://news.ycombinator.com/submitlink?u=http%3A%2F%2Fwww.xcombinator.com%2F2009%2F08%2F05%2Frough-cut-erlang-code-coverage-with-rake%2F&amp;t=rough%20cut%3A%20erlang%20code%20coverage%20with%20rake" title="HackerNews"><img src="http://www.xcombinator.com/wp-content/plugins/sociable/images/hackernews.png" title="HackerNews" alt="HackerNews" class="sociable-hovers" /></a><br />
	<a rel="nofollow"  href="http://www.printfriendly.com/print?url=http%3A%2F%2Fwww.xcombinator.com%2F2009%2F08%2F05%2Frough-cut-erlang-code-coverage-with-rake%2F&amp;partner=sociable" title="PDF"><img src="http://www.xcombinator.com/wp-content/plugins/sociable/images/pdf.png" title="PDF" alt="PDF" class="sociable-hovers" /></a><br />
	<a rel="nofollow"  href="http://www.xcombinator.com/feed/" title="RSS"><img src="http://www.xcombinator.com/wp-content/plugins/sociable/images/rss.png" title="RSS" alt="RSS" class="sociable-hovers" /></a></p>
<p><br/><br/></p>
]]></content:encoded>
			<wfw:commentRss>http://www.xcombinator.com/2009/08/05/rough-cut-erlang-code-coverage-with-rake/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		<feedburner:origLink>http://www.xcombinator.com/2009/08/05/rough-cut-erlang-code-coverage-with-rake/</feedburner:origLink></item>
		<item>
		<title>fixing the disabled snapshot button in vmware fusion</title>
		<link>http://feedproxy.google.com/~r/xcombinator/~3/w0I3FhwDO0k/</link>
		<comments>http://www.xcombinator.com/2009/07/17/fixing-the-disabled-snapshot-button-in-vmware-fusion/#comments</comments>
		<pubDate>Fri, 17 Jul 2009 18:22:55 +0000</pubDate>
		<dc:creator>Nate Murray</dc:creator>
				<category><![CDATA[sysadmin]]></category>
		<category><![CDATA[tips]]></category>

		<guid isPermaLink="false">http://www.xcombinator.com/2009/07/17/fixing-the-disabled-snapshot-button-in-vmware-fusion/</guid>
		<description><![CDATA[I recently created a new CentOS 5 vmware image. Unfortunately the &#8220;Take Snapshot&#8221; button was disabled while the system was running. After searching around I found this post.
What you need to do is open up your vmx file and comment out (disable) the following line:

scsi0:0.mode = &#34;independent-persistent&#34;

Others have also reported finding the following line in [...]]]></description>
			<content:encoded><![CDATA[<p>I recently created a new CentOS 5 vmware image. Unfortunately the &#8220;Take Snapshot&#8221; button was disabled while the system was running. After searching around I found <a href="http://communities.vmware.com/message/589046#589046">this post</a>.</p>
<p>What you need to do is open up your <code>vmx</code> file and comment out (disable) the following line:</p>

<div class="wp_syntax"><div class="code"><pre class="bash" style="font-family:monospace;">scsi0:0.mode = <span style="color: #ff0000;">&quot;independent-persistent&quot;</span></pre></div></div>

<p>Others have also reported finding the following line in their <code>vmx</code> file:</p>

<div class="wp_syntax"><div class="code"><pre class="bash" style="font-family:monospace;">snapshot.disabled = <span style="color: #ff0000;">&quot;TRUE&quot;</span></pre></div></div>

<p>Share:</p>
<p>	<a rel="nofollow"  href="http://delicious.com/post?url=http%3A%2F%2Fwww.xcombinator.com%2F2009%2F07%2F17%2Ffixing-the-disabled-snapshot-button-in-vmware-fusion%2F&amp;title=fixing%20the%20disabled%20snapshot%20button%20in%20vmware%20fusion&amp;notes=I%20recently%20created%20a%20new%20CentOS%205%20vmware%20image.%20Unfortunately%20the%20%22Take%20Snapshot%22%20button%20was%20disabled%20while%20the%20system%20was%20running.%20After%20searching%20around%20I%20found%20this%20post.%0D%0A%0D%0AWhat%20you%20need%20to%20do%20is%20open%20up%20your%20vmx%20file%20and%20comment%20out%20%28disable%29%20th" title="del.icio.us"><img src="http://www.xcombinator.com/wp-content/plugins/sociable/images/delicious.png" title="del.icio.us" alt="del.icio.us" class="sociable-hovers" /></a><br />
	<a rel="nofollow"  href="http://reddit.com/submit?url=http%3A%2F%2Fwww.xcombinator.com%2F2009%2F07%2F17%2Ffixing-the-disabled-snapshot-button-in-vmware-fusion%2F&amp;title=fixing%20the%20disabled%20snapshot%20button%20in%20vmware%20fusion" title="Reddit"><img src="http://www.xcombinator.com/wp-content/plugins/sociable/images/reddit.png" title="Reddit" alt="Reddit" class="sociable-hovers" /></a><br />
	<a rel="nofollow"  href="http://technorati.com/faves?add=http%3A%2F%2Fwww.xcombinator.com%2F2009%2F07%2F17%2Ffixing-the-disabled-snapshot-button-in-vmware-fusion%2F" title="Technorati"><img src="http://www.xcombinator.com/wp-content/plugins/sociable/images/technorati.png" title="Technorati" alt="Technorati" class="sociable-hovers" /></a><br />
	<a rel="nofollow"  href="http://twitter.com/home?status=fixing%20the%20disabled%20snapshot%20button%20in%20vmware%20fusion%20-%20http%3A%2F%2Fwww.xcombinator.com%2F2009%2F07%2F17%2Ffixing-the-disabled-snapshot-button-in-vmware-fusion%2F" title="Twitter"><img src="http://www.xcombinator.com/wp-content/plugins/sociable/images/twitter.png" title="Twitter" alt="Twitter" class="sociable-hovers" /></a><br />
	<a rel="nofollow"  href="http://www.facebook.com/share.php?u=http%3A%2F%2Fwww.xcombinator.com%2F2009%2F07%2F17%2Ffixing-the-disabled-snapshot-button-in-vmware-fusion%2F&amp;t=fixing%20the%20disabled%20snapshot%20button%20in%20vmware%20fusion" title="Facebook"><img src="http://www.xcombinator.com/wp-content/plugins/sociable/images/facebook.png" title="Facebook" alt="Facebook" class="sociable-hovers" /></a><br />
	<a rel="nofollow"  href="http://www.google.com/bookmarks/mark?op=edit&amp;bkmk=http%3A%2F%2Fwww.xcombinator.com%2F2009%2F07%2F17%2Ffixing-the-disabled-snapshot-button-in-vmware-fusion%2F&amp;title=fixing%20the%20disabled%20snapshot%20button%20in%20vmware%20fusion&amp;annotation=I%20recently%20created%20a%20new%20CentOS%205%20vmware%20image.%20Unfortunately%20the%20%22Take%20Snapshot%22%20button%20was%20disabled%20while%20the%20system%20was%20running.%20After%20searching%20around%20I%20found%20this%20post.%0D%0A%0D%0AWhat%20you%20need%20to%20do%20is%20open%20up%20your%20vmx%20file%20and%20comment%20out%20%28disable%29%20th" title="Google Bookmarks"><img src="http://www.xcombinator.com/wp-content/plugins/sociable/images/googlebookmark.png" title="Google Bookmarks" alt="Google Bookmarks" class="sociable-hovers" /></a><br />
	<a rel="nofollow"  href="http://news.ycombinator.com/submitlink?u=http%3A%2F%2Fwww.xcombinator.com%2F2009%2F07%2F17%2Ffixing-the-disabled-snapshot-button-in-vmware-fusion%2F&amp;t=fixing%20the%20disabled%20snapshot%20button%20in%20vmware%20fusion" title="HackerNews"><img src="http://www.xcombinator.com/wp-content/plugins/sociable/images/hackernews.png" title="HackerNews" alt="HackerNews" class="sociable-hovers" /></a><br />
	<a rel="nofollow"  href="http://www.printfriendly.com/print?url=http%3A%2F%2Fwww.xcombinator.com%2F2009%2F07%2F17%2Ffixing-the-disabled-snapshot-button-in-vmware-fusion%2F&amp;partner=sociable" title="PDF"><img src="http://www.xcombinator.com/wp-content/plugins/sociable/images/pdf.png" title="PDF" alt="PDF" class="sociable-hovers" /></a><br />
	<a rel="nofollow"  href="http://www.xcombinator.com/feed/" title="RSS"><img src="http://www.xcombinator.com/wp-content/plugins/sociable/images/rss.png" title="RSS" alt="RSS" class="sociable-hovers" /></a></p>
<p><br/><br/></p>
]]></content:encoded>
			<wfw:commentRss>http://www.xcombinator.com/2009/07/17/fixing-the-disabled-snapshot-button-in-vmware-fusion/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		<feedburner:origLink>http://www.xcombinator.com/2009/07/17/fixing-the-disabled-snapshot-button-in-vmware-fusion/</feedburner:origLink></item>
		<item>
		<title>automate installing tripwire using expect</title>
		<link>http://feedproxy.google.com/~r/xcombinator/~3/z6Bokq1QaMg/</link>
		<comments>http://www.xcombinator.com/2009/07/10/automate-installing-tripwire-using-expect/#comments</comments>
		<pubDate>Fri, 10 Jul 2009 21:48:06 +0000</pubDate>
		<dc:creator>Nate Murray</dc:creator>
				<category><![CDATA[deployment]]></category>
		<category><![CDATA[programming]]></category>
		<category><![CDATA[shell]]></category>
		<category><![CDATA[sysadmin]]></category>
		<category><![CDATA[tips]]></category>

		<guid isPermaLink="false">http://www.xcombinator.com/2009/07/10/automate-installing-tripwire-using-expect/</guid>
		<description><![CDATA[tripwire is a handy part of an intrusion detection system. It&#8217;s a nice piece of software but the installer is interactive which makes it a pain to install automatically (e.g. when using PoolParty/EC2). Below is a simple expect script I whipped up to solve the make install problem. Hopefully this will save someone two or [...]]]></description>
			<content:encoded><![CDATA[<p><a href="http://sourceforge.net/projects/tripwire/"><tt>tripwire</tt></a> is a handy part of an intrusion detection system. It&#8217;s a nice piece of software but the installer is interactive which makes it a pain to install automatically (e.g. when using PoolParty/EC2). Below is a simple <tt>expect</tt> script I whipped up to solve the <tt>make install</tt> problem. Hopefully this will save someone two or three minutes.</p>

<div class="wp_syntax"><div class="code"><pre class="shell" style="font-family:monospace;"># Usage: expect install-tripwire.tcl pass1 pass2 
set PASS1 [lindex $argv 0]
set PASS2 [lindex $argv 1]
&nbsp;
spawn make install
&nbsp;
expect &quot;Press ENTER to view the License Agreement.&quot;
send &quot;\r&quot;
send &quot;q&quot;
expect &quot;license agreement. \[do not accept\]&quot;
send &quot;accept\r&quot;
expect &quot;Continue with installation? \[y/n\]&quot;
send &quot;y\r&quot;
&nbsp;
expect &quot;Enter the site keyfile passphrase:&quot;
send &quot;$PASS1\r&quot;
expect &quot;Verify the site keyfile passphrase:&quot;
send &quot;$PASS1\r&quot;
&nbsp;
expect &quot;Enter the local keyfile passphrase:&quot;
send &quot;$PASS2\r&quot;
expect &quot;Verify the local keyfile passphrase:&quot;
send &quot;$PASS2\r&quot;
&nbsp;
expect &quot;Please enter your site passphrase:&quot;
send &quot;$PASS1\r&quot;
&nbsp;
expect &quot;Please enter your site passphrase:&quot;
send &quot;$PASS1\r&quot;</pre></div></div>

<p>Share:</p>
<p>	<a rel="nofollow"  href="http://delicious.com/post?url=http%3A%2F%2Fwww.xcombinator.com%2F2009%2F07%2F10%2Fautomate-installing-tripwire-using-expect%2F&amp;title=automate%20installing%20tripwire%20using%20expect&amp;notes=tripwire%20is%20a%20handy%20part%20of%20an%20intrusion%20detection%20system.%20It%27s%20a%20nice%20piece%20of%20software%20but%20the%20installer%20is%20interactive%20which%20makes%20it%20a%20pain%20to%20install%20automatically%20%28e.g.%20when%20using%20PoolParty%2FEC2%29.%20Below%20is%20a%20simple%20expect%20script%20I%20whipped%20up%20to%20" title="del.icio.us"><img src="http://www.xcombinator.com/wp-content/plugins/sociable/images/delicious.png" title="del.icio.us" alt="del.icio.us" class="sociable-hovers" /></a><br />
	<a rel="nofollow"  href="http://reddit.com/submit?url=http%3A%2F%2Fwww.xcombinator.com%2F2009%2F07%2F10%2Fautomate-installing-tripwire-using-expect%2F&amp;title=automate%20installing%20tripwire%20using%20expect" title="Reddit"><img src="http://www.xcombinator.com/wp-content/plugins/sociable/images/reddit.png" title="Reddit" alt="Reddit" class="sociable-hovers" /></a><br />
	<a rel="nofollow"  href="http://technorati.com/faves?add=http%3A%2F%2Fwww.xcombinator.com%2F2009%2F07%2F10%2Fautomate-installing-tripwire-using-expect%2F" title="Technorati"><img src="http://www.xcombinator.com/wp-content/plugins/sociable/images/technorati.png" title="Technorati" alt="Technorati" class="sociable-hovers" /></a><br />
	<a rel="nofollow"  href="http://twitter.com/home?status=automate%20installing%20tripwire%20using%20expect%20-%20http%3A%2F%2Fwww.xcombinator.com%2F2009%2F07%2F10%2Fautomate-installing-tripwire-using-expect%2F" title="Twitter"><img src="http://www.xcombinator.com/wp-content/plugins/sociable/images/twitter.png" title="Twitter" alt="Twitter" class="sociable-hovers" /></a><br />
	<a rel="nofollow"  href="http://www.facebook.com/share.php?u=http%3A%2F%2Fwww.xcombinator.com%2F2009%2F07%2F10%2Fautomate-installing-tripwire-using-expect%2F&amp;t=automate%20installing%20tripwire%20using%20expect" title="Facebook"><img src="http://www.xcombinator.com/wp-content/plugins/sociable/images/facebook.png" title="Facebook" alt="Facebook" class="sociable-hovers" /></a><br />
	<a rel="nofollow"  href="http://www.google.com/bookmarks/mark?op=edit&amp;bkmk=http%3A%2F%2Fwww.xcombinator.com%2F2009%2F07%2F10%2Fautomate-installing-tripwire-using-expect%2F&amp;title=automate%20installing%20tripwire%20using%20expect&amp;annotation=tripwire%20is%20a%20handy%20part%20of%20an%20intrusion%20detection%20system.%20It%27s%20a%20nice%20piece%20of%20software%20but%20the%20installer%20is%20interactive%20which%20makes%20it%20a%20pain%20to%20install%20automatically%20%28e.g.%20when%20using%20PoolParty%2FEC2%29.%20Below%20is%20a%20simple%20expect%20script%20I%20whipped%20up%20to%20" title="Google Bookmarks"><img src="http://www.xcombinator.com/wp-content/plugins/sociable/images/googlebookmark.png" title="Google Bookmarks" alt="Google Bookmarks" class="sociable-hovers" /></a><br />
	<a rel="nofollow"  href="http://news.ycombinator.com/submitlink?u=http%3A%2F%2Fwww.xcombinator.com%2F2009%2F07%2F10%2Fautomate-installing-tripwire-using-expect%2F&amp;t=automate%20installing%20tripwire%20using%20expect" title="HackerNews"><img src="http://www.xcombinator.com/wp-content/plugins/sociable/images/hackernews.png" title="HackerNews" alt="HackerNews" class="sociable-hovers" /></a><br />
	<a rel="nofollow"  href="http://www.printfriendly.com/print?url=http%3A%2F%2Fwww.xcombinator.com%2F2009%2F07%2F10%2Fautomate-installing-tripwire-using-expect%2F&amp;partner=sociable" title="PDF"><img src="http://www.xcombinator.com/wp-content/plugins/sociable/images/pdf.png" title="PDF" alt="PDF" class="sociable-hovers" /></a><br />
	<a rel="nofollow"  href="http://www.xcombinator.com/feed/" title="RSS"><img src="http://www.xcombinator.com/wp-content/plugins/sociable/images/rss.png" title="RSS" alt="RSS" class="sociable-hovers" /></a></p>
<p><br/><br/></p>
]]></content:encoded>
			<wfw:commentRss>http://www.xcombinator.com/2009/07/10/automate-installing-tripwire-using-expect/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		<feedburner:origLink>http://www.xcombinator.com/2009/07/10/automate-installing-tripwire-using-expect/</feedburner:origLink></item>
		<item>
		<title>“Easily” setup a monitored Hadoop / Hive Cluster in EC2 with PoolParty</title>
		<link>http://feedproxy.google.com/~r/xcombinator/~3/LzbeXhUOZtg/</link>
		<comments>http://www.xcombinator.com/2009/07/08/easily-setup-a-monitored-hadoop-hive-cluster-in-ec2-with-poolparty/#comments</comments>
		<pubDate>Wed, 08 Jul 2009 14:13:34 +0000</pubDate>
		<dc:creator>Nate Murray</dc:creator>
				<category><![CDATA[hadoop]]></category>
		<category><![CDATA[poolparty]]></category>
		<category><![CDATA[programming]]></category>
		<category><![CDATA[ruby]]></category>
		<category><![CDATA[scalability]]></category>

		<guid isPermaLink="false">http://www.xcombinator.com/2009/07/08/easily-setup-a-monitored-hadoop-hive-cluster-in-ec2-with-poolparty/</guid>
		<description><![CDATA[
Summary
Setting up a scalable Hadoop cluster isn&#8217;t easy, but PoolParty makes it easier
and manageable.
By the time we&#8217;re done with this tutorial you&#8217;ll have a Hadoop cluster consisting of one master node and two slaves.  The slaves are formatted with HDFS and process MapReduce jobs that are delegated to them from the master. 

The whole [...]]]></description>
			<content:encoded><![CDATA[<p></p>
<h1>Summary</h1>
<p>Setting up a scalable Hadoop cluster isn&#8217;t easy, but PoolParty makes it easier<br />
and manageable.</p>
<p>By the time we&#8217;re done with this tutorial you&#8217;ll have a Hadoop cluster consisting of one master node and two slaves.  The slaves are formatted with HDFS and process MapReduce jobs that are delegated to them from the master.<br /> 
</p>
<p>The whole cluster is monitored by Ganglia.</p>
<p> <a href='http://www.xcombinator.com/wp-content/uploads/2009/07/picture-8.png' title='ganglia cluster monitoring'><img src='http://www.xcombinator.com/wp-content/uploads/2009/07/picture-8.thumbnail.png' alt='ganglia cluster monitoring' /></a></p>
<h1>Benefits of PoolParty</h1>
<p>The nodes are very interdependent. By that I mean that each node needs to have 2 or 3 configuration files that are based on the other currently running nodes in the cluster. As nodes are joining and leaving the cluster each of these files on every node needs to be updated. PoolParty handles this process for you more-or-less automatically. The benefit is that you don&#8217;t have roll your own methods to do this every time you want to setup a cluster. </p>
<p>In PoolParty plugins are first-class citizens. This means you can write your own plugins and they are every bit as powerful as the resources that make up PoolParty core itself. This makes it easy to break up server functionality into <em>modules of code</em> . PoolParty, in a sense, gives you object-oriented server configurations. You can, for instance, take a Ganglia object, call a few methods and PoolParty takes care of executing the required commands to deploy a configured Ganglia cluster.</p>
<h1>Architecture </h1>
<p>PoolParty is built around the notion of <em>pools</em> and <em>clouds</em> . A pool is simply a collection of clouds. A cloud is a homogeneous set of nodes. i.e. <strong>every node in a cloud is <em>configured</em> the same way</strong> . Obviously nodes in a cloud will have different sets of working data as they run, but the idea is any node in a cloud could be substituted for any other node in that same cloud.<br /> 
</p>
<p>PoolParty itself is designed to be fully distributed and masterless. There is no required concept of &#8220;master&#8221; and &#8220;slave&#8221; in PoolParty itself. That said, many pieces of software, such as Hadoop, do have this concept and PoolParty can be configured to take advantage of that. </p>
<p>We&#8217;ll be setting up our pool as two clouds <code>hadoop_master</code> and <code>hadoop_slave</code>. Obviously, <code>hadoop_slave</code> will be a cloud (cluster) of nodes configured to be Hadoop slaves. <code>hadoop_master</code> will also be a cloud of masters. In our example we&#8217;re only going to use 1 node as the master. But  you could relatively easily configure everything to have more than one master.<br /> 
</p>
<h1>Software involved</h1>
<ul>
<li><a href="http://hadoop.apache.org/core/">Hadoop</a> </li>
<li><a href="http://wiki.apache.org/hadoop/Hive">Hive</a></li>
<li><a href="http://ganglia.info/">Ganglia</a></li>
<li><a href="http://poolpartyrb.com">PoolParty</a></li>
</ul>
<h1>Prerequisites</h1>
<p>This tutorial assumes that:</p>
<ol>
<li><strong>You have Amazon EC2 java tools installed</strong>. See <a href="http://docs.amazonwebservices.com/AWSEC2/latest/GettingStartedGuide/index.html?StartCLI.html">EC2: Getting Started with the Command Line Tools</a></li>
<li><strong>You have the proper EC2 environment variables setup</strong>. See <a href="http://auser.github.com/poolparty/amazon_ec2_setup.html">Setting up EC2</a> on the PoolParty website. For instance, a typical PoolParty install would have these variables in <code>$HOME/.ec2/keys_and_secrets.sh</code>.</li>
<li><strong>You have PoolParty installed from source</strong>. In theory, you should be able to install the gem. However, <em>today</em>  you should probably install from source. Make sure you have <code>git://github.com/auser/poolparty.git</code> checked out and then follow the &#8220;Installing&#8221; directions on <a href="http://wiki.github.com/auser/poolparty/installing">the PoolParty wiki</a>. You only need to complete the two sections <strong>Dependencies required to build gem locally</strong> and <strong>Instructions</strong> . This will install all the development dependency gems and then make sure you have all of the submodules. <strong>NOTE</strong> PoolParty deploys ruby gem versions based on the versions on your <em>local</em> machine. So make sure you have the most recent versions of the required gems installed locally.</li>
<li><strong>You have the <a href="http://github.com/jashmenn/poolparty-examples/tree/master">jashmenn/poolparty-examples</a> repository</strong>. <code>git clone git://github.com/jashmenn/poolparty-examples.git /path/to/poolparty-examples</code> </li>
<li><strong>You have the <a href="http://github.com/jashmenn/poolparty-extensions/tree/master">jashmenn/poolparty-extensions</a> repository</strong>. Note that this directory must be a <em>sibling</em> directory to the <code>poolparty-examples</code> directory. <code>git clone git://github.com/jashmenn/poolparty-extensions.git /path/to/poolparty-extensions</code></li>
</ol>
<h1>EC2 Security</h1>
<p>Now that we have the code issue complete, we now need to deal with Amazon&#8217;s security. (See <a href="http://auser.github.com/poolparty/amazon.html">here</a> if you are unclear on how EC2 security works.)</p>
<h2>Setup Keypairs</h2>
<hr />
<p>Every cloud in PoolParty must have its own unique keypair. Thats important enough it&#8217;s worth repeating: <em>every cloud in PoolParty must have its own unique keypair</em> .</p>
<p>So run the following commands:</p>

<div class="wp_syntax"><div class="code"><pre class="shell" style="font-family:monospace;">ec2-add-keypair cloud_hadoop_slave &amp;gt; ~/.ssh/cloud_hadoop_slave
ec2-add-keypair cloud_hadoop_master &amp;gt; ~/.ssh/cloud_hadoop_master
chmod 600 ~/.ssh/cloud_hadoop_*</pre></div></div>

<h2>Security Groups</h2>
<hr />
<p>You&#8217;ll also want to create a security group for our <em>pool</em> . </p>

<div class="wp_syntax"><div class="code"><pre class="shell" style="font-family:monospace;">ec2-add-group hadoop_pool -d &quot;the pool of hadoop masters and slaves&quot;</pre></div></div>

<p><strong>NOTICE:</strong> Hadoop has a crazy number of ports that it requires. The ports below will <em>work</em> but may not be the most secure configuration. If you understand this better than I please recommend better settings. Otherwise proceed knowing that these ports are probably a little <em>too</em> open.</p>
<p>We also need to open a number of ports for this security group:</p>

<div class="wp_syntax"><div class="code"><pre class="shell" style="font-family:monospace;">&lt;code&gt;ec2-authorize -p 22 hadoop_pool               # ssh
ec2-authorize -p 8642 hadoop_pool             # poolparty internal daemons
ec2-authorize -P icmp -t -1:-1 hadoop_pool    # if you want to ping (optional, i guess)
ec2-authorize -p 80 hadoop_pool               # apache
&nbsp;
ec2-authorize -p 8649 -P udp hadoop_pool      # ganglia UDP
ec2-authorize hadoop_pool -o hadoop_pool -u xxxxxxxxxxxx # xxxxxxxxxxxx is your amazon account id. ugly but true
&lt;/code&gt;</pre></div></div>

<h1>Start your cloud</h1>
<p><strong>NOTE</strong> : There are a number of configurations that rely on the whole cloud being booted. This means that the first time you run <code>cloud-start</code> you may see a few shell errors. This is okay as long as it goes away after subsequent configures. The idea is that all nodes need to be started before the whole configuration will work properly.</p>

<div class="wp_syntax"><div class="code"><pre class="shell" style="font-family:monospace;">cd /path/to/poolparty-examples/hadoop
cloud-list # sanity check, no instances should show up, no exceptions should be raised
cloud-start -vd</pre></div></div>

<p><em>Tons</em>  of information will fly by. Be patient, this could take upwards of 15 minutes. </p>
<p>Everything done? Good. Now you&#8217;re going to need to configure a second time. Now that all the nodes are booted they can be configured to talk to each other properly.</p>

<div class="wp_syntax"><div class="code"><pre class="shell" style="font-family:monospace;">cloud-configure -vd</pre></div></div>

<p>Again, tons of output should fly by. Wait for it to finish.</p>
<p>Now what we want to do is actually run our hadoop sample job. Open up the <code>hadoop/clouds.rb</code> and find the lines that look like this:</p>

<div class="wp_syntax"><div class="code"><pre class="ruby" style="font-family:monospace;">hadoop <span style="color:#9966CC; font-weight:bold;">do</span>
  configure_master
  prep_example_job
  <span style="color:#008000; font-style:italic;"># run_example_job</span>
<span style="color:#9966CC; font-weight:bold;">end</span></pre></div></div>

<p>Uncomment the <code>run_example_job</code> line and configure, but this time we only need to configure master.</p>

<div class="wp_syntax"><div class="code"><pre class="shell" style="font-family:monospace;">cloud-configure -vd -c hadoop_master</pre></div></div>

<p>This <em>should</em> work, but there is a chance the hdfs wont be started in time to load the sample job. If that happens, just configure one more time.<br />
You know it worked if you see output like the following (it wont be at the bottom):</p>
<pre>[Fri, 26 Jun 2009 20:09:50 +0000] DEBUG: STDERR: 09/06/26 20:09:11 INFO input.FileInputFormat: Total input paths to process : 3
09/06/26 20:09:12 INFO mapred.JobClient: Running job: job_200906262006_0001
09/06/26 20:09:13 INFO mapred.JobClient:  map 0% reduce 0%
09/06/26 20:09:32 INFO mapred.JobClient:  map 66% reduce 0%
09/06/26 20:09:38 INFO mapred.JobClient:  map 100% reduce 0%
09/06/26 20:09:47 INFO mapred.JobClient:  map 100% reduce 100%
09/06/26 20:09:49 INFO mapred.JobClient: Job complete: job_200906262006_0001
09/06/26 20:09:49 INFO mapred.JobClient: Counters: 17
</pre>
<p>Congradulations! You now have a scalable Hadoop cluster at your disposal!</p>
<h1>What to do when something goes wrong</h1>
<ul>
<li>Checkout the <a href="http://auser.github.com/poolparty/community.html">PoolParty IRC channel</a>, we&#8217;re always around and ready to help #poolpartyrb. </li>
</ul>
<p>This plugin was based on a number of helpful sites on the web. Checkout the following links:</p>
<h2>Hadoop</h2>
<hr />
<ul>
<li><a href="http://www.michael-noll.com/wiki/Running_Hadoop_On_Ubuntu_Linux_(Multi-Node_Cluster">Michael Noll&#8217;s Haddop Tutorial</a>)</li>
</ul>
<h2>Hive</h2>
<hr />
<ul>
<li><a href="http://wiki.apache.org/hadoop/Hive">Apache&#8217;s Hive website</a></li>
</ul>
<h2>Ganglia</h2>
<hr />
<ul>
<li><a href="http://www.ibm.com/developerworks/wikis/display/WikiPtype/ganglia">IBM&#8217;s Ganglia Tutorial</a></li>
</ul>
<h1>References</h1>
<ul>
<li><a href="http://auser.github.com/poolparty/docs/index.html">PoolParty Documentation</a></li>
</ul>
<p>Share:</p>
<p>	<a rel="nofollow"  href="http://delicious.com/post?url=http%3A%2F%2Fwww.xcombinator.com%2F2009%2F07%2F08%2Feasily-setup-a-monitored-hadoop-hive-cluster-in-ec2-with-poolparty%2F&amp;title=%22Easily%22%20setup%20a%20monitored%20Hadoop%20%2F%20Hive%20Cluster%20in%20EC2%20with%20PoolParty&amp;notes=%20%0D%0A%20%0D%0ASummary%20%0D%0A%20%0D%0ASetting%20up%20a%20scalable%20Hadoop%20cluster%20isn%27t%20easy%2C%20but%20PoolParty%20makes%20it%20easier%0D%0Aand%20manageable.%20%0D%0A%20%0D%0ABy%20the%20time%20we%27re%20done%20with%20this%20tutorial%20you%27ll%20have%20a%20Hadoop%20cluster%20consisting%20of%20one%20master%20node%20and%20two%20slaves.%20%20The%20slaves%20a" title="del.icio.us"><img src="http://www.xcombinator.com/wp-content/plugins/sociable/images/delicious.png" title="del.icio.us" alt="del.icio.us" class="sociable-hovers" /></a><br />
	<a rel="nofollow"  href="http://reddit.com/submit?url=http%3A%2F%2Fwww.xcombinator.com%2F2009%2F07%2F08%2Feasily-setup-a-monitored-hadoop-hive-cluster-in-ec2-with-poolparty%2F&amp;title=%22Easily%22%20setup%20a%20monitored%20Hadoop%20%2F%20Hive%20Cluster%20in%20EC2%20with%20PoolParty" title="Reddit"><img src="http://www.xcombinator.com/wp-content/plugins/sociable/images/reddit.png" title="Reddit" alt="Reddit" class="sociable-hovers" /></a><br />
	<a rel="nofollow"  href="http://technorati.com/faves?add=http%3A%2F%2Fwww.xcombinator.com%2F2009%2F07%2F08%2Feasily-setup-a-monitored-hadoop-hive-cluster-in-ec2-with-poolparty%2F" title="Technorati"><img src="http://www.xcombinator.com/wp-content/plugins/sociable/images/technorati.png" title="Technorati" alt="Technorati" class="sociable-hovers" /></a><br />
	<a rel="nofollow"  href="http://twitter.com/home?status=%22Easily%22%20setup%20a%20monitored%20Hadoop%20%2F%20Hive%20Cluster%20in%20EC2%20with%20PoolParty%20-%20http%3A%2F%2Fwww.xcombinator.com%2F2009%2F07%2F08%2Feasily-setup-a-monitored-hadoop-hive-cluster-in-ec2-with-poolparty%2F" title="Twitter"><img src="http://www.xcombinator.com/wp-content/plugins/sociable/images/twitter.png" title="Twitter" alt="Twitter" class="sociable-hovers" /></a><br />
	<a rel="nofollow"  href="http://www.facebook.com/share.php?u=http%3A%2F%2Fwww.xcombinator.com%2F2009%2F07%2F08%2Feasily-setup-a-monitored-hadoop-hive-cluster-in-ec2-with-poolparty%2F&amp;t=%22Easily%22%20setup%20a%20monitored%20Hadoop%20%2F%20Hive%20Cluster%20in%20EC2%20with%20PoolParty" title="Facebook"><img src="http://www.xcombinator.com/wp-content/plugins/sociable/images/facebook.png" title="Facebook" alt="Facebook" class="sociable-hovers" /></a><br />
	<a rel="nofollow"  href="http://www.google.com/bookmarks/mark?op=edit&amp;bkmk=http%3A%2F%2Fwww.xcombinator.com%2F2009%2F07%2F08%2Feasily-setup-a-monitored-hadoop-hive-cluster-in-ec2-with-poolparty%2F&amp;title=%22Easily%22%20setup%20a%20monitored%20Hadoop%20%2F%20Hive%20Cluster%20in%20EC2%20with%20PoolParty&amp;annotation=%20%0D%0A%20%0D%0ASummary%20%0D%0A%20%0D%0ASetting%20up%20a%20scalable%20Hadoop%20cluster%20isn%27t%20easy%2C%20but%20PoolParty%20makes%20it%20easier%0D%0Aand%20manageable.%20%0D%0A%20%0D%0ABy%20the%20time%20we%27re%20done%20with%20this%20tutorial%20you%27ll%20have%20a%20Hadoop%20cluster%20consisting%20of%20one%20master%20node%20and%20two%20slaves.%20%20The%20slaves%20a" title="Google Bookmarks"><img src="http://www.xcombinator.com/wp-content/plugins/sociable/images/googlebookmark.png" title="Google Bookmarks" alt="Google Bookmarks" class="sociable-hovers" /></a><br />
	<a rel="nofollow"  href="http://news.ycombinator.com/submitlink?u=http%3A%2F%2Fwww.xcombinator.com%2F2009%2F07%2F08%2Feasily-setup-a-monitored-hadoop-hive-cluster-in-ec2-with-poolparty%2F&amp;t=%22Easily%22%20setup%20a%20monitored%20Hadoop%20%2F%20Hive%20Cluster%20in%20EC2%20with%20PoolParty" title="HackerNews"><img src="http://www.xcombinator.com/wp-content/plugins/sociable/images/hackernews.png" title="HackerNews" alt="HackerNews" class="sociable-hovers" /></a><br />
	<a rel="nofollow"  href="http://www.printfriendly.com/print?url=http%3A%2F%2Fwww.xcombinator.com%2F2009%2F07%2F08%2Feasily-setup-a-monitored-hadoop-hive-cluster-in-ec2-with-poolparty%2F&amp;partner=sociable" title="PDF"><img src="http://www.xcombinator.com/wp-content/plugins/sociable/images/pdf.png" title="PDF" alt="PDF" class="sociable-hovers" /></a><br />
	<a rel="nofollow"  href="http://www.xcombinator.com/feed/" title="RSS"><img src="http://www.xcombinator.com/wp-content/plugins/sociable/images/rss.png" title="RSS" alt="RSS" class="sociable-hovers" /></a></p>
<p><br/><br/></p>
]]></content:encoded>
			<wfw:commentRss>http://www.xcombinator.com/2009/07/08/easily-setup-a-monitored-hadoop-hive-cluster-in-ec2-with-poolparty/feed/</wfw:commentRss>
		<slash:comments>1</slash:comments>
		<feedburner:origLink>http://www.xcombinator.com/2009/07/08/easily-setup-a-monitored-hadoop-hive-cluster-in-ec2-with-poolparty/</feedburner:origLink></item>
		<item>
		<title>git-style-binaries screencast</title>
		<link>http://feedproxy.google.com/~r/xcombinator/~3/5kfwwahUV3E/</link>
		<comments>http://www.xcombinator.com/2009/06/10/git-style-binaries-screencast/#comments</comments>
		<pubDate>Wed, 10 Jun 2009 18:16:44 +0000</pubDate>
		<dc:creator>Nate Murray</dc:creator>
				<category><![CDATA[code]]></category>
		<category><![CDATA[gems]]></category>
		<category><![CDATA[git]]></category>
		<category><![CDATA[programming]]></category>
		<category><![CDATA[ruby]]></category>

		<guid isPermaLink="false">http://www.xcombinator.com/2009/06/10/git-style-binaries-screencast/</guid>
		<description><![CDATA[Just released: git-style-binaries ruby gem. Checkout the README on github.
Checkout the screencast.

Share:
	
	
	
	
	
	
	
	
	

]]></description>
			<content:encoded><![CDATA[<p>Just released: git-style-binaries ruby gem. Checkout <a href="http://github.com/jashmenn/git-style-binaries">the README on github</a>.</p>
<p>Checkout <a href="http://www.xcombinator.com/movies/git-style-binaries.mov">the screencast</a>.</p>
<p><a href='http://www.xcombinator.com/movies/git-style-binaries.mov' title='gsb-screencast'><img src='http://www.xcombinator.com/wp-content/uploads/2009/06/gsb-screencast1.png' alt='gsb-screencast1.png' /></a></p>
<p>Share:</p>
<p>	<a rel="nofollow"  href="http://delicious.com/post?url=http%3A%2F%2Fwww.xcombinator.com%2F2009%2F06%2F10%2Fgit-style-binaries-screencast%2F&amp;title=git-style-binaries%20screencast&amp;notes=Just%20released%3A%20git-style-binaries%20ruby%20gem.%20Checkout%20the%20README%20on%20github.%0D%0A%0D%0ACheckout%20the%20screencast.%0D%0A%0D%0A%0D%0A%0D%0A" title="del.icio.us"><img src="http://www.xcombinator.com/wp-content/plugins/sociable/images/delicious.png" title="del.icio.us" alt="del.icio.us" class="sociable-hovers" /></a><br />
	<a rel="nofollow"  href="http://reddit.com/submit?url=http%3A%2F%2Fwww.xcombinator.com%2F2009%2F06%2F10%2Fgit-style-binaries-screencast%2F&amp;title=git-style-binaries%20screencast" title="Reddit"><img src="http://www.xcombinator.com/wp-content/plugins/sociable/images/reddit.png" title="Reddit" alt="Reddit" class="sociable-hovers" /></a><br />
	<a rel="nofollow"  href="http://technorati.com/faves?add=http%3A%2F%2Fwww.xcombinator.com%2F2009%2F06%2F10%2Fgit-style-binaries-screencast%2F" title="Technorati"><img src="http://www.xcombinator.com/wp-content/plugins/sociable/images/technorati.png" title="Technorati" alt="Technorati" class="sociable-hovers" /></a><br />
	<a rel="nofollow"  href="http://twitter.com/home?status=git-style-binaries%20screencast%20-%20http%3A%2F%2Fwww.xcombinator.com%2F2009%2F06%2F10%2Fgit-style-binaries-screencast%2F" title="Twitter"><img src="http://www.xcombinator.com/wp-content/plugins/sociable/images/twitter.png" title="Twitter" alt="Twitter" class="sociable-hovers" /></a><br />
	<a rel="nofollow"  href="http://www.facebook.com/share.php?u=http%3A%2F%2Fwww.xcombinator.com%2F2009%2F06%2F10%2Fgit-style-binaries-screencast%2F&amp;t=git-style-binaries%20screencast" title="Facebook"><img src="http://www.xcombinator.com/wp-content/plugins/sociable/images/facebook.png" title="Facebook" alt="Facebook" class="sociable-hovers" /></a><br />
	<a rel="nofollow"  href="http://www.google.com/bookmarks/mark?op=edit&amp;bkmk=http%3A%2F%2Fwww.xcombinator.com%2F2009%2F06%2F10%2Fgit-style-binaries-screencast%2F&amp;title=git-style-binaries%20screencast&amp;annotation=Just%20released%3A%20git-style-binaries%20ruby%20gem.%20Checkout%20the%20README%20on%20github.%0D%0A%0D%0ACheckout%20the%20screencast.%0D%0A%0D%0A%0D%0A%0D%0A" title="Google Bookmarks"><img src="http://www.xcombinator.com/wp-content/plugins/sociable/images/googlebookmark.png" title="Google Bookmarks" alt="Google Bookmarks" class="sociable-hovers" /></a><br />
	<a rel="nofollow"  href="http://news.ycombinator.com/submitlink?u=http%3A%2F%2Fwww.xcombinator.com%2F2009%2F06%2F10%2Fgit-style-binaries-screencast%2F&amp;t=git-style-binaries%20screencast" title="HackerNews"><img src="http://www.xcombinator.com/wp-content/plugins/sociable/images/hackernews.png" title="HackerNews" alt="HackerNews" class="sociable-hovers" /></a><br />
	<a rel="nofollow"  href="http://www.printfriendly.com/print?url=http%3A%2F%2Fwww.xcombinator.com%2F2009%2F06%2F10%2Fgit-style-binaries-screencast%2F&amp;partner=sociable" title="PDF"><img src="http://www.xcombinator.com/wp-content/plugins/sociable/images/pdf.png" title="PDF" alt="PDF" class="sociable-hovers" /></a><br />
	<a rel="nofollow"  href="http://www.xcombinator.com/feed/" title="RSS"><img src="http://www.xcombinator.com/wp-content/plugins/sociable/images/rss.png" title="RSS" alt="RSS" class="sociable-hovers" /></a></p>
<p><br/><br/></p>
]]></content:encoded>
			<wfw:commentRss>http://www.xcombinator.com/2009/06/10/git-style-binaries-screencast/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>

		<feedburner:origLink>http://www.xcombinator.com/2009/06/10/git-style-binaries-screencast/</feedburner:origLink><enclosure url="http://feedproxy.google.com/~r/xcombinator/~5/jmBJXkECgRw/git-style-binaries.mov" length="135240332" type="video/quicktime" /><feedburner:origEnclosureLink>http://www.xcombinator.com/movies/git-style-binaries.mov</feedburner:origEnclosureLink></item>
		<item>
		<title>adding macruby to multiruby versions</title>
		<link>http://feedproxy.google.com/~r/xcombinator/~3/MVC0Bdn9dPk/</link>
		<comments>http://www.xcombinator.com/2009/05/22/adding-macruby-to-multiruby-versions/#comments</comments>
		<pubDate>Fri, 22 May 2009 21:11:20 +0000</pubDate>
		<dc:creator>Nate Murray</dc:creator>
				<category><![CDATA[ruby]]></category>
		<category><![CDATA[tips]]></category>

		<guid isPermaLink="false">http://www.xcombinator.com/2009/05/22/adding-macruby-to-multiruby-versions/</guid>
		<description><![CDATA[Modified from Rob Seaman&#8217;s post.
multiruby is a great way to make sure your ruby code runs on the multitude of ruby versions (it&#8217;s part of ZenTest). It doesn&#8217;t install macruby by default. Here are instructions on how to set it up.
Since I installed macruby from the package installer my macruby files are in /Library/Frameworks/MacRuby.framework/Versions/0.4/. If [...]]]></description>
			<content:encoded><![CDATA[<p>Modified from <a href="http://blog.robseaman.com/2008/12/21/adding-jruby-to-multiruby-versions">Rob Seaman&#8217;s post</a>.</p>
<p>multiruby is a great way to make sure your ruby code runs on the multitude of ruby versions (it&#8217;s part of ZenTest). It doesn&#8217;t install macruby by default. Here are instructions on how to set it up.</p>
<p>Since I installed macruby from the <a href="http://www.macruby.org/">package installer</a> my macruby files are in <code>/Library/Frameworks/MacRuby.framework/Versions/0.4/</code>. If your macruby files are somewhere else, adjust accordingly.</p>
<p>First make sure you already have multiruby setup for other versions (don&#8217;t proceed if this doesn&#8217;t work):<br />
<code><br />
multiruby_setup the_usual<br />
</code></p>
<p>One problem I had with the above command was that I had <code>RUBYOPT</code> set in my .profile. This was calling each of these ruby versions with <code>RUBYOPT=rubygems</code> when trying to install. This won&#8217;t work because rubygems is one of the things you&#8217;re trying to install. Make sure you unset this variable etc. before trying to setup multiruby.</p>

<div class="wp_syntax"><div class="code"><pre class="ruby" style="font-family:monospace;">ln <span style="color:#006600; font-weight:bold;">-</span>s <span style="color:#006600; font-weight:bold;">/</span>Library<span style="color:#006600; font-weight:bold;">/</span>Frameworks<span style="color:#006600; font-weight:bold;">/</span>MacRuby.<span style="color:#9900CC;">framework</span><span style="color:#006600; font-weight:bold;">/</span>Versions<span style="color:#006600; font-weight:bold;">/</span><span style="color:#006666;">0.4</span><span style="color:#006600; font-weight:bold;">/</span>usr ~<span style="color:#006600; font-weight:bold;">/</span>.<span style="color:#9900CC;">multiruby</span><span style="color:#006600; font-weight:bold;">/</span>install<span style="color:#006600; font-weight:bold;">/</span>macruby<span style="color:#006600; font-weight:bold;">-</span>0.0.4
sudo ln <span style="color:#006600; font-weight:bold;">-</span>s ~<span style="color:#006600; font-weight:bold;">/</span>.<span style="color:#9900CC;">multiruby</span><span style="color:#006600; font-weight:bold;">/</span>install<span style="color:#006600; font-weight:bold;">/</span>macruby<span style="color:#006600; font-weight:bold;">-</span>0.0.4<span style="color:#006600; font-weight:bold;">/</span>bin<span style="color:#006600; font-weight:bold;">/</span>macruby ~<span style="color:#006600; font-weight:bold;">/</span>.<span style="color:#9900CC;">multiruby</span><span style="color:#006600; font-weight:bold;">/</span>install<span style="color:#006600; font-weight:bold;">/</span>macruby<span style="color:#006600; font-weight:bold;">-</span>0.0.4<span style="color:#006600; font-weight:bold;">/</span>bin<span style="color:#006600; font-weight:bold;">/</span>ruby
sudo ln <span style="color:#006600; font-weight:bold;">-</span>s ~<span style="color:#006600; font-weight:bold;">/</span>.<span style="color:#9900CC;">multiruby</span><span style="color:#006600; font-weight:bold;">/</span>install<span style="color:#006600; font-weight:bold;">/</span>macruby<span style="color:#006600; font-weight:bold;">-</span>0.0.4<span style="color:#006600; font-weight:bold;">/</span>bin<span style="color:#006600; font-weight:bold;">/</span>macgem ~<span style="color:#006600; font-weight:bold;">/</span>.<span style="color:#9900CC;">multiruby</span><span style="color:#006600; font-weight:bold;">/</span>install<span style="color:#006600; font-weight:bold;">/</span>macruby<span style="color:#006600; font-weight:bold;">-</span>0.0.4<span style="color:#006600; font-weight:bold;">/</span>bin<span style="color:#006600; font-weight:bold;">/</span>gem
touch ~<span style="color:#006600; font-weight:bold;">/</span>.<span style="color:#9900CC;">multiruby</span><span style="color:#006600; font-weight:bold;">/</span>versions<span style="color:#006600; font-weight:bold;">/</span>macruby<span style="color:#006600; font-weight:bold;">-</span>0.0.4.<span style="color:#9900CC;">tar</span>.<span style="color:#9900CC;">gz</span> <span style="color:#008000; font-style:italic;"># fake-out</span></pre></div></div>

<p>Now try:<br />
<code><br />
multiruby -e "p 1+1"<br />
</code></p>
<p>Share:</p>
<p>	<a rel="nofollow"  href="http://delicious.com/post?url=http%3A%2F%2Fwww.xcombinator.com%2F2009%2F05%2F22%2Fadding-macruby-to-multiruby-versions%2F&amp;title=adding%20macruby%20to%20multiruby%20versions&amp;notes=Modified%20from%20Rob%20Seaman%27s%20post.%0D%0A%0D%0Amultiruby%20is%20a%20great%20way%20to%20make%20sure%20your%20ruby%20code%20runs%20on%20the%20multitude%20of%20ruby%20versions%20%28it%27s%20part%20of%20ZenTest%29.%20It%20doesn%27t%20install%20macruby%20by%20default.%20Here%20are%20instructions%20on%20how%20to%20set%20it%20up.%0D%0A%0D%0ASince%20I%20insta" title="del.icio.us"><img src="http://www.xcombinator.com/wp-content/plugins/sociable/images/delicious.png" title="del.icio.us" alt="del.icio.us" class="sociable-hovers" /></a><br />
	<a rel="nofollow"  href="http://reddit.com/submit?url=http%3A%2F%2Fwww.xcombinator.com%2F2009%2F05%2F22%2Fadding-macruby-to-multiruby-versions%2F&amp;title=adding%20macruby%20to%20multiruby%20versions" title="Reddit"><img src="http://www.xcombinator.com/wp-content/plugins/sociable/images/reddit.png" title="Reddit" alt="Reddit" class="sociable-hovers" /></a><br />
	<a rel="nofollow"  href="http://technorati.com/faves?add=http%3A%2F%2Fwww.xcombinator.com%2F2009%2F05%2F22%2Fadding-macruby-to-multiruby-versions%2F" title="Technorati"><img src="http://www.xcombinator.com/wp-content/plugins/sociable/images/technorati.png" title="Technorati" alt="Technorati" class="sociable-hovers" /></a><br />
	<a rel="nofollow"  href="http://twitter.com/home?status=adding%20macruby%20to%20multiruby%20versions%20-%20http%3A%2F%2Fwww.xcombinator.com%2F2009%2F05%2F22%2Fadding-macruby-to-multiruby-versions%2F" title="Twitter"><img src="http://www.xcombinator.com/wp-content/plugins/sociable/images/twitter.png" title="Twitter" alt="Twitter" class="sociable-hovers" /></a><br />
	<a rel="nofollow"  href="http://www.facebook.com/share.php?u=http%3A%2F%2Fwww.xcombinator.com%2F2009%2F05%2F22%2Fadding-macruby-to-multiruby-versions%2F&amp;t=adding%20macruby%20to%20multiruby%20versions" title="Facebook"><img src="http://www.xcombinator.com/wp-content/plugins/sociable/images/facebook.png" title="Facebook" alt="Facebook" class="sociable-hovers" /></a><br />
	<a rel="nofollow"  href="http://www.google.com/bookmarks/mark?op=edit&amp;bkmk=http%3A%2F%2Fwww.xcombinator.com%2F2009%2F05%2F22%2Fadding-macruby-to-multiruby-versions%2F&amp;title=adding%20macruby%20to%20multiruby%20versions&amp;annotation=Modified%20from%20Rob%20Seaman%27s%20post.%0D%0A%0D%0Amultiruby%20is%20a%20great%20way%20to%20make%20sure%20your%20ruby%20code%20runs%20on%20the%20multitude%20of%20ruby%20versions%20%28it%27s%20part%20of%20ZenTest%29.%20It%20doesn%27t%20install%20macruby%20by%20default.%20Here%20are%20instructions%20on%20how%20to%20set%20it%20up.%0D%0A%0D%0ASince%20I%20insta" title="Google Bookmarks"><img src="http://www.xcombinator.com/wp-content/plugins/sociable/images/googlebookmark.png" title="Google Bookmarks" alt="Google Bookmarks" class="sociable-hovers" /></a><br />
	<a rel="nofollow"  href="http://news.ycombinator.com/submitlink?u=http%3A%2F%2Fwww.xcombinator.com%2F2009%2F05%2F22%2Fadding-macruby-to-multiruby-versions%2F&amp;t=adding%20macruby%20to%20multiruby%20versions" title="HackerNews"><img src="http://www.xcombinator.com/wp-content/plugins/sociable/images/hackernews.png" title="HackerNews" alt="HackerNews" class="sociable-hovers" /></a><br />
	<a rel="nofollow"  href="http://www.printfriendly.com/print?url=http%3A%2F%2Fwww.xcombinator.com%2F2009%2F05%2F22%2Fadding-macruby-to-multiruby-versions%2F&amp;partner=sociable" title="PDF"><img src="http://www.xcombinator.com/wp-content/plugins/sociable/images/pdf.png" title="PDF" alt="PDF" class="sociable-hovers" /></a><br />
	<a rel="nofollow"  href="http://www.xcombinator.com/feed/" title="RSS"><img src="http://www.xcombinator.com/wp-content/plugins/sociable/images/rss.png" title="RSS" alt="RSS" class="sociable-hovers" /></a></p>
<p><br/><br/></p>
]]></content:encoded>
			<wfw:commentRss>http://www.xcombinator.com/2009/05/22/adding-macruby-to-multiruby-versions/feed/</wfw:commentRss>
		<slash:comments>1</slash:comments>
		<feedburner:origLink>http://www.xcombinator.com/2009/05/22/adding-macruby-to-multiruby-versions/</feedburner:origLink></item>
		<item>
		<title>tweet twitter util – cli feedback on tweet length</title>
		<link>http://feedproxy.google.com/~r/xcombinator/~3/6pPhbO_VsrQ/</link>
		<comments>http://www.xcombinator.com/2009/05/21/tweet-twitter-util-cli-feedback-on-tweet-length/#comments</comments>
		<pubDate>Thu, 21 May 2009 15:01:21 +0000</pubDate>
		<dc:creator>Nate Murray</dc:creator>
				<category><![CDATA[ruby]]></category>
		<category><![CDATA[shell]]></category>
		<category><![CDATA[tips]]></category>

		<guid isPermaLink="false">http://www.xcombinator.com/2009/05/21/tweet-twitter-util-cli-feedback-on-tweet-length/</guid>
		<description><![CDATA[One of the nice things about the Twitter web-interface is that it gives you feedback on the number of characters you&#8217;ve typed so far.

 Since I use the command-line twitter gem (by John Nunemaker) I miss out on this feature and find myself using echo and wc to make sure I&#8217;m not over the limit.
To [...]]]></description>
			<content:encoded><![CDATA[<p>One of the nice things about the Twitter web-interface is that it gives you feedback on the number of characters you&#8217;ve typed so far.<a href='http://www.xcombinator.com/wp-content/uploads/2009/05/twitter-warning.png' title='twitter-warning.png'><img src='http://www.xcombinator.com/wp-content/uploads/2009/05/twitter-warning.thumbnail.png' alt='twitter-warning.png' /></a>
</p>
<p> Since I use the command-line <a href="http://twitter.rubyforge.org/"><tt>twitter</tt> gem</a> (by John Nunemaker) I miss out on this feature and find myself using <tt>echo</tt> and <tt>wc</tt> to make sure I&#8217;m not over the limit.</p>
<p>To fix this problem, I&#8217;ve written a small, immediate-feedback utility called <tt>tweet</tt>. It shows you the number of characters typed so far and colorizes them accordingly.</p>
<p> Screenshots: </p>
<p>warning:<br />
<a href='http://www.xcombinator.com/wp-content/uploads/2009/05/tweet-warning.png' title='tweet-warning.png'><img src='http://www.xcombinator.com/wp-content/uploads/2009/05/tweet-warning.png' alt='tweet-warning.png' /></a>
</p>
<p>over:<br />
<a href='http://www.xcombinator.com/wp-content/uploads/2009/05/tweet-overage.png' title='tweet-overage.png'><img src='http://www.xcombinator.com/wp-content/uploads/2009/05/tweet-overage.png' alt='tweet-overage.png' /></a>
</p>
<p>
Just download this script and save it as <tt>tweet</tt> somewhere in your <tt>$PATH</tt><br />
<script src="http://gist.github.com/112317.js"></script>
</p>
<p>Share:</p>
<p>	<a rel="nofollow"  href="http://delicious.com/post?url=http%3A%2F%2Fwww.xcombinator.com%2F2009%2F05%2F21%2Ftweet-twitter-util-cli-feedback-on-tweet-length%2F&amp;title=tweet%20twitter%20util%20-%20cli%20feedback%20on%20tweet%20length&amp;notes=One%20of%20the%20nice%20things%20about%20the%20Twitter%20web-interface%20is%20that%20it%20gives%20you%20feedback%20on%20the%20number%20of%20characters%20you%27ve%20typed%20so%20far.%0D%0A%0D%0A%0D%0A%20Since%20I%20use%20the%20command-line%20twitter%20gem%20%28by%20John%20Nunemaker%29%20I%20miss%20out%20on%20this%20feature%20and%20find%20myself%20using%20" title="del.icio.us"><img src="http://www.xcombinator.com/wp-content/plugins/sociable/images/delicious.png" title="del.icio.us" alt="del.icio.us" class="sociable-hovers" /></a><br />
	<a rel="nofollow"  href="http://reddit.com/submit?url=http%3A%2F%2Fwww.xcombinator.com%2F2009%2F05%2F21%2Ftweet-twitter-util-cli-feedback-on-tweet-length%2F&amp;title=tweet%20twitter%20util%20-%20cli%20feedback%20on%20tweet%20length" title="Reddit"><img src="http://www.xcombinator.com/wp-content/plugins/sociable/images/reddit.png" title="Reddit" alt="Reddit" class="sociable-hovers" /></a><br />
	<a rel="nofollow"  href="http://technorati.com/faves?add=http%3A%2F%2Fwww.xcombinator.com%2F2009%2F05%2F21%2Ftweet-twitter-util-cli-feedback-on-tweet-length%2F" title="Technorati"><img src="http://www.xcombinator.com/wp-content/plugins/sociable/images/technorati.png" title="Technorati" alt="Technorati" class="sociable-hovers" /></a><br />
	<a rel="nofollow"  href="http://twitter.com/home?status=tweet%20twitter%20util%20-%20cli%20feedback%20on%20tweet%20length%20-%20http%3A%2F%2Fwww.xcombinator.com%2F2009%2F05%2F21%2Ftweet-twitter-util-cli-feedback-on-tweet-length%2F" title="Twitter"><img src="http://www.xcombinator.com/wp-content/plugins/sociable/images/twitter.png" title="Twitter" alt="Twitter" class="sociable-hovers" /></a><br />
	<a rel="nofollow"  href="http://www.facebook.com/share.php?u=http%3A%2F%2Fwww.xcombinator.com%2F2009%2F05%2F21%2Ftweet-twitter-util-cli-feedback-on-tweet-length%2F&amp;t=tweet%20twitter%20util%20-%20cli%20feedback%20on%20tweet%20length" title="Facebook"><img src="http://www.xcombinator.com/wp-content/plugins/sociable/images/facebook.png" title="Facebook" alt="Facebook" class="sociable-hovers" /></a><br />
	<a rel="nofollow"  href="http://www.google.com/bookmarks/mark?op=edit&amp;bkmk=http%3A%2F%2Fwww.xcombinator.com%2F2009%2F05%2F21%2Ftweet-twitter-util-cli-feedback-on-tweet-length%2F&amp;title=tweet%20twitter%20util%20-%20cli%20feedback%20on%20tweet%20length&amp;annotation=One%20of%20the%20nice%20things%20about%20the%20Twitter%20web-interface%20is%20that%20it%20gives%20you%20feedback%20on%20the%20number%20of%20characters%20you%27ve%20typed%20so%20far.%0D%0A%0D%0A%0D%0A%20Since%20I%20use%20the%20command-line%20twitter%20gem%20%28by%20John%20Nunemaker%29%20I%20miss%20out%20on%20this%20feature%20and%20find%20myself%20using%20" title="Google Bookmarks"><img src="http://www.xcombinator.com/wp-content/plugins/sociable/images/googlebookmark.png" title="Google Bookmarks" alt="Google Bookmarks" class="sociable-hovers" /></a><br />
	<a rel="nofollow"  href="http://news.ycombinator.com/submitlink?u=http%3A%2F%2Fwww.xcombinator.com%2F2009%2F05%2F21%2Ftweet-twitter-util-cli-feedback-on-tweet-length%2F&amp;t=tweet%20twitter%20util%20-%20cli%20feedback%20on%20tweet%20length" title="HackerNews"><img src="http://www.xcombinator.com/wp-content/plugins/sociable/images/hackernews.png" title="HackerNews" alt="HackerNews" class="sociable-hovers" /></a><br />
	<a rel="nofollow"  href="http://www.printfriendly.com/print?url=http%3A%2F%2Fwww.xcombinator.com%2F2009%2F05%2F21%2Ftweet-twitter-util-cli-feedback-on-tweet-length%2F&amp;partner=sociable" title="PDF"><img src="http://www.xcombinator.com/wp-content/plugins/sociable/images/pdf.png" title="PDF" alt="PDF" class="sociable-hovers" /></a><br />
	<a rel="nofollow"  href="http://www.xcombinator.com/feed/" title="RSS"><img src="http://www.xcombinator.com/wp-content/plugins/sociable/images/rss.png" title="RSS" alt="RSS" class="sociable-hovers" /></a></p>
<p><br/><br/></p>
]]></content:encoded>
			<wfw:commentRss>http://www.xcombinator.com/2009/05/21/tweet-twitter-util-cli-feedback-on-tweet-length/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		<feedburner:origLink>http://www.xcombinator.com/2009/05/21/tweet-twitter-util-cli-feedback-on-tweet-length/</feedburner:origLink></item>
		<item>
		<title>temporarily undo commit(s) on a remote server</title>
		<link>http://feedproxy.google.com/~r/xcombinator/~3/v8hrCUth3M8/</link>
		<comments>http://www.xcombinator.com/2009/05/20/temporarily-undo-commits-on-a-remote-server/#comments</comments>
		<pubDate>Wed, 20 May 2009 23:51:20 +0000</pubDate>
		<dc:creator>brian</dc:creator>
				<category><![CDATA[programming]]></category>

		<guid isPermaLink="false">http://www.xcombinator.com/2009/05/20/temporarily-undo-commits-on-a-remote-server/</guid>
		<description><![CDATA[I do not claim to be a wiz at git, and I do not ensure what I am writing about, but it seemed to work for me, and I appreciate any comments.
My goal was to temporarily revert one or many commits that I had pushed to the remote server.
http://cheat.errtheblog.com/s/git &#8212; specifically the &#8220;Fix mistakes / [...]]]></description>
			<content:encoded><![CDATA[<p>I do not claim to be a wiz at git, and I do not ensure what I am writing about, but it seemed to work for me, and I appreciate any comments.</p>
<p>My goal was to temporarily revert one or many commits that I had pushed to the remote server.</p>
<p><a href="http://cheat.errtheblog.com/s/git">http://cheat.errtheblog.com/s/git</a> &#8212; specifically the &#8220;<span highlight="Search">Fix</span> mistakes / Undo&#8221; section was helpful.</p>
<p>What I found:</p>

<div class="wp_syntax"><div class="code"><pre class="bash" style="font-family:monospace;">git revert <span style="color: #660033;">-n</span> <span style="color: #000000; font-weight: bold;">&amp;</span>lt;sha<span style="color: #000000; font-weight: bold;">&amp;</span>gt;</pre></div></div>

<p>#run this for each commit you would like to &#8220;undo&#8221;</p>
<p>(the -n makes it so that you are not actually creating a commit, but staging the reverse of the changes made by your &lt;sha&gt; commit in your index. git status will show you this)</p>

<div class="wp_syntax"><div class="code"><pre class="bash" style="font-family:monospace;">git ci <span style="color: #660033;">-a</span> <span style="color: #666666; font-style: italic;"># apply your revision</span>
git push <span style="color: #666666; font-style: italic;">#origin to master (these steps effectively created one commit that was the product of reversing all the commits you picked in the git revert -n step)</span></pre></div></div>

<p>now your index looks like:</p>
<li>&lt;sha1&gt;&#8230; revision of &lt;commit&#8230;s&gt;</li>
<li>&lt;sha2&gt;&#8230; commit4</li>
<li>&lt;sha3&gt;&#8230; commit3</li>
<p>now, lets say, the time has come to reapply your commits. Because you didn&#8217;t just do</p>

<div class="wp_syntax"><div class="code"><pre class="bash" style="font-family:monospace;">git reset <span style="color: #660033;">--hard</span> <span style="color: #000000; font-weight: bold;">&amp;</span>lt;commit3<span style="color: #000000; font-weight: bold;">&amp;</span>gt;</pre></div></div>

<p>or something like that, all you have to do is git reset &#8211;hard &lt;sha1&gt; which will &#8220;undo your undo&#8221;</p>
<p>then</p>

<div class="wp_syntax"><div class="code"><pre class="bash" style="font-family:monospace;">git push <span style="color: #666666; font-style: italic;">#origin master</span></pre></div></div>

<p> again and you are back to where you were.</p>
<p>Share:</p>
<p>	<a rel="nofollow"  href="http://delicious.com/post?url=http%3A%2F%2Fwww.xcombinator.com%2F2009%2F05%2F20%2Ftemporarily-undo-commits-on-a-remote-server%2F&amp;title=temporarily%20undo%20commit%28s%29%20on%20a%20remote%20server&amp;notes=I%20do%20not%20claim%20to%20be%20a%20wiz%20at%20git%2C%20and%20I%20do%20not%20ensure%20what%20I%20am%20writing%20about%2C%20but%20it%20seemed%20to%20work%20for%20me%2C%20and%20I%20appreciate%20any%20comments.%0D%0A%0D%0AMy%20goal%20was%20to%20temporarily%20revert%20one%20or%20many%20commits%20that%20I%20had%20pushed%20to%20the%20remote%20server.%0D%0A%0D%0Ahttp%3A%2F%2Fch" title="del.icio.us"><img src="http://www.xcombinator.com/wp-content/plugins/sociable/images/delicious.png" title="del.icio.us" alt="del.icio.us" class="sociable-hovers" /></a><br />
	<a rel="nofollow"  href="http://reddit.com/submit?url=http%3A%2F%2Fwww.xcombinator.com%2F2009%2F05%2F20%2Ftemporarily-undo-commits-on-a-remote-server%2F&amp;title=temporarily%20undo%20commit%28s%29%20on%20a%20remote%20server" title="Reddit"><img src="http://www.xcombinator.com/wp-content/plugins/sociable/images/reddit.png" title="Reddit" alt="Reddit" class="sociable-hovers" /></a><br />
	<a rel="nofollow"  href="http://technorati.com/faves?add=http%3A%2F%2Fwww.xcombinator.com%2F2009%2F05%2F20%2Ftemporarily-undo-commits-on-a-remote-server%2F" title="Technorati"><img src="http://www.xcombinator.com/wp-content/plugins/sociable/images/technorati.png" title="Technorati" alt="Technorati" class="sociable-hovers" /></a><br />
	<a rel="nofollow"  href="http://twitter.com/home?status=temporarily%20undo%20commit%28s%29%20on%20a%20remote%20server%20-%20http%3A%2F%2Fwww.xcombinator.com%2F2009%2F05%2F20%2Ftemporarily-undo-commits-on-a-remote-server%2F" title="Twitter"><img src="http://www.xcombinator.com/wp-content/plugins/sociable/images/twitter.png" title="Twitter" alt="Twitter" class="sociable-hovers" /></a><br />
	<a rel="nofollow"  href="http://www.facebook.com/share.php?u=http%3A%2F%2Fwww.xcombinator.com%2F2009%2F05%2F20%2Ftemporarily-undo-commits-on-a-remote-server%2F&amp;t=temporarily%20undo%20commit%28s%29%20on%20a%20remote%20server" title="Facebook"><img src="http://www.xcombinator.com/wp-content/plugins/sociable/images/facebook.png" title="Facebook" alt="Facebook" class="sociable-hovers" /></a><br />
	<a rel="nofollow"  href="http://www.google.com/bookmarks/mark?op=edit&amp;bkmk=http%3A%2F%2Fwww.xcombinator.com%2F2009%2F05%2F20%2Ftemporarily-undo-commits-on-a-remote-server%2F&amp;title=temporarily%20undo%20commit%28s%29%20on%20a%20remote%20server&amp;annotation=I%20do%20not%20claim%20to%20be%20a%20wiz%20at%20git%2C%20and%20I%20do%20not%20ensure%20what%20I%20am%20writing%20about%2C%20but%20it%20seemed%20to%20work%20for%20me%2C%20and%20I%20appreciate%20any%20comments.%0D%0A%0D%0AMy%20goal%20was%20to%20temporarily%20revert%20one%20or%20many%20commits%20that%20I%20had%20pushed%20to%20the%20remote%20server.%0D%0A%0D%0Ahttp%3A%2F%2Fch" title="Google Bookmarks"><img src="http://www.xcombinator.com/wp-content/plugins/sociable/images/googlebookmark.png" title="Google Bookmarks" alt="Google Bookmarks" class="sociable-hovers" /></a><br />
	<a rel="nofollow"  href="http://news.ycombinator.com/submitlink?u=http%3A%2F%2Fwww.xcombinator.com%2F2009%2F05%2F20%2Ftemporarily-undo-commits-on-a-remote-server%2F&amp;t=temporarily%20undo%20commit%28s%29%20on%20a%20remote%20server" title="HackerNews"><img src="http://www.xcombinator.com/wp-content/plugins/sociable/images/hackernews.png" title="HackerNews" alt="HackerNews" class="sociable-hovers" /></a><br />
	<a rel="nofollow"  href="http://www.printfriendly.com/print?url=http%3A%2F%2Fwww.xcombinator.com%2F2009%2F05%2F20%2Ftemporarily-undo-commits-on-a-remote-server%2F&amp;partner=sociable" title="PDF"><img src="http://www.xcombinator.com/wp-content/plugins/sociable/images/pdf.png" title="PDF" alt="PDF" class="sociable-hovers" /></a><br />
	<a rel="nofollow"  href="http://www.xcombinator.com/feed/" title="RSS"><img src="http://www.xcombinator.com/wp-content/plugins/sociable/images/rss.png" title="RSS" alt="RSS" class="sociable-hovers" /></a></p>
<p><br/><br/></p>
]]></content:encoded>
			<wfw:commentRss>http://www.xcombinator.com/2009/05/20/temporarily-undo-commits-on-a-remote-server/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		<feedburner:origLink>http://www.xcombinator.com/2009/05/20/temporarily-undo-commits-on-a-remote-server/</feedburner:origLink></item>
		<item>
		<title>runaway process… on a mac</title>
		<link>http://feedproxy.google.com/~r/xcombinator/~3/6RqcEmGeiOY/</link>
		<comments>http://www.xcombinator.com/2009/04/18/runaway-process-on-a-mac/#comments</comments>
		<pubDate>Sat, 18 Apr 2009 23:58:59 +0000</pubDate>
		<dc:creator>brian</dc:creator>
				<category><![CDATA[programming]]></category>

		<guid isPermaLink="false">http://www.xcombinator.com/2009/04/18/runaway-process-on-a-mac/</guid>
		<description><![CDATA[wresting with the command line, and some cool cli programs I learned on the way
I want desperately to know how to detach a process from one terminal, and re-attach it to another, without using screen from the get-go. The more I read about it, the more I figure that the answer (you can&#8217;t) probably has [...]]]></description>
			<content:encoded><![CDATA[<p>wresting with the command line, and some cool cli programs I learned on the way</p>
<p>I want desperately to know how to detach a process from one terminal, and re-attach it to another, without using screen from the get-go. The more I read about it, the more I figure that the answer (you can&#8217;t) probably has more to do with my lack of understanding of how processes and terminals work. I read a great post <a href="http://www.xaprb.com/blog/2008/08/01/how-to-leave-a-program-running-after-you-log-out/">here</a> that introduced me to <tt>disown -h</tt> (careful) and <tt>nohup</tt>, some really great bash builtins. I thought, ok, lets try it. This is where I got stuck.</p>
<p>I tried</p>

<div class="wp_syntax"><div class="code"><pre class="bash" style="font-family:monospace;"><span style="color: #000000; font-weight: bold;">while</span> <span style="color: #c20cb9; font-weight: bold;">true</span>; <span style="color: #000000; font-weight: bold;">do</span> <span style="color: #c20cb9; font-weight: bold;">sleep</span> <span style="color: #000000;">10</span>; <span style="color: #000000; font-weight: bold;">done</span> <span style="color: #000000; font-weight: bold;">&amp;</span>amp;
<span style="color: #7a0874; font-weight: bold;">disown</span> <span style="color: #660033;">-h</span> <span style="color: #000000; font-weight: bold;">%</span>1
<span style="color: #7a0874; font-weight: bold;">exit</span></pre></div></div>

<p>The disown builtin handles a problem with background processes: From the bash man page (and also the above blog)</p>

<div class="wp_syntax"><div class="code"><pre class="bash" style="font-family:monospace;">The shell exits by default upon receipt of a SIGHUP</pre></div></div>

<p>therefore killing your process you &#8216;thought&#8217; you put in the background, and then logged out to go home for the night. Disown tells the jobspec not to accept a SIGHUP, and the -h switch tells it to remain in the jobs table. I thought, cool, maybe if it stays in the the jobs table, I could also transfer it to another jobs table of another tty. (no, you can&#8217;t&#8230;)<br />
but now I had a process on my hands that wasn&#8217;t attached to a terminal, and would just run forever unless I rebooted.</p>
<p>The while loop itself didn&#8217;t have a process ID, which is interesting, and because of the nature of while, the sleep commands PID kept changing, so a normal <tt>ps aux | grep slee[p] | awk '{print $2}' | xargs kill -9</tt> wasn&#8217;t working. (This post is loosing topic fast, but the <tt>slee[p]</tt> in the above command was a cool trick I learned so that I didn&#8217;t need a <tt>grep -v grep</tt> in there).</p>
<p>I *did* find that I could use <tt>ps</tt> to figure out the ppid (parent process ID) and just kill -9 that, but I was also interested in knowing for sure that it wasn&#8217;t in charge of doing something else important. A little digging around, and I came across the UNIX utility <tt>pstree</tt> which of course didn&#8217;t come on my mac, but I quickly figured out that it could be installed with</p>

<div class="wp_syntax"><div class="code"><pre class="bash" style="font-family:monospace;"><span style="color: #c20cb9; font-weight: bold;">sudo</span> port <span style="color: #c20cb9; font-weight: bold;">install</span> <span style="color: #c20cb9; font-weight: bold;">pstree</span></pre></div></div>

<p>Yesterday, I had done a similar thing with the UNIX command <tt>watch</tt>, which also nicely installed using <tt>port</tt><br />
And, for those who don&#8217;t know, the UNIX command <tt>watch</tt> is a great poller utility, that will display the first screen&#8217;s worth of output of any command, and update it on a regular basis.</p>
<p>I used <tt>ps | grep</tt> to find the ppid of the sleep process, then ran this command:</p>

<div class="wp_syntax"><div class="code"><pre class="bash" style="font-family:monospace;">watch <span style="color: #ff0000;">&quot;pstree <span style="color: #007800;">$PPID</span>&quot;</span></pre></div></div>

<p>This was way cool, as every ten seconds, I watched as the PID of sleep (the child process of this bash process I had just found) changed.</p>
<p>Take away:</p>

<div class="wp_syntax"><div class="code"><pre class="bash" style="font-family:monospace;"><span style="color: #c20cb9; font-weight: bold;">sudo</span> port <span style="color: #c20cb9; font-weight: bold;">install</span> watch
<span style="color: #c20cb9; font-weight: bold;">sudo</span> port <span style="color: #c20cb9; font-weight: bold;">install</span> <span style="color: #c20cb9; font-weight: bold;">pstree</span></pre></div></div>

<p>Share:</p>
<p>	<a rel="nofollow"  href="http://delicious.com/post?url=http%3A%2F%2Fwww.xcombinator.com%2F2009%2F04%2F18%2Frunaway-process-on-a-mac%2F&amp;title=runaway%20process...%20on%20a%20mac&amp;notes=wresting%20with%20the%20command%20line%2C%20and%20some%20cool%20cli%20programs%20I%20learned%20on%20the%20way%0D%0A%0D%0AI%20want%20desperately%20to%20know%20how%20to%20detach%20a%20process%20from%20one%20terminal%2C%20and%20re-attach%20it%20to%20another%2C%20without%20using%20screen%20from%20the%20get-go.%20The%20more%20I%20read%20about%20it%2C%20the%20" title="del.icio.us"><img src="http://www.xcombinator.com/wp-content/plugins/sociable/images/delicious.png" title="del.icio.us" alt="del.icio.us" class="sociable-hovers" /></a><br />
	<a rel="nofollow"  href="http://reddit.com/submit?url=http%3A%2F%2Fwww.xcombinator.com%2F2009%2F04%2F18%2Frunaway-process-on-a-mac%2F&amp;title=runaway%20process...%20on%20a%20mac" title="Reddit"><img src="http://www.xcombinator.com/wp-content/plugins/sociable/images/reddit.png" title="Reddit" alt="Reddit" class="sociable-hovers" /></a><br />
	<a rel="nofollow"  href="http://technorati.com/faves?add=http%3A%2F%2Fwww.xcombinator.com%2F2009%2F04%2F18%2Frunaway-process-on-a-mac%2F" title="Technorati"><img src="http://www.xcombinator.com/wp-content/plugins/sociable/images/technorati.png" title="Technorati" alt="Technorati" class="sociable-hovers" /></a><br />
	<a rel="nofollow"  href="http://twitter.com/home?status=runaway%20process...%20on%20a%20mac%20-%20http%3A%2F%2Fwww.xcombinator.com%2F2009%2F04%2F18%2Frunaway-process-on-a-mac%2F" title="Twitter"><img src="http://www.xcombinator.com/wp-content/plugins/sociable/images/twitter.png" title="Twitter" alt="Twitter" class="sociable-hovers" /></a><br />
	<a rel="nofollow"  href="http://www.facebook.com/share.php?u=http%3A%2F%2Fwww.xcombinator.com%2F2009%2F04%2F18%2Frunaway-process-on-a-mac%2F&amp;t=runaway%20process...%20on%20a%20mac" title="Facebook"><img src="http://www.xcombinator.com/wp-content/plugins/sociable/images/facebook.png" title="Facebook" alt="Facebook" class="sociable-hovers" /></a><br />
	<a rel="nofollow"  href="http://www.google.com/bookmarks/mark?op=edit&amp;bkmk=http%3A%2F%2Fwww.xcombinator.com%2F2009%2F04%2F18%2Frunaway-process-on-a-mac%2F&amp;title=runaway%20process...%20on%20a%20mac&amp;annotation=wresting%20with%20the%20command%20line%2C%20and%20some%20cool%20cli%20programs%20I%20learned%20on%20the%20way%0D%0A%0D%0AI%20want%20desperately%20to%20know%20how%20to%20detach%20a%20process%20from%20one%20terminal%2C%20and%20re-attach%20it%20to%20another%2C%20without%20using%20screen%20from%20the%20get-go.%20The%20more%20I%20read%20about%20it%2C%20the%20" title="Google Bookmarks"><img src="http://www.xcombinator.com/wp-content/plugins/sociable/images/googlebookmark.png" title="Google Bookmarks" alt="Google Bookmarks" class="sociable-hovers" /></a><br />
	<a rel="nofollow"  href="http://news.ycombinator.com/submitlink?u=http%3A%2F%2Fwww.xcombinator.com%2F2009%2F04%2F18%2Frunaway-process-on-a-mac%2F&amp;t=runaway%20process...%20on%20a%20mac" title="HackerNews"><img src="http://www.xcombinator.com/wp-content/plugins/sociable/images/hackernews.png" title="HackerNews" alt="HackerNews" class="sociable-hovers" /></a><br />
	<a rel="nofollow"  href="http://www.printfriendly.com/print?url=http%3A%2F%2Fwww.xcombinator.com%2F2009%2F04%2F18%2Frunaway-process-on-a-mac%2F&amp;partner=sociable" title="PDF"><img src="http://www.xcombinator.com/wp-content/plugins/sociable/images/pdf.png" title="PDF" alt="PDF" class="sociable-hovers" /></a><br />
	<a rel="nofollow"  href="http://www.xcombinator.com/feed/" title="RSS"><img src="http://www.xcombinator.com/wp-content/plugins/sociable/images/rss.png" title="RSS" alt="RSS" class="sociable-hovers" /></a></p>
<p><br/><br/></p>
]]></content:encoded>
			<wfw:commentRss>http://www.xcombinator.com/2009/04/18/runaway-process-on-a-mac/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		<feedburner:origLink>http://www.xcombinator.com/2009/04/18/runaway-process-on-a-mac/</feedburner:origLink></item>
		<item>
		<title>starting screen as a login shell</title>
		<link>http://feedproxy.google.com/~r/xcombinator/~3/iMySJuy-74Y/</link>
		<comments>http://www.xcombinator.com/2009/04/14/starting-screen-as-a-login-shell/#comments</comments>
		<pubDate>Wed, 15 Apr 2009 00:21:52 +0000</pubDate>
		<dc:creator>brian</dc:creator>
				<category><![CDATA[programming]]></category>

		<guid isPermaLink="false">http://www.xcombinator.com/2009/04/14/starting-screen-as-a-login-shell/</guid>
		<description><![CDATA[I realized a while ago that I wanted to invoke my shell as a login shell when starting screen. This of course gives me immediate access to things in my .profile like aliases, etc.

shell -bash

Everywhere I read said to put that in your .screenrc file. On my Mac, OS X 10.5, however it seemed to [...]]]></description>
			<content:encoded><![CDATA[<p>I realized a while ago that I wanted to invoke my shell as a login shell when starting screen. This of course gives me immediate access to things in my .profile like aliases, etc.</p>

<div class="wp_syntax"><div class="code"><pre class="bash" style="font-family:monospace;">shell <span style="color: #660033;">-bash</span></pre></div></div>

<p>Everywhere I read said to put that in your .screenrc file. On my Mac, OS X 10.5, however it seemed to have the (extremely) unwanted circumstance of changing my cwd whenever I started screen to my $HOME folder.</p>
<p>I was able to do some testing my remoting into a *fairly* vanilla fedora box and running the command:</p>

<div class="wp_syntax"><div class="code"><pre class="bash" style="font-family:monospace;"><span style="color: #7a0874; font-weight: bold;">cd</span> <span style="color: #000000; font-weight: bold;">/</span>; <span style="color: #c20cb9; font-weight: bold;">screen</span> <span style="color: #660033;">-s</span> <span style="color: #660033;">-bash</span></pre></div></div>

<p>This started bash as a login shell</p>

<div class="wp_syntax"><div class="code"><pre class="bash" style="font-family:monospace;"><span style="color: #7a0874; font-weight: bold;">shopt</span> login_shell <span style="color: #666666; font-style: italic;">#=&amp;gt; login_shell    	on</span></pre></div></div>

<p>but did not change my cwd.</p>
<p>I tried moving my .profile file to see if it was the culprit.</p>
<p>I finally came up with this hackish solution.</p>
<p>create file</p>

<div class="wp_syntax"><div class="code"><pre class="bash" style="font-family:monospace;">screen_shell</pre></div></div>

<p>and place in it the line</p>

<div class="wp_syntax"><div class="code"><pre class="bash" style="font-family:monospace;"><span style="color: #007800;">$SHELL</span> <span style="color: #660033;">-l</span></pre></div></div>

<p>I knew from other testing that</p>

<div class="wp_syntax"><div class="code"><pre class="bash" style="font-family:monospace;">shell <span style="color: #ff0000;">'bash -l'</span></pre></div></div>

<p>didn&#8217;t work, course, now, having remembered that I had a similar experience with vi&#8230; I wonder if</p>

<div class="wp_syntax"><div class="code"><pre class="bash" style="font-family:monospace;">shell <span style="color: #c20cb9; font-weight: bold;">bash</span>\ <span style="color: #660033;">-l</span></pre></div></div>

<p>would work&#8230; (nope&#8230;)</p>
<p>so, I then changed my .screenrc file to read</p>

<div class="wp_syntax"><div class="code"><pre class="bash" style="font-family:monospace;">shell <span style="color: #000000; font-weight: bold;">/</span>Users<span style="color: #000000; font-weight: bold;">/</span>bhenderson<span style="color: #000000; font-weight: bold;">/</span>.screen_shell</pre></div></div>

<p>made sure that I did a</p>

<div class="wp_syntax"><div class="code"><pre class="bash" style="font-family:monospace;"><span style="color: #c20cb9; font-weight: bold;">chmod</span> u+x ~<span style="color: #000000; font-weight: bold;">/</span>.screen_shell</pre></div></div>

<p>and off I went.</p>
<p>If anyone would like to add to my understanding of what was going on, or a better solution, please feel free to comment. thanks.</p>
<p>Share:</p>
<p>	<a rel="nofollow"  href="http://delicious.com/post?url=http%3A%2F%2Fwww.xcombinator.com%2F2009%2F04%2F14%2Fstarting-screen-as-a-login-shell%2F&amp;title=starting%20screen%20as%20a%20login%20shell&amp;notes=I%20realized%20a%20while%20ago%20that%20I%20wanted%20to%20invoke%20my%20shell%20as%20a%20login%20shell%20when%20starting%20screen.%20This%20of%20course%20gives%20me%20immediate%20access%20to%20things%20in%20my%20.profile%20like%20aliases%2C%20etc.%0D%0A%0D%0Ashell%20-bash%0D%0AEverywhere%20I%20read%20said%20to%20put%20that%20in%20your%20.screenrc%20f" title="del.icio.us"><img src="http://www.xcombinator.com/wp-content/plugins/sociable/images/delicious.png" title="del.icio.us" alt="del.icio.us" class="sociable-hovers" /></a><br />
	<a rel="nofollow"  href="http://reddit.com/submit?url=http%3A%2F%2Fwww.xcombinator.com%2F2009%2F04%2F14%2Fstarting-screen-as-a-login-shell%2F&amp;title=starting%20screen%20as%20a%20login%20shell" title="Reddit"><img src="http://www.xcombinator.com/wp-content/plugins/sociable/images/reddit.png" title="Reddit" alt="Reddit" class="sociable-hovers" /></a><br />
	<a rel="nofollow"  href="http://technorati.com/faves?add=http%3A%2F%2Fwww.xcombinator.com%2F2009%2F04%2F14%2Fstarting-screen-as-a-login-shell%2F" title="Technorati"><img src="http://www.xcombinator.com/wp-content/plugins/sociable/images/technorati.png" title="Technorati" alt="Technorati" class="sociable-hovers" /></a><br />
	<a rel="nofollow"  href="http://twitter.com/home?status=starting%20screen%20as%20a%20login%20shell%20-%20http%3A%2F%2Fwww.xcombinator.com%2F2009%2F04%2F14%2Fstarting-screen-as-a-login-shell%2F" title="Twitter"><img src="http://www.xcombinator.com/wp-content/plugins/sociable/images/twitter.png" title="Twitter" alt="Twitter" class="sociable-hovers" /></a><br />
	<a rel="nofollow"  href="http://www.facebook.com/share.php?u=http%3A%2F%2Fwww.xcombinator.com%2F2009%2F04%2F14%2Fstarting-screen-as-a-login-shell%2F&amp;t=starting%20screen%20as%20a%20login%20shell" title="Facebook"><img src="http://www.xcombinator.com/wp-content/plugins/sociable/images/facebook.png" title="Facebook" alt="Facebook" class="sociable-hovers" /></a><br />
	<a rel="nofollow"  href="http://www.google.com/bookmarks/mark?op=edit&amp;bkmk=http%3A%2F%2Fwww.xcombinator.com%2F2009%2F04%2F14%2Fstarting-screen-as-a-login-shell%2F&amp;title=starting%20screen%20as%20a%20login%20shell&amp;annotation=I%20realized%20a%20while%20ago%20that%20I%20wanted%20to%20invoke%20my%20shell%20as%20a%20login%20shell%20when%20starting%20screen.%20This%20of%20course%20gives%20me%20immediate%20access%20to%20things%20in%20my%20.profile%20like%20aliases%2C%20etc.%0D%0A%0D%0Ashell%20-bash%0D%0AEverywhere%20I%20read%20said%20to%20put%20that%20in%20your%20.screenrc%20f" title="Google Bookmarks"><img src="http://www.xcombinator.com/wp-content/plugins/sociable/images/googlebookmark.png" title="Google Bookmarks" alt="Google Bookmarks" class="sociable-hovers" /></a><br />
	<a rel="nofollow"  href="http://news.ycombinator.com/submitlink?u=http%3A%2F%2Fwww.xcombinator.com%2F2009%2F04%2F14%2Fstarting-screen-as-a-login-shell%2F&amp;t=starting%20screen%20as%20a%20login%20shell" title="HackerNews"><img src="http://www.xcombinator.com/wp-content/plugins/sociable/images/hackernews.png" title="HackerNews" alt="HackerNews" class="sociable-hovers" /></a><br />
	<a rel="nofollow"  href="http://www.printfriendly.com/print?url=http%3A%2F%2Fwww.xcombinator.com%2F2009%2F04%2F14%2Fstarting-screen-as-a-login-shell%2F&amp;partner=sociable" title="PDF"><img src="http://www.xcombinator.com/wp-content/plugins/sociable/images/pdf.png" title="PDF" alt="PDF" class="sociable-hovers" /></a><br />
	<a rel="nofollow"  href="http://www.xcombinator.com/feed/" title="RSS"><img src="http://www.xcombinator.com/wp-content/plugins/sociable/images/rss.png" title="RSS" alt="RSS" class="sociable-hovers" /></a></p>
<p><br/><br/></p>
]]></content:encoded>
			<wfw:commentRss>http://www.xcombinator.com/2009/04/14/starting-screen-as-a-login-shell/feed/</wfw:commentRss>
		<slash:comments>2</slash:comments>
		<feedburner:origLink>http://www.xcombinator.com/2009/04/14/starting-screen-as-a-login-shell/</feedburner:origLink></item>
		<item>
		<title>rsync vs. cp</title>
		<link>http://feedproxy.google.com/~r/xcombinator/~3/8VWYIHsy3Qo/</link>
		<comments>http://www.xcombinator.com/2009/03/03/rsync-vs-cp/#comments</comments>
		<pubDate>Tue, 03 Mar 2009 21:40:49 +0000</pubDate>
		<dc:creator>brian</dc:creator>
				<category><![CDATA[programming]]></category>

		<guid isPermaLink="false">http://www.xcombinator.com/2009/03/03/rsync-vs-cp/</guid>
		<description><![CDATA[
rsync -a /path/to/bar/ /path/to/foo/  # =&#38;gt; /path/to/foo/[contents of bar]
rsync -a /path/to/bar /path/to/foo/   # =&#38;gt; /path/to/foo/bar/[contents of bar]
&#160;
cp -a /path/to/bar/ /path/to/foo/     # =&#38;gt; /path/to/foo/bar
cp -a /path/to/bar /path/to/foo/      # =&#38;gt; /path/to/foo/bar

why can&#8217;t cp have the same source behavior as rsync?
btw, I found the solution on [...]]]></description>
			<content:encoded><![CDATA[
<div class="wp_syntax"><div class="code"><pre class="bash" style="font-family:monospace;">rsync <span style="color: #660033;">-a</span> <span style="color: #000000; font-weight: bold;">/</span>path<span style="color: #000000; font-weight: bold;">/</span>to<span style="color: #000000; font-weight: bold;">/</span>bar<span style="color: #000000; font-weight: bold;">/</span> <span style="color: #000000; font-weight: bold;">/</span>path<span style="color: #000000; font-weight: bold;">/</span>to<span style="color: #000000; font-weight: bold;">/</span>foo<span style="color: #000000; font-weight: bold;">/</span>  <span style="color: #666666; font-style: italic;"># =&amp;gt; /path/to/foo/[contents of bar]</span>
rsync <span style="color: #660033;">-a</span> <span style="color: #000000; font-weight: bold;">/</span>path<span style="color: #000000; font-weight: bold;">/</span>to<span style="color: #000000; font-weight: bold;">/</span>bar <span style="color: #000000; font-weight: bold;">/</span>path<span style="color: #000000; font-weight: bold;">/</span>to<span style="color: #000000; font-weight: bold;">/</span>foo<span style="color: #000000; font-weight: bold;">/</span>   <span style="color: #666666; font-style: italic;"># =&amp;gt; /path/to/foo/bar/[contents of bar]</span>
&nbsp;
<span style="color: #c20cb9; font-weight: bold;">cp</span> <span style="color: #660033;">-a</span> <span style="color: #000000; font-weight: bold;">/</span>path<span style="color: #000000; font-weight: bold;">/</span>to<span style="color: #000000; font-weight: bold;">/</span>bar<span style="color: #000000; font-weight: bold;">/</span> <span style="color: #000000; font-weight: bold;">/</span>path<span style="color: #000000; font-weight: bold;">/</span>to<span style="color: #000000; font-weight: bold;">/</span>foo<span style="color: #000000; font-weight: bold;">/</span>     <span style="color: #666666; font-style: italic;"># =&amp;gt; /path/to/foo/bar</span>
<span style="color: #c20cb9; font-weight: bold;">cp</span> <span style="color: #660033;">-a</span> <span style="color: #000000; font-weight: bold;">/</span>path<span style="color: #000000; font-weight: bold;">/</span>to<span style="color: #000000; font-weight: bold;">/</span>bar <span style="color: #000000; font-weight: bold;">/</span>path<span style="color: #000000; font-weight: bold;">/</span>to<span style="color: #000000; font-weight: bold;">/</span>foo<span style="color: #000000; font-weight: bold;">/</span>      <span style="color: #666666; font-style: italic;"># =&amp;gt; /path/to/foo/bar</span></pre></div></div>

<p>why can&#8217;t cp have the same source behavior as rsync?</p>
<p>btw, I found the solution on this <a href="http://blog.maisnam.com/archives/000109.php">blog:</a></p>

<div class="wp_syntax"><div class="code"><pre class="bash" style="font-family:monospace;"><span style="color: #c20cb9; font-weight: bold;">mkdir</span> target_directory
<span style="color: #7a0874; font-weight: bold;">cd</span> source_directory
<span style="color: #c20cb9; font-weight: bold;">cp</span> <span style="color: #660033;">-a</span> . target_directory</pre></div></div>

<p>(on the blog, the author does cp -ap, but that looks redundant according to the man page)</p>
<p>Share:</p>
<p>	<a rel="nofollow"  href="http://delicious.com/post?url=http%3A%2F%2Fwww.xcombinator.com%2F2009%2F03%2F03%2Frsync-vs-cp%2F&amp;title=rsync%20vs.%20cp&amp;notes=%0D%0A%0D%0Arsync%20-a%20%2Fpath%2Fto%2Fbar%2F%20%2Fpath%2Fto%2Ffoo%2F%20%20%23%20%3D%26gt%3B%20%2Fpath%2Fto%2Ffoo%2F%5Bcontents%20of%20bar%5D%0D%0Arsync%20-a%20%2Fpath%2Fto%2Fbar%20%2Fpath%2Fto%2Ffoo%2F%20%20%20%23%20%3D%26gt%3B%20%2Fpath%2Fto%2Ffoo%2Fbar%2F%5Bcontents%20of%20bar%5D%0D%0A%0D%0Acp%20-a%20%2Fpath%2Fto%2Fbar%2F%20%2Fpath%2Fto%2Ffoo%2F%20%20%20%20%20%23%20%3D%26gt%3B%20%2Fpath%2Fto%2Ffoo%2Fbar%0D%0Acp%20-a%20%2Fpath%2Fto%2Fbar%20%2F" title="del.icio.us"><img src="http://www.xcombinator.com/wp-content/plugins/sociable/images/delicious.png" title="del.icio.us" alt="del.icio.us" class="sociable-hovers" /></a><br />
	<a rel="nofollow"  href="http://reddit.com/submit?url=http%3A%2F%2Fwww.xcombinator.com%2F2009%2F03%2F03%2Frsync-vs-cp%2F&amp;title=rsync%20vs.%20cp" title="Reddit"><img src="http://www.xcombinator.com/wp-content/plugins/sociable/images/reddit.png" title="Reddit" alt="Reddit" class="sociable-hovers" /></a><br />
	<a rel="nofollow"  href="http://technorati.com/faves?add=http%3A%2F%2Fwww.xcombinator.com%2F2009%2F03%2F03%2Frsync-vs-cp%2F" title="Technorati"><img src="http://www.xcombinator.com/wp-content/plugins/sociable/images/technorati.png" title="Technorati" alt="Technorati" class="sociable-hovers" /></a><br />
	<a rel="nofollow"  href="http://twitter.com/home?status=rsync%20vs.%20cp%20-%20http%3A%2F%2Fwww.xcombinator.com%2F2009%2F03%2F03%2Frsync-vs-cp%2F" title="Twitter"><img src="http://www.xcombinator.com/wp-content/plugins/sociable/images/twitter.png" title="Twitter" alt="Twitter" class="sociable-hovers" /></a><br />
	<a rel="nofollow"  href="http://www.facebook.com/share.php?u=http%3A%2F%2Fwww.xcombinator.com%2F2009%2F03%2F03%2Frsync-vs-cp%2F&amp;t=rsync%20vs.%20cp" title="Facebook"><img src="http://www.xcombinator.com/wp-content/plugins/sociable/images/facebook.png" title="Facebook" alt="Facebook" class="sociable-hovers" /></a><br />
	<a rel="nofollow"  href="http://www.google.com/bookmarks/mark?op=edit&amp;bkmk=http%3A%2F%2Fwww.xcombinator.com%2F2009%2F03%2F03%2Frsync-vs-cp%2F&amp;title=rsync%20vs.%20cp&amp;annotation=%0D%0A%0D%0Arsync%20-a%20%2Fpath%2Fto%2Fbar%2F%20%2Fpath%2Fto%2Ffoo%2F%20%20%23%20%3D%26gt%3B%20%2Fpath%2Fto%2Ffoo%2F%5Bcontents%20of%20bar%5D%0D%0Arsync%20-a%20%2Fpath%2Fto%2Fbar%20%2Fpath%2Fto%2Ffoo%2F%20%20%20%23%20%3D%26gt%3B%20%2Fpath%2Fto%2Ffoo%2Fbar%2F%5Bcontents%20of%20bar%5D%0D%0A%0D%0Acp%20-a%20%2Fpath%2Fto%2Fbar%2F%20%2Fpath%2Fto%2Ffoo%2F%20%20%20%20%20%23%20%3D%26gt%3B%20%2Fpath%2Fto%2Ffoo%2Fbar%0D%0Acp%20-a%20%2Fpath%2Fto%2Fbar%20%2F" title="Google Bookmarks"><img src="http://www.xcombinator.com/wp-content/plugins/sociable/images/googlebookmark.png" title="Google Bookmarks" alt="Google Bookmarks" class="sociable-hovers" /></a><br />
	<a rel="nofollow"  href="http://news.ycombinator.com/submitlink?u=http%3A%2F%2Fwww.xcombinator.com%2F2009%2F03%2F03%2Frsync-vs-cp%2F&amp;t=rsync%20vs.%20cp" title="HackerNews"><img src="http://www.xcombinator.com/wp-content/plugins/sociable/images/hackernews.png" title="HackerNews" alt="HackerNews" class="sociable-hovers" /></a><br />
	<a rel="nofollow"  href="http://www.printfriendly.com/print?url=http%3A%2F%2Fwww.xcombinator.com%2F2009%2F03%2F03%2Frsync-vs-cp%2F&amp;partner=sociable" title="PDF"><img src="http://www.xcombinator.com/wp-content/plugins/sociable/images/pdf.png" title="PDF" alt="PDF" class="sociable-hovers" /></a><br />
	<a rel="nofollow"  href="http://www.xcombinator.com/feed/" title="RSS"><img src="http://www.xcombinator.com/wp-content/plugins/sociable/images/rss.png" title="RSS" alt="RSS" class="sociable-hovers" /></a></p>
<p><br/><br/></p>
]]></content:encoded>
			<wfw:commentRss>http://www.xcombinator.com/2009/03/03/rsync-vs-cp/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		<feedburner:origLink>http://www.xcombinator.com/2009/03/03/rsync-vs-cp/</feedburner:origLink></item>
		<item>
		<title>what does this return? or ‘why i love ruby’</title>
		<link>http://feedproxy.google.com/~r/xcombinator/~3/B4IlXAEvhY4/</link>
		<comments>http://www.xcombinator.com/2009/02/19/what-does-this-return-or-why-i-love-ruby/#comments</comments>
		<pubDate>Thu, 19 Feb 2009 17:18:51 +0000</pubDate>
		<dc:creator>Nate Murray</dc:creator>
				<category><![CDATA[ruby]]></category>

		<guid isPermaLink="false">http://www.xcombinator.com/2009/02/19/what-does-this-return-or-why-i-love-ruby/</guid>
		<description><![CDATA[
def x
  5
end
&#160;
if false
  x = 3
end
&#160;
puts x # =&#62; ?

Share:
	
	
	
	
	
	
	
	
	

]]></description>
			<content:encoded><![CDATA[
<div class="wp_syntax"><div class="code"><pre class="ruby" style="font-family:monospace;"><span style="color:#9966CC; font-weight:bold;">def</span> x
  <span style="color:#006666;">5</span>
<span style="color:#9966CC; font-weight:bold;">end</span>
&nbsp;
<span style="color:#9966CC; font-weight:bold;">if</span> <span style="color:#0000FF; font-weight:bold;">false</span>
  x = <span style="color:#006666;">3</span>
<span style="color:#9966CC; font-weight:bold;">end</span>
&nbsp;
<span style="color:#CC0066; font-weight:bold;">puts</span> x <span style="color:#008000; font-style:italic;"># =&gt; ?</span></pre></div></div>

<p>Share:</p>
<p>	<a rel="nofollow"  href="http://delicious.com/post?url=http%3A%2F%2Fwww.xcombinator.com%2F2009%2F02%2F19%2Fwhat-does-this-return-or-why-i-love-ruby%2F&amp;title=what%20does%20this%20return%3F%20or%20%27why%20i%20love%20ruby%27&amp;notes=%0D%0Adef%20x%0D%0A%20%205%0D%0Aend%0D%0A%0D%0Aif%20false%0D%0A%20%20x%20%3D%203%0D%0Aend%0D%0A%0D%0Aputs%20x%20%23%20%3D%3E%20%3F%0D%0A" title="del.icio.us"><img src="http://www.xcombinator.com/wp-content/plugins/sociable/images/delicious.png" title="del.icio.us" alt="del.icio.us" class="sociable-hovers" /></a><br />
	<a rel="nofollow"  href="http://reddit.com/submit?url=http%3A%2F%2Fwww.xcombinator.com%2F2009%2F02%2F19%2Fwhat-does-this-return-or-why-i-love-ruby%2F&amp;title=what%20does%20this%20return%3F%20or%20%27why%20i%20love%20ruby%27" title="Reddit"><img src="http://www.xcombinator.com/wp-content/plugins/sociable/images/reddit.png" title="Reddit" alt="Reddit" class="sociable-hovers" /></a><br />
	<a rel="nofollow"  href="http://technorati.com/faves?add=http%3A%2F%2Fwww.xcombinator.com%2F2009%2F02%2F19%2Fwhat-does-this-return-or-why-i-love-ruby%2F" title="Technorati"><img src="http://www.xcombinator.com/wp-content/plugins/sociable/images/technorati.png" title="Technorati" alt="Technorati" class="sociable-hovers" /></a><br />
	<a rel="nofollow"  href="http://twitter.com/home?status=what%20does%20this%20return%3F%20or%20%27why%20i%20love%20ruby%27%20-%20http%3A%2F%2Fwww.xcombinator.com%2F2009%2F02%2F19%2Fwhat-does-this-return-or-why-i-love-ruby%2F" title="Twitter"><img src="http://www.xcombinator.com/wp-content/plugins/sociable/images/twitter.png" title="Twitter" alt="Twitter" class="sociable-hovers" /></a><br />
	<a rel="nofollow"  href="http://www.facebook.com/share.php?u=http%3A%2F%2Fwww.xcombinator.com%2F2009%2F02%2F19%2Fwhat-does-this-return-or-why-i-love-ruby%2F&amp;t=what%20does%20this%20return%3F%20or%20%27why%20i%20love%20ruby%27" title="Facebook"><img src="http://www.xcombinator.com/wp-content/plugins/sociable/images/facebook.png" title="Facebook" alt="Facebook" class="sociable-hovers" /></a><br />
	<a rel="nofollow"  href="http://www.google.com/bookmarks/mark?op=edit&amp;bkmk=http%3A%2F%2Fwww.xcombinator.com%2F2009%2F02%2F19%2Fwhat-does-this-return-or-why-i-love-ruby%2F&amp;title=what%20does%20this%20return%3F%20or%20%27why%20i%20love%20ruby%27&amp;annotation=%0D%0Adef%20x%0D%0A%20%205%0D%0Aend%0D%0A%0D%0Aif%20false%0D%0A%20%20x%20%3D%203%0D%0Aend%0D%0A%0D%0Aputs%20x%20%23%20%3D%3E%20%3F%0D%0A" title="Google Bookmarks"><img src="http://www.xcombinator.com/wp-content/plugins/sociable/images/googlebookmark.png" title="Google Bookmarks" alt="Google Bookmarks" class="sociable-hovers" /></a><br />
	<a rel="nofollow"  href="http://news.ycombinator.com/submitlink?u=http%3A%2F%2Fwww.xcombinator.com%2F2009%2F02%2F19%2Fwhat-does-this-return-or-why-i-love-ruby%2F&amp;t=what%20does%20this%20return%3F%20or%20%27why%20i%20love%20ruby%27" title="HackerNews"><img src="http://www.xcombinator.com/wp-content/plugins/sociable/images/hackernews.png" title="HackerNews" alt="HackerNews" class="sociable-hovers" /></a><br />
	<a rel="nofollow"  href="http://www.printfriendly.com/print?url=http%3A%2F%2Fwww.xcombinator.com%2F2009%2F02%2F19%2Fwhat-does-this-return-or-why-i-love-ruby%2F&amp;partner=sociable" title="PDF"><img src="http://www.xcombinator.com/wp-content/plugins/sociable/images/pdf.png" title="PDF" alt="PDF" class="sociable-hovers" /></a><br />
	<a rel="nofollow"  href="http://www.xcombinator.com/feed/" title="RSS"><img src="http://www.xcombinator.com/wp-content/plugins/sociable/images/rss.png" title="RSS" alt="RSS" class="sociable-hovers" /></a></p>
<p><br/><br/></p>
]]></content:encoded>
			<wfw:commentRss>http://www.xcombinator.com/2009/02/19/what-does-this-return-or-why-i-love-ruby/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		<feedburner:origLink>http://www.xcombinator.com/2009/02/19/what-does-this-return-or-why-i-love-ruby/</feedburner:origLink></item>
		<item>
		<title>Ruby’s #each_with_index for Erlang</title>
		<link>http://feedproxy.google.com/~r/xcombinator/~3/FudXB0UIysU/</link>
		<comments>http://www.xcombinator.com/2009/02/10/rubys-each_with_index-for-erlang/#comments</comments>
		<pubDate>Tue, 10 Feb 2009 19:30:49 +0000</pubDate>
		<dc:creator>Nate Murray</dc:creator>
				<category><![CDATA[erlang]]></category>
		<category><![CDATA[programming]]></category>

		<guid isPermaLink="false">http://www.xcombinator.com/2009/02/10/rubys-each_with_index-for-erlang/</guid>
		<description><![CDATA[
Ruby has a great method for enumerations called #each_with_index. It&#8217;s a handy way to iterate over a list of elements and and know where you&#8217;re at while doing it.

Erlang has a group of highly optimized list operations in the lists module (Try erl -man lists to see them all). We&#8217;re going to be using those [...]]]></description>
			<content:encoded><![CDATA[<p>
Ruby has a great method for enumerations called <tt>#each_with_index</tt>. It&#8217;s a handy way to iterate over a list of elements and and know where you&#8217;re at while doing it.</p>
<p>
Erlang has a group of highly optimized list operations in the <tt>lists</tt> module (Try <tt>erl -man lists</tt> to see them all). We&#8217;re going to be using those to build our Erlang version of <tt>#each_with_index</tt>.
</p>
<p>
There are two methods from <tt>list</tt> we&#8217;re going to use: <tt>lists:seq</tt> and <tt>lists:zip</tt>. <tt>lists:seq</tt> simply returns a list of integers between a given range. For instance:</p>

<div class="wp_syntax"><div class="code"><pre class="erlang" style="font-family:monospace;"><span style="color: #ff9600;">1</span><span style="color: #014ea4;">&gt;</span> <span style="color: #45b3e6;">Seq</span> <span style="color: #014ea4;">=</span> <span style="color: #ff4e18;">lists</span>:<span style="color: #ff3c00;">seq</span><span style="color: #109ab8;">&#40;</span><span style="color: #ff9600;">0</span><span style="color: #6bb810;">,</span> <span style="color: #ff9600;">9</span><span style="color: #109ab8;">&#41;</span><span style="color: #6bb810;">.</span>
<span style="color: #109ab8;">&#91;</span><span style="color: #ff9600;">0</span><span style="color: #6bb810;">,</span><span style="color: #ff9600;">1</span><span style="color: #6bb810;">,</span><span style="color: #ff9600;">2</span><span style="color: #6bb810;">,</span><span style="color: #ff9600;">3</span><span style="color: #6bb810;">,</span><span style="color: #ff9600;">4</span><span style="color: #6bb810;">,</span><span style="color: #ff9600;">5</span><span style="color: #6bb810;">,</span><span style="color: #ff9600;">6</span><span style="color: #6bb810;">,</span><span style="color: #ff9600;">7</span><span style="color: #6bb810;">,</span><span style="color: #ff9600;">8</span><span style="color: #6bb810;">,</span><span style="color: #ff9600;">9</span><span style="color: #109ab8;">&#93;</span></pre></div></div>

<p><tt>lists:zip</tt> takes two lists (of equal length) and returns a list of tuples. Like so:</p>

<div class="wp_syntax"><div class="code"><pre class="erlang" style="font-family:monospace;"><span style="color: #ff9600;">2</span><span style="color: #014ea4;">&gt;</span> <span style="color: #ff4e18;">lists</span>:<span style="color: #ff3c00;">zip</span><span style="color: #109ab8;">&#40;</span><span style="color: #109ab8;">&#91;</span>a<span style="color: #6bb810;">,</span>b<span style="color: #6bb810;">,</span>c<span style="color: #109ab8;">&#93;</span><span style="color: #6bb810;">,</span> <span style="color: #109ab8;">&#91;</span><span style="color: #ff9600;">1</span><span style="color: #6bb810;">,</span><span style="color: #ff9600;">2</span><span style="color: #6bb810;">,</span><span style="color: #ff9600;">3</span><span style="color: #109ab8;">&#93;</span><span style="color: #109ab8;">&#41;</span><span style="color: #6bb810;">.</span>
<span style="color: #109ab8;">&#91;</span><span style="color: #109ab8;">&#123;</span>a<span style="color: #6bb810;">,</span><span style="color: #ff9600;">1</span><span style="color: #109ab8;">&#125;</span><span style="color: #6bb810;">,</span><span style="color: #109ab8;">&#123;</span>b<span style="color: #6bb810;">,</span><span style="color: #ff9600;">2</span><span style="color: #109ab8;">&#125;</span><span style="color: #6bb810;">,</span><span style="color: #109ab8;">&#123;</span>c<span style="color: #6bb810;">,</span><span style="color: #ff9600;">3</span><span style="color: #109ab8;">&#125;</span><span style="color: #109ab8;">&#93;</span></pre></div></div>

<p>The last thing we need is a list comprehension, which is similar to <tt>each</tt> with a block in Ruby. For instance, in Ruby:</p>

<div class="wp_syntax"><div class="code"><pre class="ruby" style="font-family:monospace;"><span style="color:#006600; font-weight:bold;">&gt;&gt;</span> <span style="color:#006600; font-weight:bold;">&#91;</span><span style="color:#ff3333; font-weight:bold;">:a</span>, <span style="color:#ff3333; font-weight:bold;">:b</span>, <span style="color:#ff3333; font-weight:bold;">:c</span><span style="color:#006600; font-weight:bold;">&#93;</span>.<span style="color:#9900CC;">each</span> <span style="color:#006600; font-weight:bold;">&#123;</span> <span style="color:#006600; font-weight:bold;">|</span>element<span style="color:#006600; font-weight:bold;">|</span> <span style="color:#CC0066; font-weight:bold;">puts</span> element <span style="color:#006600; font-weight:bold;">&#125;</span>
a
b
c
<span style="color:#006600; font-weight:bold;">=&gt;</span> <span style="color:#006600; font-weight:bold;">&#91;</span><span style="color:#ff3333; font-weight:bold;">:a</span>, <span style="color:#ff3333; font-weight:bold;">:b</span>, <span style="color:#ff3333; font-weight:bold;">:c</span><span style="color:#006600; font-weight:bold;">&#93;</span></pre></div></div>

<p>In Erlang we would do the following:</p>

<div class="wp_syntax"><div class="code"><pre class="erlang" style="font-family:monospace;"><span style="color: #ff9600;">3</span><span style="color: #014ea4;">&gt;</span> <span style="color: #109ab8;">&#91;</span><span style="color: #ff4e18;">io</span>:<span style="color: #ff3c00;">format</span><span style="color: #109ab8;">&#40;</span><span style="color: #ff7800;">&quot;~p~n&quot;</span><span style="color: #6bb810;">,</span> <span style="color: #109ab8;">&#91;</span><span style="color: #45b3e6;">Element</span><span style="color: #109ab8;">&#93;</span><span style="color: #109ab8;">&#41;</span> <span style="color: #014ea4;">||</span> <span style="color: #45b3e6;">Element</span> <span style="color: #014ea4;">&lt;-</span> <span style="color: #109ab8;">&#91;</span>a<span style="color: #6bb810;">,</span>b<span style="color: #6bb810;">,</span>c<span style="color: #109ab8;">&#93;</span><span style="color: #109ab8;">&#93;</span><span style="color: #6bb810;">.</span>
a
b
c
<span style="color: #109ab8;">&#91;</span>ok<span style="color: #6bb810;">,</span>ok<span style="color: #6bb810;">,</span>ok<span style="color: #109ab8;">&#93;</span></pre></div></div>

<p>There is one difference here: the Erlang list comprehension returns a new list which is the value of each call to <tt>io:format</tt>. In this way an Erlang list comprehension is closer to Ruby&#8217;s <tt>#collect</tt> rather than <tt>#each</tt>.</p>
<p>
We now have all the pieces to build our Erlang version of <tt>#each_with_index</tt>.</p>

<div class="wp_syntax"><div class="code"><pre class="erlang" style="font-family:monospace;"><span style="color: #ff9600;">4</span><span style="color: #014ea4;">&gt;</span> <span style="color: #45b3e6;">EachWithIndex</span> <span style="color: #014ea4;">=</span> <span style="color: #ff3c00;">fun</span><span style="color: #109ab8;">&#40;</span><span style="color: #45b3e6;">L</span><span style="color: #6bb810;">,</span> <span style="color: #45b3e6;">X</span><span style="color: #109ab8;">&#41;</span> <span style="color: #6bb810;">-&gt;</span> <span style="color: #109ab8;">&#91;</span>
  <span style="color: #45b3e6;">X</span><span style="color: #109ab8;">&#40;</span><span style="color: #45b3e6;">Element</span><span style="color: #6bb810;">,</span> <span style="color: #45b3e6;">Index</span><span style="color: #109ab8;">&#41;</span> <span style="color: #014ea4;">||</span> 
  <span style="color: #109ab8;">&#123;</span><span style="color: #45b3e6;">Element</span><span style="color: #6bb810;">,</span> <span style="color: #45b3e6;">Index</span><span style="color: #109ab8;">&#125;</span> <span style="color: #014ea4;">&lt;-</span> <span style="color: #ff4e18;">lists</span>:<span style="color: #ff3c00;">zip</span><span style="color: #109ab8;">&#40;</span><span style="color: #45b3e6;">L</span><span style="color: #6bb810;">,</span> <span style="color: #ff4e18;">lists</span>:<span style="color: #ff3c00;">seq</span><span style="color: #109ab8;">&#40;</span><span style="color: #ff9600;">1</span><span style="color: #6bb810;">,</span> <span style="color: #ff3c00;">length</span><span style="color: #109ab8;">&#40;</span><span style="color: #45b3e6;">L</span><span style="color: #109ab8;">&#41;</span><span style="color: #109ab8;">&#41;</span><span style="color: #109ab8;">&#41;</span>
   <span style="color: #109ab8;">&#93;</span> <span style="color: #186895;">end</span><span style="color: #6bb810;">.</span></pre></div></div>

<p>Whats going on here?</p>

<div class="wp_syntax"><div class="code"><pre class="erlang" style="font-family:monospace;"><span style="color: #ff4e18;">lists</span>:<span style="color: #ff3c00;">zip</span><span style="color: #109ab8;">&#40;</span><span style="color: #45b3e6;">L</span><span style="color: #6bb810;">,</span> <span style="color: #ff4e18;">lists</span>:<span style="color: #ff3c00;">seq</span><span style="color: #109ab8;">&#40;</span><span style="color: #ff9600;">1</span><span style="color: #6bb810;">,</span> <span style="color: #ff3c00;">length</span><span style="color: #109ab8;">&#40;</span><span style="color: #45b3e6;">L</span><span style="color: #109ab8;">&#41;</span><span style="color: #109ab8;">&#41;</span><span style="color: #109ab8;">&#41;</span></pre></div></div>

<p>creates a list of tuples with each tuple containing an element of <tt>L</tt> and a companion integer.</p>

<div class="wp_syntax"><div class="code"><pre class="erlang" style="font-family:monospace;"><span style="color: #109ab8;">&#91;</span><span style="color: #45b3e6;">X</span><span style="color: #109ab8;">&#40;</span><span style="color: #45b3e6;">Element</span><span style="color: #6bb810;">,</span> <span style="color: #45b3e6;">Index</span><span style="color: #109ab8;">&#41;</span> <span style="color: #014ea4;">||</span> 
  <span style="color: #109ab8;">&#123;</span><span style="color: #45b3e6;">Element</span><span style="color: #6bb810;">,</span> <span style="color: #45b3e6;">Index</span><span style="color: #109ab8;">&#125;</span> <span style="color: #014ea4;">&lt;-</span> <span style="color: #ff4e18;">lists</span>:<span style="color: #ff3c00;">zip</span><span style="color: #109ab8;">&#40;</span><span style="color: #45b3e6;">L</span><span style="color: #6bb810;">,</span> <span style="color: #ff4e18;">lists</span>:<span style="color: #ff3c00;">seq</span><span style="color: #109ab8;">&#40;</span><span style="color: #ff9600;">1</span><span style="color: #6bb810;">,</span> <span style="color: #ff3c00;">length</span><span style="color: #109ab8;">&#40;</span><span style="color: #45b3e6;">L</span><span style="color: #109ab8;">&#41;</span><span style="color: #109ab8;">&#41;</span><span style="color: #109ab8;">&#41;</span><span style="color: #109ab8;">&#93;</span></pre></div></div>

<p>tells us to take that list of tuples and do a list comprehension on each of the elements, calling <tt>fun X</tt> in turn.</p>

<div class="wp_syntax"><div class="code"><pre class="erlang" style="font-family:monospace;"><span style="color: #45b3e6;">EachWithIndex</span> <span style="color: #014ea4;">=</span> <span style="color: #ff3c00;">fun</span><span style="color: #109ab8;">&#40;</span><span style="color: #45b3e6;">L</span><span style="color: #6bb810;">,</span> <span style="color: #45b3e6;">X</span><span style="color: #109ab8;">&#41;</span> <span style="color: #6bb810;">-&gt;</span> <span style="color: #6bb810;">...</span> <span style="color: #186895;">end</span><span style="color: #6bb810;">.</span></pre></div></div>

<p>creates a <tt>fun</tt> (think <i>lambda</i>) and assigns it to <tt>EachWithIndex</tt>. You could just as easily create this as a regular function in a <tt>.erl</tt> file somewhere.
</p>
<p>
Now we can call our new <tt>EachWithIndex</tt> function by passing in a list and a <tt>fun</tt>:
</p>

<div class="wp_syntax"><div class="code"><pre class="erlang" style="font-family:monospace;"><span style="color: #ff9600;">5</span><span style="color: #014ea4;">&gt;</span> <span style="color: #45b3e6;">E</span><span style="color: #ff3c00;">achWithIndex</span><span style="color: #109ab8;">&#40;</span><span style="color: #109ab8;">&#91;</span>a<span style="color: #6bb810;">,</span>b<span style="color: #6bb810;">,</span>c<span style="color: #6bb810;">,</span>d<span style="color: #6bb810;">,</span>e<span style="color: #109ab8;">&#93;</span><span style="color: #6bb810;">,</span> <span style="color: #ff3c00;">fun</span><span style="color: #109ab8;">&#40;</span><span style="color: #45b3e6;">Element</span><span style="color: #6bb810;">,</span> <span style="color: #45b3e6;">Index</span><span style="color: #109ab8;">&#41;</span> <span style="color: #6bb810;">-&gt;</span> <span style="color: #ff4e18;">io</span>:<span style="color: #ff3c00;">format</span><span style="color: #109ab8;">&#40;</span><span style="color: #ff7800;">&quot;~p at ~p~n&quot;</span><span style="color: #6bb810;">,</span> <span style="color: #109ab8;">&#91;</span><span style="color: #45b3e6;">Element</span><span style="color: #6bb810;">,</span> <span style="color: #45b3e6;">Index</span><span style="color: #109ab8;">&#93;</span><span style="color: #109ab8;">&#41;</span> <span style="color: #186895;">end</span><span style="color: #109ab8;">&#41;</span><span style="color: #6bb810;">.</span>
a at <span style="color: #ff9600;">1</span>
b at <span style="color: #ff9600;">2</span>
c at <span style="color: #ff9600;">3</span>
d at <span style="color: #ff9600;">4</span>
e at <span style="color: #ff9600;">5</span>
<span style="color: #109ab8;">&#91;</span>ok<span style="color: #6bb810;">,</span>ok<span style="color: #6bb810;">,</span>ok<span style="color: #6bb810;">,</span>ok<span style="color: #6bb810;">,</span>ok<span style="color: #109ab8;">&#93;</span></pre></div></div>

<p>Share:</p>
<p>	<a rel="nofollow"  href="http://delicious.com/post?url=http%3A%2F%2Fwww.xcombinator.com%2F2009%2F02%2F10%2Frubys-each_with_index-for-erlang%2F&amp;title=Ruby%27s%20%3Ctt%3E%23each_with_index%3C%2Ftt%3E%20for%20Erlang&amp;notes=%0D%0ARuby%20has%20a%20great%20method%20for%20enumerations%20called%20%23each_with_index.%20It%27s%20a%20handy%20way%20to%20iterate%20over%20a%20list%20of%20elements%20and%20and%20know%20where%20you%27re%20at%20while%20doing%20it.%0D%0A%0D%0A%0D%0AErlang%20has%20a%20group%20of%20highly%20optimized%20list%20operations%20in%20the%20lists%20module%20%28Try%20" title="del.icio.us"><img src="http://www.xcombinator.com/wp-content/plugins/sociable/images/delicious.png" title="del.icio.us" alt="del.icio.us" class="sociable-hovers" /></a><br />
	<a rel="nofollow"  href="http://reddit.com/submit?url=http%3A%2F%2Fwww.xcombinator.com%2F2009%2F02%2F10%2Frubys-each_with_index-for-erlang%2F&amp;title=Ruby%27s%20%3Ctt%3E%23each_with_index%3C%2Ftt%3E%20for%20Erlang" title="Reddit"><img src="http://www.xcombinator.com/wp-content/plugins/sociable/images/reddit.png" title="Reddit" alt="Reddit" class="sociable-hovers" /></a><br />
	<a rel="nofollow"  href="http://technorati.com/faves?add=http%3A%2F%2Fwww.xcombinator.com%2F2009%2F02%2F10%2Frubys-each_with_index-for-erlang%2F" title="Technorati"><img src="http://www.xcombinator.com/wp-content/plugins/sociable/images/technorati.png" title="Technorati" alt="Technorati" class="sociable-hovers" /></a><br />
	<a rel="nofollow"  href="http://twitter.com/home?status=Ruby%27s%20%3Ctt%3E%23each_with_index%3C%2Ftt%3E%20for%20Erlang%20-%20http%3A%2F%2Fwww.xcombinator.com%2F2009%2F02%2F10%2Frubys-each_with_index-for-erlang%2F" title="Twitter"><img src="http://www.xcombinator.com/wp-content/plugins/sociable/images/twitter.png" title="Twitter" alt="Twitter" class="sociable-hovers" /></a><br />
	<a rel="nofollow"  href="http://www.facebook.com/share.php?u=http%3A%2F%2Fwww.xcombinator.com%2F2009%2F02%2F10%2Frubys-each_with_index-for-erlang%2F&amp;t=Ruby%27s%20%3Ctt%3E%23each_with_index%3C%2Ftt%3E%20for%20Erlang" title="Facebook"><img src="http://www.xcombinator.com/wp-content/plugins/sociable/images/facebook.png" title="Facebook" alt="Facebook" class="sociable-hovers" /></a><br />
	<a rel="nofollow"  href="http://www.google.com/bookmarks/mark?op=edit&amp;bkmk=http%3A%2F%2Fwww.xcombinator.com%2F2009%2F02%2F10%2Frubys-each_with_index-for-erlang%2F&amp;title=Ruby%27s%20%3Ctt%3E%23each_with_index%3C%2Ftt%3E%20for%20Erlang&amp;annotation=%0D%0ARuby%20has%20a%20great%20method%20for%20enumerations%20called%20%23each_with_index.%20It%27s%20a%20handy%20way%20to%20iterate%20over%20a%20list%20of%20elements%20and%20and%20know%20where%20you%27re%20at%20while%20doing%20it.%0D%0A%0D%0A%0D%0AErlang%20has%20a%20group%20of%20highly%20optimized%20list%20operations%20in%20the%20lists%20module%20%28Try%20" title="Google Bookmarks"><img src="http://www.xcombinator.com/wp-content/plugins/sociable/images/googlebookmark.png" title="Google Bookmarks" alt="Google Bookmarks" class="sociable-hovers" /></a><br />
	<a rel="nofollow"  href="http://news.ycombinator.com/submitlink?u=http%3A%2F%2Fwww.xcombinator.com%2F2009%2F02%2F10%2Frubys-each_with_index-for-erlang%2F&amp;t=Ruby%27s%20%3Ctt%3E%23each_with_index%3C%2Ftt%3E%20for%20Erlang" title="HackerNews"><img src="http://www.xcombinator.com/wp-content/plugins/sociable/images/hackernews.png" title="HackerNews" alt="HackerNews" class="sociable-hovers" /></a><br />
	<a rel="nofollow"  href="http://www.printfriendly.com/print?url=http%3A%2F%2Fwww.xcombinator.com%2F2009%2F02%2F10%2Frubys-each_with_index-for-erlang%2F&amp;partner=sociable" title="PDF"><img src="http://www.xcombinator.com/wp-content/plugins/sociable/images/pdf.png" title="PDF" alt="PDF" class="sociable-hovers" /></a><br />
	<a rel="nofollow"  href="http://www.xcombinator.com/feed/" title="RSS"><img src="http://www.xcombinator.com/wp-content/plugins/sociable/images/rss.png" title="RSS" alt="RSS" class="sociable-hovers" /></a></p>
<p><br/><br/></p>
]]></content:encoded>
			<wfw:commentRss>http://www.xcombinator.com/2009/02/10/rubys-each_with_index-for-erlang/feed/</wfw:commentRss>
		<slash:comments>2</slash:comments>
		<feedburner:origLink>http://www.xcombinator.com/2009/02/10/rubys-each_with_index-for-erlang/</feedburner:origLink></item>
		<item>
		<title>PoolParty s3fs Plugin</title>
		<link>http://feedproxy.google.com/~r/xcombinator/~3/hveQQVHGQcM/</link>
		<comments>http://www.xcombinator.com/2009/02/10/poolparty-s3fs-plugin/#comments</comments>
		<pubDate>Tue, 10 Feb 2009 17:51:41 +0000</pubDate>
		<dc:creator>Nate Murray</dc:creator>
				<category><![CDATA[deployment]]></category>
		<category><![CDATA[ec2]]></category>
		<category><![CDATA[git]]></category>
		<category><![CDATA[ruby]]></category>

		<guid isPermaLink="false">http://www.xcombinator.com/2009/02/10/poolparty-s3fs-plugin/</guid>
		<description><![CDATA[Goal
A new plugin install and mount s3fs volume on an instance using PoolParty.
Getting it
git clone git://github.com/jashmenn/poolparty-s3fs-plugin.git
Usage
NOTICE You must have already created your S3 bucket. This plugin will not
create it for you.

cloud&#40;:app&#41;
  ...
  s3fs&#40;:bucket =&#62; &#34;my-fun-bucket&#34;&#41;
  ...
end

This will be mounted at /mnt/my-fun-bucket
You can mount multiple buckets and/or change the mount point:

s3fs do
  [...]]]></description>
			<content:encoded><![CDATA[<h2>Goal</h2>
<p>A new plugin install and mount s3fs volume on an instance using PoolParty.</p>
<h2>Getting it</h2>
<p><tt>git clone git://github.com/jashmenn/poolparty-s3fs-plugin.git</tt></p>
<h2>Usage</h2>
<p><em>NOTICE</em> You must have already created your S3 bucket. This plugin will <em>not</em><br />
create it for you.</p>

<div class="wp_syntax"><div class="code"><pre class="ruby" style="font-family:monospace;">cloud<span style="color:#006600; font-weight:bold;">&#40;</span><span style="color:#ff3333; font-weight:bold;">:app</span><span style="color:#006600; font-weight:bold;">&#41;</span>
  ...
  <span style="color:#9900CC;">s3fs</span><span style="color:#006600; font-weight:bold;">&#40;</span><span style="color:#ff3333; font-weight:bold;">:bucket</span> <span style="color:#006600; font-weight:bold;">=&gt;</span> <span style="color:#996600;">&quot;my-fun-bucket&quot;</span><span style="color:#006600; font-weight:bold;">&#41;</span>
  ...
<span style="color:#9966CC; font-weight:bold;">end</span></pre></div></div>

<p>This will be mounted at <code>/mnt/my-fun-bucket</code><br />
You can mount multiple buckets and/or change the mount point:</p>

<div class="wp_syntax"><div class="code"><pre class="ruby" style="font-family:monospace;">s3fs <span style="color:#9966CC; font-weight:bold;">do</span>
  bucket <span style="color:#996600;">&quot;my-fun-bucket&quot;</span>
  bucket <span style="color:#996600;">&quot;my-other-bucket&quot;</span>, <span style="color:#996600;">&quot;/mnt/a-disk&quot;</span>
<span style="color:#9966CC; font-weight:bold;">end</span></pre></div></div>

<h2>References:</h2>
<ul>
<li><a href="http://code.google.com/p/s3fs/wiki/FuseOverAmazon">http://code.google.com/p/s3fs/wiki/FuseOverAmazon</a></li>
<li><a href="http://groups.google.com/group/ec2ubuntu/browse_thread/thread/9093236bc07d220b?pli=1">http://groups.google.com/group/ec2ubuntu/browse_thread/thread/9093236bc07d220b?pli=1</a></li>
</ul>
<p>Share:</p>
<p>	<a rel="nofollow"  href="http://delicious.com/post?url=http%3A%2F%2Fwww.xcombinator.com%2F2009%2F02%2F10%2Fpoolparty-s3fs-plugin%2F&amp;title=PoolParty%20s3fs%20Plugin&amp;notes=Goal%0D%0A%0D%0AA%20new%20plugin%20install%20and%20mount%20s3fs%20volume%20on%20an%20instance%20using%20PoolParty.%0D%0A%0D%0AGetting%20it%0D%0Agit%20clone%20git%3A%2F%2Fgithub.com%2Fjashmenn%2Fpoolparty-s3fs-plugin.git%0D%0A%0D%0AUsage%0D%0A%0D%0ANOTICE%20You%20must%20have%20already%20created%20your%20S3%20bucket.%20This%20plugin%20will%20not%0D%0Acre" title="del.icio.us"><img src="http://www.xcombinator.com/wp-content/plugins/sociable/images/delicious.png" title="del.icio.us" alt="del.icio.us" class="sociable-hovers" /></a><br />
	<a rel="nofollow"  href="http://reddit.com/submit?url=http%3A%2F%2Fwww.xcombinator.com%2F2009%2F02%2F10%2Fpoolparty-s3fs-plugin%2F&amp;title=PoolParty%20s3fs%20Plugin" title="Reddit"><img src="http://www.xcombinator.com/wp-content/plugins/sociable/images/reddit.png" title="Reddit" alt="Reddit" class="sociable-hovers" /></a><br />
	<a rel="nofollow"  href="http://technorati.com/faves?add=http%3A%2F%2Fwww.xcombinator.com%2F2009%2F02%2F10%2Fpoolparty-s3fs-plugin%2F" title="Technorati"><img src="http://www.xcombinator.com/wp-content/plugins/sociable/images/technorati.png" title="Technorati" alt="Technorati" class="sociable-hovers" /></a><br />
	<a rel="nofollow"  href="http://twitter.com/home?status=PoolParty%20s3fs%20Plugin%20-%20http%3A%2F%2Fwww.xcombinator.com%2F2009%2F02%2F10%2Fpoolparty-s3fs-plugin%2F" title="Twitter"><img src="http://www.xcombinator.com/wp-content/plugins/sociable/images/twitter.png" title="Twitter" alt="Twitter" class="sociable-hovers" /></a><br />
	<a rel="nofollow"  href="http://www.facebook.com/share.php?u=http%3A%2F%2Fwww.xcombinator.com%2F2009%2F02%2F10%2Fpoolparty-s3fs-plugin%2F&amp;t=PoolParty%20s3fs%20Plugin" title="Facebook"><img src="http://www.xcombinator.com/wp-content/plugins/sociable/images/facebook.png" title="Facebook" alt="Facebook" class="sociable-hovers" /></a><br />
	<a rel="nofollow"  href="http://www.google.com/bookmarks/mark?op=edit&amp;bkmk=http%3A%2F%2Fwww.xcombinator.com%2F2009%2F02%2F10%2Fpoolparty-s3fs-plugin%2F&amp;title=PoolParty%20s3fs%20Plugin&amp;annotation=Goal%0D%0A%0D%0AA%20new%20plugin%20install%20and%20mount%20s3fs%20volume%20on%20an%20instance%20using%20PoolParty.%0D%0A%0D%0AGetting%20it%0D%0Agit%20clone%20git%3A%2F%2Fgithub.com%2Fjashmenn%2Fpoolparty-s3fs-plugin.git%0D%0A%0D%0AUsage%0D%0A%0D%0ANOTICE%20You%20must%20have%20already%20created%20your%20S3%20bucket.%20This%20plugin%20will%20not%0D%0Acre" title="Google Bookmarks"><img src="http://www.xcombinator.com/wp-content/plugins/sociable/images/googlebookmark.png" title="Google Bookmarks" alt="Google Bookmarks" class="sociable-hovers" /></a><br />
	<a rel="nofollow"  href="http://news.ycombinator.com/submitlink?u=http%3A%2F%2Fwww.xcombinator.com%2F2009%2F02%2F10%2Fpoolparty-s3fs-plugin%2F&amp;t=PoolParty%20s3fs%20Plugin" title="HackerNews"><img src="http://www.xcombinator.com/wp-content/plugins/sociable/images/hackernews.png" title="HackerNews" alt="HackerNews" class="sociable-hovers" /></a><br />
	<a rel="nofollow"  href="http://www.printfriendly.com/print?url=http%3A%2F%2Fwww.xcombinator.com%2F2009%2F02%2F10%2Fpoolparty-s3fs-plugin%2F&amp;partner=sociable" title="PDF"><img src="http://www.xcombinator.com/wp-content/plugins/sociable/images/pdf.png" title="PDF" alt="PDF" class="sociable-hovers" /></a><br />
	<a rel="nofollow"  href="http://www.xcombinator.com/feed/" title="RSS"><img src="http://www.xcombinator.com/wp-content/plugins/sociable/images/rss.png" title="RSS" alt="RSS" class="sociable-hovers" /></a></p>
<p><br/><br/></p>
]]></content:encoded>
			<wfw:commentRss>http://www.xcombinator.com/2009/02/10/poolparty-s3fs-plugin/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		<feedburner:origLink>http://www.xcombinator.com/2009/02/10/poolparty-s3fs-plugin/</feedburner:origLink></item>
		<item>
		<title>PoolParty MRTG Plugin</title>
		<link>http://feedproxy.google.com/~r/xcombinator/~3/NTy5rHhP40Q/</link>
		<comments>http://www.xcombinator.com/2009/02/03/poolparty-mrtg-plugin/#comments</comments>
		<pubDate>Wed, 04 Feb 2009 04:28:06 +0000</pubDate>
		<dc:creator>Nate Murray</dc:creator>
				<category><![CDATA[code]]></category>
		<category><![CDATA[deployment]]></category>
		<category><![CDATA[ec2]]></category>
		<category><![CDATA[poolparty]]></category>
		<category><![CDATA[scalability]]></category>
		<category><![CDATA[sysadmin]]></category>

		<guid isPermaLink="false">http://www.xcombinator.com/2009/02/03/poolparty-mrtg-plugin/</guid>
		<description><![CDATA[I&#8217;ve created a PoolParty plugin that makes it dead-simple to install ]]></description>
			<content:encoded><![CDATA[<p>I&#8217;ve created a <a href="http://www.poolpartyrb.com">PoolParty</a> plugin that makes it dead-simple to install <a href="http://oss.oetiker.ch/mrtg/>MRTG</a> on the nodes in your cloud</p>
<p>The <a href="http://github.com/jashmenn/poolparty-mrtg-plugin/tree/master">GitHub Repo is here</a>.</p>
<p>or <tt>git clone git://github.com/jashmenn/poolparty-mrtg-plugin.git</tt></p>
<p>Usage:</p>
<p>Declare <tt>mrtg</tt> in your <tt>cloud</tt> block</p>

<div class="wp_syntax"><div class="code"><pre class="ruby" style="font-family:monospace;">mrtg <span style="color:#9966CC; font-weight:bold;">do</span>
   monitor <span style="color:#ff3333; font-weight:bold;">:cpu</span>, <span style="color:#ff3333; font-weight:bold;">:uptime</span>, <span style="color:#ff3333; font-weight:bold;">:memory</span>, <span style="color:#ff3333; font-weight:bold;">:open_files</span>, <span style="color:#ff3333; font-weight:bold;">:processes</span>, <span style="color:#ff3333; font-weight:bold;">:apache</span>, <span style="color:#ff3333; font-weight:bold;">:network_interfaces</span>
<span style="color:#9966CC; font-weight:bold;">end</span></pre></div></div>

</p>
<p><img src='http://www.xcombinator.com/wp-content/uploads/2009/02/picture-11.png' alt='picture-11.png' /></p>
<p>Share:</p>
<p>	<a rel="nofollow"  href="http://delicious.com/post?url=http%3A%2F%2Fwww.xcombinator.com%2F2009%2F02%2F03%2Fpoolparty-mrtg-plugin%2F&amp;title=PoolParty%20MRTG%20Plugin&amp;notes=I%27ve%20created%20a%20PoolParty%20plugin%20that%20makes%20it%20dead-simple%20to%20install%20" title="del.icio.us"><img src="http://www.xcombinator.com/wp-content/plugins/sociable/images/delicious.png" title="del.icio.us" alt="del.icio.us" class="sociable-hovers" /></a><br />
	<a rel="nofollow"  href="http://reddit.com/submit?url=http%3A%2F%2Fwww.xcombinator.com%2F2009%2F02%2F03%2Fpoolparty-mrtg-plugin%2F&amp;title=PoolParty%20MRTG%20Plugin" title="Reddit"><img src="http://www.xcombinator.com/wp-content/plugins/sociable/images/reddit.png" title="Reddit" alt="Reddit" class="sociable-hovers" /></a><br />
	<a rel="nofollow"  href="http://technorati.com/faves?add=http%3A%2F%2Fwww.xcombinator.com%2F2009%2F02%2F03%2Fpoolparty-mrtg-plugin%2F" title="Technorati"><img src="http://www.xcombinator.com/wp-content/plugins/sociable/images/technorati.png" title="Technorati" alt="Technorati" class="sociable-hovers" /></a><br />
	<a rel="nofollow"  href="http://twitter.com/home?status=PoolParty%20MRTG%20Plugin%20-%20http%3A%2F%2Fwww.xcombinator.com%2F2009%2F02%2F03%2Fpoolparty-mrtg-plugin%2F" title="Twitter"><img src="http://www.xcombinator.com/wp-content/plugins/sociable/images/twitter.png" title="Twitter" alt="Twitter" class="sociable-hovers" /></a><br />
	<a rel="nofollow"  href="http://www.facebook.com/share.php?u=http%3A%2F%2Fwww.xcombinator.com%2F2009%2F02%2F03%2Fpoolparty-mrtg-plugin%2F&amp;t=PoolParty%20MRTG%20Plugin" title="Facebook"><img src="http://www.xcombinator.com/wp-content/plugins/sociable/images/facebook.png" title="Facebook" alt="Facebook" class="sociable-hovers" /></a><br />
	<a rel="nofollow"  href="http://www.google.com/bookmarks/mark?op=edit&amp;bkmk=http%3A%2F%2Fwww.xcombinator.com%2F2009%2F02%2F03%2Fpoolparty-mrtg-plugin%2F&amp;title=PoolParty%20MRTG%20Plugin&amp;annotation=I%27ve%20created%20a%20PoolParty%20plugin%20that%20makes%20it%20dead-simple%20to%20install%20" title="Google Bookmarks"><img src="http://www.xcombinator.com/wp-content/plugins/sociable/images/googlebookmark.png" title="Google Bookmarks" alt="Google Bookmarks" class="sociable-hovers" /></a><br />
	<a rel="nofollow"  href="http://news.ycombinator.com/submitlink?u=http%3A%2F%2Fwww.xcombinator.com%2F2009%2F02%2F03%2Fpoolparty-mrtg-plugin%2F&amp;t=PoolParty%20MRTG%20Plugin" title="HackerNews"><img src="http://www.xcombinator.com/wp-content/plugins/sociable/images/hackernews.png" title="HackerNews" alt="HackerNews" class="sociable-hovers" /></a><br />
	<a rel="nofollow"  href="http://www.printfriendly.com/print?url=http%3A%2F%2Fwww.xcombinator.com%2F2009%2F02%2F03%2Fpoolparty-mrtg-plugin%2F&amp;partner=sociable" title="PDF"><img src="http://www.xcombinator.com/wp-content/plugins/sociable/images/pdf.png" title="PDF" alt="PDF" class="sociable-hovers" /></a><br />
	<a rel="nofollow"  href="http://www.xcombinator.com/feed/" title="RSS"><img src="http://www.xcombinator.com/wp-content/plugins/sociable/images/rss.png" title="RSS" alt="RSS" class="sociable-hovers" /></a></p>
<p><br/><br/></p>
]]></content:encoded>
			<wfw:commentRss>http://www.xcombinator.com/2009/02/03/poolparty-mrtg-plugin/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		<feedburner:origLink>http://www.xcombinator.com/2009/02/03/poolparty-mrtg-plugin/</feedburner:origLink></item>
		<item>
		<title>Getting Started with PoolParty and EC2</title>
		<link>http://feedproxy.google.com/~r/xcombinator/~3/i3tk1Cz_1K4/</link>
		<comments>http://www.xcombinator.com/2009/02/03/getting-started-with-poolparty-and-ec2/#comments</comments>
		<pubDate>Wed, 04 Feb 2009 04:07:48 +0000</pubDate>
		<dc:creator>Nate Murray</dc:creator>
				<category><![CDATA[deployment]]></category>
		<category><![CDATA[ec2]]></category>
		<category><![CDATA[poolparty]]></category>
		<category><![CDATA[ruby]]></category>
		<category><![CDATA[scalability]]></category>

		<guid isPermaLink="false">http://www.xcombinator.com/2009/02/03/getting-started-with-poolparty-and-ec2/</guid>
		<description><![CDATA[Today I gave a presentation and workshop titled &#8220;Getting Started with PoolParty and EC2&#8243;. The goal was to 1) be an introduction to the myriad of terms used in Amazon&#8217;s cloud computing infrastructure and to 2) be a practical introduction to PoolParty configuration and provisioning.
Posted below are the slides. The slides alone certainly are not [...]]]></description>
			<content:encoded><![CDATA[<p>Today I gave a presentation and workshop titled &#8220;Getting Started with PoolParty and EC2&#8243;. The goal was to 1) be an introduction to the myriad of terms used in Amazon&#8217;s cloud computing infrastructure and to 2) be a practical introduction to PoolParty configuration and provisioning.</p>
<p>Posted below are the slides. The slides alone certainly are not enough for a complete introduction to PoolParty. However, I hope they have some information that is helpful to beginners.</p>
<div style="width:425px;text-align:left" id="__ss_986273"><a style="font:14px Helvetica,Arial,Sans-serif;display:block;margin:12px 0 3px 0;text-decoration:underline;" href="http://www.slideshare.net/jashmenn/getting-started-with-poolparty-and-ec2?type=powerpoint" title="Getting Started with PoolParty and EC2">Getting Started with PoolParty and EC2</a><object style="margin:0px" width="425" height="355"><param name="movie" value="http://static.slideshare.net/swf/ssplayer2.swf?doc=gettingstartedpresentation-1233710085637297-3&#038;stripped_title=getting-started-with-poolparty-and-ec2" /><param name="allowFullScreen" value="true"/><param name="allowScriptAccess" value="always"/><embed src="http://static.slideshare.net/swf/ssplayer2.swf?doc=gettingstartedpresentation-1233710085637297-3&#038;stripped_title=getting-started-with-poolparty-and-ec2" type="application/x-shockwave-flash" allowscriptaccess="always" allowfullscreen="true" width="425" height="355"></embed></object></p>
<div style="font-size:11px;font-family:tahoma,arial;height:26px;padding-top:2px;">View more <a style="text-decoration:underline;" href="http://www.slideshare.net/">presentations</a> from <a style="text-decoration:underline;" href="http://www.slideshare.net/jashmenn">jashmenn</a>. (tags: <a style="text-decoration:underline;" href="http://slideshare.net/tag/ec2">ec2</a> <a style="text-decoration:underline;" href="http://slideshare.net/tag/poolparty">poolparty</a>)</div>
</div>
<p>Check out the <a href="http://wiki.github.com/auser/poolparty">PoolParty wiki</a> for more documentation.</p>
<p>Share:</p>
<p>	<a rel="nofollow"  href="http://delicious.com/post?url=http%3A%2F%2Fwww.xcombinator.com%2F2009%2F02%2F03%2Fgetting-started-with-poolparty-and-ec2%2F&amp;title=Getting%20Started%20with%20PoolParty%20and%20EC2&amp;notes=Today%20I%20gave%20a%20presentation%20and%20workshop%20titled%20%22Getting%20Started%20with%20PoolParty%20and%20EC2%22.%20The%20goal%20was%20to%201%29%20be%20an%20introduction%20to%20the%20myriad%20of%20terms%20used%20in%20Amazon%27s%20cloud%20computing%20infrastructure%20and%20to%202%29%20be%20a%20practical%20introduction%20to%20PoolParty%20" title="del.icio.us"><img src="http://www.xcombinator.com/wp-content/plugins/sociable/images/delicious.png" title="del.icio.us" alt="del.icio.us" class="sociable-hovers" /></a><br />
	<a rel="nofollow"  href="http://reddit.com/submit?url=http%3A%2F%2Fwww.xcombinator.com%2F2009%2F02%2F03%2Fgetting-started-with-poolparty-and-ec2%2F&amp;title=Getting%20Started%20with%20PoolParty%20and%20EC2" title="Reddit"><img src="http://www.xcombinator.com/wp-content/plugins/sociable/images/reddit.png" title="Reddit" alt="Reddit" class="sociable-hovers" /></a><br />
	<a rel="nofollow"  href="http://technorati.com/faves?add=http%3A%2F%2Fwww.xcombinator.com%2F2009%2F02%2F03%2Fgetting-started-with-poolparty-and-ec2%2F" title="Technorati"><img src="http://www.xcombinator.com/wp-content/plugins/sociable/images/technorati.png" title="Technorati" alt="Technorati" class="sociable-hovers" /></a><br />
	<a rel="nofollow"  href="http://twitter.com/home?status=Getting%20Started%20with%20PoolParty%20and%20EC2%20-%20http%3A%2F%2Fwww.xcombinator.com%2F2009%2F02%2F03%2Fgetting-started-with-poolparty-and-ec2%2F" title="Twitter"><img src="http://www.xcombinator.com/wp-content/plugins/sociable/images/twitter.png" title="Twitter" alt="Twitter" class="sociable-hovers" /></a><br />
	<a rel="nofollow"  href="http://www.facebook.com/share.php?u=http%3A%2F%2Fwww.xcombinator.com%2F2009%2F02%2F03%2Fgetting-started-with-poolparty-and-ec2%2F&amp;t=Getting%20Started%20with%20PoolParty%20and%20EC2" title="Facebook"><img src="http://www.xcombinator.com/wp-content/plugins/sociable/images/facebook.png" title="Facebook" alt="Facebook" class="sociable-hovers" /></a><br />
	<a rel="nofollow"  href="http://www.google.com/bookmarks/mark?op=edit&amp;bkmk=http%3A%2F%2Fwww.xcombinator.com%2F2009%2F02%2F03%2Fgetting-started-with-poolparty-and-ec2%2F&amp;title=Getting%20Started%20with%20PoolParty%20and%20EC2&amp;annotation=Today%20I%20gave%20a%20presentation%20and%20workshop%20titled%20%22Getting%20Started%20with%20PoolParty%20and%20EC2%22.%20The%20goal%20was%20to%201%29%20be%20an%20introduction%20to%20the%20myriad%20of%20terms%20used%20in%20Amazon%27s%20cloud%20computing%20infrastructure%20and%20to%202%29%20be%20a%20practical%20introduction%20to%20PoolParty%20" title="Google Bookmarks"><img src="http://www.xcombinator.com/wp-content/plugins/sociable/images/googlebookmark.png" title="Google Bookmarks" alt="Google Bookmarks" class="sociable-hovers" /></a><br />
	<a rel="nofollow"  href="http://news.ycombinator.com/submitlink?u=http%3A%2F%2Fwww.xcombinator.com%2F2009%2F02%2F03%2Fgetting-started-with-poolparty-and-ec2%2F&amp;t=Getting%20Started%20with%20PoolParty%20and%20EC2" title="HackerNews"><img src="http://www.xcombinator.com/wp-content/plugins/sociable/images/hackernews.png" title="HackerNews" alt="HackerNews" class="sociable-hovers" /></a><br />
	<a rel="nofollow"  href="http://www.printfriendly.com/print?url=http%3A%2F%2Fwww.xcombinator.com%2F2009%2F02%2F03%2Fgetting-started-with-poolparty-and-ec2%2F&amp;partner=sociable" title="PDF"><img src="http://www.xcombinator.com/wp-content/plugins/sociable/images/pdf.png" title="PDF" alt="PDF" class="sociable-hovers" /></a><br />
	<a rel="nofollow"  href="http://www.xcombinator.com/feed/" title="RSS"><img src="http://www.xcombinator.com/wp-content/plugins/sociable/images/rss.png" title="RSS" alt="RSS" class="sociable-hovers" /></a></p>
<p><br/><br/></p>
]]></content:encoded>
			<wfw:commentRss>http://www.xcombinator.com/2009/02/03/getting-started-with-poolparty-and-ec2/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		<feedburner:origLink>http://www.xcombinator.com/2009/02/03/getting-started-with-poolparty-and-ec2/</feedburner:origLink></item>
		<item>
		<title>Whatsmyip from the Command Line</title>
		<link>http://feedproxy.google.com/~r/xcombinator/~3/9OROqPnoBMQ/</link>
		<comments>http://www.xcombinator.com/2009/01/21/whatsmyip-from-the-command-line/#comments</comments>
		<pubDate>Wed, 21 Jan 2009 17:20:31 +0000</pubDate>
		<dc:creator>adam</dc:creator>
				<category><![CDATA[programming]]></category>

		<guid isPermaLink="false">http://www.xcombinator.com/2009/01/21/whatsmyip-from-the-command-line/</guid>
		<description><![CDATA[Nice little one liner to obtain your WAN IP address.

&#160;
curl http://www.whatismyip.com/automation/n09230945.asp ; echo

Then alias that badboy E.g.:

&#160;
alias whatsmyip='curl http://www.whatismyip.com/automation/n09230945.asp ; echo'

Happy day.
Share:
	
	
	
	
	
	
	
	
	

]]></description>
			<content:encoded><![CDATA[<p>Nice little one liner to obtain your WAN IP address.</p>

<div class="wp_syntax"><div class="code"><pre class="bash" style="font-family:monospace;">&nbsp;
curl http:<span style="color: #000000; font-weight: bold;">//</span>www.whatismyip.com<span style="color: #000000; font-weight: bold;">/</span>automation<span style="color: #000000; font-weight: bold;">/</span>n09230945.asp ; <span style="color: #7a0874; font-weight: bold;">echo</span></pre></div></div>

<p>Then alias that badboy E.g.:</p>

<div class="wp_syntax"><div class="code"><pre class="bash" style="font-family:monospace;">&nbsp;
<span style="color: #7a0874; font-weight: bold;">alias</span> <span style="color: #007800;">whatsmyip</span>=<span style="color: #ff0000;">'curl http://www.whatismyip.com/automation/n09230945.asp ; echo'</span></pre></div></div>

<p>Happy day.</p>
<p>Share:</p>
<p>	<a rel="nofollow"  href="http://delicious.com/post?url=http%3A%2F%2Fwww.xcombinator.com%2F2009%2F01%2F21%2Fwhatsmyip-from-the-command-line%2F&amp;title=Whatsmyip%20from%20the%20Command%20Line&amp;notes=Nice%20little%20one%20liner%20to%20obtain%20your%20WAN%20IP%20address.%0D%0A%0D%0A%0D%0Acurl%20http%3A%2F%2Fwww.whatismyip.com%2Fautomation%2Fn09230945.asp%20%3B%20echo%0D%0AThen%20alias%20that%20badboy%20E.g.%3A%0D%0A%0D%0A%0D%0Aalias%20whatsmyip%3D%27curl%20http%3A%2F%2Fwww.whatismyip.com%2Fautomation%2Fn09230945.asp%20%3B%20echo%27%0D%0AHappy%20day." title="del.icio.us"><img src="http://www.xcombinator.com/wp-content/plugins/sociable/images/delicious.png" title="del.icio.us" alt="del.icio.us" class="sociable-hovers" /></a><br />
	<a rel="nofollow"  href="http://reddit.com/submit?url=http%3A%2F%2Fwww.xcombinator.com%2F2009%2F01%2F21%2Fwhatsmyip-from-the-command-line%2F&amp;title=Whatsmyip%20from%20the%20Command%20Line" title="Reddit"><img src="http://www.xcombinator.com/wp-content/plugins/sociable/images/reddit.png" title="Reddit" alt="Reddit" class="sociable-hovers" /></a><br />
	<a rel="nofollow"  href="http://technorati.com/faves?add=http%3A%2F%2Fwww.xcombinator.com%2F2009%2F01%2F21%2Fwhatsmyip-from-the-command-line%2F" title="Technorati"><img src="http://www.xcombinator.com/wp-content/plugins/sociable/images/technorati.png" title="Technorati" alt="Technorati" class="sociable-hovers" /></a><br />
	<a rel="nofollow"  href="http://twitter.com/home?status=Whatsmyip%20from%20the%20Command%20Line%20-%20http%3A%2F%2Fwww.xcombinator.com%2F2009%2F01%2F21%2Fwhatsmyip-from-the-command-line%2F" title="Twitter"><img src="http://www.xcombinator.com/wp-content/plugins/sociable/images/twitter.png" title="Twitter" alt="Twitter" class="sociable-hovers" /></a><br />
	<a rel="nofollow"  href="http://www.facebook.com/share.php?u=http%3A%2F%2Fwww.xcombinator.com%2F2009%2F01%2F21%2Fwhatsmyip-from-the-command-line%2F&amp;t=Whatsmyip%20from%20the%20Command%20Line" title="Facebook"><img src="http://www.xcombinator.com/wp-content/plugins/sociable/images/facebook.png" title="Facebook" alt="Facebook" class="sociable-hovers" /></a><br />
	<a rel="nofollow"  href="http://www.google.com/bookmarks/mark?op=edit&amp;bkmk=http%3A%2F%2Fwww.xcombinator.com%2F2009%2F01%2F21%2Fwhatsmyip-from-the-command-line%2F&amp;title=Whatsmyip%20from%20the%20Command%20Line&amp;annotation=Nice%20little%20one%20liner%20to%20obtain%20your%20WAN%20IP%20address.%0D%0A%0D%0A%0D%0Acurl%20http%3A%2F%2Fwww.whatismyip.com%2Fautomation%2Fn09230945.asp%20%3B%20echo%0D%0AThen%20alias%20that%20badboy%20E.g.%3A%0D%0A%0D%0A%0D%0Aalias%20whatsmyip%3D%27curl%20http%3A%2F%2Fwww.whatismyip.com%2Fautomation%2Fn09230945.asp%20%3B%20echo%27%0D%0AHappy%20day." title="Google Bookmarks"><img src="http://www.xcombinator.com/wp-content/plugins/sociable/images/googlebookmark.png" title="Google Bookmarks" alt="Google Bookmarks" class="sociable-hovers" /></a><br />
	<a rel="nofollow"  href="http://news.ycombinator.com/submitlink?u=http%3A%2F%2Fwww.xcombinator.com%2F2009%2F01%2F21%2Fwhatsmyip-from-the-command-line%2F&amp;t=Whatsmyip%20from%20the%20Command%20Line" title="HackerNews"><img src="http://www.xcombinator.com/wp-content/plugins/sociable/images/hackernews.png" title="HackerNews" alt="HackerNews" class="sociable-hovers" /></a><br />
	<a rel="nofollow"  href="http://www.printfriendly.com/print?url=http%3A%2F%2Fwww.xcombinator.com%2F2009%2F01%2F21%2Fwhatsmyip-from-the-command-line%2F&amp;partner=sociable" title="PDF"><img src="http://www.xcombinator.com/wp-content/plugins/sociable/images/pdf.png" title="PDF" alt="PDF" class="sociable-hovers" /></a><br />
	<a rel="nofollow"  href="http://www.xcombinator.com/feed/" title="RSS"><img src="http://www.xcombinator.com/wp-content/plugins/sociable/images/rss.png" title="RSS" alt="RSS" class="sociable-hovers" /></a></p>
<p><br/><br/></p>
]]></content:encoded>
			<wfw:commentRss>http://www.xcombinator.com/2009/01/21/whatsmyip-from-the-command-line/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		<feedburner:origLink>http://www.xcombinator.com/2009/01/21/whatsmyip-from-the-command-line/</feedburner:origLink></item>
		<item>
		<title>cp a symlink to multiple directories</title>
		<link>http://feedproxy.google.com/~r/xcombinator/~3/IqUWZSToro0/</link>
		<comments>http://www.xcombinator.com/2009/01/14/cp-a-symlink-to-multiple-directories/#comments</comments>
		<pubDate>Wed, 14 Jan 2009 17:18:01 +0000</pubDate>
		<dc:creator>adam</dc:creator>
				<category><![CDATA[osx]]></category>
		<category><![CDATA[shell]]></category>
		<category><![CDATA[sysadmin]]></category>
		<category><![CDATA[tips]]></category>

		<guid isPermaLink="false">http://www.xcombinator.com/2009/01/14/cp-a-symlink-to-multiple-directories/</guid>
		<description><![CDATA[Today I wanted to copy a symlink to many different directories. So I tried the following:

for f in `find . -regex ''.*cp.*snippets''` ; do cp bbb.html $f/ ; done

Which returned:

cp: cannot stat `bbb.html': No such file or directory

bbb.html is a symlink and the default behavior of cp (I think) is to try and copy the [...]]]></description>
			<content:encoded><![CDATA[<p>Today I wanted to copy a symlink to many different directories. So I tried the following:</p>

<div class="wp_syntax"><div class="code"><pre class="bash" style="font-family:monospace;"><span style="color: #000000; font-weight: bold;">for</span> f <span style="color: #000000; font-weight: bold;">in</span> <span style="color: #000000; font-weight: bold;">`</span><span style="color: #c20cb9; font-weight: bold;">find</span> . <span style="color: #660033;">-regex</span> <span style="color: #ff0000;">''</span>.<span style="color: #000000; font-weight: bold;">*</span>cp.<span style="color: #000000; font-weight: bold;">*</span>snippets<span style="color: #ff0000;">''</span><span style="color: #000000; font-weight: bold;">`</span> ; <span style="color: #000000; font-weight: bold;">do</span> <span style="color: #c20cb9; font-weight: bold;">cp</span> bbb.html <span style="color: #007800;">$f</span><span style="color: #000000; font-weight: bold;">/</span> ; <span style="color: #000000; font-weight: bold;">done</span></pre></div></div>

<p>Which returned:</p>

<div class="wp_syntax"><div class="code"><pre class="bash" style="font-family:monospace;"><span style="color: #c20cb9; font-weight: bold;">cp</span>: cannot <span style="color: #c20cb9; font-weight: bold;">stat</span> <span style="color: #000000; font-weight: bold;">`</span>bbb.html<span style="color: #ff0000;">': No such file or directory</span></pre></div></div>

<p>bbb.html is a symlink and the default behavior of cp (I think) is to try and copy the actual file, which didn&#8217;t exist from the current directory. So just adding the <strong>-R</strong> made cp copy it as a symlink with the final command being:</p>

<div class="wp_syntax"><div class="code"><pre class="bash" style="font-family:monospace;"><span style="color: #000000; font-weight: bold;">for</span> f <span style="color: #000000; font-weight: bold;">in</span> <span style="color: #000000; font-weight: bold;">`</span><span style="color: #c20cb9; font-weight: bold;">find</span> . <span style="color: #660033;">-regex</span> <span style="color: #ff0000;">''</span>.<span style="color: #000000; font-weight: bold;">*</span>cp.<span style="color: #000000; font-weight: bold;">*</span>snippets<span style="color: #ff0000;">''</span><span style="color: #000000; font-weight: bold;">`</span> ; <span style="color: #000000; font-weight: bold;">do</span> <span style="color: #c20cb9; font-weight: bold;">cp</span> <span style="color: #660033;">-R</span> bbb.html <span style="color: #007800;">$f</span><span style="color: #000000; font-weight: bold;">/</span> ; <span style="color: #000000; font-weight: bold;">done</span></pre></div></div>

<p>Share:</p>
<p>	<a rel="nofollow"  href="http://delicious.com/post?url=http%3A%2F%2Fwww.xcombinator.com%2F2009%2F01%2F14%2Fcp-a-symlink-to-multiple-directories%2F&amp;title=cp%20a%20symlink%20to%20multiple%20directories&amp;notes=Today%20I%20wanted%20to%20copy%20a%20symlink%20to%20many%20different%20directories.%20So%20I%20tried%20the%20following%3A%0D%0A%0D%0Afor%20f%20in%20%60find%20.%20-regex%20%27%27.%2Acp.%2Asnippets%27%27%60%20%3B%20do%20cp%20bbb.html%20%24f%2F%20%3B%20done%0D%0AWhich%20returned%3A%0D%0A%0D%0Acp%3A%20cannot%20stat%20%60bbb.html%27%3A%20No%20such%20file%20or%20directory%0D%0Abbb.html%20i" title="del.icio.us"><img src="http://www.xcombinator.com/wp-content/plugins/sociable/images/delicious.png" title="del.icio.us" alt="del.icio.us" class="sociable-hovers" /></a><br />
	<a rel="nofollow"  href="http://reddit.com/submit?url=http%3A%2F%2Fwww.xcombinator.com%2F2009%2F01%2F14%2Fcp-a-symlink-to-multiple-directories%2F&amp;title=cp%20a%20symlink%20to%20multiple%20directories" title="Reddit"><img src="http://www.xcombinator.com/wp-content/plugins/sociable/images/reddit.png" title="Reddit" alt="Reddit" class="sociable-hovers" /></a><br />
	<a rel="nofollow"  href="http://technorati.com/faves?add=http%3A%2F%2Fwww.xcombinator.com%2F2009%2F01%2F14%2Fcp-a-symlink-to-multiple-directories%2F" title="Technorati"><img src="http://www.xcombinator.com/wp-content/plugins/sociable/images/technorati.png" title="Technorati" alt="Technorati" class="sociable-hovers" /></a><br />
	<a rel="nofollow"  href="http://twitter.com/home?status=cp%20a%20symlink%20to%20multiple%20directories%20-%20http%3A%2F%2Fwww.xcombinator.com%2F2009%2F01%2F14%2Fcp-a-symlink-to-multiple-directories%2F" title="Twitter"><img src="http://www.xcombinator.com/wp-content/plugins/sociable/images/twitter.png" title="Twitter" alt="Twitter" class="sociable-hovers" /></a><br />
	<a rel="nofollow"  href="http://www.facebook.com/share.php?u=http%3A%2F%2Fwww.xcombinator.com%2F2009%2F01%2F14%2Fcp-a-symlink-to-multiple-directories%2F&amp;t=cp%20a%20symlink%20to%20multiple%20directories" title="Facebook"><img src="http://www.xcombinator.com/wp-content/plugins/sociable/images/facebook.png" title="Facebook" alt="Facebook" class="sociable-hovers" /></a><br />
	<a rel="nofollow"  href="http://www.google.com/bookmarks/mark?op=edit&amp;bkmk=http%3A%2F%2Fwww.xcombinator.com%2F2009%2F01%2F14%2Fcp-a-symlink-to-multiple-directories%2F&amp;title=cp%20a%20symlink%20to%20multiple%20directories&amp;annotation=Today%20I%20wanted%20to%20copy%20a%20symlink%20to%20many%20different%20directories.%20So%20I%20tried%20the%20following%3A%0D%0A%0D%0Afor%20f%20in%20%60find%20.%20-regex%20%27%27.%2Acp.%2Asnippets%27%27%60%20%3B%20do%20cp%20bbb.html%20%24f%2F%20%3B%20done%0D%0AWhich%20returned%3A%0D%0A%0D%0Acp%3A%20cannot%20stat%20%60bbb.html%27%3A%20No%20such%20file%20or%20directory%0D%0Abbb.html%20i" title="Google Bookmarks"><img src="http://www.xcombinator.com/wp-content/plugins/sociable/images/googlebookmark.png" title="Google Bookmarks" alt="Google Bookmarks" class="sociable-hovers" /></a><br />
	<a rel="nofollow"  href="http://news.ycombinator.com/submitlink?u=http%3A%2F%2Fwww.xcombinator.com%2F2009%2F01%2F14%2Fcp-a-symlink-to-multiple-directories%2F&amp;t=cp%20a%20symlink%20to%20multiple%20directories" title="HackerNews"><img src="http://www.xcombinator.com/wp-content/plugins/sociable/images/hackernews.png" title="HackerNews" alt="HackerNews" class="sociable-hovers" /></a><br />
	<a rel="nofollow"  href="http://www.printfriendly.com/print?url=http%3A%2F%2Fwww.xcombinator.com%2F2009%2F01%2F14%2Fcp-a-symlink-to-multiple-directories%2F&amp;partner=sociable" title="PDF"><img src="http://www.xcombinator.com/wp-content/plugins/sociable/images/pdf.png" title="PDF" alt="PDF" class="sociable-hovers" /></a><br />
	<a rel="nofollow"  href="http://www.xcombinator.com/feed/" title="RSS"><img src="http://www.xcombinator.com/wp-content/plugins/sociable/images/rss.png" title="RSS" alt="RSS" class="sociable-hovers" /></a></p>
<p><br/><br/></p>
]]></content:encoded>
			<wfw:commentRss>http://www.xcombinator.com/2009/01/14/cp-a-symlink-to-multiple-directories/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		<feedburner:origLink>http://www.xcombinator.com/2009/01/14/cp-a-symlink-to-multiple-directories/</feedburner:origLink></item>
		<item>
		<title>quick(er) way to symlink your `pwd`</title>
		<link>http://feedproxy.google.com/~r/xcombinator/~3/RTRtaogVvPg/</link>
		<comments>http://www.xcombinator.com/2009/01/12/symlink-pwd/#comments</comments>
		<pubDate>Mon, 12 Jan 2009 16:54:13 +0000</pubDate>
		<dc:creator>brian</dc:creator>
				<category><![CDATA[programming]]></category>

		<guid isPermaLink="false">http://www.xcombinator.com/2009/01/12/symlink-pwd/</guid>
		<description><![CDATA[I learned the other day about a neat shortcut for tilde expansion in bash.

$ ls ~-/

The neat thing about this expansion is that it does tab completion. What this lead me to discover is that you can also do ~N, where n is a number refering to your directory stack. (the bash man page says [...]]]></description>
			<content:encoded><![CDATA[<p>I learned the other day about a neat shortcut for tilde expansion in bash.</p>

<div class="wp_syntax"><div class="code"><pre class="bash" style="font-family:monospace;">$ <span style="color: #c20cb9; font-weight: bold;">ls</span> ~-<span style="color: #000000; font-weight: bold;">/</span></pre></div></div>

<p>The neat thing about this expansion is that it does tab completion. What this lead me to discover is that you can also do ~N, where n is a number refering to your directory stack. (the bash man page says you can use the command `dirs&#8217; to view the stack, but it doesn&#8217;t seem to work for me. When you put in a 0 (zero), it is the current working dir.  Combined with tab completion, this gave me a great way for creating symlinks. Before, I had to do something like</p>

<div class="wp_syntax"><div class="code"><pre class="bash" style="font-family:monospace;">$ <span style="color: #c20cb9; font-weight: bold;">ls</span> <span style="color: #000000; font-weight: bold;">`</span><span style="color: #7a0874; font-weight: bold;">pwd</span><span style="color: #000000; font-weight: bold;">`/</span></pre></div></div>

<p>Which does do tab completion. But if you want to save a whopping 3 key strokes!, you can do something like this:</p>

<div class="wp_syntax"><div class="code"><pre class="bash" style="font-family:monospace;">$ <span style="color: #7a0874; font-weight: bold;">pwd</span>
&nbsp;
<span style="color: #000000; font-weight: bold;">/</span>Users<span style="color: #000000; font-weight: bold;">/</span>bhenderson<span style="color: #000000; font-weight: bold;">/</span>programming<span style="color: #000000; font-weight: bold;">/</span>ruby<span style="color: #000000; font-weight: bold;">/</span>guides.rubyonrails.org
&nbsp;
$ <span style="color: #c20cb9; font-weight: bold;">ln</span> <span style="color: #660033;">-s</span> ~<span style="color: #000000;">0</span><span style="color: #000000; font-weight: bold;">/</span>index.html ~<span style="color: #000000; font-weight: bold;">/</span>Sites<span style="color: #000000; font-weight: bold;">/</span>ruby_guides
&nbsp;
$ <span style="color: #c20cb9; font-weight: bold;">ls</span> <span style="color: #660033;">-l</span> <span style="color: #000000; font-weight: bold;">!</span>:$
&nbsp;
<span style="color: #c20cb9; font-weight: bold;">ls</span> <span style="color: #660033;">-l</span> ~<span style="color: #000000; font-weight: bold;">/</span>Sites<span style="color: #000000; font-weight: bold;">/</span>ruby_guides
&nbsp;
lrwxr-xr-x  <span style="color: #000000;">1</span> bhenderson  staff  <span style="color: #000000;">68</span> Jan <span style="color: #000000;">12</span> 08:<span style="color: #000000;">47</span> <span style="color: #000000; font-weight: bold;">/</span>Users<span style="color: #000000; font-weight: bold;">/</span>bhenderson<span style="color: #000000; font-weight: bold;">/</span>Sites<span style="color: #000000; font-weight: bold;">/</span>ruby_guides -<span style="color: #000000; font-weight: bold;">&amp;</span>gt; <span style="color: #000000; font-weight: bold;">/</span>Users<span style="color: #000000; font-weight: bold;">/</span>bhenderson<span style="color: #000000; font-weight: bold;">/</span>programming<span style="color: #000000; font-weight: bold;">/</span>ruby<span style="color: #000000; font-weight: bold;">/</span>guides.rubyonrails.org<span style="color: #000000; font-weight: bold;">/</span>index.html
&nbsp;
$</pre></div></div>

<p>Guide spidered from <a href="http://guides.rubyonrails.org/index.html">here</a>.</p>
<p>Share:</p>
<p>	<a rel="nofollow"  href="http://delicious.com/post?url=http%3A%2F%2Fwww.xcombinator.com%2F2009%2F01%2F12%2Fsymlink-pwd%2F&amp;title=quick%28er%29%20way%20to%20symlink%20your%20%60pwd%60&amp;notes=I%20learned%20the%20other%20day%20about%20a%20neat%20shortcut%20for%20tilde%20expansion%20in%20bash.%0D%0A%0D%0A%24%20ls%20%7E-%2F%0D%0AThe%20neat%20thing%20about%20this%20expansion%20is%20that%20it%20does%20tab%20completion.%20What%20this%20lead%20me%20to%20discover%20is%20that%20you%20can%20also%20do%20%7EN%2C%20where%20n%20is%20a%20number%20refering%20to%20your" title="del.icio.us"><img src="http://www.xcombinator.com/wp-content/plugins/sociable/images/delicious.png" title="del.icio.us" alt="del.icio.us" class="sociable-hovers" /></a><br />
	<a rel="nofollow"  href="http://reddit.com/submit?url=http%3A%2F%2Fwww.xcombinator.com%2F2009%2F01%2F12%2Fsymlink-pwd%2F&amp;title=quick%28er%29%20way%20to%20symlink%20your%20%60pwd%60" title="Reddit"><img src="http://www.xcombinator.com/wp-content/plugins/sociable/images/reddit.png" title="Reddit" alt="Reddit" class="sociable-hovers" /></a><br />
	<a rel="nofollow"  href="http://technorati.com/faves?add=http%3A%2F%2Fwww.xcombinator.com%2F2009%2F01%2F12%2Fsymlink-pwd%2F" title="Technorati"><img src="http://www.xcombinator.com/wp-content/plugins/sociable/images/technorati.png" title="Technorati" alt="Technorati" class="sociable-hovers" /></a><br />
	<a rel="nofollow"  href="http://twitter.com/home?status=quick%28er%29%20way%20to%20symlink%20your%20%60pwd%60%20-%20http%3A%2F%2Fwww.xcombinator.com%2F2009%2F01%2F12%2Fsymlink-pwd%2F" title="Twitter"><img src="http://www.xcombinator.com/wp-content/plugins/sociable/images/twitter.png" title="Twitter" alt="Twitter" class="sociable-hovers" /></a><br />
	<a rel="nofollow"  href="http://www.facebook.com/share.php?u=http%3A%2F%2Fwww.xcombinator.com%2F2009%2F01%2F12%2Fsymlink-pwd%2F&amp;t=quick%28er%29%20way%20to%20symlink%20your%20%60pwd%60" title="Facebook"><img src="http://www.xcombinator.com/wp-content/plugins/sociable/images/facebook.png" title="Facebook" alt="Facebook" class="sociable-hovers" /></a><br />
	<a rel="nofollow"  href="http://www.google.com/bookmarks/mark?op=edit&amp;bkmk=http%3A%2F%2Fwww.xcombinator.com%2F2009%2F01%2F12%2Fsymlink-pwd%2F&amp;title=quick%28er%29%20way%20to%20symlink%20your%20%60pwd%60&amp;annotation=I%20learned%20the%20other%20day%20about%20a%20neat%20shortcut%20for%20tilde%20expansion%20in%20bash.%0D%0A%0D%0A%24%20ls%20%7E-%2F%0D%0AThe%20neat%20thing%20about%20this%20expansion%20is%20that%20it%20does%20tab%20completion.%20What%20this%20lead%20me%20to%20discover%20is%20that%20you%20can%20also%20do%20%7EN%2C%20where%20n%20is%20a%20number%20refering%20to%20your" title="Google Bookmarks"><img src="http://www.xcombinator.com/wp-content/plugins/sociable/images/googlebookmark.png" title="Google Bookmarks" alt="Google Bookmarks" class="sociable-hovers" /></a><br />
	<a rel="nofollow"  href="http://news.ycombinator.com/submitlink?u=http%3A%2F%2Fwww.xcombinator.com%2F2009%2F01%2F12%2Fsymlink-pwd%2F&amp;t=quick%28er%29%20way%20to%20symlink%20your%20%60pwd%60" title="HackerNews"><img src="http://www.xcombinator.com/wp-content/plugins/sociable/images/hackernews.png" title="HackerNews" alt="HackerNews" class="sociable-hovers" /></a><br />
	<a rel="nofollow"  href="http://www.printfriendly.com/print?url=http%3A%2F%2Fwww.xcombinator.com%2F2009%2F01%2F12%2Fsymlink-pwd%2F&amp;partner=sociable" title="PDF"><img src="http://www.xcombinator.com/wp-content/plugins/sociable/images/pdf.png" title="PDF" alt="PDF" class="sociable-hovers" /></a><br />
	<a rel="nofollow"  href="http://www.xcombinator.com/feed/" title="RSS"><img src="http://www.xcombinator.com/wp-content/plugins/sociable/images/rss.png" title="RSS" alt="RSS" class="sociable-hovers" /></a></p>
<p><br/><br/></p>
]]></content:encoded>
			<wfw:commentRss>http://www.xcombinator.com/2009/01/12/symlink-pwd/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		<feedburner:origLink>http://www.xcombinator.com/2009/01/12/symlink-pwd/</feedburner:origLink></item>
		<item>
		<title>renaming (lots of) files in bash</title>
		<link>http://feedproxy.google.com/~r/xcombinator/~3/7pC-P-vzMjY/</link>
		<comments>http://www.xcombinator.com/2009/01/09/renaming-lots-of-files-in-bash/#comments</comments>
		<pubDate>Fri, 09 Jan 2009 22:57:47 +0000</pubDate>
		<dc:creator>brian</dc:creator>
				<category><![CDATA[programming]]></category>
		<category><![CDATA[bash]]></category>

		<guid isPermaLink="false">http://www.xcombinator.com/2009/01/09/renaming-lots-of-files-in-bash/</guid>
		<description><![CDATA[I found this method the other day. Unfortunately, I forget where.

$ for f in `ls -1 &#124; grep string`; do mv $f ${f/string/replace};done

I&#8217;d like to find a method of using the bash command `find&#8217;, but this is pretty clean, and I don&#8217;t yet know how to manipulate the `{}&#8217; in find -exec {} \;
great site [...]]]></description>
			<content:encoded><![CDATA[<p>I found this method the other day. Unfortunately, I forget where.</p>

<div class="wp_syntax"><div class="code"><pre class="bash" style="font-family:monospace;">$ <span style="color: #000000; font-weight: bold;">for</span> f <span style="color: #000000; font-weight: bold;">in</span> <span style="color: #000000; font-weight: bold;">`</span><span style="color: #c20cb9; font-weight: bold;">ls</span> <span style="color: #660033;">-1</span> <span style="color: #000000; font-weight: bold;">|</span> <span style="color: #c20cb9; font-weight: bold;">grep</span> string<span style="color: #000000; font-weight: bold;">`</span>; <span style="color: #000000; font-weight: bold;">do</span> <span style="color: #c20cb9; font-weight: bold;">mv</span> <span style="color: #007800;">$f</span> <span style="color: #800000;">${f/string/replace}</span>;<span style="color: #000000; font-weight: bold;">done</span></pre></div></div>

<p>I&#8217;d like to find a method of using the bash command `find&#8217;, but this is pretty clean, and I don&#8217;t yet know how to manipulate the `{}&#8217; in find -exec {} \;</p>
<p>great site for explaining <a href="http://tldp.org/LDP/abs/html/string-manipulation.html">bash variable manipulation</a>.</p>
<p>Share:</p>
<p>	<a rel="nofollow"  href="http://delicious.com/post?url=http%3A%2F%2Fwww.xcombinator.com%2F2009%2F01%2F09%2Frenaming-lots-of-files-in-bash%2F&amp;title=renaming%20%28lots%20of%29%20files%20in%20bash&amp;notes=I%20found%20this%20method%20the%20other%20day.%20Unfortunately%2C%20I%20forget%20where.%0D%0A%0D%0A%24%20for%20f%20in%20%60ls%20-1%20%7C%20grep%20string%60%3B%20do%20mv%20%24f%20%24%7Bf%2Fstring%2Freplace%7D%3Bdone%0D%0AI%27d%20like%20to%20find%20a%20method%20of%20using%20the%20bash%20command%20%60find%27%2C%20but%20this%20is%20pretty%20clean%2C%20and%20I%20don%27t%20yet%20know%20how%20t" title="del.icio.us"><img src="http://www.xcombinator.com/wp-content/plugins/sociable/images/delicious.png" title="del.icio.us" alt="del.icio.us" class="sociable-hovers" /></a><br />
	<a rel="nofollow"  href="http://reddit.com/submit?url=http%3A%2F%2Fwww.xcombinator.com%2F2009%2F01%2F09%2Frenaming-lots-of-files-in-bash%2F&amp;title=renaming%20%28lots%20of%29%20files%20in%20bash" title="Reddit"><img src="http://www.xcombinator.com/wp-content/plugins/sociable/images/reddit.png" title="Reddit" alt="Reddit" class="sociable-hovers" /></a><br />
	<a rel="nofollow"  href="http://technorati.com/faves?add=http%3A%2F%2Fwww.xcombinator.com%2F2009%2F01%2F09%2Frenaming-lots-of-files-in-bash%2F" title="Technorati"><img src="http://www.xcombinator.com/wp-content/plugins/sociable/images/technorati.png" title="Technorati" alt="Technorati" class="sociable-hovers" /></a><br />
	<a rel="nofollow"  href="http://twitter.com/home?status=renaming%20%28lots%20of%29%20files%20in%20bash%20-%20http%3A%2F%2Fwww.xcombinator.com%2F2009%2F01%2F09%2Frenaming-lots-of-files-in-bash%2F" title="Twitter"><img src="http://www.xcombinator.com/wp-content/plugins/sociable/images/twitter.png" title="Twitter" alt="Twitter" class="sociable-hovers" /></a><br />
	<a rel="nofollow"  href="http://www.facebook.com/share.php?u=http%3A%2F%2Fwww.xcombinator.com%2F2009%2F01%2F09%2Frenaming-lots-of-files-in-bash%2F&amp;t=renaming%20%28lots%20of%29%20files%20in%20bash" title="Facebook"><img src="http://www.xcombinator.com/wp-content/plugins/sociable/images/facebook.png" title="Facebook" alt="Facebook" class="sociable-hovers" /></a><br />
	<a rel="nofollow"  href="http://www.google.com/bookmarks/mark?op=edit&amp;bkmk=http%3A%2F%2Fwww.xcombinator.com%2F2009%2F01%2F09%2Frenaming-lots-of-files-in-bash%2F&amp;title=renaming%20%28lots%20of%29%20files%20in%20bash&amp;annotation=I%20found%20this%20method%20the%20other%20day.%20Unfortunately%2C%20I%20forget%20where.%0D%0A%0D%0A%24%20for%20f%20in%20%60ls%20-1%20%7C%20grep%20string%60%3B%20do%20mv%20%24f%20%24%7Bf%2Fstring%2Freplace%7D%3Bdone%0D%0AI%27d%20like%20to%20find%20a%20method%20of%20using%20the%20bash%20command%20%60find%27%2C%20but%20this%20is%20pretty%20clean%2C%20and%20I%20don%27t%20yet%20know%20how%20t" title="Google Bookmarks"><img src="http://www.xcombinator.com/wp-content/plugins/sociable/images/googlebookmark.png" title="Google Bookmarks" alt="Google Bookmarks" class="sociable-hovers" /></a><br />
	<a rel="nofollow"  href="http://news.ycombinator.com/submitlink?u=http%3A%2F%2Fwww.xcombinator.com%2F2009%2F01%2F09%2Frenaming-lots-of-files-in-bash%2F&amp;t=renaming%20%28lots%20of%29%20files%20in%20bash" title="HackerNews"><img src="http://www.xcombinator.com/wp-content/plugins/sociable/images/hackernews.png" title="HackerNews" alt="HackerNews" class="sociable-hovers" /></a><br />
	<a rel="nofollow"  href="http://www.printfriendly.com/print?url=http%3A%2F%2Fwww.xcombinator.com%2F2009%2F01%2F09%2Frenaming-lots-of-files-in-bash%2F&amp;partner=sociable" title="PDF"><img src="http://www.xcombinator.com/wp-content/plugins/sociable/images/pdf.png" title="PDF" alt="PDF" class="sociable-hovers" /></a><br />
	<a rel="nofollow"  href="http://www.xcombinator.com/feed/" title="RSS"><img src="http://www.xcombinator.com/wp-content/plugins/sociable/images/rss.png" title="RSS" alt="RSS" class="sociable-hovers" /></a></p>
<p><br/><br/></p>
]]></content:encoded>
			<wfw:commentRss>http://www.xcombinator.com/2009/01/09/renaming-lots-of-files-in-bash/feed/</wfw:commentRss>
		<slash:comments>2</slash:comments>
		<feedburner:origLink>http://www.xcombinator.com/2009/01/09/renaming-lots-of-files-in-bash/</feedburner:origLink></item>
		<item>
		<title>fixing do_mysql hanging or install problems on mac os x</title>
		<link>http://feedproxy.google.com/~r/xcombinator/~3/KoHaWJ0kgRQ/</link>
		<comments>http://www.xcombinator.com/2008/11/20/fixing-do_mysql-hanging-or-install-problems-on-mac-os-x/#comments</comments>
		<pubDate>Thu, 20 Nov 2008 16:57:03 +0000</pubDate>
		<dc:creator>Nate Murray</dc:creator>
				<category><![CDATA[merb]]></category>
		<category><![CDATA[ruby]]></category>
		<category><![CDATA[tips]]></category>

		<guid isPermaLink="false">http://www.xcombinator.com/2008/11/20/fixing-do_mysql-hanging-or-install-problems-on-mac-os-x/</guid>
		<description><![CDATA[Just a quick tip:
If you&#8217;re having trouble getting do_mysql to install on Mac OS X. Try the following:

$ locate mysql_config
/usr/local/mysql/bin/mysql_config

The directory /usr/local/mysql above is your mysql directory. Then try to install do_mysql with the following command (split for readability):

$ gem install do_mysql -- \
   --with-mysql-dir="/usr/local/mysql/" \
   --with-mysql-config="/usr/local/mysql/bin/mysql_config"

This solution was found here. [...]]]></description>
			<content:encoded><![CDATA[<p>Just a quick tip:</p>
<p>If you&#8217;re having trouble getting <tt>do_mysql</tt> to install on Mac OS X. Try the following:</p>
<pre>
$ locate mysql_config
/usr/local/mysql/bin/mysql_config
</pre>
<p>The directory <tt>/usr/local/mysql</tt> above is your mysql directory. Then try to install <tt>do_mysql</tt> with the following command (split for readability):</p>
<pre>
$ gem install do_mysql -- \
   --with-mysql-dir="/usr/local/mysql/" \
   --with-mysql-config="/usr/local/mysql/bin/mysql_config"
</pre>
<p>This solution was found <a href="http://groups.google.com/group/merb/msg/63d160d7d690e4d7">here</a>. I experienced the problem while trying to get merb to run with datamapper on mysql.</p>
<p>Share:</p>
<p>	<a rel="nofollow"  href="http://delicious.com/post?url=http%3A%2F%2Fwww.xcombinator.com%2F2008%2F11%2F20%2Ffixing-do_mysql-hanging-or-install-problems-on-mac-os-x%2F&amp;title=fixing%20do_mysql%20hanging%20or%20install%20problems%20on%20mac%20os%20x&amp;notes=Just%20a%20quick%20tip%3A%0D%0A%0D%0AIf%20you%27re%20having%20trouble%20getting%20do_mysql%20to%20install%20on%20Mac%20OS%20X.%20Try%20the%20following%3A%0D%0A%0D%0A%24%20locate%20mysql_config%0D%0A%2Fusr%2Flocal%2Fmysql%2Fbin%2Fmysql_config%0D%0A%0D%0A%0D%0AThe%20directory%20%2Fusr%2Flocal%2Fmysql%20above%20is%20your%20mysql%20directory.%20Then%20try%20to%20insta" title="del.icio.us"><img src="http://www.xcombinator.com/wp-content/plugins/sociable/images/delicious.png" title="del.icio.us" alt="del.icio.us" class="sociable-hovers" /></a><br />
	<a rel="nofollow"  href="http://reddit.com/submit?url=http%3A%2F%2Fwww.xcombinator.com%2F2008%2F11%2F20%2Ffixing-do_mysql-hanging-or-install-problems-on-mac-os-x%2F&amp;title=fixing%20do_mysql%20hanging%20or%20install%20problems%20on%20mac%20os%20x" title="Reddit"><img src="http://www.xcombinator.com/wp-content/plugins/sociable/images/reddit.png" title="Reddit" alt="Reddit" class="sociable-hovers" /></a><br />
	<a rel="nofollow"  href="http://technorati.com/faves?add=http%3A%2F%2Fwww.xcombinator.com%2F2008%2F11%2F20%2Ffixing-do_mysql-hanging-or-install-problems-on-mac-os-x%2F" title="Technorati"><img src="http://www.xcombinator.com/wp-content/plugins/sociable/images/technorati.png" title="Technorati" alt="Technorati" class="sociable-hovers" /></a><br />
	<a rel="nofollow"  href="http://twitter.com/home?status=fixing%20do_mysql%20hanging%20or%20install%20problems%20on%20mac%20os%20x%20-%20http%3A%2F%2Fwww.xcombinator.com%2F2008%2F11%2F20%2Ffixing-do_mysql-hanging-or-install-problems-on-mac-os-x%2F" title="Twitter"><img src="http://www.xcombinator.com/wp-content/plugins/sociable/images/twitter.png" title="Twitter" alt="Twitter" class="sociable-hovers" /></a><br />
	<a rel="nofollow"  href="http://www.facebook.com/share.php?u=http%3A%2F%2Fwww.xcombinator.com%2F2008%2F11%2F20%2Ffixing-do_mysql-hanging-or-install-problems-on-mac-os-x%2F&amp;t=fixing%20do_mysql%20hanging%20or%20install%20problems%20on%20mac%20os%20x" title="Facebook"><img src="http://www.xcombinator.com/wp-content/plugins/sociable/images/facebook.png" title="Facebook" alt="Facebook" class="sociable-hovers" /></a><br />
	<a rel="nofollow"  href="http://www.google.com/bookmarks/mark?op=edit&amp;bkmk=http%3A%2F%2Fwww.xcombinator.com%2F2008%2F11%2F20%2Ffixing-do_mysql-hanging-or-install-problems-on-mac-os-x%2F&amp;title=fixing%20do_mysql%20hanging%20or%20install%20problems%20on%20mac%20os%20x&amp;annotation=Just%20a%20quick%20tip%3A%0D%0A%0D%0AIf%20you%27re%20having%20trouble%20getting%20do_mysql%20to%20install%20on%20Mac%20OS%20X.%20Try%20the%20following%3A%0D%0A%0D%0A%24%20locate%20mysql_config%0D%0A%2Fusr%2Flocal%2Fmysql%2Fbin%2Fmysql_config%0D%0A%0D%0A%0D%0AThe%20directory%20%2Fusr%2Flocal%2Fmysql%20above%20is%20your%20mysql%20directory.%20Then%20try%20to%20insta" title="Google Bookmarks"><img src="http://www.xcombinator.com/wp-content/plugins/sociable/images/googlebookmark.png" title="Google Bookmarks" alt="Google Bookmarks" class="sociable-hovers" /></a><br />
	<a rel="nofollow"  href="http://news.ycombinator.com/submitlink?u=http%3A%2F%2Fwww.xcombinator.com%2F2008%2F11%2F20%2Ffixing-do_mysql-hanging-or-install-problems-on-mac-os-x%2F&amp;t=fixing%20do_mysql%20hanging%20or%20install%20problems%20on%20mac%20os%20x" title="HackerNews"><img src="http://www.xcombinator.com/wp-content/plugins/sociable/images/hackernews.png" title="HackerNews" alt="HackerNews" class="sociable-hovers" /></a><br />
	<a rel="nofollow"  href="http://www.printfriendly.com/print?url=http%3A%2F%2Fwww.xcombinator.com%2F2008%2F11%2F20%2Ffixing-do_mysql-hanging-or-install-problems-on-mac-os-x%2F&amp;partner=sociable" title="PDF"><img src="http://www.xcombinator.com/wp-content/plugins/sociable/images/pdf.png" title="PDF" alt="PDF" class="sociable-hovers" /></a><br />
	<a rel="nofollow"  href="http://www.xcombinator.com/feed/" title="RSS"><img src="http://www.xcombinator.com/wp-content/plugins/sociable/images/rss.png" title="RSS" alt="RSS" class="sociable-hovers" /></a></p>
<p><br/><br/></p>
]]></content:encoded>
			<wfw:commentRss>http://www.xcombinator.com/2008/11/20/fixing-do_mysql-hanging-or-install-problems-on-mac-os-x/feed/</wfw:commentRss>
		<slash:comments>1</slash:comments>
		<feedburner:origLink>http://www.xcombinator.com/2008/11/20/fixing-do_mysql-hanging-or-install-problems-on-mac-os-x/</feedburner:origLink></item>
		<item>
		<title>sake task for remote git repo init</title>
		<link>http://feedproxy.google.com/~r/xcombinator/~3/Ap7bTwbnmao/</link>
		<comments>http://www.xcombinator.com/2008/11/07/sake-task-for-remote-git-repo-init/#comments</comments>
		<pubDate>Fri, 07 Nov 2008 16:52:50 +0000</pubDate>
		<dc:creator>Nate Murray</dc:creator>
				<category><![CDATA[git]]></category>
		<category><![CDATA[ruby]]></category>
		<category><![CDATA[sysadmin]]></category>

		<guid isPermaLink="false">http://www.xcombinator.com/2008/11/07/sake-task-for-remote-git-repo-init/</guid>
		<description><![CDATA[sake advantages

  sake is a tool for system-wide rake tasks. It was created by Chris Wanstrath and is now maintained by postmodern.  It provides a handy way to distribute generally-useful rake tasks. The advantage of sake over, say, a script in ~/bin is that 1) you have a predictable interface and 2) its [...]]]></description>
			<content:encoded><![CDATA[<h1><tt>sake</tt> advantages</h1>
<p>
  <a href="http://www.rubyinside.com/sake-system-wide-rake-tasks-543.html"><tt>sake</tt></a> is a tool for system-wide rake tasks. It was created by <a href="http://ozmm.org/">Chris Wanstrath</a> and is now maintained by <a href="http://github.com/postmodern">postmodern</a>.  It provides a handy way to distribute generally-useful rake tasks. The advantage of <tt>sake</tt> over, say, a script in <tt>~/bin</tt> is that 1) you have a predictable interface and 2) its easy to distribute tasks with <tt>sake -i http://any-url</tt> (in theory).
  </p>
<h1>Examples</h1>
<p>
  Ben Schwarz has written a great <a href="http://github.com/benschwarz/sake-tasks/tree/master/ssh/ssh.sake"><tt>sake</tt> task for installing a ssh-public-key on a remote server</a>. You can install it with <tt>sake -i http://github.com/benschwarz/sake-tasks/tree/master%2Fssh%2Fssh.sake?raw=true</tt> . (If you haven&#8217;t seen <a href="http://highline.rubyforge.org/">highline</a> before, check it out. It&#8217;s a nice abstraction and clean alternative to using <tt>gets</tt> and <tt>puts</tt>.)
  </p>
<h1>A <tt>sake</tt> task for installing remote git repos</h1>
<p>
    Based on Ben&#8217;s task I&#8217;ve created a task for installing remote git repos.
  </p>
<p>  <script src="http://gist.github.com/22673.js"></script></p>
<p>
  The above task will do two things:
  </p>
<ul>
<ol>Create the bare repository on a foreign server</ol>
<ol>Optionally create a local working copy</ol>
</ul>
<p>
  There&#8217;s a bug in the above authentication code, did you catch it?  For authentication, it will use your ssh keys if it finds it otherwise it will ask you for a password. However, if your ssh keys aren&#8217;t <i>valid</i> then it simply fails. Ideally it would ask you for a password and retry in this case.
  </p>
<p>
  I&#8217;m not too concerned about this however; if you&#8217;re creating a git repo remotely, you probably want to clone it and you also probably have your ssh keys setup to do so. (I probably shouldn&#8217;t be checking for a password at all.)
  </p>
<h1><tt>sake</tt> disadvantages</h1>
<p>
  I believe <tt>sake</tt> is a great idea, but there is some rough edges in the current implementation.
  </p>
<h2>Current Gem has a bug</h2>
<p>
  Today, if you <tt>gem install sake</tt> there is a bug such that sake wont even run. Your best bet is to clone <a href="http://github.com/drnic/sake/tree/master">drnic&#8217;s repo</a> <tt>sake >= 1.0.16</tt> and install from there.
  </p>
<p>
  My guess is that this is because sake&#8217;s creator recently <a href="http://ozmm.org/posts/good_homes_wanted.html">put out a request</a> for someone to take over the project and the person who took it over hasn&#8217;t upgraded the rubyforge gem.
  </p>
<h2>Task installation</h2>
<p>
  Another bug that seems to be specific to this version of <tt>sake</tt>, when I run <tt>sake -i</tt> the task names and namespaces are created but the <tt>~/.sake</tt> file contains no code.</p>
<p>
  Again, this just seems to be a minor bug with the current version and as such I see it as temporary. I&#8217;m planning on working on a patch on for this, though I&#8217;m not sure I&#8217;ll fix it before someone else.
  </p>
<h2>Task development</h2>
<p>
  The built-in way to do sake task development is to write a little bit, then <tt>sake -i</tt> your file, then write a little bit more etc. This gets old fast.  Because of that drnic has written <a href="http://github.com/drnic/sake-tasks/tree/master">a great project</a> for sake task development. In that project you run <tt>sake testrun <i>taskname</i></tt>.
  </p>
<p>  drnic&#8217;s project is handy and makes sake task development a snap. However, I think this fact could slow the adoption of sake; it&#8217;s a barrier to entry if you have to install a second project just to develop the first.</p>
<h1>Even so &#8230;</h1>
<p>
  I still think that the <i>idea</i> of <tt>sake</tt> is solid. There is definitely a need for easily distributable, reusable, system-wide rake tasks. Despite its current shortcomings, <tt>sake</tt> is definitely worth a look.</p>
<p>Share:</p>
<p>	<a rel="nofollow"  href="http://delicious.com/post?url=http%3A%2F%2Fwww.xcombinator.com%2F2008%2F11%2F07%2Fsake-task-for-remote-git-repo-init%2F&amp;title=%3Ctt%3Esake%3C%2Ftt%3E%20task%20for%20remote%20git%20repo%20init&amp;notes=%20%20sake%20advantages%0D%0A%0D%0A%20%20%0D%0A%20%20sake%20is%20a%20tool%20for%20system-wide%20rake%20tasks.%20It%20was%20created%20by%20Chris%20Wanstrath%20and%20is%20now%20maintained%20by%20postmodern.%20%20It%20provides%20a%20handy%20way%20to%20distribute%20generally-useful%20rake%20tasks.%20The%20advantage%20of%20sake%20over%2C%20say%2C%20a%20script" title="del.icio.us"><img src="http://www.xcombinator.com/wp-content/plugins/sociable/images/delicious.png" title="del.icio.us" alt="del.icio.us" class="sociable-hovers" /></a><br />
	<a rel="nofollow"  href="http://reddit.com/submit?url=http%3A%2F%2Fwww.xcombinator.com%2F2008%2F11%2F07%2Fsake-task-for-remote-git-repo-init%2F&amp;title=%3Ctt%3Esake%3C%2Ftt%3E%20task%20for%20remote%20git%20repo%20init" title="Reddit"><img src="http://www.xcombinator.com/wp-content/plugins/sociable/images/reddit.png" title="Reddit" alt="Reddit" class="sociable-hovers" /></a><br />
	<a rel="nofollow"  href="http://technorati.com/faves?add=http%3A%2F%2Fwww.xcombinator.com%2F2008%2F11%2F07%2Fsake-task-for-remote-git-repo-init%2F" title="Technorati"><img src="http://www.xcombinator.com/wp-content/plugins/sociable/images/technorati.png" title="Technorati" alt="Technorati" class="sociable-hovers" /></a><br />
	<a rel="nofollow"  href="http://twitter.com/home?status=%3Ctt%3Esake%3C%2Ftt%3E%20task%20for%20remote%20git%20repo%20init%20-%20http%3A%2F%2Fwww.xcombinator.com%2F2008%2F11%2F07%2Fsake-task-for-remote-git-repo-init%2F" title="Twitter"><img src="http://www.xcombinator.com/wp-content/plugins/sociable/images/twitter.png" title="Twitter" alt="Twitter" class="sociable-hovers" /></a><br />
	<a rel="nofollow"  href="http://www.facebook.com/share.php?u=http%3A%2F%2Fwww.xcombinator.com%2F2008%2F11%2F07%2Fsake-task-for-remote-git-repo-init%2F&amp;t=%3Ctt%3Esake%3C%2Ftt%3E%20task%20for%20remote%20git%20repo%20init" title="Facebook"><img src="http://www.xcombinator.com/wp-content/plugins/sociable/images/facebook.png" title="Facebook" alt="Facebook" class="sociable-hovers" /></a><br />
	<a rel="nofollow"  href="http://www.google.com/bookmarks/mark?op=edit&amp;bkmk=http%3A%2F%2Fwww.xcombinator.com%2F2008%2F11%2F07%2Fsake-task-for-remote-git-repo-init%2F&amp;title=%3Ctt%3Esake%3C%2Ftt%3E%20task%20for%20remote%20git%20repo%20init&amp;annotation=%20%20sake%20advantages%0D%0A%0D%0A%20%20%0D%0A%20%20sake%20is%20a%20tool%20for%20system-wide%20rake%20tasks.%20It%20was%20created%20by%20Chris%20Wanstrath%20and%20is%20now%20maintained%20by%20postmodern.%20%20It%20provides%20a%20handy%20way%20to%20distribute%20generally-useful%20rake%20tasks.%20The%20advantage%20of%20sake%20over%2C%20say%2C%20a%20script" title="Google Bookmarks"><img src="http://www.xcombinator.com/wp-content/plugins/sociable/images/googlebookmark.png" title="Google Bookmarks" alt="Google Bookmarks" class="sociable-hovers" /></a><br />
	<a rel="nofollow"  href="http://news.ycombinator.com/submitlink?u=http%3A%2F%2Fwww.xcombinator.com%2F2008%2F11%2F07%2Fsake-task-for-remote-git-repo-init%2F&amp;t=%3Ctt%3Esake%3C%2Ftt%3E%20task%20for%20remote%20git%20repo%20init" title="HackerNews"><img src="http://www.xcombinator.com/wp-content/plugins/sociable/images/hackernews.png" title="HackerNews" alt="HackerNews" class="sociable-hovers" /></a><br />
	<a rel="nofollow"  href="http://www.printfriendly.com/print?url=http%3A%2F%2Fwww.xcombinator.com%2F2008%2F11%2F07%2Fsake-task-for-remote-git-repo-init%2F&amp;partner=sociable" title="PDF"><img src="http://www.xcombinator.com/wp-content/plugins/sociable/images/pdf.png" title="PDF" alt="PDF" class="sociable-hovers" /></a><br />
	<a rel="nofollow"  href="http://www.xcombinator.com/feed/" title="RSS"><img src="http://www.xcombinator.com/wp-content/plugins/sociable/images/rss.png" title="RSS" alt="RSS" class="sociable-hovers" /></a></p>
<p><br/><br/></p>
]]></content:encoded>
			<wfw:commentRss>http://www.xcombinator.com/2008/11/07/sake-task-for-remote-git-repo-init/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		<feedburner:origLink>http://www.xcombinator.com/2008/11/07/sake-task-for-remote-git-repo-init/</feedburner:origLink></item>
		<item>
		<title>Why Do Cells Have DNA?</title>
		<link>http://feedproxy.google.com/~r/xcombinator/~3/YtFeGSuHW5A/</link>
		<comments>http://www.xcombinator.com/2008/11/01/why-do-cells-have-dna/#comments</comments>
		<pubDate>Sat, 01 Nov 2008 23:16:52 +0000</pubDate>
		<dc:creator>Matt Pulver</dc:creator>
				<category><![CDATA[programming]]></category>
		<category><![CDATA[ruby]]></category>
		<category><![CDATA[bach]]></category>
		<category><![CDATA[dna]]></category>
		<category><![CDATA[escher]]></category>
		<category><![CDATA[godel]]></category>
		<category><![CDATA[self-replicating code]]></category>
		<category><![CDATA[self-replication]]></category>

		<guid isPermaLink="false">http://www.xcombinator.com/2008/11/01/why-do-cells-have-dna/</guid>
		<description><![CDATA[In order for a system to reproduce itself, it seems necessary for it to hold an encoded form of itself somehow. This idea, and the inevitability of the existence of DNA-like structures within living cells, is well-illustrated using computer code.

We start with the problem: Write a ruby script that can print itself out, without it [...]]]></description>
			<content:encoded><![CDATA[<p>In order for a system to reproduce itself, it seems necessary for it to hold an encoded form of itself somehow. This idea, and the inevitability of the existence of DNA-like structures within living cells, is well-illustrated using computer code.</p>
<p><span id="more-85"></span></p>
<p>We start with the problem: <strong>Write a ruby script that can print itself out, without it reading its own file.</strong></p>
<p>The restriction &#8220;without it reading its own file&#8221; is important, otherwise a trivial solution would be:</p>

<div class="wp_syntax"><div class="code"><pre class="ruby" style="font-family:monospace;"><span style="color:#008000; font-style:italic;">#!/usr/bin/env ruby</span>
&nbsp;
<span style="color:#CC0066; font-weight:bold;">puts</span> <span style="color:#CC00FF; font-weight:bold;">File</span>.<span style="color:#9900CC;">read</span><span style="color:#006600; font-weight:bold;">&#40;</span> <span style="color:#0000FF; font-weight:bold;">__FILE__</span> <span style="color:#006600; font-weight:bold;">&#41;</span></pre></div></div>

<p>Without thinking about it too much and just starting naively, we may try:</p>

<div class="wp_syntax"><div class="code"><pre class="ruby" style="font-family:monospace;"><span style="color:#008000; font-style:italic;">#!/usr/bin/env ruby</span>
&nbsp;
<span style="color:#CC0066; font-weight:bold;">puts</span> <span style="color:#996600;">&quot;#!/usr/bin/env ruby<span style="color:#000099;">\n</span><span style="color:#000099;">\n</span>puts <span style="color:#000099;">\&quot;</span>#!/usr/bin/env ruby<span style="color:#000099;">\\</span>n<span style="color:#000099;">\\</span>nputs <span style="color:#000099;">\\</span><span style="color:#000099;">\&quot;</span>#!/usr/bin/env ruby ...</span></pre></div></div>

<p>We soon find ourselves entering into an infinite regress that we quickly realize has no escape. Seems we have to be a little bit more clever.</p>
<p>Before getting to the solution, the interested reader is urged to stop reading at this point and try to come up with a solution independently.</p>
<p>Here&#8217;s one way to accomplish this. Create the following script, which is just the first step toward the final script:</p>

<div class="wp_syntax"><div class="code"><pre class="ruby" style="font-family:monospace;"><span style="color:#008000; font-style:italic;">#!/usr/bin/env ruby</span>
&nbsp;
<span style="color:#CC0066; font-weight:bold;">require</span> <span style="color:#996600;">'cgi'</span>
&nbsp;
dna = <span style="color:#996600;">'DNA'</span>
cell = <span style="color:#CC00FF; font-weight:bold;">CGI</span>.<span style="color:#9900CC;">unescape</span> dna
<span style="color:#CC0066; font-weight:bold;">puts</span> cell.<span style="color:#CC0066; font-weight:bold;">sub</span><span style="color:#006600; font-weight:bold;">&#40;</span> <span style="color:#996600;">'DNA'</span>, dna <span style="color:#006600; font-weight:bold;">&#41;</span></pre></div></div>

<p>Save the above file as &#8220;pregodel.rb&#8221;. Next create this helper script:</p>

<div class="wp_syntax"><div class="code"><pre class="ruby" style="font-family:monospace;"><span style="color:#008000; font-style:italic;">#!/usr/bin/env ruby</span>
&nbsp;
<span style="color:#CC0066; font-weight:bold;">require</span> <span style="color:#996600;">'cgi'</span>
&nbsp;
<span style="color:#CC0066; font-weight:bold;">puts</span> <span style="color:#CC00FF; font-weight:bold;">CGI</span>.<span style="color:#9900CC;">escape</span><span style="color:#006600; font-weight:bold;">&#40;</span> STDIN.<span style="color:#9900CC;">read</span> <span style="color:#006600; font-weight:bold;">&#41;</span></pre></div></div>

<p>Save this as &#8220;godelize.rb&#8221;, and run it taking pregodel.rb into STDIN:</p>
<p><code>$ ruby godelize.rb < pregodel.rb</code></p>
<p>This outputs a cgi-encoded string whose initial characters are '%23%21%2Fusr%2Fbin%2Fenv ...'. Finally, copy pregodel.rb to godel.rb and edit godel.rb. Replace the first instance of DNA with the output of godelize.rb, and save it.</p>
<p>godel.rb should now be:</p>

<div class="wp_syntax"><div class="code"><pre class="ruby" style="font-family:monospace;"><span style="color:#008000; font-style:italic;">#!/usr/bin/env ruby</span>
&nbsp;
<span style="color:#CC0066; font-weight:bold;">require</span> <span style="color:#996600;">'cgi'</span>
&nbsp;
dna = <span style="color:#996600;">'%23%21%2Fusr%2Fbin%2Fenv+ruby%0A%0Arequire+%27cgi%27%0A%0Adna+%3D+%27DNA%27%0Acell+%3D+CGI.unescape+dna%0Aputs+cell.sub%28+%27DNA%27%2C+dna+%29%0A'</span>
cell = <span style="color:#CC00FF; font-weight:bold;">CGI</span>.<span style="color:#9900CC;">unescape</span> dna
<span style="color:#CC0066; font-weight:bold;">puts</span> cell.<span style="color:#CC0066; font-weight:bold;">sub</span><span style="color:#006600; font-weight:bold;">&#40;</span> <span style="color:#996600;">'DNA'</span>, dna <span style="color:#006600; font-weight:bold;">&#41;</span></pre></div></div>

<p>When run, the output is identical to the file contents. A conclusive test is comparing md5 sums:</p>
<p><code>$ cat godel.rb | md5<br />
4b92a6303568cde3a98d042a67616d2d</code></p>
<p><code>$ ruby godel.rb | md5<br />
4b92a6303568cde3a98d042a67616d2d</code></p>
<p>(This was run on a Mac&mdash;many linux distros have md5sum instead.)</p>
<h4>Discussion</h4>
<p>So what does this have to do with DNA in cells? The godel.rb script is about as simple of a self-replicating ruby script that one can write (again, without invoking the file itself). Its function and structure is surprisingly similar to how a biological cell works.  The entire script is stored in the dna variable as a cgi-encoded string, just as a cell is encoded in its nucleus with deoxyribonucleic acid:</p>

<div class="wp_syntax"><div class="code"><pre class="ruby" style="font-family:monospace;">dna = <span style="color:#996600;">'%23%21%2Fusr%2Fbin%2Fenv+ruby%0A%0Arequire+%27cgi%27%0A%0Adna+%3D+%27DNA%27%0Acell+%3D+CGI.unescape+dna%0Aputs+cell.sub%28+%27DNA%27%2C+dna+%29%0A'</span></pre></div></div>

<p>The first step in the script's self-replication process is to unescape itself from a cgi-encoded string to ruby code. This is analogous to a cell's ribosomes performing its role in translating DNA into protein. (The intermediate step of RNA transcription is omitted for simplicity without loss of accuracy.) Protein is encoded as sequences of nucleic acids in DNA, just as ruby code is encoded into cgi-encoded character sequences.</p>

<div class="wp_syntax"><div class="code"><pre class="ruby" style="font-family:monospace;">cell = <span style="color:#CC00FF; font-weight:bold;">CGI</span>.<span style="color:#9900CC;">unescape</span> dna</pre></div></div>

<p>Finally, a cell's DNA must make a copy of itself during mitosis and insert it into the cell's copy. The analog of this is the last line of the script:</p>

<div class="wp_syntax"><div class="code"><pre class="ruby" style="font-family:monospace;"><span style="color:#CC0066; font-weight:bold;">puts</span> cell.<span style="color:#CC0066; font-weight:bold;">sub</span><span style="color:#006600; font-weight:bold;">&#40;</span> <span style="color:#996600;">'DNA'</span>, dna <span style="color:#006600; font-weight:bold;">&#41;</span></pre></div></div>

<p>Though the dna string has a representation of the whole script, observe how it was able to avoid the infinite regress. The place in the string that references itself, rather than storing itself again (which would lead to an infinitely long string) it instead uses a symbol for itself, namely, DNA. This acts as a placeholder for where the dna variable will be substituted into when the string is printed out.</p>
<p>For further reading, check out the book <em>G&#246;del, Escher, Bach</em> by Douglas Hofstadter, which applies the above ideas to not only self-replicating cells, but to the nature of mathematical truth, the art of Escher, the music of Bach, and human consciousness, among other related topics.</p>
<p>Share:</p>
<p>	<a rel="nofollow"  href="http://delicious.com/post?url=http%3A%2F%2Fwww.xcombinator.com%2F2008%2F11%2F01%2Fwhy-do-cells-have-dna%2F&amp;title=Why%20Do%20Cells%20Have%20DNA%3F&amp;notes=In%20order%20for%20a%20system%20to%20reproduce%20itself%2C%20it%20seems%20necessary%20for%20it%20to%20hold%20an%20encoded%20form%20of%20itself%20somehow.%20This%20idea%2C%20and%20the%20inevitability%20of%20the%20existence%20of%20DNA-like%20structures%20within%20living%20cells%2C%20is%20well-illustrated%20using%20computer%20code.%0D%0A%0D%0A" title="del.icio.us"><img src="http://www.xcombinator.com/wp-content/plugins/sociable/images/delicious.png" title="del.icio.us" alt="del.icio.us" class="sociable-hovers" /></a><br />
	<a rel="nofollow"  href="http://reddit.com/submit?url=http%3A%2F%2Fwww.xcombinator.com%2F2008%2F11%2F01%2Fwhy-do-cells-have-dna%2F&amp;title=Why%20Do%20Cells%20Have%20DNA%3F" title="Reddit"><img src="http://www.xcombinator.com/wp-content/plugins/sociable/images/reddit.png" title="Reddit" alt="Reddit" class="sociable-hovers" /></a><br />
	<a rel="nofollow"  href="http://technorati.com/faves?add=http%3A%2F%2Fwww.xcombinator.com%2F2008%2F11%2F01%2Fwhy-do-cells-have-dna%2F" title="Technorati"><img src="http://www.xcombinator.com/wp-content/plugins/sociable/images/technorati.png" title="Technorati" alt="Technorati" class="sociable-hovers" /></a><br />
	<a rel="nofollow"  href="http://twitter.com/home?status=Why%20Do%20Cells%20Have%20DNA%3F%20-%20http%3A%2F%2Fwww.xcombinator.com%2F2008%2F11%2F01%2Fwhy-do-cells-have-dna%2F" title="Twitter"><img src="http://www.xcombinator.com/wp-content/plugins/sociable/images/twitter.png" title="Twitter" alt="Twitter" class="sociable-hovers" /></a><br />
	<a rel="nofollow"  href="http://www.facebook.com/share.php?u=http%3A%2F%2Fwww.xcombinator.com%2F2008%2F11%2F01%2Fwhy-do-cells-have-dna%2F&amp;t=Why%20Do%20Cells%20Have%20DNA%3F" title="Facebook"><img src="http://www.xcombinator.com/wp-content/plugins/sociable/images/facebook.png" title="Facebook" alt="Facebook" class="sociable-hovers" /></a><br />
	<a rel="nofollow"  href="http://www.google.com/bookmarks/mark?op=edit&amp;bkmk=http%3A%2F%2Fwww.xcombinator.com%2F2008%2F11%2F01%2Fwhy-do-cells-have-dna%2F&amp;title=Why%20Do%20Cells%20Have%20DNA%3F&amp;annotation=In%20order%20for%20a%20system%20to%20reproduce%20itself%2C%20it%20seems%20necessary%20for%20it%20to%20hold%20an%20encoded%20form%20of%20itself%20somehow.%20This%20idea%2C%20and%20the%20inevitability%20of%20the%20existence%20of%20DNA-like%20structures%20within%20living%20cells%2C%20is%20well-illustrated%20using%20computer%20code.%0D%0A%0D%0A" title="Google Bookmarks"><img src="http://www.xcombinator.com/wp-content/plugins/sociable/images/googlebookmark.png" title="Google Bookmarks" alt="Google Bookmarks" class="sociable-hovers" /></a><br />
	<a rel="nofollow"  href="http://news.ycombinator.com/submitlink?u=http%3A%2F%2Fwww.xcombinator.com%2F2008%2F11%2F01%2Fwhy-do-cells-have-dna%2F&amp;t=Why%20Do%20Cells%20Have%20DNA%3F" title="HackerNews"><img src="http://www.xcombinator.com/wp-content/plugins/sociable/images/hackernews.png" title="HackerNews" alt="HackerNews" class="sociable-hovers" /></a><br />
	<a rel="nofollow"  href="http://www.printfriendly.com/print?url=http%3A%2F%2Fwww.xcombinator.com%2F2008%2F11%2F01%2Fwhy-do-cells-have-dna%2F&amp;partner=sociable" title="PDF"><img src="http://www.xcombinator.com/wp-content/plugins/sociable/images/pdf.png" title="PDF" alt="PDF" class="sociable-hovers" /></a><br />
	<a rel="nofollow"  href="http://www.xcombinator.com/feed/" title="RSS"><img src="http://www.xcombinator.com/wp-content/plugins/sociable/images/rss.png" title="RSS" alt="RSS" class="sociable-hovers" /></a></p>
<p><br/><br/></p>
]]></content:encoded>
			<wfw:commentRss>http://www.xcombinator.com/2008/11/01/why-do-cells-have-dna/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		<feedburner:origLink>http://www.xcombinator.com/2008/11/01/why-do-cells-have-dna/</feedburner:origLink></item>
	</channel>
</rss><!-- Dynamic Page Served (once) in 4.669 seconds -->
