<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0"
	xmlns:content="http://purl.org/rss/1.0/modules/content/"
	xmlns:wfw="http://wellformedweb.org/CommentAPI/"
	xmlns:dc="http://purl.org/dc/elements/1.1/"
	xmlns:atom="http://www.w3.org/2005/Atom"
	xmlns:sy="http://purl.org/rss/1.0/modules/syndication/"
	xmlns:slash="http://purl.org/rss/1.0/modules/slash/"
	>

<channel>
	<title>Pivotal Labs &#187; Onsi Fakhouri</title>
	<atom:link href="http://pivotallabs.com/author/onsi/feed/" rel="self" type="application/rss+xml" />
	<link>http://pivotallabs.com</link>
	<description>Agility Developed</description>
	<lastBuildDate>Fri, 24 May 2013 05:20:56 +0000</lastBuildDate>
	<language>en-US</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=3.5.1</generator>
		<item>
		<title>Cocktail: DRY up your backbone code with mixins</title>
		<link>http://pivotallabs.com/cocktail-dry-up-your-backbone-code-with-mixins/</link>
		<comments>http://pivotallabs.com/cocktail-dry-up-your-backbone-code-with-mixins/#comments</comments>
		<pubDate>Tue, 24 Jul 2012 15:34:00 +0000</pubDate>
		<dc:creator>Onsi Fakhouri</dc:creator>
				<category><![CDATA[Labs]]></category>
		<category><![CDATA[backbone]]></category>
		<category><![CDATA[javascript]]></category>

		<guid isPermaLink="false">http://pivotallabs.com/cocktail-dry-up-your-backbone-code-with-mixins/</guid>
		<description><![CDATA[<p><p>I've continued to enjoy using <a href="http://backbonejs.org">Backbone.js</a> to build single page apps.  As I've seen more and more real world backbone I've started to develop opinions to augment the blissfully unopinionated little framework that could.</p>

<p>One of these opinions has turned into a mini-library: <a href="http://github.com/onsi/cocktail">Cocktail</a> adds functionality to Backbone's <code>extend</code> to facilitate breaking up reusable code into mixins.  It's pretty straightforward:</p>

<ol>
<li><p>Define your mixin.  Mixins are just plain vanilla JavaScript objects with methods and properties hanging off of them.  Here's a slightly contrived mixin that makes a view selectable:</p>

<pre><code>window.MyMixins = {};
MyMixins.SelectMixin = {
  initialize: function&#40;&#41; {
    this.model.on&#40;'change:selected', this.refreshSelect, this&#41;;
  },


  events: {
    click: 'toggleSelect'
  },


  render: function&#40;&#41; {
    this.refreshSelect&#40;&#41;;
  },


  refreshSelect: function&#40;&#41; {
    this.$el.toggleClass&#40;'selected', this.model.get&#40;'selected'&#41;&#41;;
  },


  toggleSelect: function&#40;&#41; {
    this.model.set&#40;'selected', !this.model.get&#40;'selected'&#41;&#41;;
  }
}
</code></pre></li>
<li><p>Mix your mixin into your views.  It's a one-liner:</p>

<pre><code>var MyView = Backbone.View.extend&#40;{
  mixins: [MyMixins.SelectMixin, MyMixins.SomeOtherMixin],


  events: {
    'click .myChild': 'myCustomHandler'
  }


  initialize: function&#40;&#41; { ... },
  render: function&#40;&#41; { ... },
  etc...
}&#41;;
</code></pre></li>
<li><p>That's it!  Instances of <code>MyView</code> will automatically inherit the behaviors and methods defined in <code>SelectMixin</code>.</p></li>
</ol>

<p>Cocktail brings two simple things to the table: </p>

<ul>
<li>it adds the special <code>mixins:[...]</code> notation to Backbone's <code>extend</code>.</li>
<li>it automatically detects and handles method collisions.  In the example above Cocktail will wrap <code>MyView</code>'s and <code>SelectMixin</code>'s implementations of <code>initialize</code> into one method and assign that method to the new, composite, class.  The return value of this composite method is the last non-<code>undefined</code> value returned by the methods it wraps.  All colliding methods are handled this way, as is the <code>events</code> hash &#40;the <code>events</code> hashes all get merged together&#41;.</li>
</ul>

<p>There are more details and examples at the <a href="http://github.com/onsi/cocktail">repo</a>.  In particular, there's an <a href="https://github.com/onsi/cocktail/tree/master/example">example</a> for testing mixins with <a href="http://www.github.com/pivotal/jasmine">Jasmine</a> -- it goes over a pattern for writing shared behaviors in Jasmine.</p> <a href="http://pivotallabs.com/cocktail-dry-up-your-backbone-code-with-mixins/">Continue reading <span class="meta-nav">&#8594;</span></a></p><p>The post <a href="http://pivotallabs.com/cocktail-dry-up-your-backbone-code-with-mixins/">Cocktail: DRY up your backbone code with mixins</a> appeared first on <a href="http://pivotallabs.com">Pivotal Labs</a>.</p>]]></description>
				<content:encoded><![CDATA[<p>I&#8217;ve continued to enjoy using <a href="http://backbonejs.org">Backbone.js</a> to build single page apps.  As I&#8217;ve seen more and more real world backbone I&#8217;ve started to develop opinions to augment the blissfully unopinionated little framework that could.</p>
<p>One of these opinions has turned into a mini-library: <a href="http://github.com/onsi/cocktail">Cocktail</a> adds functionality to Backbone&#8217;s <code>extend</code> to facilitate breaking up reusable code into mixins.  It&#8217;s pretty straightforward:</p>
<ol>
<li>
<p>Define your mixin.  Mixins are just plain vanilla JavaScript objects with methods and properties hanging off of them.  Here&#8217;s a slightly contrived mixin that makes a view selectable:</p>
<pre><code>window.MyMixins = {};
MyMixins.SelectMixin = {
  initialize: function&#40;&#41; {
    this.model.on&#40;'change:selected', this.refreshSelect, this&#41;;
  },


  events: {
    click: 'toggleSelect'
  },


  render: function&#40;&#41; {
    this.refreshSelect&#40;&#41;;
  },


  refreshSelect: function&#40;&#41; {
    this.$el.toggleClass&#40;'selected', this.model.get&#40;'selected'&#41;&#41;;
  },


  toggleSelect: function&#40;&#41; {
    this.model.set&#40;'selected', !this.model.get&#40;'selected'&#41;&#41;;
  }
}
</code></pre>
</li>
<li>
<p>Mix your mixin into your views.  It&#8217;s a one-liner:</p>
<pre><code>var MyView = Backbone.View.extend&#40;{
  mixins: [MyMixins.SelectMixin, MyMixins.SomeOtherMixin],


  events: {
    'click .myChild': 'myCustomHandler'
  }


  initialize: function&#40;&#41; { ... },
  render: function&#40;&#41; { ... },
  etc...
}&#41;;
</code></pre>
</li>
<li>
<p>That&#8217;s it!  Instances of <code>MyView</code> will automatically inherit the behaviors and methods defined in <code>SelectMixin</code>.</p>
</li>
</ol>
<p>Cocktail brings two simple things to the table: </p>
<ul>
<li>it adds the special <code>mixins:[...]</code> notation to Backbone&#8217;s <code>extend</code>.</li>
<li>it automatically detects and handles method collisions.  In the example above Cocktail will wrap <code>MyView</code>&#8216;s and <code>SelectMixin</code>&#8216;s implementations of <code>initialize</code> into one method and assign that method to the new, composite, class.  The return value of this composite method is the last non-<code>undefined</code> value returned by the methods it wraps.  All colliding methods are handled this way, as is the <code>events</code> hash &#40;the <code>events</code> hashes all get merged together&#41;.</li>
</ul>
<p>There are more details and examples at the <a href="http://github.com/onsi/cocktail">repo</a>.  In particular, there&#8217;s an <a href="https://github.com/onsi/cocktail/tree/master/example">example</a> for testing mixins with <a href="http://www.github.com/pivotal/jasmine">Jasmine</a> &#8212; it goes over a pattern for writing shared behaviors in Jasmine.</p>
<p>The post <a href="http://pivotallabs.com/cocktail-dry-up-your-backbone-code-with-mixins/">Cocktail: DRY up your backbone code with mixins</a> appeared first on <a href="http://pivotallabs.com">Pivotal Labs</a>.</p>]]></content:encoded>
			<wfw:commentRss>http://pivotallabs.com/cocktail-dry-up-your-backbone-code-with-mixins/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Coccyx: plug up those backbone leaks</title>
		<link>http://pivotallabs.com/coccyx-plug-up-those-backbone-leaks/</link>
		<comments>http://pivotallabs.com/coccyx-plug-up-those-backbone-leaks/#comments</comments>
		<pubDate>Thu, 14 Jun 2012 04:48:00 +0000</pubDate>
		<dc:creator>Onsi Fakhouri</dc:creator>
				<category><![CDATA[Labs]]></category>
		<category><![CDATA[backbone]]></category>
		<category><![CDATA[javascript]]></category>

		<guid isPermaLink="false">http://pivotallabs.com/coccyx-plug-up-those-backbone-leaks/</guid>
		<description><![CDATA[<p><p>A number of projects at Pivotal have been using <a href="http://backbonejs.org/">Backbone.js</a> to build single page web apps.  I've enjoyed using Backbone: it's lightweight, unopinionated, helps encourage good separation of concerns between models and views, and reduces a fair bit of JavaScript boilerplate by bringing just enough framework to the table.</p>

<p>Unfortunately, it's very easy to write Backbone code that leaks - especially in the view layer.  A common backbone pattern is to set up some event bindings for a view:</p>

<pre><code>var MyView = Backbone.View.extend&#40;{
    initialize: function&#40;&#41; {
        this.model.on&#40;'change', this.update, this&#41;;
        this.someOtherModel.on&#40;'change', this.update, this&#41;;
        this.boundResizeHandler = _.bind&#40;this.resizeHandler, this&#41;;
        $&#40;window&#41;.on&#40;'resize', this.boundResizeHandler&#41;;
    },
    ...etc..
}&#41;;
</code></pre>

<p>If your app needs to switch between several such views it is <strong>not</strong> enough to simply remove the view's DOM and <code>null</code> out any references to the view.  You must also unbind these event bindings in order for the view to be garbage collected.  Moreover, if this view contains any subviews, you must also tear down all event bindings for all its subviews.  If you do not succesfully clear out all bindings the view &#40;and/or its subviews&#41; will leak.</p>

<p>What's worse: while there are some <a href="https://developers.google.com/chrome-developer-tools/docs/heap-profiling">great tools</a> out there to identify leaking objects, Backbone's default constructor lists all objects as type <code>child</code>.  This makes finding the leaky Backbone objects that are instances of <code>MyView</code> nearly impossible in Chrome's heap propfiler.</p>

<p><a href="https://github.com/onsi/coccyx">Coccyx</a> attempts to adress these problems by doing two things:</p>

<ol>
<li><p>Coccyx adds named constructors to Backbone.  You no longer need to wonder which <code>child</code> is yours.  By adding <code>constructorName</code> when you <code>extend</code> a Backbone class you'll be able to easily tell which object is which in the console and the heap profiler.</p></li>
<li><p>Coccyx implements teardown-able view hierarchies.  You can easily build view hierarchies in which parents are aware of their children and can tear the entire structure down by calling <code>tearDown&#40;&#41;</code> on a root node.  <code>tearDown&#40;&#41;</code> automatically unbinds any Backbone event bindings, cleans up DOM events and gives your view a chance to perform any custom teardown via a callback.</p></li>
</ol>

<p>There are many more details at <a href="https://github.com/onsi/coccyx">https://github.com/onsi/coccyx</a>.  Bug reports and pull requests are encouraged!</p> <a href="http://pivotallabs.com/coccyx-plug-up-those-backbone-leaks/">Continue reading <span class="meta-nav">&#8594;</span></a></p><p>The post <a href="http://pivotallabs.com/coccyx-plug-up-those-backbone-leaks/">Coccyx: plug up those backbone leaks</a> appeared first on <a href="http://pivotallabs.com">Pivotal Labs</a>.</p>]]></description>
				<content:encoded><![CDATA[<p>A number of projects at Pivotal have been using <a href="http://backbonejs.org/">Backbone.js</a> to build single page web apps.  I&#8217;ve enjoyed using Backbone: it&#8217;s lightweight, unopinionated, helps encourage good separation of concerns between models and views, and reduces a fair bit of JavaScript boilerplate by bringing just enough framework to the table.</p>
<p>Unfortunately, it&#8217;s very easy to write Backbone code that leaks &#8211; especially in the view layer.  A common backbone pattern is to set up some event bindings for a view:</p>
<pre><code>var MyView = Backbone.View.extend&#40;{
    initialize: function&#40;&#41; {
        this.model.on&#40;'change', this.update, this&#41;;
        this.someOtherModel.on&#40;'change', this.update, this&#41;;
        this.boundResizeHandler = _.bind&#40;this.resizeHandler, this&#41;;
        $&#40;window&#41;.on&#40;'resize', this.boundResizeHandler&#41;;
    },
    ...etc..
}&#41;;
</code></pre>
<p>If your app needs to switch between several such views it is <strong>not</strong> enough to simply remove the view&#8217;s DOM and <code>null</code> out any references to the view.  You must also unbind these event bindings in order for the view to be garbage collected.  Moreover, if this view contains any subviews, you must also tear down all event bindings for all its subviews.  If you do not succesfully clear out all bindings the view &#40;and/or its subviews&#41; will leak.</p>
<p>What&#8217;s worse: while there are some <a href="https://developers.google.com/chrome-developer-tools/docs/heap-profiling">great tools</a> out there to identify leaking objects, Backbone&#8217;s default constructor lists all objects as type <code>child</code>.  This makes finding the leaky Backbone objects that are instances of <code>MyView</code> nearly impossible in Chrome&#8217;s heap propfiler.</p>
<p><a href="https://github.com/onsi/coccyx">Coccyx</a> attempts to adress these problems by doing two things:</p>
<ol>
<li>
<p>Coccyx adds named constructors to Backbone.  You no longer need to wonder which <code>child</code> is yours.  By adding <code>constructorName</code> when you <code>extend</code> a Backbone class you&#8217;ll be able to easily tell which object is which in the console and the heap profiler.</p>
</li>
<li>
<p>Coccyx implements teardown-able view hierarchies.  You can easily build view hierarchies in which parents are aware of their children and can tear the entire structure down by calling <code>tearDown&#40;&#41;</code> on a root node.  <code>tearDown&#40;&#41;</code> automatically unbinds any Backbone event bindings, cleans up DOM events and gives your view a chance to perform any custom teardown via a callback.</p>
</li>
</ol>
<p>There are many more details at <a href="https://github.com/onsi/coccyx">https://github.com/onsi/coccyx</a>.  Bug reports and pull requests are encouraged!</p>
<p>The post <a href="http://pivotallabs.com/coccyx-plug-up-those-backbone-leaks/">Coccyx: plug up those backbone leaks</a> appeared first on <a href="http://pivotallabs.com">Pivotal Labs</a>.</p>]]></content:encoded>
			<wfw:commentRss>http://pivotallabs.com/coccyx-plug-up-those-backbone-leaks/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>[SF] Standup 4/26/2012: Hush Terminal, Hush</title>
		<link>http://pivotallabs.com/sf-standup-4-26-2012-hush-terminal-hush/</link>
		<comments>http://pivotallabs.com/sf-standup-4-26-2012-hush-terminal-hush/#comments</comments>
		<pubDate>Thu, 26 Apr 2012 14:53:00 +0000</pubDate>
		<dc:creator>Onsi Fakhouri</dc:creator>
				<category><![CDATA[Standup]]></category>
		<category><![CDATA[agile]]></category>

		<guid isPermaLink="false">http://pivotallabs.com/sf-standup-4-26-2012-hush-terminal-hush/</guid>
		<description><![CDATA[<p><h2>Help!</h2>

<blockquote>
    <p><em>"How do I prevent the asset pipeline from concatenating all my javascript when running Jasmine tests?"</em></p>
</blockquote>

<p>Max has an almost-there solution that he sent out to the mailing list:</p>

<pre><code>module Jasmine
  class Config
    def src_files
      Rails.application.assets["application"].dependencies.map do &#124;asset&#124;
        "assets/" + asset.logical_path
      end
    end
  end
end
</code></pre>

<p>This only works if application.js requires <em>all</em> relevant javascript, and <strong>contains no code itself</strong>.</p>

<blockquote>
    <p><em>"I'm looking for a client-side JS syntax highlighter!"</em></p>
</blockquote>

<ul>
<li>Don't use: <a href="http://pygments.org/">pygments</a> -- it's what GitHub uses and is server-side only.</li>
<li>Consider using: <a href="http://codemirror.net/">code mirror</a></li>
</ul>

<h2>Interesting?</h2>

<p>That slowness when you start Terminal?  It's parsing through all your system logs to figure out when the last log-in occured.  Speed up your terminal with</p>

<pre><code>touch ~/.hushlogin
</code></pre>

<hr />

<p><code>http != https</code> -- who knew?  Turns out sending an AJAX post from a non-secured origin &#40;http&#41; to a secured end point &#40;https&#41; smacks agains the same-origin policy.  Solutions?</p>

<ul>
<li>Bring up and iframe pointed to https and AJAX post from there.</li>
<li>Or &#40;better&#41;: Enforce SSL on the originating page.</li>
</ul> <a href="http://pivotallabs.com/sf-standup-4-26-2012-hush-terminal-hush/">Continue reading <span class="meta-nav">&#8594;</span></a></p><p>The post <a href="http://pivotallabs.com/sf-standup-4-26-2012-hush-terminal-hush/">[SF] Standup 4/26/2012: Hush Terminal, Hush</a> appeared first on <a href="http://pivotallabs.com">Pivotal Labs</a>.</p>]]></description>
				<content:encoded><![CDATA[<h2>Help!</h2>
<blockquote>
<p><em>&#8220;How do I prevent the asset pipeline from concatenating all my javascript when running Jasmine tests?&#8221;</em></p>
</blockquote>
<p>Max has an almost-there solution that he sent out to the mailing list:</p>
<pre><code>module Jasmine
  class Config
    def src_files
      Rails.application.assets["application"].dependencies.map do |asset|
        "assets/" + asset.logical_path
      end
    end
  end
end
</code></pre>
<p>This only works if application.js requires <em>all</em> relevant javascript, and <strong>contains no code itself</strong>.</p>
<blockquote>
<p><em>&#8220;I&#8217;m looking for a client-side JS syntax highlighter!&#8221;</em></p>
</blockquote>
<ul>
<li>Don&#8217;t use: <a href="http://pygments.org/">pygments</a> &#8212; it&#8217;s what GitHub uses and is server-side only.</li>
<li>Consider using: <a href="http://codemirror.net/">code mirror</a></li>
</ul>
<h2>Interesting?</h2>
<p>That slowness when you start Terminal?  It&#8217;s parsing through all your system logs to figure out when the last log-in occured.  Speed up your terminal with</p>
<pre><code>touch ~/.hushlogin
</code></pre>
<hr />
<p><code>http != https</code> &#8212; who knew?  Turns out sending an AJAX post from a non-secured origin &#40;http&#41; to a secured end point &#40;https&#41; smacks agains the same-origin policy.  Solutions?</p>
<ul>
<li>Bring up and iframe pointed to https and AJAX post from there.</li>
<li>Or &#40;better&#41;: Enforce SSL on the originating page.</li>
</ul>
<p>The post <a href="http://pivotallabs.com/sf-standup-4-26-2012-hush-terminal-hush/">[SF] Standup 4/26/2012: Hush Terminal, Hush</a> appeared first on <a href="http://pivotallabs.com">Pivotal Labs</a>.</p>]]></content:encoded>
			<wfw:commentRss>http://pivotallabs.com/sf-standup-4-26-2012-hush-terminal-hush/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>[SF] Standup 4/25/2012: Haproxymations</title>
		<link>http://pivotallabs.com/sf-standup-4-25-2012-haproxymations/</link>
		<comments>http://pivotallabs.com/sf-standup-4-25-2012-haproxymations/#comments</comments>
		<pubDate>Thu, 26 Apr 2012 02:33:00 +0000</pubDate>
		<dc:creator>Onsi Fakhouri</dc:creator>
				<category><![CDATA[Standup]]></category>
		<category><![CDATA[agile]]></category>

		<guid isPermaLink="false">http://pivotallabs.com/sf-standup-4-25-2012-haproxymations/</guid>
		<description><![CDATA[<p><h2>Ask for Help</h2>

<blockquote>
    <p><em>What's the best way to think about redirects for API calls?  e.g. You post to create an object, what should you get in return?</em></p>
</blockquote>

<p>The crowd: Some concensus emerged around: send back a 201 with a location header pointing to the url for the object and a body containing the object itself.</p>

<blockquote>
    <p><em>Mongoid's atomic operations don't trigger hooks &#40;before_save, after_save, etc...&#41;</em></p>
</blockquote>

<p>The crowd: Crickets...</p>

<blockquote>
    <p><em>haproxy, like nginx, can pass http connection through with the header 'X-Forwarded-For' set so that it is possible for the app to know the original client IP. But haproxy doesn't have support for serving as an SSL endpoint, so https:// connections are proxied in tcp mode instead of http mode. And no headers can be added because the request remains encrypted.</em></p>
</blockquote>

<p>Some solutions:</p>

<ul>
<li><p>Terminate the SSL connection in <em>front</em> of haproxy.  PIvots suggested doing this via an additional nginx instance.  Online resources show how to do this using stunnel. &#40;http://www.completefusion.com/ssl-load-balancing-with-haproxy-and-stunnel-on-debian/&#41;</p></li>
<li><p>Use nginx as the load balancer and discontinue using haproxy, or find a load balancer that fully supports SSL.</p></li>
<li><p>Build HAProxy with TPROXY support. http://blog.loadbalancer.org/configure-haproxy-with-tproxy-kernel-for-full-transparent-proxy/</p></li>
</ul> <a href="http://pivotallabs.com/sf-standup-4-25-2012-haproxymations/">Continue reading <span class="meta-nav">&#8594;</span></a></p><p>The post <a href="http://pivotallabs.com/sf-standup-4-25-2012-haproxymations/">[SF] Standup 4/25/2012: Haproxymations</a> appeared first on <a href="http://pivotallabs.com">Pivotal Labs</a>.</p>]]></description>
				<content:encoded><![CDATA[<h2>Ask for Help</h2>
<blockquote>
<p><em>What&#8217;s the best way to think about redirects for API calls?  e.g. You post to create an object, what should you get in return?</em></p>
</blockquote>
<p>The crowd: Some concensus emerged around: send back a 201 with a location header pointing to the url for the object and a body containing the object itself.</p>
<blockquote>
<p><em>Mongoid&#8217;s atomic operations don&#8217;t trigger hooks &#40;before_save, after_save, etc&#8230;&#41;</em></p>
</blockquote>
<p>The crowd: Crickets&#8230;</p>
<blockquote>
<p><em>haproxy, like nginx, can pass http connection through with the header &#8216;X-Forwarded-For&#8217; set so that it is possible for the app to know the original client IP. But haproxy doesn&#8217;t have support for serving as an SSL endpoint, so https:// connections are proxied in tcp mode instead of http mode. And no headers can be added because the request remains encrypted.</em></p>
</blockquote>
<p>Some solutions:</p>
<ul>
<li>
<p>Terminate the SSL connection in <em>front</em> of haproxy.  PIvots suggested doing this via an additional nginx instance.  Online resources show how to do this using stunnel. &#40;http://www.completefusion.com/ssl-load-balancing-with-haproxy-and-stunnel-on-debian/&#41;</p>
</li>
<li>
<p>Use nginx as the load balancer and discontinue using haproxy, or find a load balancer that fully supports SSL.</p>
</li>
<li>
<p>Build HAProxy with TPROXY support. http://blog.loadbalancer.org/configure-haproxy-with-tproxy-kernel-for-full-transparent-proxy/</p>
</li>
</ul>
<p>The post <a href="http://pivotallabs.com/sf-standup-4-25-2012-haproxymations/">[SF] Standup 4/25/2012: Haproxymations</a> appeared first on <a href="http://pivotallabs.com">Pivotal Labs</a>.</p>]]></content:encoded>
			<wfw:commentRss>http://pivotallabs.com/sf-standup-4-25-2012-haproxymations/feed/</wfw:commentRss>
		<slash:comments>1</slash:comments>
		</item>
		<item>
		<title>A More Kosher Approach to Spork</title>
		<link>http://pivotallabs.com/a-more-kosher-approach-to-spork/</link>
		<comments>http://pivotallabs.com/a-more-kosher-approach-to-spork/#comments</comments>
		<pubDate>Thu, 01 Dec 2011 15:34:00 +0000</pubDate>
		<dc:creator>Onsi Fakhouri</dc:creator>
				<category><![CDATA[Standup]]></category>
		<category><![CDATA[agile]]></category>

		<guid isPermaLink="false">http://pivotallabs.com/a-more-kosher-approach-to-spork/</guid>
		<description><![CDATA[<p><h2>Ask for Help</h2>

<blockquote>
    <p><em>"Reloading of models under spork?"</em></p>
</blockquote>

<p>From hybrid-cutlery expert Sobo:</p>

<p>Spork requires you to divide your spec helper into two phases, before fork and after fork.
Before fork, you want to do time consuming things like loading the Rails environment, so you don't have to pay that cost on each test run.
If you end up requiring model classes or other volatile files before forking, then they won't be reloaded for each test run.
This can happen, for example, when you use Devise route helpers, which touch the User constant during route evaluation.
This causes user.rb to be auto-required before fork.
Since the User constant is defined after forking, Rails won't autoload changes to User, forcing you to restart the Spork server every time you change it.</p>

<p>There are two solutions: </p>

<ul>
<li>The first is simply to avoid loading models or other code you want to auto-reload before fork.</li>
<li>If you must refer to models before fork, as is the case with the Devise route helpers, then put an explicit <code>load</code> &#40;not <code>require</code> because it won't load the file if it's already been loaded&#41; in your after fork block for the files that were loaded before fork.
This will force them to be reloaded.</li>
</ul>

<h2>Interesting Things</h2>

<ul>
<li>It's open season on open enrollment.  SF will have an info session today at 12:30.  Pizza will be served.  Y'all have between now and December 9th to make changes.</li>
<li>Those with mohawks and staches in SF are encouraged to take a picture at the Vermehr e-mail station &#40;closest e-mail station to the bathrooms&#41;.</li>
</ul> <a href="http://pivotallabs.com/a-more-kosher-approach-to-spork/">Continue reading <span class="meta-nav">&#8594;</span></a></p><p>The post <a href="http://pivotallabs.com/a-more-kosher-approach-to-spork/">A More Kosher Approach to Spork</a> appeared first on <a href="http://pivotallabs.com">Pivotal Labs</a>.</p>]]></description>
				<content:encoded><![CDATA[<h2>Ask for Help</h2>
<blockquote>
<p><em>&#8220;Reloading of models under spork?&#8221;</em></p>
</blockquote>
<p>From hybrid-cutlery expert Sobo:</p>
<p>Spork requires you to divide your spec helper into two phases, before fork and after fork.<br />
Before fork, you want to do time consuming things like loading the Rails environment, so you don&#8217;t have to pay that cost on each test run.<br />
If you end up requiring model classes or other volatile files before forking, then they won&#8217;t be reloaded for each test run.<br />
This can happen, for example, when you use Devise route helpers, which touch the User constant during route evaluation.<br />
This causes user.rb to be auto-required before fork.<br />
Since the User constant is defined after forking, Rails won&#8217;t autoload changes to User, forcing you to restart the Spork server every time you change it.</p>
<p>There are two solutions: </p>
<ul>
<li>The first is simply to avoid loading models or other code you want to auto-reload before fork.</li>
<li>If you must refer to models before fork, as is the case with the Devise route helpers, then put an explicit <code>load</code> &#40;not <code>require</code> because it won&#8217;t load the file if it&#8217;s already been loaded&#41; in your after fork block for the files that were loaded before fork.<br />
This will force them to be reloaded.</li>
</ul>
<h2>Interesting Things</h2>
<ul>
<li>It&#8217;s open season on open enrollment.  SF will have an info session today at 12:30.  Pizza will be served.  Y&#8217;all have between now and December 9th to make changes.</li>
<li>Those with mohawks and staches in SF are encouraged to take a picture at the Vermehr e-mail station &#40;closest e-mail station to the bathrooms&#41;.</li>
</ul>
<p>The post <a href="http://pivotallabs.com/a-more-kosher-approach-to-spork/">A More Kosher Approach to Spork</a> appeared first on <a href="http://pivotallabs.com">Pivotal Labs</a>.</p>]]></content:encoded>
			<wfw:commentRss>http://pivotallabs.com/a-more-kosher-approach-to-spork/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>No really, you have to pick *one*</title>
		<link>http://pivotallabs.com/no-really-you-have-to-pick-one/</link>
		<comments>http://pivotallabs.com/no-really-you-have-to-pick-one/#comments</comments>
		<pubDate>Tue, 29 Nov 2011 15:36:00 +0000</pubDate>
		<dc:creator>Onsi Fakhouri</dc:creator>
				<category><![CDATA[Standup]]></category>
		<category><![CDATA[agile]]></category>

		<guid isPermaLink="false">http://pivotallabs.com/no-really-you-have-to-pick-one/</guid>
		<description><![CDATA[<p><h2>Ask for Help</h2>

<blockquote>
    <p><em>"Postgres SELECT * GROUP BY insists that all selected fields must either appear in the GROUP BY or be aggregated."</em></p>
</blockquote>

<p>Many agreed that this is, in fact, how a database should behave and that MySQL's leniency on this matter is faulty.  If you select a field that you don't group by, you must tell Postgres how to combine the sub-set of values that fall in a given group into a single result &#40;should it take the max? the min? the mean? the most purple?&#41;.</p> <a href="http://pivotallabs.com/no-really-you-have-to-pick-one/">Continue reading <span class="meta-nav">&#8594;</span></a></p><p>The post <a href="http://pivotallabs.com/no-really-you-have-to-pick-one/">No really, you have to pick *one*</a> appeared first on <a href="http://pivotallabs.com">Pivotal Labs</a>.</p>]]></description>
				<content:encoded><![CDATA[<h2>Ask for Help</h2>
<blockquote>
<p><em>&#8220;Postgres SELECT * GROUP BY insists that all selected fields must either appear in the GROUP BY or be aggregated.&#8221;</em></p>
</blockquote>
<p>Many agreed that this is, in fact, how a database should behave and that MySQL&#8217;s leniency on this matter is faulty.  If you select a field that you don&#8217;t group by, you must tell Postgres how to combine the sub-set of values that fall in a given group into a single result &#40;should it take the max? the min? the mean? the most purple?&#41;.</p>
<p>The post <a href="http://pivotallabs.com/no-really-you-have-to-pick-one/">No really, you have to pick *one*</a> appeared first on <a href="http://pivotallabs.com">Pivotal Labs</a>.</p>]]></content:encoded>
			<wfw:commentRss>http://pivotallabs.com/no-really-you-have-to-pick-one/feed/</wfw:commentRss>
		<slash:comments>6</slash:comments>
		</item>
		<item>
		<title>SF Standup 9/16/2011: Schrodinger&#8217;s Cucumber</title>
		<link>http://pivotallabs.com/sf-standup-9-16-2011-schrodinger-s-cucumber/</link>
		<comments>http://pivotallabs.com/sf-standup-9-16-2011-schrodinger-s-cucumber/#comments</comments>
		<pubDate>Fri, 16 Sep 2011 14:40:00 +0000</pubDate>
		<dc:creator>Onsi Fakhouri</dc:creator>
				<category><![CDATA[Standup]]></category>
		<category><![CDATA[agile]]></category>

		<guid isPermaLink="false">http://pivotallabs.com/sf-standup-9-16-2011-schrodinger-s-cucumber/</guid>
		<description><![CDATA[<p><h2>Ask for Help</h2>

<blockquote>
    <p>"I have a fresh install of Rails 3.1 and when I run specs with rake &#40;with the development server running&#41; it complains that the database is already in use."</p>
</blockquote>

<p>A chorus of replies: "I hate it when it says that."</p>

<p>Looks like the test suite is trying to use the development DB.  Try:</p>

<pre><code>RAILS_ENV=test rake ...
</code></pre>

<p>It was pointed out that a call to rake that does not explicitly specify RAILS_ENV typically runs in development mode, detects that tests are being run, then switches to test mode.  Any code that runs before the environment switch &#40;in initializers, say&#41; will run against the development DB.</p>

<blockquote>
    <p>"I have a large inherited cucumber suite that consistently fails on CI.... unless I screen share in and watch it.  Why do I need to peek for my tests to pass?"</p>
</blockquote>

<p>The likely answer: The very act of screen-sharing causes the test-suite to slow down. Use the setSpeed method in Selenium to force Selenium to take a breather between commands &#40;the passed in value is in milliseconds&#41;.</p>

<h2>Interesting Things</h2>

<ul>
<li><p>resque [ˈrɛsk] + JSON [jāsʌn] = surprise</p>

<p>Ruby objects queued and dequeued by resque suffer a translation through JSON.  What you put in may not be what you get out!</p></li>
</ul> <a href="http://pivotallabs.com/sf-standup-9-16-2011-schrodinger-s-cucumber/">Continue reading <span class="meta-nav">&#8594;</span></a></p><p>The post <a href="http://pivotallabs.com/sf-standup-9-16-2011-schrodinger-s-cucumber/">SF Standup 9/16/2011: Schrodinger&#8217;s Cucumber</a> appeared first on <a href="http://pivotallabs.com">Pivotal Labs</a>.</p>]]></description>
				<content:encoded><![CDATA[<h2>Ask for Help</h2>
<blockquote>
<p>&#8220;I have a fresh install of Rails 3.1 and when I run specs with rake &#40;with the development server running&#41; it complains that the database is already in use.&#8221;</p>
</blockquote>
<p>A chorus of replies: &#8220;I hate it when it says that.&#8221;</p>
<p>Looks like the test suite is trying to use the development DB.  Try:</p>
<pre><code>RAILS_ENV=test rake ...
</code></pre>
<p>It was pointed out that a call to rake that does not explicitly specify RAILS_ENV typically runs in development mode, detects that tests are being run, then switches to test mode.  Any code that runs before the environment switch &#40;in initializers, say&#41; will run against the development DB.</p>
<blockquote>
<p>&#8220;I have a large inherited cucumber suite that consistently fails on CI&#8230;. unless I screen share in and watch it.  Why do I need to peek for my tests to pass?&#8221;</p>
</blockquote>
<p>The likely answer: The very act of screen-sharing causes the test-suite to slow down. Use the setSpeed method in Selenium to force Selenium to take a breather between commands &#40;the passed in value is in milliseconds&#41;.</p>
<h2>Interesting Things</h2>
<ul>
<li>
<p>resque [ˈrɛsk] + JSON [jāsʌn] = surprise</p>
<p>Ruby objects queued and dequeued by resque suffer a translation through JSON.  What you put in may not be what you get out!</p>
</li>
</ul>
<p>The post <a href="http://pivotallabs.com/sf-standup-9-16-2011-schrodinger-s-cucumber/">SF Standup 9/16/2011: Schrodinger&#8217;s Cucumber</a> appeared first on <a href="http://pivotallabs.com">Pivotal Labs</a>.</p>]]></content:encoded>
			<wfw:commentRss>http://pivotallabs.com/sf-standup-9-16-2011-schrodinger-s-cucumber/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>The Vegetarian Version &#124; It&#8217;s Pure and Good</title>
		<link>http://pivotallabs.com/the-vegetarian-version-it-s-pure-and-good/</link>
		<comments>http://pivotallabs.com/the-vegetarian-version-it-s-pure-and-good/#comments</comments>
		<pubDate>Fri, 22 Jul 2011 14:30:00 +0000</pubDate>
		<dc:creator>Onsi Fakhouri</dc:creator>
				<category><![CDATA[Standup]]></category>
		<category><![CDATA[agile]]></category>

		<guid isPermaLink="false">http://pivotallabs.com/the-vegetarian-version-it-s-pure-and-good/</guid>
		<description><![CDATA[<p><h2>Ask for Help</h2>

<blockquote>
    <p><em>"We're trying to get the Google Docs API working on our project but we keep hitting unauthorized/bad request responses.  Help!"</em></p>
</blockquote>

<p>One thought: some ruby OAuth implementations are known to fail.  Try shelling out and running a command line OAuth to make sure this isn't an incompatibility with your ruby OAuth library.</p>

<h2>Interesting Things</h2>

<ul>
<li><p>Ruby is slower than node.js.</p>

<p>Two loops and a square root turns out to be a recipe for ruby slowness.  The v8 engine wins again!</p></li>
<li><p>Ubiquitous Singaporean Chile &#40;"Sambal Chilli"&#41; now available - briefly - in the San Francisco lounge &#40;courtesy of Nate Clark&#41;.</p>

<p>To quote Nate: <em>"It's usually Shrimp based but this is the Vegetarian version which I find to be pure and good."</em></p></li>
<li><p>Gogaruco sign up is now open.. and the early bird tickets are gone.  <a href="http://gogaruco.com/">Sign up soon!</a></p></li>
</ul> <a href="http://pivotallabs.com/the-vegetarian-version-it-s-pure-and-good/">Continue reading <span class="meta-nav">&#8594;</span></a></p><p>The post <a href="http://pivotallabs.com/the-vegetarian-version-it-s-pure-and-good/">The Vegetarian Version | It&#8217;s Pure and Good</a> appeared first on <a href="http://pivotallabs.com">Pivotal Labs</a>.</p>]]></description>
				<content:encoded><![CDATA[<h2>Ask for Help</h2>
<blockquote>
<p><em>&#8220;We&#8217;re trying to get the Google Docs API working on our project but we keep hitting unauthorized/bad request responses.  Help!&#8221;</em></p>
</blockquote>
<p>One thought: some ruby OAuth implementations are known to fail.  Try shelling out and running a command line OAuth to make sure this isn&#8217;t an incompatibility with your ruby OAuth library.</p>
<h2>Interesting Things</h2>
<ul>
<li>
<p>Ruby is slower than node.js.</p>
<p>Two loops and a square root turns out to be a recipe for ruby slowness.  The v8 engine wins again!</p>
</li>
<li>
<p>Ubiquitous Singaporean Chile &#40;&#8221;Sambal Chilli&#8221;&#41; now available &#8211; briefly &#8211; in the San Francisco lounge &#40;courtesy of Nate Clark&#41;.</p>
<p>To quote Nate: <em>&#8220;It&#8217;s usually Shrimp based but this is the Vegetarian version which I find to be pure and good.&#8221;</em></p>
</li>
<li>
<p>Gogaruco sign up is now open.. and the early bird tickets are gone.  <a href="http://gogaruco.com/">Sign up soon!</a></p>
</li>
</ul>
<p>The post <a href="http://pivotallabs.com/the-vegetarian-version-it-s-pure-and-good/">The Vegetarian Version | It&#8217;s Pure and Good</a> appeared first on <a href="http://pivotallabs.com">Pivotal Labs</a>.</p>]]></content:encoded>
			<wfw:commentRss>http://pivotallabs.com/the-vegetarian-version-it-s-pure-and-good/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>I Bless the Rains Down in Africa</title>
		<link>http://pivotallabs.com/i-bless-the-rains-down-in-africa/</link>
		<comments>http://pivotallabs.com/i-bless-the-rains-down-in-africa/#comments</comments>
		<pubDate>Mon, 18 Jul 2011 14:34:00 +0000</pubDate>
		<dc:creator>Onsi Fakhouri</dc:creator>
				<category><![CDATA[Standup]]></category>
		<category><![CDATA[agile]]></category>

		<guid isPermaLink="false">http://pivotallabs.com/i-bless-the-rains-down-in-africa/</guid>
		<description><![CDATA[<p><p>&#40;Title: Standup 7/18/2011: I Bless the Rains Down in Africa&#41;</p>

<h2>Ask for Help</h2>

<blockquote>
    <p><em>"I want a super-lightweight rack-based CMS/blogging setup.  Any thoughts?"</em></p>
</blockquote>

<p>Try out <a href="http://cloudhead.io/toto">Toto</a> a light-weight git-powered blog engine.</p> <a href="http://pivotallabs.com/i-bless-the-rains-down-in-africa/">Continue reading <span class="meta-nav">&#8594;</span></a></p><p>The post <a href="http://pivotallabs.com/i-bless-the-rains-down-in-africa/">I Bless the Rains Down in Africa</a> appeared first on <a href="http://pivotallabs.com">Pivotal Labs</a>.</p>]]></description>
				<content:encoded><![CDATA[<p>&#40;Title: Standup 7/18/2011: I Bless the Rains Down in Africa&#41;</p>
<h2>Ask for Help</h2>
<blockquote>
<p><em>&#8220;I want a super-lightweight rack-based CMS/blogging setup.  Any thoughts?&#8221;</em></p>
</blockquote>
<p>Try out <a href="http://cloudhead.io/toto">Toto</a> a light-weight git-powered blog engine.</p>
<p>The post <a href="http://pivotallabs.com/i-bless-the-rains-down-in-africa/">I Bless the Rains Down in Africa</a> appeared first on <a href="http://pivotallabs.com">Pivotal Labs</a>.</p>]]></content:encoded>
			<wfw:commentRss>http://pivotallabs.com/i-bless-the-rains-down-in-africa/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Standup 1/14/2011: Key-Value-Fun</title>
		<link>http://pivotallabs.com/standup-1-14-2011/</link>
		<comments>http://pivotallabs.com/standup-1-14-2011/#comments</comments>
		<pubDate>Fri, 14 Jan 2011 15:15:00 +0000</pubDate>
		<dc:creator>Onsi Fakhouri</dc:creator>
				<category><![CDATA[Standup]]></category>
		<category><![CDATA[agile]]></category>

		<guid isPermaLink="false">http://pivotallabs.com/standup-1-14-2011/</guid>
		<description><![CDATA[<p><h2>Ask For Help</h2>

<p>We're running into a problem where MongoMapper is somehow setting the value of a 'many' relationship to null in the parent document, which then makes MongoMapper blow up when trying to load the parent doc from mongo.  There's an argument to be made that MongoMapper shouldn't blow up, but it's understandable that it's confused when the key exists - here's a spec demonstrating what happens when the null exists in
mongo: <a href="https://gist.github.com/779930">https://gist.github.com/779930</a></p>

<p>The big question is what is creating these values.  All our inserts are through MongoMapper, so we're blaming a bug we can't reproduce in MongoMapper for the moment.</p>

<h2>Interesting Things</h2>

<p>How to fill up your Redis instance &#40;part 2&#41;.  Resque stores all records of failed jobs - including full backtraces - on Redis.  Pushing a bug that generates lots of these can rapidly fill up your Redis instance.  The solution?  Send your Resque errors directly to hoptoad &#40;which has better error management infrastructure anyway&#41;.</p> <a href="http://pivotallabs.com/standup-1-14-2011/">Continue reading <span class="meta-nav">&#8594;</span></a></p><p>The post <a href="http://pivotallabs.com/standup-1-14-2011/">Standup 1/14/2011: Key-Value-Fun</a> appeared first on <a href="http://pivotallabs.com">Pivotal Labs</a>.</p>]]></description>
				<content:encoded><![CDATA[<h2>Ask For Help</h2>
<p>We&#8217;re running into a problem where MongoMapper is somehow setting the value of a &#8216;many&#8217; relationship to null in the parent document, which then makes MongoMapper blow up when trying to load the parent doc from mongo.  There&#8217;s an argument to be made that MongoMapper shouldn&#8217;t blow up, but it&#8217;s understandable that it&#8217;s confused when the key exists &#8211; here&#8217;s a spec demonstrating what happens when the null exists in<br />
mongo: <a href="https://gist.github.com/779930">https://gist.github.com/779930</a></p>
<p>The big question is what is creating these values.  All our inserts are through MongoMapper, so we&#8217;re blaming a bug we can&#8217;t reproduce in MongoMapper for the moment.</p>
<h2>Interesting Things</h2>
<p>How to fill up your Redis instance &#40;part 2&#41;.  Resque stores all records of failed jobs &#8211; including full backtraces &#8211; on Redis.  Pushing a bug that generates lots of these can rapidly fill up your Redis instance.  The solution?  Send your Resque errors directly to hoptoad &#40;which has better error management infrastructure anyway&#41;.</p>
<p>The post <a href="http://pivotallabs.com/standup-1-14-2011/">Standup 1/14/2011: Key-Value-Fun</a> appeared first on <a href="http://pivotallabs.com">Pivotal Labs</a>.</p>]]></content:encoded>
			<wfw:commentRss>http://pivotallabs.com/standup-1-14-2011/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
	</channel>
</rss>

<!-- Performance optimized by W3 Total Cache. Learn more: http://www.w3-edge.com/wordpress-plugins/

Minified using disk: basic (Feed is rejected)
Page Caching using apc
Database Caching using apc
Object Caching 1131/1246 objects using apc

 Served from: pivotallabs.com @ 2013-05-24 03:17:00 by W3 Total Cache -->