<?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/"
	xmlns:georss="http://www.georss.org/georss" xmlns:geo="http://www.w3.org/2003/01/geo/wgs84_pos#" xmlns:media="http://search.yahoo.com/mrss/"
	>

<channel>
	<title>Helder's Tech Stuff</title>
	<atom:link href="http://obvio171.wordpress.com/feed/" rel="self" type="application/rss+xml" />
	<link>http://obvio171.wordpress.com</link>
	<description>Gathering my tech awes, links and findings.</description>
	<lastBuildDate>Mon, 24 Aug 2009 21:04:13 +0000</lastBuildDate>
	<generator>http://wordpress.com/</generator>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<cloud domain='obvio171.wordpress.com' port='80' path='/?rsscloud=notify' registerProcedure='' protocol='http-post' />
<image>
		<url>http://www.gravatar.com/blavatar/f9b60596f8f32b93f5430a7b9f48b2e9?s=96&#038;d=http://s.wordpress.com/i/buttonw-com.png</url>
		<title>Helder's Tech Stuff</title>
		<link>http://obvio171.wordpress.com</link>
	</image>
			<item>
		<title>MOVED</title>
		<link>http://obvio171.wordpress.com/2009/08/22/moved/</link>
		<comments>http://obvio171.wordpress.com/2009/08/22/moved/#comments</comments>
		<pubDate>Sat, 22 Aug 2009 20:12:52 +0000</pubDate>
		<dc:creator>Helder</dc:creator>
				<category><![CDATA[Uncategorized]]></category>

		<guid isPermaLink="false">http://obvio171.wordpress.com/?p=66</guid>
		<description><![CDATA[I&#8217;m now at http://helderribeiro.net.
       <img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=obvio171.wordpress.com&blog=106106&post=66&subd=obvio171&ref=&feed=1" />]]></description>
			<content:encoded><![CDATA[<div class='snap_preview'><br /><p>I&#8217;m now at <a href="http://helderribeiro.net">http://helderribeiro.net</a>.</p>
  <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gocomments/obvio171.wordpress.com/66/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/comments/obvio171.wordpress.com/66/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godelicious/obvio171.wordpress.com/66/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/delicious/obvio171.wordpress.com/66/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gostumble/obvio171.wordpress.com/66/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/stumble/obvio171.wordpress.com/66/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godigg/obvio171.wordpress.com/66/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/digg/obvio171.wordpress.com/66/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/goreddit/obvio171.wordpress.com/66/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/reddit/obvio171.wordpress.com/66/" /></a> <img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=obvio171.wordpress.com&blog=106106&post=66&subd=obvio171&ref=&feed=1" /></div>]]></content:encoded>
			<wfw:commentRss>http://obvio171.wordpress.com/2009/08/22/moved/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
	
		<media:content url="http://0.gravatar.com/avatar/e22005d49d02e800c0c51d0177904283?s=96&#38;d=identicon&#38;r=G" medium="image">
			<media:title type="html">helder</media:title>
		</media:content>
	</item>
		<item>
		<title>Scaling and Tools Diversity: Google vs. Facebook</title>
		<link>http://obvio171.wordpress.com/2008/05/17/scaling-and-tools-diversity-google-vs-facebook/</link>
		<comments>http://obvio171.wordpress.com/2008/05/17/scaling-and-tools-diversity-google-vs-facebook/#comments</comments>
		<pubDate>Sat, 17 May 2008 15:10:55 +0000</pubDate>
		<dc:creator>Helder</dc:creator>
				<category><![CDATA[Uncategorized]]></category>
		<category><![CDATA[distributed systems]]></category>
		<category><![CDATA[erlang]]></category>
		<category><![CDATA[Facebook]]></category>
		<category><![CDATA[facebook chat]]></category>
		<category><![CDATA[google]]></category>
		<category><![CDATA[javascript]]></category>
		<category><![CDATA[programming]]></category>
		<category><![CDATA[programming languages]]></category>
		<category><![CDATA[Ruby on Rails]]></category>
		<category><![CDATA[scalability]]></category>
		<category><![CDATA[Steve Yegge]]></category>
		<category><![CDATA[Thrift]]></category>
		<category><![CDATA[tools]]></category>

		<guid isPermaLink="false">http://obvio171.wordpress.com/?p=65</guid>
		<description><![CDATA[Steve Yegge in one of his posts talks about Google&#8217;s policy of standardizing on the use of only a few programming languages. He mentions how he, as a guy interested in different languages, was at first annoyed by that fact, but later came to realize it was the only sensible way of building systems as [...]<img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=obvio171.wordpress.com&blog=106106&post=65&subd=obvio171&ref=&feed=1" />]]></description>
			<content:encoded><![CDATA[<div class='snap_preview'><br /><p>Steve Yegge in <a title="Yegge" href="http://steve-yegge.blogspot.com/2007/06/rhino-on-rails.html">one of his posts</a> talks about Google&#8217;s policy of standardizing on the use of only a few programming languages. He mentions how he, as a guy interested in different languages, was at first annoyed by that fact, but later came to realize it was the only sensible way of building systems as scalable as theirs have to be.</p>
<p>In what seems to contradict that view, in Facebook&#8217;s <a title="Facebook Developers Blog" href="http://www.facebook.com/notes.php?id=9445547199">recent discussion</a> of the decisions they had to make when designing Facebook Chat, they mention choosing Erlang because, well, it was <em>made</em> to do distributed, realtime systems with&#8230; <em>message passing</em>. Can&#8217;t get a better fit for a Chat project than that.</p>
<p>To make that code interface with their existing codebase, they used <a href="http://developers.facebook.com/thrift/">Thrift</a>, their free software &#8220;framework for scalable cross-language services development&#8221;, whose <a href="http://developers.facebook.com/thrift/thrift-20070401.pdf">white paper</a> begins with the strong remark:</p>
<blockquote><p>&#8220;In our implementation of these services [Facebook], various programming lan-<br />
guages have been selected to optimize for the right combination of performance, ease and speed of development, availability of existing libraries, etc. <em>By and large, <strong>Facebook’s engineering culture has tended towards choosing the best tools and implementations available over standardizing on any one programming language and begrudgingly accepting its inherent limitations</strong>.</em>&#8220;</p></blockquote>
<p>Now, of course Google and Facebook have very different needs (crawling, storing, rating and indexing the whole web on a regular basis must be a bit more challenging than showing user profiles &#8212; even if it&#8217;s showing <em>many</em> of them, many many times a day), and playing safe has surely worked out well for Google so far. But sometimes that requires <a href="http://steve-yegge.blogspot.com/2007/06/rhino-on-rails.html">reimplementing Ruby on Rails in Javascript</a> just to suite a company requirement.</p>
<p>It&#8217;s good to see there is a place in the monster-traffic world for programming language enthusiasts :)</p>
<img alt="" border="0" src="http://feeds.wordpress.com/1.0/categories/obvio171.wordpress.com/65/" /> <img alt="" border="0" src="http://feeds.wordpress.com/1.0/tags/obvio171.wordpress.com/65/" /> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gocomments/obvio171.wordpress.com/65/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/comments/obvio171.wordpress.com/65/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godelicious/obvio171.wordpress.com/65/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/delicious/obvio171.wordpress.com/65/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gostumble/obvio171.wordpress.com/65/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/stumble/obvio171.wordpress.com/65/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godigg/obvio171.wordpress.com/65/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/digg/obvio171.wordpress.com/65/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/goreddit/obvio171.wordpress.com/65/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/reddit/obvio171.wordpress.com/65/" /></a> <img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=obvio171.wordpress.com&blog=106106&post=65&subd=obvio171&ref=&feed=1" /></div>]]></content:encoded>
			<wfw:commentRss>http://obvio171.wordpress.com/2008/05/17/scaling-and-tools-diversity-google-vs-facebook/feed/</wfw:commentRss>
		<slash:comments>2</slash:comments>
	
		<media:content url="http://0.gravatar.com/avatar/e22005d49d02e800c0c51d0177904283?s=96&#38;d=identicon&#38;r=G" medium="image">
			<media:title type="html">helder</media:title>
		</media:content>
	</item>
		<item>
		<title>Making Gmail always use HTTPS without any Greasemonkey</title>
		<link>http://obvio171.wordpress.com/2008/05/16/making-gmail-always-use-https-without-any-greasemonkey/</link>
		<comments>http://obvio171.wordpress.com/2008/05/16/making-gmail-always-use-https-without-any-greasemonkey/#comments</comments>
		<pubDate>Sat, 17 May 2008 00:59:40 +0000</pubDate>
		<dc:creator>Helder</dc:creator>
				<category><![CDATA[Uncategorized]]></category>
		<category><![CDATA[better gmail]]></category>
		<category><![CDATA[Gmail]]></category>
		<category><![CDATA[google]]></category>
		<category><![CDATA[https]]></category>
		<category><![CDATA[privacy]]></category>
		<category><![CDATA[security]]></category>
		<category><![CDATA[ssl]]></category>
		<category><![CDATA[tip]]></category>
		<category><![CDATA[trick]]></category>

		<guid isPermaLink="false">http://obvio171.wordpress.com/?p=64</guid>
		<description><![CDATA[It&#8217;s the stupidest solution, but I hadn&#8217;t thought of it before.
I had seen that the Better Gmail extension had this feature of making Gmail always run over HTTPS, but it also came with so much other stuff that I found it to be just too bloated, and kept wishing for a simpler solution (meanwhile exposing [...]<img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=obvio171.wordpress.com&blog=106106&post=64&subd=obvio171&ref=&feed=1" />]]></description>
			<content:encoded><![CDATA[<div class='snap_preview'><br /><p>It&#8217;s the stupidest solution, but I hadn&#8217;t thought of it before.</p>
<p>I had seen that the <a title="Better Gmail" href="https://addons.mozilla.org/en-US/firefox/addon/4866">Better Gmail</a> extension had this feature of making Gmail always run over HTTPS, but it also came with so much other stuff that I found it to be just too bloated, and kept wishing for a simpler solution (meanwhile exposing my privacy to all those sniffers out there &#8212; oh the danger!).</p>
<p>Of course, I could always replace &#8220;http&#8221; with &#8220;https&#8221; on the address bar, but it&#8217;s a pain doing that every time. If only I could set it to be always like that&#8230;</p>
<p>Wait a second: I always start Gmail as my home page. Always use Alt+Home when I want to go to it. Yes, people, I had this brilliant idea: <strong>why not just put the address with &#8220;HTTPS://&#8221; in the configs as my Home page?</strong></p>
<p>And that I did. Now I&#8217;m a safe, happy Gmail user. No extensions, no glitchy Greasemonkey scripts. Just the ululating obvious.</p>
<img alt="" border="0" src="http://feeds.wordpress.com/1.0/categories/obvio171.wordpress.com/64/" /> <img alt="" border="0" src="http://feeds.wordpress.com/1.0/tags/obvio171.wordpress.com/64/" /> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gocomments/obvio171.wordpress.com/64/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/comments/obvio171.wordpress.com/64/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godelicious/obvio171.wordpress.com/64/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/delicious/obvio171.wordpress.com/64/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gostumble/obvio171.wordpress.com/64/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/stumble/obvio171.wordpress.com/64/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godigg/obvio171.wordpress.com/64/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/digg/obvio171.wordpress.com/64/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/goreddit/obvio171.wordpress.com/64/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/reddit/obvio171.wordpress.com/64/" /></a> <img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=obvio171.wordpress.com&blog=106106&post=64&subd=obvio171&ref=&feed=1" /></div>]]></content:encoded>
			<wfw:commentRss>http://obvio171.wordpress.com/2008/05/16/making-gmail-always-use-https-without-any-greasemonkey/feed/</wfw:commentRss>
		<slash:comments>1</slash:comments>
	
		<media:content url="http://0.gravatar.com/avatar/e22005d49d02e800c0c51d0177904283?s=96&#38;d=identicon&#38;r=G" medium="image">
			<media:title type="html">helder</media:title>
		</media:content>
	</item>
		<item>
		<title>When testing isn&#8217;t worth the price</title>
		<link>http://obvio171.wordpress.com/2008/04/24/when-testing-isnt-worth-the-price/</link>
		<comments>http://obvio171.wordpress.com/2008/04/24/when-testing-isnt-worth-the-price/#comments</comments>
		<pubDate>Thu, 24 Apr 2008 16:42:06 +0000</pubDate>
		<dc:creator>Helder</dc:creator>
				<category><![CDATA[Uncategorized]]></category>
		<category><![CDATA[html]]></category>
		<category><![CDATA[mvc]]></category>
		<category><![CDATA[rails]]></category>
		<category><![CDATA[rspec]]></category>
		<category><![CDATA[ruby]]></category>
		<category><![CDATA[rubyonrails]]></category>
		<category><![CDATA[test]]></category>
		<category><![CDATA[testing]]></category>
		<category><![CDATA[test_unit]]></category>
		<category><![CDATA[views]]></category>

		<guid isPermaLink="false">http://obvio171.wordpress.com/?p=62</guid>
		<description><![CDATA[Views are too unstructured and change too often for it to be worth keeping it all tested, and most of the time you're not testing Ruby code, but HTML, and I don't think that's what tests are for. If your controllers are well tested, views should do ok.<img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=obvio171.wordpress.com&blog=106106&post=62&subd=obvio171&ref=&feed=1" />]]></description>
			<content:encoded><![CDATA[<div class='snap_preview'><br /><p>I&#8217;m just starting to use RSpec for Rails instead of Test::Unit, and with it comes a little novelty: there are separate Controller and View tests (unlike TUnit&#8217;s functional tests). At first I thought &#8220;hm.. cool&#8221;. But after spending the first hours writing tests for views I started to feel very stupid, and the whole thing feels very awkward and unnecessary.</p>
<p>Views are too unstructured and change too often for it to be worth keeping it all tested, and most of the time you&#8217;re not testing Ruby code, but HTML, and I don&#8217;t think that&#8217;s what tests are for. If your controllers are well tested, views should do OK.</p>
<p>As convinced as I am about this, I was feeling a little guilty to just ditch testing like that, so I searched for some supporting opinion and found <a title="Fragility of View Tests" href="http://tuples.us/2007/06/03/fragility-of-view-tests/">this post</a>. It agrees with me, so it must be right :) The comments are also interesting. The main idea is that you should just test if the views render without errors and get on with life. Now I just have to find out how to test <em>that</em> little thing.</p>
<img alt="" border="0" src="http://feeds.wordpress.com/1.0/categories/obvio171.wordpress.com/62/" /> <img alt="" border="0" src="http://feeds.wordpress.com/1.0/tags/obvio171.wordpress.com/62/" /> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gocomments/obvio171.wordpress.com/62/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/comments/obvio171.wordpress.com/62/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godelicious/obvio171.wordpress.com/62/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/delicious/obvio171.wordpress.com/62/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gostumble/obvio171.wordpress.com/62/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/stumble/obvio171.wordpress.com/62/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godigg/obvio171.wordpress.com/62/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/digg/obvio171.wordpress.com/62/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/goreddit/obvio171.wordpress.com/62/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/reddit/obvio171.wordpress.com/62/" /></a> <img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=obvio171.wordpress.com&blog=106106&post=62&subd=obvio171&ref=&feed=1" /></div>]]></content:encoded>
			<wfw:commentRss>http://obvio171.wordpress.com/2008/04/24/when-testing-isnt-worth-the-price/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
	
		<media:content url="http://0.gravatar.com/avatar/e22005d49d02e800c0c51d0177904283?s=96&#38;d=identicon&#38;r=G" medium="image">
			<media:title type="html">helder</media:title>
		</media:content>
	</item>
		<item>
		<title>Yak Shaving: optimizing brain usage for code snippets</title>
		<link>http://obvio171.wordpress.com/2008/04/12/yak-shaving-optimizing-brain-usage-for-code-snippets/</link>
		<comments>http://obvio171.wordpress.com/2008/04/12/yak-shaving-optimizing-brain-usage-for-code-snippets/#comments</comments>
		<pubDate>Sat, 12 Apr 2008 22:23:53 +0000</pubDate>
		<dc:creator>Helder</dc:creator>
				<category><![CDATA[Uncategorized]]></category>
		<category><![CDATA[cheatsheet]]></category>
		<category><![CDATA[dynamic cheatseet]]></category>
		<category><![CDATA[editor]]></category>
		<category><![CDATA[emacs]]></category>
		<category><![CDATA[one-liner]]></category>
		<category><![CDATA[ruby]]></category>
		<category><![CDATA[snippets]]></category>
		<category><![CDATA[textmate]]></category>
		<category><![CDATA[yak shaving]]></category>

		<guid isPermaLink="false">http://obvio171.wordpress.com/?p=61</guid>
		<description><![CDATA[So you checked out how TextMate has all those wonderful snippets for every possible piece of code you could think of (and how now Emacs also does!), but you&#8217;re having second thoughts on wether it pays off to memorizing all those little abreviations and their meanings?
Not anymore!
With the cute one-liner below, you can fire up [...]<img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=obvio171.wordpress.com&blog=106106&post=61&subd=obvio171&ref=&feed=1" />]]></description>
			<content:encoded><![CDATA[<div class='snap_preview'><br /><p>So you checked out how TextMate has all those wonderful snippets for every possible piece of code you could think of (and how now Emacs also does!), but you&#8217;re having second thoughts on wether it pays off to memorizing all those little abreviations and their meanings?</p>
<p>Not anymore!</p>
<p>With the cute one-liner below, you can fire up <strong>irb</strong> on your snippets directory and see instantly the TOP 5 winners in <em>characters-saved / characters-typed</em> !! Pretty neat huh? ;)</p>
<p>Here&#8217;s an example:</p>
<p><code>$ cd ~/.emacs.d/yasnippet/snippets/text-mode/ruby-mode<br />
$ irb<br />
irb(main):019:0&gt; Dir['*'].map {|f| [f,File.read(f).reject{|s| s =~ /^#/}.join.size.to_f/f.size]}.sort {|a,b| b.last &lt;=&gt; a.last}.first(5).each {|f| puts "####" + f.first,File.read(f.first), "\n" *2}<br />
####w<br />
#name : attr_writer ...<br />
# --<br />
attr_writer :${attr_names}</code></p>
<p>####r<br />
#name : attr_reader &#8230;<br />
# &#8211;<br />
attr_reader :${attr_names}</p>
<p>####mm<br />
#name : def method_missing &#8230; end<br />
# &#8211;<br />
def method_missing(method, *args)<br />
$0<br />
end</p>
<p>####am<br />
#name : alias_method new, old<br />
# &#8211;<br />
alias_method :${new_name}, :${old_name}</p>
<p>####bm<br />
#name : Benchmark.bmbm(&#8230;) do &#8230; end<br />
# &#8211;<br />
Benchmark.bmbm(${1:10}) do |x|<br />
$0<br />
end</p>
<p>=&gt; [["w", 26.0], ["r", 26.0], ["mm", 21.0], ["am", 19.5], ["bm", 19.5]]</p>
<p>It would probably be nice also to consider how much typing it saves you by mirroring variable names and stuff&#8230; And also how frequent that particular construct actually is in your code&#8230; Come to think of it, this one-liner is pretty useless, but at least picking an arbitrary 5 or 6 snippets to add to your <a href="http://www.lispcast.com/2007/12/9-tips-for-the-aspiring-emacs-playboy/">dynamic cheatsheet</a> is better than trying to randomly memorize them.</p>
<p>In case you didn&#8217;t catch it, here it is in full color (and we discover wordpress doesn&#8217;t use a full parser for syntax highlighting, what a shame :P):</p>
<pre class="brush: ruby;">
Dir['*'].map {|f| [f,File.read(f).reject{|s| s =~ /^#/}.join.size.to_f/f.size]}.sort {|a,b| b.last =&gt; a.last}.first(5).each {|f| puts &quot;####&quot; + f.first,File.read(f.first), &quot;\n&quot; *2}
</pre>
<img alt="" border="0" src="http://feeds.wordpress.com/1.0/categories/obvio171.wordpress.com/61/" /> <img alt="" border="0" src="http://feeds.wordpress.com/1.0/tags/obvio171.wordpress.com/61/" /> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gocomments/obvio171.wordpress.com/61/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/comments/obvio171.wordpress.com/61/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godelicious/obvio171.wordpress.com/61/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/delicious/obvio171.wordpress.com/61/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gostumble/obvio171.wordpress.com/61/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/stumble/obvio171.wordpress.com/61/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godigg/obvio171.wordpress.com/61/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/digg/obvio171.wordpress.com/61/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/goreddit/obvio171.wordpress.com/61/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/reddit/obvio171.wordpress.com/61/" /></a> <img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=obvio171.wordpress.com&blog=106106&post=61&subd=obvio171&ref=&feed=1" /></div>]]></content:encoded>
			<wfw:commentRss>http://obvio171.wordpress.com/2008/04/12/yak-shaving-optimizing-brain-usage-for-code-snippets/feed/</wfw:commentRss>
		<slash:comments>1</slash:comments>
	
		<media:content url="http://0.gravatar.com/avatar/e22005d49d02e800c0c51d0177904283?s=96&#38;d=identicon&#38;r=G" medium="image">
			<media:title type="html">helder</media:title>
		</media:content>
	</item>
		<item>
		<title>Rails vs SCM: resolving conflicts between local and upstream Migrations</title>
		<link>http://obvio171.wordpress.com/2008/03/26/rails-vs-scm-resolving-conflicts-between-local-and-upstream-migrations/</link>
		<comments>http://obvio171.wordpress.com/2008/03/26/rails-vs-scm-resolving-conflicts-between-local-and-upstream-migrations/#comments</comments>
		<pubDate>Wed, 26 Mar 2008 22:16:58 +0000</pubDate>
		<dc:creator>Helder</dc:creator>
				<category><![CDATA[Uncategorized]]></category>
		<category><![CDATA[enhanced_migrations]]></category>
		<category><![CDATA[git]]></category>
		<category><![CDATA[migration buddy]]></category>
		<category><![CDATA[migrations]]></category>
		<category><![CDATA[rails]]></category>
		<category><![CDATA[rake]]></category>
		<category><![CDATA[ruby]]></category>
		<category><![CDATA[rubyonrails]]></category>
		<category><![CDATA[scm]]></category>
		<category><![CDATA[svn]]></category>
		<category><![CDATA[tasks]]></category>
		<category><![CDATA[tool]]></category>

		<guid isPermaLink="false">http://obvio171.wordpress.com/?p=60</guid>
		<description><![CDATA[If you&#8217;re working on a local branch of a Rais project for long enough, you&#8217;re bound to run into this irritating problem: you create a new migration, it gets the smallest unique number from the ones you got from upstream, BUT, before you get the chance to commit it, someone does it first, and in [...]<img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=obvio171.wordpress.com&blog=106106&post=60&subd=obvio171&ref=&feed=1" />]]></description>
			<content:encoded><![CDATA[<div class='snap_preview'><br /><p>If you&#8217;re working on a local branch of a Rais project for long enough, you&#8217;re bound to run into this irritating problem: you create a new migration, it gets the smallest unique number from the ones you got from upstream, BUT, <i>before</i> you get the chance to commit it, someone does it first, and in your next update (svn up || git pull) you have that tangled migration mess.</p>
<p>This little rake task might help you out. <b>Warning</b>: it assumes that all your local migrations have already been run, and that *none* of the new migrations from upstream have been run.</p>
<p>The code is definetely not very DRY and doesn&#8217;t take much advantage of Rake (I&#8217;m pretty n00b on Rake), so I accept suggestions/patches :)</p>
<p>To use it, just throw it in your lib/tasks folder and call it using &#8220;rake db:migrate:fast_forward&#8221;.</p>
<p>Next (and easy) step is making it receive a SCM parameter (git/svn) so it&#8217;ll use the proper &#8220;mv&#8221; command.</p>
<pre class="brush: ruby;">

namespace :db do
  namespace :migrate do
    desc &lt;&lt;STR
Resolves conflicts between local and upstream migrations.

This task assumes the following scenario:
During your local development, you've created migrations and ran rake db:migrate;
Then, you updated from upstream (svn update || git svn rebase), and ended up with
pairs of migrations with the same number: one is the local you created, and the
other is the one from upstream that someone commited before you.

Besides that, there might be some other non-overlapping migrations *after* the
overlapping zone that are *also* local (you had more local migrations than new ones
that came from upstream on the update).

This tasks takes *all your local migrations*, **reverts them** (in reverse order),
and moves them (in order) to the end of the line.

After that you can run rake db:migrate again and it'll run first the migrations
from upstream, and yours last.
STR

    task :fast_forward =&gt; :environment do
      migrator = ActiveRecord::Migrator.new(:down, 'db/migrate')
      puts &quot;Looking for migrations with repeated numbers&quot;
      all_migrations = Dir['db/migrate/*'].sort
      pairs = all_migrations.group_by{|migration| migration =~ /(\d+)/; $1}.
        select {|number, migrations| 1 &lt; migrations.size &amp;&amp; migrations.size &lt; 3}
      pairs = pairs.sort {|x, y| x[0] &lt;=&gt; y[0]}

      # Pick the range of (local) migrations that will be slided to the end
      migrations_to_move = []
      # First the ones that overlap (disambiguated by user)
      pairs.map{|pair| pair[1]}.each do |mig1, mig2|
        begin
          puts &quot;\n[1]\t#{mig1}&quot;
          puts &quot;[2]\t#{mig2}&quot;
          puts &quot;\nWhich one is part of the range to be slided to the end of the list?&quot;
          option = STDIN.gets.to_i
        end until option == 1 || option == 2

        migrations_to_move &lt;&lt; (option == 1 ? mig1 : mig2)

      end
      # Then the (local) ones past the overlap zone
      unless pairs.empty?
        idx_last_overlapping_migration = all_migrations.index(pairs.last[1].last)
        migrations_to_move += all_migrations[idx_last_overlapping_migration+1..-1]
        # Assumes all (and only) the local ones past the overlap zone have already been run
        migrations_to_move.reject! { |m| m =~ /(\d+)/; $1.to_i &gt; migrator.current_version }
      end

      migrations_to_move.first =~ /(\d+)/
      schema_version = $1.to_i # set_schema_version subtracts one

      # Slide the range to be slided to the end of the list
      upstream_migrations = all_migrations - migrations_to_move
      upstream_migrations.last =~ /(\d+)/
      next_number = $1.to_i + 1

      new_names = migrations_to_move.map { |migration|
        migration =~ /(\d+)(.*)/
        name_migration_to_move = $2

        new_name = 'db/migrate/' + (&quot;%03d&quot; % next_number) + name_migration_to_move
        next_number += 1
        new_name
      }

      # Confirm and execute
      unless migrations_to_move.empty?
        pp &quot;Latest upstream migrations&quot;, upstream_migrations.last(5)
        pp &quot;These are your local migrations: &quot;, migrations_to_move
        pp &quot;They will be reverted and renamed to: &quot;, new_names
        puts &quot;And the new schema version will be: #{schema_version-1}&quot;

        begin
          puts &quot;\nShould I proceed? [Y/n] &quot;
          option = STDIN.gets.strip.downcase
        end until option == 'y' || option == 'n'

        if option == 'y'
          # Revert
          migrations_to_move.reverse.each do |migration|
            require migration
            migration_class = migrator.send(:migration_class, *(migrator.send(:migration_version_and_name, migration).reverse))
            migration_class.down
          end
          migrator.send(:set_schema_version, schema_version)
          # Move to end of line
          migrations_to_move.zip(new_names) do |old_name, new_name|
            File.rename old_name, new_name
          end
        end
      else
        puts &quot;No overlapping migrations. You can safely run rake db:migrate.&quot;
      end
    end
  end
end</pre>
<p><i>Update: Just after writing this, a friend told me about the <a href="http://weblog.techno-weenie.net/2008/3/25/rails-migrations-in-git-branches" title="Technoweenie">Git Migration Buddy</a>. It is git specific and seems to handle handle multiple branches better. Mine is kinda 1-n (main (svn in my case) repo syncing with multiple local branches). There&#8217;s the enhanced_migrations plugin that supposedly stops the problem at the root, having timestamps instead of increasing numbers for migrations. Zach in the comments also mentions a great solution he&#8217;s coming up with: a post-checkout hook to change database.yml and have a different db for each branch (dunno if it works too well with big dbs, but it&#8217;s a great idea nonetheless).</i></p>
<img alt="" border="0" src="http://feeds.wordpress.com/1.0/categories/obvio171.wordpress.com/60/" /> <img alt="" border="0" src="http://feeds.wordpress.com/1.0/tags/obvio171.wordpress.com/60/" /> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gocomments/obvio171.wordpress.com/60/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/comments/obvio171.wordpress.com/60/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godelicious/obvio171.wordpress.com/60/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/delicious/obvio171.wordpress.com/60/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gostumble/obvio171.wordpress.com/60/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/stumble/obvio171.wordpress.com/60/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godigg/obvio171.wordpress.com/60/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/digg/obvio171.wordpress.com/60/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/goreddit/obvio171.wordpress.com/60/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/reddit/obvio171.wordpress.com/60/" /></a> <img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=obvio171.wordpress.com&blog=106106&post=60&subd=obvio171&ref=&feed=1" /></div>]]></content:encoded>
			<wfw:commentRss>http://obvio171.wordpress.com/2008/03/26/rails-vs-scm-resolving-conflicts-between-local-and-upstream-migrations/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
	
		<media:content url="http://0.gravatar.com/avatar/e22005d49d02e800c0c51d0177904283?s=96&#38;d=identicon&#38;r=G" medium="image">
			<media:title type="html">helder</media:title>
		</media:content>
	</item>
		<item>
		<title>Fast-forwarding through screencasts without ant voice</title>
		<link>http://obvio171.wordpress.com/2008/02/03/fast-forwarding-through-screencasts-without-ant-voice/</link>
		<comments>http://obvio171.wordpress.com/2008/02/03/fast-forwarding-through-screencasts-without-ant-voice/#comments</comments>
		<pubDate>Sun, 03 Feb 2008 18:16:22 +0000</pubDate>
		<dc:creator>Helder</dc:creator>
				<category><![CDATA[Uncategorized]]></category>
		<category><![CDATA[audio]]></category>
		<category><![CDATA[fast-forward]]></category>
		<category><![CDATA[howto]]></category>
		<category><![CDATA[installation]]></category>
		<category><![CDATA[mplayer]]></category>
		<category><![CDATA[pitch]]></category>
		<category><![CDATA[playback]]></category>
		<category><![CDATA[scaletempo]]></category>
		<category><![CDATA[tutorial]]></category>
		<category><![CDATA[video]]></category>

		<guid isPermaLink="false">http://obvio171.wordpress.com/?p=59</guid>
		<description><![CDATA[One thing that always stopped me from using screencasts as a viable learning tool is that they usually take too long. And most of the time it&#8217;s the guy moving around, or saying &#8220;uh&#8221;, &#8220;er&#8230;&#8221;, or doing stuff I already know. And when I tried skipping a few seconds ahead I usually skipped the very [...]<img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=obvio171.wordpress.com&blog=106106&post=59&subd=obvio171&ref=&feed=1" />]]></description>
			<content:encoded><![CDATA[<div class='snap_preview'><br /><p>One thing that always stopped me from using screencasts as a viable learning tool is that they usually <em>take too long</em>. And most of the time it&#8217;s the guy moving around, or saying &#8220;uh&#8221;, &#8220;er&#8230;&#8221;, or doing stuff I already know. And when I tried skipping a few seconds ahead I usually skipped the very few meaty bits and had to go back and listen to them again. So what I did sometimes was increasing the playback speed (by pressing the ]-key on mplayer), but that made the guy speak as if breathing helium.</p>
<p>Not anymore!</p>
<p>Mplayer (from svn) has a fantastic new audio filter called <em>scaletempo</em>. It basically lets you change the playback speed without changing the sound pitch. The guy speaks faster, but in the same tone. Isn&#8217;t that amazing?! So, here&#8217;s how to do it (you really need the svn version as of now; 1.0rc2 won&#8217;t do it) on Ubuntu:</p>
<p>First, we need to install the dependencies for compiling the new package (without installing the package itself):</p>
<p><code>sudo apt-get build-dep mplayer</code></p>
<p>Now the usual checkout, compile and install:<br />
<code><br />
cd /tmp<br />
svn checkout svn://svn.mplayerhq.hu/mplayer/trunk mplayer<br />
cd mplayer<br />
./configure<br />
make<br />
sudo make install<br />
</code></p>
<p>And that&#8217;s it! Now you just open your videos like this:</p>
<p><code>mplayer screencast.ogm -af scaletempo</code></p>
<p>and use the keys [ and ] to adjust playback speed at will.</p>
<p><em>Edit: from my experience, you can speed up speech up to 1.5-1.75 without losing quality. <strong>That means you can watch a 1-hour video in 34-40min!</strong></em></p>
<img alt="" border="0" src="http://feeds.wordpress.com/1.0/categories/obvio171.wordpress.com/59/" /> <img alt="" border="0" src="http://feeds.wordpress.com/1.0/tags/obvio171.wordpress.com/59/" /> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gocomments/obvio171.wordpress.com/59/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/comments/obvio171.wordpress.com/59/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godelicious/obvio171.wordpress.com/59/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/delicious/obvio171.wordpress.com/59/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gostumble/obvio171.wordpress.com/59/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/stumble/obvio171.wordpress.com/59/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godigg/obvio171.wordpress.com/59/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/digg/obvio171.wordpress.com/59/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/goreddit/obvio171.wordpress.com/59/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/reddit/obvio171.wordpress.com/59/" /></a> <img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=obvio171.wordpress.com&blog=106106&post=59&subd=obvio171&ref=&feed=1" /></div>]]></content:encoded>
			<wfw:commentRss>http://obvio171.wordpress.com/2008/02/03/fast-forwarding-through-screencasts-without-ant-voice/feed/</wfw:commentRss>
		<slash:comments>1</slash:comments>
	
		<media:content url="http://0.gravatar.com/avatar/e22005d49d02e800c0c51d0177904283?s=96&#38;d=identicon&#38;r=G" medium="image">
			<media:title type="html">helder</media:title>
		</media:content>
	</item>
		<item>
		<title>Making Vlad copy database.yml to shared folder</title>
		<link>http://obvio171.wordpress.com/2008/01/12/making-vlad-copy-databaseyml-to-shared-folder/</link>
		<comments>http://obvio171.wordpress.com/2008/01/12/making-vlad-copy-databaseyml-to-shared-folder/#comments</comments>
		<pubDate>Sat, 12 Jan 2008 21:48:22 +0000</pubDate>
		<dc:creator>Helder</dc:creator>
				<category><![CDATA[configuration]]></category>
		<category><![CDATA[database]]></category>
		<category><![CDATA[deployment]]></category>
		<category><![CDATA[rake]]></category>
		<category><![CDATA[ruby]]></category>
		<category><![CDATA[Ruby on Rails]]></category>
		<category><![CDATA[rubyonrails]]></category>
		<category><![CDATA[vlad]]></category>
		<category><![CDATA[vlad the deployer]]></category>

		<guid isPermaLink="false">http://obvio171.wordpress.com/2008/01/12/making-vlad-copy-databaseyml-to-shared-folder/</guid>
		<description><![CDATA[Found this at http://topfunky.net/svn/shovel/merb/vlad_config.rb
Also good example of how to make vlad tasks.

# config/deploy.rb
# ... 
set :config_files, ['database.yml']

 namespace :vlad do

   desc &#34;Copy config files from shared/config to release dir&#34;
   remote_task :copy_config_files, :roles =&#62; :app do
     config_files.each do &#124;filename&#124;
       run &#34;cp #{shared_path}/config/#{filename} #{release_path}/config/#{filename}&#34;
 [...]<img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=obvio171.wordpress.com&blog=106106&post=58&subd=obvio171&ref=&feed=1" />]]></description>
			<content:encoded><![CDATA[<div class='snap_preview'><br /><p>Found this at http://topfunky.net/svn/shovel/merb/vlad_config.rb</p>
<p>Also good example of how to make vlad tasks.</p>
<pre class="brush: ruby;">
# config/deploy.rb
# ... 
set :config_files, ['database.yml']

 namespace :vlad do

   desc &quot;Copy config files from shared/config to release dir&quot;
   remote_task :copy_config_files, :roles =&gt; :app do
     config_files.each do |filename|
       run &quot;cp #{shared_path}/config/#{filename} #{release_path}/config/#{filename}&quot;
     end
   end

   desc &quot;Deploys&quot;
   remote_task :deploy do
   end

   task :deploy =&gt; [:setup, :update, :copy_config_files, :migrate, :start]

 end
end</pre>
<p>As you can see, I couldn&#8217;t find a way to make :copy_config_files be called after :update by just using</p>
<pre class="brush: ruby;">
namespace :vlad
  task :update do
    Rake::Task[:copy_config_files].invoke
  end
end</pre>
<p>so I ended up just creating an all-encompassing task, and that takes care of my needs at least for now. If you have any ideas on how to make this better, plesae pitch in.</p>
<img alt="" border="0" src="http://feeds.wordpress.com/1.0/categories/obvio171.wordpress.com/58/" /> <img alt="" border="0" src="http://feeds.wordpress.com/1.0/tags/obvio171.wordpress.com/58/" /> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gocomments/obvio171.wordpress.com/58/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/comments/obvio171.wordpress.com/58/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godelicious/obvio171.wordpress.com/58/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/delicious/obvio171.wordpress.com/58/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gostumble/obvio171.wordpress.com/58/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/stumble/obvio171.wordpress.com/58/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godigg/obvio171.wordpress.com/58/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/digg/obvio171.wordpress.com/58/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/goreddit/obvio171.wordpress.com/58/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/reddit/obvio171.wordpress.com/58/" /></a> <img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=obvio171.wordpress.com&blog=106106&post=58&subd=obvio171&ref=&feed=1" /></div>]]></content:encoded>
			<wfw:commentRss>http://obvio171.wordpress.com/2008/01/12/making-vlad-copy-databaseyml-to-shared-folder/feed/</wfw:commentRss>
		<slash:comments>2</slash:comments>
	
		<media:content url="http://0.gravatar.com/avatar/e22005d49d02e800c0c51d0177904283?s=96&#38;d=identicon&#38;r=G" medium="image">
			<media:title type="html">helder</media:title>
		</media:content>
	</item>
		<item>
		<title>emerge humor</title>
		<link>http://obvio171.wordpress.com/2008/01/06/emerge-humor/</link>
		<comments>http://obvio171.wordpress.com/2008/01/06/emerge-humor/#comments</comments>
		<pubDate>Sun, 06 Jan 2008 11:22:32 +0000</pubDate>
		<dc:creator>Helder</dc:creator>
				<category><![CDATA[apache]]></category>
		<category><![CDATA[emerge]]></category>
		<category><![CDATA[gentoo]]></category>
		<category><![CDATA[humor]]></category>
		<category><![CDATA[php]]></category>

		<guid isPermaLink="false">http://obvio171.wordpress.com/2008/01/06/emerge-humor/</guid>
		<description><![CDATA[* If this package fails with a fatal error about Apache2 not having
* been compiled with a compatible MPM, this is normally because you
* need to toggle the &#8216;threads&#8217; USE flag.
*
* If &#8216;threads&#8217; is off, try switching it on.
* If &#8216;threads&#8217; is on, try switching it off.
       <img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=obvio171.wordpress.com&blog=106106&post=56&subd=obvio171&ref=&feed=1" />]]></description>
			<content:encoded><![CDATA[<div class='snap_preview'><br /><p>* If this package fails with a fatal error about Apache2 not having<br />
* been compiled with a compatible MPM, this is normally because you<br />
* need to toggle the &#8216;threads&#8217; USE flag.<br />
*<br />
* If &#8216;threads&#8217; is off, try switching it on.<br />
* If &#8216;threads&#8217; is on, try switching it off.</p>
<img alt="" border="0" src="http://feeds.wordpress.com/1.0/categories/obvio171.wordpress.com/56/" /> <img alt="" border="0" src="http://feeds.wordpress.com/1.0/tags/obvio171.wordpress.com/56/" /> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gocomments/obvio171.wordpress.com/56/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/comments/obvio171.wordpress.com/56/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godelicious/obvio171.wordpress.com/56/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/delicious/obvio171.wordpress.com/56/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gostumble/obvio171.wordpress.com/56/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/stumble/obvio171.wordpress.com/56/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godigg/obvio171.wordpress.com/56/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/digg/obvio171.wordpress.com/56/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/goreddit/obvio171.wordpress.com/56/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/reddit/obvio171.wordpress.com/56/" /></a> <img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=obvio171.wordpress.com&blog=106106&post=56&subd=obvio171&ref=&feed=1" /></div>]]></content:encoded>
			<wfw:commentRss>http://obvio171.wordpress.com/2008/01/06/emerge-humor/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
	
		<media:content url="http://0.gravatar.com/avatar/e22005d49d02e800c0c51d0177904283?s=96&#38;d=identicon&#38;r=G" medium="image">
			<media:title type="html">helder</media:title>
		</media:content>
	</item>
		<item>
		<title>Power-Set Method For Ruby Hash</title>
		<link>http://obvio171.wordpress.com/2007/12/13/power-set-method-for-ruby-hash/</link>
		<comments>http://obvio171.wordpress.com/2007/12/13/power-set-method-for-ruby-hash/#comments</comments>
		<pubDate>Thu, 13 Dec 2007 15:24:46 +0000</pubDate>
		<dc:creator>Helder</dc:creator>
				<category><![CDATA[array]]></category>
		<category><![CDATA[arrays]]></category>
		<category><![CDATA[base class]]></category>
		<category><![CDATA[code]]></category>
		<category><![CDATA[hash]]></category>
		<category><![CDATA[power-set]]></category>
		<category><![CDATA[powerset]]></category>
		<category><![CDATA[programming]]></category>
		<category><![CDATA[ruby]]></category>
		<category><![CDATA[set]]></category>
		<category><![CDATA[sets]]></category>
		<category><![CDATA[snippet]]></category>

		<guid isPermaLink="false">http://obvio171.wordpress.com/2007/12/13/power-set-method-for-ruby-hash/</guid>
		<description><![CDATA[
# The Array power set is stolen from http://snippets.dzone.com/posts/show/3524
class Array
  # Returns the &#34;power set&#34; for this Array. This means that an array with all
  # subsets of the array's elements will be returned.
  def power_set
    # the power set line is stolen from http://johncarrino.net/blog/2006/08/11/powerset-in-ruby/
    inject([[]]){&#124;c,y&#124;r=[];c.each{&#124;i&#124;r&#60;&#60;i;r&#60;&#60;i+[y]};r}
 [...]<img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=obvio171.wordpress.com&blog=106106&post=55&subd=obvio171&ref=&feed=1" />]]></description>
			<content:encoded><![CDATA[<div class='snap_preview'><br /><pre class="brush: ruby;">
# The Array power set is stolen from http://snippets.dzone.com/posts/show/3524
class Array
  # Returns the &quot;power set&quot; for this Array. This means that an array with all
  # subsets of the array's elements will be returned.
  def power_set
    # the power set line is stolen from http://johncarrino.net/blog/2006/08/11/powerset-in-ruby/
    inject([[]]){|c,y|r=[];c.each{|i|r&lt;&lt;i;r&lt;&lt;i+[y]};r}
  end
end

class Hash
  def power_set
    # Returns the &quot;power set&quot; for this Hash. This means that a array with hashes of all
    # subsets of the hash's (key =&gt; value) pairs will be returned.
    # Example:
    # &gt;&gt; {:feedback_type=&gt;&quot;&quot;, :language_code=&gt;&quot;&quot;, :comment=&gt;&quot;&quot;}.power_set
    #
    # [{}, {:comment=&gt;&quot;&quot;}, {:language_code=&gt;&quot;&quot;}, {:language_code=&gt;&quot;&quot;, :comment=&gt;&quot;&quot;}, {:feedback_type=&gt;&quot;&quot;}, {:feedback_type=&gt;&quot;&quot;, :comment=&gt;&quot;&quot;}, {:feedback_type=&gt;&quot;&quot;, :language_code=&gt;&quot;&quot;}, {:feedback_type=&gt;&quot;&quot;, :language_code=&gt;&quot;&quot;, :comment=&gt;&quot;&quot;}]

    hash_to_array = self.to_a
    array_power_set = hash_to_array.power_set
    hash_power_set = array_power_set.collect { |pairs| pairs.inject({}) { |hash,pair| hash[pair[0]] = pair[1]; hash } }
    hash_power_set
  end
end</pre>
<img alt="" border="0" src="http://feeds.wordpress.com/1.0/categories/obvio171.wordpress.com/55/" /> <img alt="" border="0" src="http://feeds.wordpress.com/1.0/tags/obvio171.wordpress.com/55/" /> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gocomments/obvio171.wordpress.com/55/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/comments/obvio171.wordpress.com/55/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godelicious/obvio171.wordpress.com/55/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/delicious/obvio171.wordpress.com/55/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gostumble/obvio171.wordpress.com/55/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/stumble/obvio171.wordpress.com/55/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godigg/obvio171.wordpress.com/55/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/digg/obvio171.wordpress.com/55/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/goreddit/obvio171.wordpress.com/55/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/reddit/obvio171.wordpress.com/55/" /></a> <img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=obvio171.wordpress.com&blog=106106&post=55&subd=obvio171&ref=&feed=1" /></div>]]></content:encoded>
			<wfw:commentRss>http://obvio171.wordpress.com/2007/12/13/power-set-method-for-ruby-hash/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
	
		<media:content url="http://0.gravatar.com/avatar/e22005d49d02e800c0c51d0177904283?s=96&#38;d=identicon&#38;r=G" medium="image">
			<media:title type="html">helder</media:title>
		</media:content>
	</item>
	</channel>
</rss>