<?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>GautamRege&#039;s Blog - I have relocated to: blog.joshsoftware.com</title>
	<atom:link href="http://gautamrege.wordpress.com/feed/" rel="self" type="application/rss+xml" />
	<link>http://gautamrege.wordpress.com</link>
	<description>My ideas, talks and views !</description>
	<lastBuildDate>Tue, 10 Jan 2012 06:01:30 +0000</lastBuildDate>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.com/</generator>
<cloud domain='gautamrege.wordpress.com' port='80' path='/?rsscloud=notify' registerProcedure='' protocol='http-post' />
<image>
		<url>http://s2.wp.com/i/buttonw-com.png</url>
		<title>GautamRege&#039;s Blog - I have relocated to: blog.joshsoftware.com</title>
		<link>http://gautamrege.wordpress.com</link>
	</image>
	<atom:link rel="search" type="application/opensearchdescription+xml" href="http://gautamrege.wordpress.com/osd.xml" title="GautamRege&#039;s Blog - I have relocated to: blog.joshsoftware.com" />
	<atom:link rel='hub' href='http://gautamrege.wordpress.com/?pushpress=hub'/>
		<item>
		<title>Discontinuing my musings here.</title>
		<link>http://gautamrege.wordpress.com/2010/04/16/discontinuing-my-musings-here/</link>
		<comments>http://gautamrege.wordpress.com/2010/04/16/discontinuing-my-musings-here/#comments</comments>
		<pubDate>Fri, 16 Apr 2010 13:10:39 +0000</pubDate>
		<dc:creator>Gautam Rege</dc:creator>
				<category><![CDATA[General]]></category>

		<guid isPermaLink="false">http://gautamrege.wordpress.com/2010/04/16/discontinuing-my-musings-here/</guid>
		<description><![CDATA[Dont worry, I am now blogging from http://blog.joshsoftware.com It has a wealth of information there, including all these posts here! Ciao.<img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=gautamrege.wordpress.com&amp;blog=9042943&amp;post=189&amp;subd=gautamrege&amp;ref=&amp;feed=1" width="1" height="1" />]]></description>
			<content:encoded><![CDATA[<p>Dont worry, I am now blogging from<br />
<a href="http://blog.joshsoftware.com" target="_self"> http://blog.joshsoftware.com </a></p>
<p>It has a wealth of information there, including all these posts here!</p>
<p>Ciao.</p>
<br />  <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gocomments/gautamrege.wordpress.com/189/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/comments/gautamrege.wordpress.com/189/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godelicious/gautamrege.wordpress.com/189/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/delicious/gautamrege.wordpress.com/189/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gofacebook/gautamrege.wordpress.com/189/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/facebook/gautamrege.wordpress.com/189/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gotwitter/gautamrege.wordpress.com/189/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/twitter/gautamrege.wordpress.com/189/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gostumble/gautamrege.wordpress.com/189/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/stumble/gautamrege.wordpress.com/189/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godigg/gautamrege.wordpress.com/189/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/digg/gautamrege.wordpress.com/189/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/goreddit/gautamrege.wordpress.com/189/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/reddit/gautamrege.wordpress.com/189/" /></a> <img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=gautamrege.wordpress.com&amp;blog=9042943&amp;post=189&amp;subd=gautamrege&amp;ref=&amp;feed=1" width="1" height="1" />]]></content:encoded>
			<wfw:commentRss>http://gautamrege.wordpress.com/2010/04/16/discontinuing-my-musings-here/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
	
		<media:content url="http://1.gravatar.com/avatar/5c07bd3a48ed2565bf1b872620bca3e9?s=96&#38;d=identicon&#38;r=G" medium="image">
			<media:title type="html">gautamrege</media:title>
		</media:content>
	</item>
		<item>
		<title>Scottish Ruby Conference 2010 roundup-1</title>
		<link>http://gautamrege.wordpress.com/2010/03/29/scottish-ruby-conference-2010-roundup-1/</link>
		<comments>http://gautamrege.wordpress.com/2010/03/29/scottish-ruby-conference-2010-roundup-1/#comments</comments>
		<pubDate>Sun, 28 Mar 2010 20:48:51 +0000</pubDate>
		<dc:creator>Gautam Rege</dc:creator>
				<category><![CDATA[Conferences]]></category>
		<category><![CDATA[Ruby On Rails]]></category>
		<category><![CDATA[scotruby]]></category>

		<guid isPermaLink="false">http://gautamrege.wordpress.com/?p=185</guid>
		<description><![CDATA[Following some inspirational talks with some great folks at Scottish Ruby Conference, I am going to apply the pomodoro technique for this blog post &#8211; 25 minutes of writing on this post! These are just some of the things you get to learn at this no-nonsense conference, which is full of geeks, innovators and innovative [...]<img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=gautamrege.wordpress.com&amp;blog=9042943&amp;post=185&amp;subd=gautamrege&amp;ref=&amp;feed=1" width="1" height="1" />]]></description>
			<content:encoded><![CDATA[<p>Following some inspirational talks with some great folks at Scottish Ruby Conference, I am going to apply the pomodoro technique for this blog post &#8211; 25 minutes of writing on this post!</p>
<p>These are just some of the things you get to learn at this no-nonsense conference, which is full of geeks, innovators and innovative geeks. This time, the renamed conference (earlier called Scotland on Rails) had a very good mix of talks on Ruby, Rails, good practices and even philosophy. I could get into details of each talk but they have all been recorded and will be out soon &#8211; it would be so much better to listen in on them instead of reading about them here !</p>
<p>What I intend to do here  is to put forth some views of the talks, the styles, the key take-home points and what I learnt.</p>
<p>Jim Wreich started with an excellent keynote and also give an awesome theatrical performance in the closing key-note! He was very clear in getting into my head that the key values of a good programmer:</p>
<p>- thinking out of the box. (Try to innovate!)</p>
<p>- accept duality (code &amp; objects are the same things from different points of view!)</p>
<p>- abstractions are good. (Write generic, re-usable code!)</p>
<p>In the closing key-note, along with Joe O&#8217;Brian, it was made clear about why we should explain the benefits (and not features) of Ruby to the decision making management &#8211; no point in talking about Ruby features like blocks, iterators and TDD/BBD instead of business aspects about how the maintenance cycle of product can be reduced drastically by using Ruby and how Ruby seamlessly integrates with legacy systems.</p>
<p>People had come from all over the globe &#8211; from US, Europe, Australia, New Zealand and us from India. If this wasn&#8217;t good enough for diversity, the enormous variety of food at lunch made up for it. The venue, Royal College of Physicians was &#8216;unbelievable&#8217;. I sat in the &#8216;Great Hall&#8217; admiring the ceiling and in the library admiring the expanse of the books lined in the racks beside and the so beautifully architected Amphi-theater.</p>
<p>The talks were well distributed in 3 tracks and each talk had a sizable crowd. There were 3 talks which discussed how to write good code (&#8216;write bad code&#8217; by Gwyn Morfey, &#8217;10 most errors in Rails&#8217; by Exceptional and &#8216;Your doing it wrong&#8217; by Tammer Saleh). Each had a different style &#8211; my personal favourite being Tammer&#8217;s talk &#8211; it seems straight from the heart. Gwyen&#8217;s talk was very well staged to show how to &#8216;really&#8217; work and it was really funny.</p>
<p>Tyler McMullen&#8217;s talk on distributed rack applications was amazing and new way to look at things. Imagine different sections on a web-page being serviced by different application servers &#8212; no! Not using ajax requests but genuine HTTP distributed requests for rendering a single page! He demonstrated it really well and there were some of us in the audience who installed the distributed_demo gem from gemcutter to see it all in action!</p>
<p>Joesph Wilk&#8217;s talk was precision perfect on scaling cucumber test cases &#8211; there is indeed a lot of potential here. Scott Chacon &#8216;showed off&#8217; the git internal plumbing with an excellent and very cool presentation &#8211; I am inspired now and do plan to use a single git repository for distributed deployment on different machines with different roles.</p>
<p>Lightening talks were really good !! I shall be using RedCar (the Ruby IDE) and Showoff, the Rails presentation gem from now on. Ryan&#8217;s talk of 2500 words (speed reading) was an awesome insight into the life-cycle of a software programmer who found the worth of testing his code!</p>
<p>Keeping in line with the pomodoro technique, I shall stop now and write another detailed post on the conference soon <img src='http://s1.wp.com/wp-includes/images/smilies/icon_wink.gif' alt=';)' class='wp-smiley' />  I stretched this post to 35 minutes &#8212; hell nobody&#8217;s perfect!</p>
<br />  <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gocomments/gautamrege.wordpress.com/185/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/comments/gautamrege.wordpress.com/185/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godelicious/gautamrege.wordpress.com/185/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/delicious/gautamrege.wordpress.com/185/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gofacebook/gautamrege.wordpress.com/185/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/facebook/gautamrege.wordpress.com/185/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gotwitter/gautamrege.wordpress.com/185/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/twitter/gautamrege.wordpress.com/185/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gostumble/gautamrege.wordpress.com/185/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/stumble/gautamrege.wordpress.com/185/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godigg/gautamrege.wordpress.com/185/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/digg/gautamrege.wordpress.com/185/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/goreddit/gautamrege.wordpress.com/185/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/reddit/gautamrege.wordpress.com/185/" /></a> <img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=gautamrege.wordpress.com&amp;blog=9042943&amp;post=185&amp;subd=gautamrege&amp;ref=&amp;feed=1" width="1" height="1" />]]></content:encoded>
			<wfw:commentRss>http://gautamrege.wordpress.com/2010/03/29/scottish-ruby-conference-2010-roundup-1/feed/</wfw:commentRss>
		<slash:comments>7</slash:comments>
	
		<media:content url="http://1.gravatar.com/avatar/5c07bd3a48ed2565bf1b872620bca3e9?s=96&#38;d=identicon&#38;r=G" medium="image">
			<media:title type="html">gautamrege</media:title>
		</media:content>
	</item>
		<item>
		<title>Pune Rails Meetup#3 ideas?</title>
		<link>http://gautamrege.wordpress.com/2010/02/01/pune-rails-meetup3-ideas/</link>
		<comments>http://gautamrege.wordpress.com/2010/02/01/pune-rails-meetup3-ideas/#comments</comments>
		<pubDate>Mon, 01 Feb 2010 10:48:14 +0000</pubDate>
		<dc:creator>Gautam Rege</dc:creator>
				<category><![CDATA[Conferences]]></category>
		<category><![CDATA[Ruby On Rails]]></category>
		<category><![CDATA[#PRM]]></category>
		<category><![CDATA[PuneRailsMeetup]]></category>

		<guid isPermaLink="false">http://gautamrege.wordpress.com/?p=152</guid>
		<description><![CDATA[At Josh, We did some brainstorming and came up with some ideas that our team suggested would be good learning topics at Rails meetup. To put that into effect, we hope to raise the bar for Pune Rails Meetup#3 and take some technical sessions ( basic and advanced). People are expected to come with their [...]<img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=gautamrege.wordpress.com&amp;blog=9042943&amp;post=152&amp;subd=gautamrege&amp;ref=&amp;feed=1" width="1" height="1" />]]></description>
			<content:encoded><![CDATA[<div id="_mcePaste">At <a href="http://www.twitter.com/joshsoftware" target="_blank">Josh</a>, We did some brainstorming and came up with some ideas that our team suggested would be good learning topics at Rails meetup.</div>
<div id="_mcePaste">To put that into effect, we hope to raise the bar for Pune Rails Meetup#3 and take some technical sessions ( basic and advanced). People are expected to come with their laptops configured with Rails.</div>
<div id="_mcePaste">Please add comments to this post with a list of topics if you are interested in learning about something in Ruby or in Rails! We need to shortlist these topics and we need feedback. We then need to finalize the comprehensive topic list &#8211; maybe get some voting on the topics from Rubyists.</div>
<h3>Ruby</h3>
<div id="_mcePaste">1. Ruby meta-programing (advanced)</div>
<div id="_mcePaste">2. Regular Expressions in Ruby (basic)</div>
<div id="_mcePaste">3. forking using spork (advanced)</div>
<div id="_mcePaste">4. Ruby threads (basic)</div>
<h3>Rails</h3>
<div id="_mcePaste">1. polymorphic associations &amp; STI (basic)</div>
<div id="_mcePaste">2. writing a rails plugin (advanced)</div>
<div id="_mcePaste">3. Social networking connects &#8211; authentication &amp; sharing via openIDs (basic)</div>
<div id="_mcePaste">4. DelayedJob  (basic)</div>
<div id="_mcePaste">5. Ruby event machine / nanite / RabbitMQ (advanced)</div>
<div>6. Deployment in the cloud (advanced)</div>
<h3>Hosting the event</h3>
<div id="_mcePaste">1. We can pool in some funds (or get some sponsors) and host this event at PYC, deccan. If there is some company or venue that can host this event, please contact us.</div>
<br />  <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gocomments/gautamrege.wordpress.com/152/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/comments/gautamrege.wordpress.com/152/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godelicious/gautamrege.wordpress.com/152/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/delicious/gautamrege.wordpress.com/152/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gofacebook/gautamrege.wordpress.com/152/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/facebook/gautamrege.wordpress.com/152/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gotwitter/gautamrege.wordpress.com/152/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/twitter/gautamrege.wordpress.com/152/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gostumble/gautamrege.wordpress.com/152/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/stumble/gautamrege.wordpress.com/152/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godigg/gautamrege.wordpress.com/152/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/digg/gautamrege.wordpress.com/152/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/goreddit/gautamrege.wordpress.com/152/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/reddit/gautamrege.wordpress.com/152/" /></a> <img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=gautamrege.wordpress.com&amp;blog=9042943&amp;post=152&amp;subd=gautamrege&amp;ref=&amp;feed=1" width="1" height="1" />]]></content:encoded>
			<wfw:commentRss>http://gautamrege.wordpress.com/2010/02/01/pune-rails-meetup3-ideas/feed/</wfw:commentRss>
		<slash:comments>16</slash:comments>
	
		<media:content url="http://1.gravatar.com/avatar/5c07bd3a48ed2565bf1b872620bca3e9?s=96&#38;d=identicon&#38;r=G" medium="image">
			<media:title type="html">gautamrege</media:title>
		</media:content>
	</item>
		<item>
		<title>Metaprogramming with RadiantCMS</title>
		<link>http://gautamrege.wordpress.com/2010/01/26/metaprogramming-with-radiantcms/</link>
		<comments>http://gautamrege.wordpress.com/2010/01/26/metaprogramming-with-radiantcms/#comments</comments>
		<pubDate>Tue, 26 Jan 2010 12:13:25 +0000</pubDate>
		<dc:creator>Gautam Rege</dc:creator>
				<category><![CDATA[Ruby On Rails]]></category>
		<category><![CDATA[metaprogramming]]></category>
		<category><![CDATA[multisite]]></category>
		<category><![CDATA[radiant]]></category>

		<guid isPermaLink="false">http://gautamrege.wordpress.com/?p=139</guid>
		<description><![CDATA[My short stint with Radiant in the near past was actually quite interesting ! &#8212; No I did not design websites or webpages. What I am talking about is the internals &#8211; making radiant plugins and creating radius tags, the overwhelming use of meta-programing and the ease of overriding and extending the base or extensions [...]<img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=gautamrege.wordpress.com&amp;blog=9042943&amp;post=139&amp;subd=gautamrege&amp;ref=&amp;feed=1" width="1" height="1" />]]></description>
			<content:encoded><![CDATA[<p>My short stint with Radiant in the near past was actually quite interesting ! &#8212; No I did not design websites or webpages. What I am talking about is the internals &#8211; making radiant plugins and creating radius tags, the overwhelming use of meta-programing and the ease of overriding and extending the base or extensions functionality.</p>
<p>First-up, Radiant is NOT for newbies. If you are looking to design some static webpages or basic content, I would probably not recommend radiant &#8211; there are other tools for this. Radiant however is very exciting if you are planning on things which are more complicated than static web-pages, like authorization based views, galleries, custom website configuration, etc. etc. If you are well versed and aware of page-parts, snippets, layouts and how they all interact with each other, then you can look at Radiant</p>
<p>Though radiant supports ALL basic HTML tags, it also supports radius tags &#8212; loaded via extensions. The excellent open source contributions as radiant extensions leaves very little to do on your own <img src='http://s1.wp.com/wp-includes/images/smilies/icon_wink.gif' alt=';)' class='wp-smiley' />  but then again &#8211; there is nothing called a free lunch.</p>
<p>Its easy to override any existing functionality in core radiant or its extensions by some simple meta-programing. Some good insight <a href="http://wiki.github.com/radiant/radiant/extending-and-overriding-radiant-behavior" target="_blank">here</a></p>
<pre><code>module MyExtension
  module SiteControllerExt
    def self.included(base)
      base.class_eval {
        def new_method
          ... # whatever new functionality you want to add to the site controller
        end
      }
    end
  end
end
</code></pre>
<p>You can then activate the SiteController by adding these additional methods in the meta-class.</p>
<pre><code>def activate
  SiteController.send(:include, MyExtension::SiteControllerExt)
end</code></pre>
<p>You can modify existing behavior of any method by using the <a href="http://weblog.rubyonrails.org/2006/4/26/new-in-rails-module-alias_method_chain">alias_method_chain</a> as in the following example:</p>
<pre><code>module MyExtension
  module SiteControllerExt
    def self.included(base)
      base.class_eval {
        def site_with_clone
          ... # pre-processing
          site_without_clone
          ... # post-processing
        end

        alias_method_chain :site, :clone
    end
  end
end
</code></pre>
<p>The alias chain method ensures that we can write some code before or after the core method. Similarly you can override the views. More details <a href="http://wiki.github.com/radiant/radiant/altering-tabs-in-the-admin-ui" target="_blank">here</a> The above are some very simple basic rules of meta-programing.</p>
<pre><code>base.class_eval {
</code></pre>
<p>This line of code is actually accessing the meta-class and changing it. In other words, we evaluate the Class object and update the methods in it! This helps us add or modify the functionality of the class.</p>
<h3>Radiant Multihosting</h3>
<p>Radius and multisite hosting is cool &#8212; but you should know how it works to reap the benefits. The following extensions help out: multi_site, scoped_admin.</p>
<p>Both these ensure that all pages are site_scoped. Using some basic meta-programing, each site now has its own &#8216;scope&#8217;. Remember the all important Page.current_site !! <a href="http://www.twitter.com/sandipransing" target="_blank">Sandip</a> and  I busted our heads trying to figure out why the following was &#8216;wierd&#8217;. On the console</p>
<pre>&gt;&gt; Site.find 13
=&gt; #&lt;Site id: 13, homepage_id: 74, position: 4, ... &gt;
&gt;&gt; s = Site.find(13).layouts
=&gt; []</pre>
<p>This implies that The Site (with id 13) does not have any layouts! However, a direct find_by_sql had a different answer in store for us !</p>
<pre>&gt;&gt; Layout.find_by_sql("select * from layouts where site_id=13")
=&gt; [#&lt;Layout id: 29, name: "Basic", content: "&lt;html&gt;\r\n ... &gt;
&gt;&gt;</pre>
<p>This implies that the data is there in the database BUT not available from the associations! So frigging wierd. Then we got into the details of multi_site plugin and realized the 'error in our ways'.  Radiant is by default single site scoped. When we work with multi_site, we need to fool Radiant and tell it which site we are working with! The following works:</p>
<pre>&gt;&gt; Page.current_site = Site.find(13)
&gt;&gt; s = Site.find(13)
&gt;&gt; s.layouts
=&gt; [#&lt;Layout id: 29, name: "Basic", content: "&lt;head&gt; ... lock_version: 0, site_id: 13&gt; ]</pre>
<p>So, it extremely important to ensure that the Page.current_site is set when working with multi-hosting. So, why did this happen or how is it so, you ask? The multi_site extension, uses some pretty cool metaprograming to override (using alias_method_chain) find, count, max, min, and other ActiveRecord methods. It defaults to &#8216;default_site&#8217; if the current_site is not set !</p>
<h3>Extension Loading and Configurations</h3>
<p>Using Radiant extensions is what makes Radiant radiant! <img src='http://s0.wp.com/wp-includes/images/smilies/icon_smile.gif' alt=':)' class='wp-smiley' />  There are plenty of extensions that can be easily installed in the radiant setup. However, its important to remember the following:</p>
<ul>
<li>environment.rb config.extensions is the file to ensure &#8216;extension load ordering&#8217;. This is very important especially if you want to override some extension functionality.</li>
<li>The :all symbol in config.extensions implies the remaining extensions. BUT remember that these extension are then loaded in ALPHABETICAL order! So, be careful to either ensure your call your extension &#8216;zzz_myextension&#8217; (LoL) or ensure that any extensions you override load before you load your own extension.</li>
<li>The &#8216;settings&#8217; extension is pretty cool for managing configurations. To add a configuration, you can simply do this:</li>
<pre>Radiant::Config["key"] = value</pre>
<li>Recommended way of adding default configurations is the have yml file use YAML::load_file in the extension activate function.</li>
<li>Remember, the configuration is saved in the database &#8212; so if you override the value from the GUI, the database gets updated &#8212; NOT the yml file. So you have to be careful.</li>
</ul>
<h3>Radius tags</h3>
<p>Radius tags look something like this:</p>
<pre>&lt;r:content /&gt;
&lt;r:gallery id="id&gt; ... &lt;/r:gallery&gt;</pre>
<p>Radius tags help in managing the programing part of dynamic pages. You can add your own radius tags to ease the effort of inserting HTML code. Some cool examples are:</p>
<pre>&lt;r:gallery:lightbox_stuff /&gt;</pre>
<p>This generates the HTML for loading JS and CSS for lightbox &#8212; simple. To create a lightbox:</p>
<pre>&lt;r:gallery id="3"&gt;
 &lt;r:gallery:lighbox /&gt;
&lt;/r:gallery&gt;</pre>
<p>To add your own radius tags, you need to do the following in a module.</p>
<pre>module MyExtensionModule
 module CustomTags

 include Radiant::Taggable

 tag "tractor" do |tag|
  desc "description of the tag"
  tag "tagname" do |tag|
    ... #custom logic
  end
 end</pre>
<p>In the extension loader file, if you want to use the radius tags in the Pages, ensure this:</p>
<pre>Page.send :include, MyExtensionModule::CustomTags</pre>
<p>Enjoy the radiance!</p>
<br />  <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gocomments/gautamrege.wordpress.com/139/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/comments/gautamrege.wordpress.com/139/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godelicious/gautamrege.wordpress.com/139/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/delicious/gautamrege.wordpress.com/139/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gofacebook/gautamrege.wordpress.com/139/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/facebook/gautamrege.wordpress.com/139/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gotwitter/gautamrege.wordpress.com/139/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/twitter/gautamrege.wordpress.com/139/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gostumble/gautamrege.wordpress.com/139/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/stumble/gautamrege.wordpress.com/139/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godigg/gautamrege.wordpress.com/139/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/digg/gautamrege.wordpress.com/139/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/goreddit/gautamrege.wordpress.com/139/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/reddit/gautamrege.wordpress.com/139/" /></a> <img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=gautamrege.wordpress.com&amp;blog=9042943&amp;post=139&amp;subd=gautamrege&amp;ref=&amp;feed=1" width="1" height="1" />]]></content:encoded>
			<wfw:commentRss>http://gautamrege.wordpress.com/2010/01/26/metaprogramming-with-radiantcms/feed/</wfw:commentRss>
		<slash:comments>1</slash:comments>
	
		<media:content url="http://1.gravatar.com/avatar/5c07bd3a48ed2565bf1b872620bca3e9?s=96&#38;d=identicon&#38;r=G" medium="image">
			<media:title type="html">gautamrege</media:title>
		</media:content>
	</item>
		<item>
		<title>PHPcamp &#8211; CakePHP Vs Ruby On Rails</title>
		<link>http://gautamrege.wordpress.com/2010/01/10/phpcamp-cakephp-vs-ruby-on-rails/</link>
		<comments>http://gautamrege.wordpress.com/2010/01/10/phpcamp-cakephp-vs-ruby-on-rails/#comments</comments>
		<pubDate>Sun, 10 Jan 2010 09:08:12 +0000</pubDate>
		<dc:creator>Gautam Rege</dc:creator>
				<category><![CDATA[Conferences]]></category>
		<category><![CDATA[Ruby On Rails]]></category>
		<category><![CDATA[cakePHP]]></category>
		<category><![CDATA[PHPCamp]]></category>

		<guid isPermaLink="false">http://gautamrege.wordpress.com/?p=121</guid>
		<description><![CDATA[On 9th Jan, &#8217;10,  I presented my topic &#8220;CakePHP Vs Rails&#8221; at PHPCamp. It was well received and it felt nice to have been able to present such a topic to PHP devs. I was expecting a &#8216;fight&#8217; (infact quite a few people did too) but I did keep the tempo low and to a [...]<img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=gautamrege.wordpress.com&amp;blog=9042943&amp;post=121&amp;subd=gautamrege&amp;ref=&amp;feed=1" width="1" height="1" />]]></description>
			<content:encoded><![CDATA[<p>On 9th Jan, &#8217;10,  I presented my topic &#8220;CakePHP Vs Rails&#8221; at <a href="http://www.phpcamp.org" target="_blank">PHPCamp</a>. It was well received and it felt nice to have been able to present such a topic to PHP devs. I was expecting a &#8216;fight&#8217; (infact quite a few people did too) but I did keep the tempo low and to a discussion and not a debate &#8211; expect the unexpected !</p>
<p>Having said this, the controversy started long before my talk though &#8211; right from the choice of the title. My opinion is that almost 90% of PHP development is web-development, so the topic &#8211; &#8216;PHP Vs Ruby On Rails&#8217; was on the button. However, <a href="http://www.twitter.com/thecancerus" target="_blank">Amit Singh</a>, <a href="http://www.twitter.com/d7y" target="_blank">Dhananjay Nene</a> disagreed &#8211; they felt it was comparing apples to oranges. I complied to their request and changed the title &#8211; Fair enough. <strong>BUT </strong>how do you explain that there were 2 hands raised in a room of about 80, who said that they used PHP earlier for non web-development <img src='http://s1.wp.com/wp-includes/images/smilies/icon_wink.gif' alt=';)' class='wp-smiley' /> . All in all, I did finally compare Ruby with PHP and CakePHP with Rails.</p>
<p>PHPcamp had 2000+ registrants and the venue was &#8216;packed&#8217; &#8211; it was very exciting to go a PHPcamp as a rubyist. I wondered if people sensed a wolf among the sheep (couldn&#8217;t resist that taunt, <img src='http://s1.wp.com/wp-includes/images/smilies/icon_wink.gif' alt=';)' class='wp-smiley' />  my apologies ) and when I went up to the wikiwall to note my topic, I did get a few curt nods and some smiles and a Ah-you-are-the-rails-guy looks!</p>
<p>I kept my talk after Aditya&#8217;s talk on &#8216;Introduction to CakePHP&#8217; because it would help my cause for people to know more about CakePHP when I compared it with Rails. The talk was really good &#8212; and I could see a lot of my effort reducing in explaining MVC, RESTfulness, relationships etc. the rails way. The slides are posted <a href="http://www.slideshare.net/gautamrege/rails-vs-cakephp" target="_blank">here</a>.</p>
<p>Before I did a deep-dive, I wanted to grasp the type of audience I was dealing with and realized a decent mix of professionals, students and even a few entrepreneurs. I decided to keep my talk a little less-technical, should people sleep off <img src='http://s1.wp.com/wp-includes/images/smilies/icon_wink.gif' alt=';)' class='wp-smiley' /> .</p>
<p>I started with a brief comparison of PHP and Ruby. The Pure OO Ruby, mention of blocks and meta-programing. The idea of blocks of code being sent as parameters to methods and the idea of defining a method on an object seemed to have intrigued the crowd &#8212; however, given that I had to keep the talk basic and not too technical, I am sure it did go a little over the top. Never mind &#8211; at least I had got everyone&#8217;s attention. In a lighter moment, I did mention the use of throwing shoes as opposed to rotten tomatoes if required. I did not have the pleasure of getting as famous as famous presidents as nobody lost any shoes !</p>
<p>I then gave a brief comparison of CakePHP and Rails which brought me to the main discussion. CakePHP has a directory structure similar to rails and I believe it has been modeled around Rails (at least in the beginning). The model based relationships are similar to Rails, except for HasAndBelongsToMany. In Rails it has been changed to has_many :through =&gt;  relationship. I particularly liked the &#8216;on the fly&#8217; binding in CakePHP &#8211; its pretty cool. In rails this is achieved by a little bit of meta-programing and adding class methods to the model to load new functionality.</p>
<p>Both frameworks preach being model-heavy which is excellent. However I was a little surprised with Aditya mentioning that scaffolding should not be used extensively. I do believe that the RESTful code generators in Rails are excellent and scaffolding should be used extensively to get a jump-start.</p>
<p>RESTfulness was skimmed through the CakePHP talk but I re-iterated in my talk the importance of inherent RESTfulness that helps in interoperability. I could see a heads nodding when I used an example of user account creation URL &#8212; got plenty of answers, /add_user, /create_users, etc. and the look of enlightenment when I explained how HTTP verbs are used to ensure that /users (with GET) will get the list of users and /users (with POST) will create a user.</p>
<p>There was finally a person who raised the question of speed and performance in pure PHP code Vs Ruby Code. Now, it is indeed undeniable that PHP code interprets faster then Ruby, in fact as the gentleman said &#8211; &#8220;The 10 lines of PHP code will run faster than the 3 line of similar Ruby code&#8221;.  Agreed!</p>
<p>I was filled with pride that he mentioned the really cool part of Ruby coding &#8212; LESS CODE, which in turn means less bugs. (Yes &#8211; I know there will be a lot of PHP enthusiasts who will flame me for this &#8212; but it is a fact!). Ok &#8211; back to the speed and performance issue &#8212; in my opinion, CakePHP would run much slower than Rails (courtesy internal caching). However, pure PHP code would run a tad faster than Rails. This is definitely debatable but I would forgo some performance and speed in favour of lesser lines of code. In addition to this, the ruby interpreters (MRI and Jruby) are reaching epic proportions of speed in interpreting.</p>
<p>I then moved onto what I found missing (or lacking) in CakePHP as opposed to Rails.</p>
<ul>
<li>The one thing that stands out is the use of migrations. I was shocked to see event the examples on the dev site, showing SQL file for creating and updating the database.</li>
<li>The lack of deployment information was understandable (standard Apache with mod_php I guess) but I think this is lacking. Capistrano is something I did not mention in the talk but its things like this that make deployment simple! I was talking to some of the experts later, Amit, Aditya and Shardul after the talk and they told me that most still rely on scp and ftp for production deployment! I hope that is incorrect, but was a little taken aback never-the-less.</li>
<li>There does not seem to be much information about the use of caching in CakePHP &#8212; it seemed to be more out of the do-it-yourself manual via memcached. Rails internal caching is superb &#8211; object caching, query caching and fragment caching really get things going. Though I found information about caching in CakePHP, I wonder how much people use it.</li>
<li>The Rails magic of instance variables in controllers directly being accessible in views is cool. CakePHP requires the use of set() to ensure this. Decent enough though lot of scope of mistakes, IMO.</li>
<li>Routing and RESTful routing seemed a little behind compared to rails. Aditya did mention that default RESTful routes are now available in CakePHP but from the documentation and usage it seemed lacking. I love the following routing in Rails which gives me all the RESTful CRUD automagically.</li>
<pre>map.resources :users</pre>
<li>Polymorphic associations were missing (but I may be wrong here &#8212; I am sure its supported).</li>
</ul>
<p>To conclude, the fact is that CakePHP makes life unbelievably happier for PHP web development &#8211; I would call it a boon! I personally do see a lot of similarity between CakePHP and Rails &#8211; in fact I did tweet that that what Rails does, CakePHP follows. However, surprisingly, <a href="http://www.twitter.com/phpnut" target="_blank">Larry E. Masters</a> disagreed with me. His opinion is very important in the context as he is the Co-founder of CakePHP! Check out his interesting replies to my tweet <a href="http://twitter.com/PhpNut/status/7553255969" target="_blank">here</a> and <a href="http://twitter.com/PhpNut/status/7552658876" target="_blank">here</a> Now, that is spunk and attitude ideal for competitive development &#8211; Its highly appreciated as it will make things better! I would like to &#8216;twibate&#8217; on it sometime, but I think that would digress from this topic <img src='http://s0.wp.com/wp-includes/images/smilies/icon_smile.gif' alt=':)' class='wp-smiley' /> </p>
<p>All in all, I say to PHP devs, &#8212; Try the real thing!</p>
<br />  <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gocomments/gautamrege.wordpress.com/121/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/comments/gautamrege.wordpress.com/121/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godelicious/gautamrege.wordpress.com/121/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/delicious/gautamrege.wordpress.com/121/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gofacebook/gautamrege.wordpress.com/121/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/facebook/gautamrege.wordpress.com/121/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gotwitter/gautamrege.wordpress.com/121/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/twitter/gautamrege.wordpress.com/121/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gostumble/gautamrege.wordpress.com/121/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/stumble/gautamrege.wordpress.com/121/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godigg/gautamrege.wordpress.com/121/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/digg/gautamrege.wordpress.com/121/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/goreddit/gautamrege.wordpress.com/121/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/reddit/gautamrege.wordpress.com/121/" /></a> <img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=gautamrege.wordpress.com&amp;blog=9042943&amp;post=121&amp;subd=gautamrege&amp;ref=&amp;feed=1" width="1" height="1" />]]></content:encoded>
			<wfw:commentRss>http://gautamrege.wordpress.com/2010/01/10/phpcamp-cakephp-vs-ruby-on-rails/feed/</wfw:commentRss>
		<slash:comments>22</slash:comments>
	
		<media:content url="http://1.gravatar.com/avatar/5c07bd3a48ed2565bf1b872620bca3e9?s=96&#38;d=identicon&#38;r=G" medium="image">
			<media:title type="html">gautamrege</media:title>
		</media:content>
	</item>
		<item>
		<title></title>
		<link>http://gautamrege.wordpress.com/2010/01/10/132/</link>
		<comments>http://gautamrege.wordpress.com/2010/01/10/132/#comments</comments>
		<pubDate>Sun, 10 Jan 2010 09:06:51 +0000</pubDate>
		<dc:creator>Gautam Rege</dc:creator>
				<category><![CDATA[Conferences]]></category>
		<category><![CDATA[Ruby On Rails]]></category>

		<guid isPermaLink="false">http://gautamrege.wordpress.com/2010/01/10/132/</guid>
		<description><![CDATA[Rails Vs CakePHP View more presentations from gautamrege.<img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=gautamrege.wordpress.com&amp;blog=9042943&amp;post=132&amp;subd=gautamrege&amp;ref=&amp;feed=1" width="1" height="1" />]]></description>
			<content:encoded><![CDATA[<p><img style="visibility:hidden;width:0;height:0;" src="http://counters.gigya.com/wildfire/IMP/CXNID=2000002.0NXC/bHQ9MTI2MzExMzQ5NjEwOCZwdD*xMjYzMTE*NDA5MzY4JnA9MTAxOTEmZD*mbj13b3JkcHJlc3MmZz*xJm89Mjg3NDljZTEzNjAxNGE1OTg1MjAxNGFiMzhmMTc4NTImb2Y9MA==.gif" border="0" alt="" width="0" height="0" /></p>
<div id="__ss_2874741" style="width:425px;text-align:left;"><a style="font:14px Helvetica,Arial,Sans-serif;display:block;text-decoration:underline;margin:12px 0 3px;" title="Rails Vs CakePHP" href="http://www.slideshare.net/gautamrege/rails-vs-cakephp">Rails Vs CakePHP</a><iframe frameborder="0" width="433" height="363" src="http://wpcomwidgets.com/?width=425&amp;height=355&amp;src=http%3A%2F%2Fstatic.slidesharecdn.com%2Fswf%2Fssplayer2.swf%3Fdoc%3Drailsvsphp-100110024905-phpapp01%26stripped_title%3Drails-vs-cakephp&amp;quality=high&amp;flashvars=gig_lt%3D1263113496108%26gig_pt%3D1263114409368%26gig_g%3D1%26gig_n%3Dwordpress&amp;wmode=tranparent&amp;_tag=gigya&amp;_hash=ed63492cdff14a5c3690756fc458fb7a" id="ed63492cdff14a5c3690756fc458fb7a"></iframe></p>
<div style="font-size:11px;font-family:tahoma,arial;height:26px;padding-top:2px;">View more <a style="text-decoration:underline;" href="http://www.slideshare.net/">presentations</a> from <a style="text-decoration:underline;" href="http://www.slideshare.net/gautamrege">gautamrege</a>.</div>
</div>
<br />  <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gocomments/gautamrege.wordpress.com/132/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/comments/gautamrege.wordpress.com/132/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godelicious/gautamrege.wordpress.com/132/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/delicious/gautamrege.wordpress.com/132/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gofacebook/gautamrege.wordpress.com/132/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/facebook/gautamrege.wordpress.com/132/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gotwitter/gautamrege.wordpress.com/132/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/twitter/gautamrege.wordpress.com/132/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gostumble/gautamrege.wordpress.com/132/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/stumble/gautamrege.wordpress.com/132/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godigg/gautamrege.wordpress.com/132/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/digg/gautamrege.wordpress.com/132/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/goreddit/gautamrege.wordpress.com/132/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/reddit/gautamrege.wordpress.com/132/" /></a> <img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=gautamrege.wordpress.com&amp;blog=9042943&amp;post=132&amp;subd=gautamrege&amp;ref=&amp;feed=1" width="1" height="1" />]]></content:encoded>
			<wfw:commentRss>http://gautamrege.wordpress.com/2010/01/10/132/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
	
		<media:content url="http://1.gravatar.com/avatar/5c07bd3a48ed2565bf1b872620bca3e9?s=96&#38;d=identicon&#38;r=G" medium="image">
			<media:title type="html">gautamrege</media:title>
		</media:content>

		<media:content url="http://counters.gigya.com/wildfire/IMP/CXNID=2000002.0NXC/bHQ9MTI2MzExMzQ5NjEwOCZwdD*xMjYzMTE*NDA5MzY4JnA9MTAxOTEmZD*mbj13b3JkcHJlc3MmZz*xJm89Mjg3NDljZTEzNjAxNGE1OTg1MjAxNGFiMzhmMTc4NTImb2Y9MA==.gif" medium="image" />
	</item>
		<item>
		<title>Pune Rails Meetup #2</title>
		<link>http://gautamrege.wordpress.com/2009/12/20/pune-rails-meetup-2/</link>
		<comments>http://gautamrege.wordpress.com/2009/12/20/pune-rails-meetup-2/#comments</comments>
		<pubDate>Sun, 20 Dec 2009 10:07:34 +0000</pubDate>
		<dc:creator>Gautam Rege</dc:creator>
				<category><![CDATA[Conferences]]></category>
		<category><![CDATA[Ruby On Rails]]></category>
		<category><![CDATA[LSRC]]></category>
		<category><![CDATA[PuneRailsMeetup]]></category>

		<guid isPermaLink="false">http://gautamrege.wordpress.com/?p=105</guid>
		<description><![CDATA[It was great to be a part of the Pune Rails Meetup which was held yesterday (19th December, 2009) at ThoughtWorks, Pune. It was an idea initiated by Anthony Hsiao of Sapna Solutions which has got the Pune Rails community up on their feet. Helping him organize was a pleasure! It was great to see [...]<img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=gautamrege.wordpress.com&amp;blog=9042943&amp;post=105&amp;subd=gautamrege&amp;ref=&amp;feed=1" width="1" height="1" />]]></description>
			<content:encoded><![CDATA[<p>It was great to be a part of the Pune Rails Meetup which was held yesterday (19th December, 2009) at ThoughtWorks, Pune. It was an idea initiated by Anthony Hsiao of <a href="http://www.sapnasolutions.com" target="_blank">Sapna Solutions</a> which has got the Pune Rails community up on their feet. Helping him organize was a pleasure!</p>
<p>It was great to see almost 35 people for this meet &#8212; it was a probably more than what we expected. It was also heartening to see a good mix in the crowd &#8211; professionals in rails, students working in rails and students interested in rails &#8211; not to forget entrepreneurs who were very helpful.</p>
<p>Proceedings began with Vincent and Anup from ThinkDRY gave an excellent presentation on BlankApplication &#8211; a CMS++ that they are developing. I say CMS++ because its not just another CMS but has quite a lot of ready-to-use features that gets developers jump-started. There were interesting discussions regarding how &#8216;workspaces&#8217; are managed and how its indeed easier to manage websites.</p>
<p>After this technical talk, I spoke next on my experience at the Lone Star Ruby Conference in Texas. I tried to keep the session interactive with the intention of telling everyone how important it is to know and use Ruby effectively while working in Rails. Dave Thomas&#8217;s references to the &#8216;glorious imperfection&#8217; of Ruby did create quite a buzz. To quote a little from Dave&#8217;s talk:</p>
<pre>name {}</pre>
<p>This is a method which takes a block as a parameter but the following line is a method which takes a has as a parameter! A simple curly parenthesis makes all the difference!</p>
<pre>name ( {} )</pre>
<p>Similarly, the following line is a method m() whose result is divided by &#8216;n&#8217; whose result is divided by &#8216;o&#8217;</p>
<pre>m/n/o</pre>
<p>but add a space between this and its a method m() which takes a regular expression as a parameter!</p>
<pre>m /n/o</pre>
<p>It was nice to see everyone get involved in these interactive sessions. More details about my experience at LSRC is <a href="http://gautamrege.wordpress.com/2009/09/01/my-experience-at-lone-star-ruby-conference/" target="_blank">here</a>.</p>
<p>After this there was another technical talk about a multi-app architecture  that has been developed by Sapna Solutions. Anthony and Hari gave a talk on this and it was very interesting to see it work. Using opensource applications like shopify, CMS and other social networking apps to work with a shared-plugin and a single database, its possible to create a mammoth application which is easily customizable and scalable.</p>
<p>Hari did mention a few problems like complexity in migrations and custom routes which they currently &#8216;work-around&#8217; but prefer a cleaner approach. Some good suggestions were provided by Scot from ThoughtWorks regarding databases. I suggested some meta-programing to align models. Working with git submodules and ensuring rake scripts to sync up data, this indeed seems to have a lot of potential.</p>
<p>There were some new entrepreneurs from <a href="http://www.vectorbrookmath.com" target="_blank">VectorBrook</a> who have already developed a live application in Merb which they discussed and explained details of. It was good to hear about how they managed performance and scalability testing. The Q&amp;A forum which was the next event was extremely interactive. Some of the discussions were:</p>
<h4>Which are really great CMS in Rails?</h4>
<p>There were some intense discussions regarding RadiantCMS, Adva and even BlankApp. The general consensus was a &#8216;programmable CMS&#8217; Vs WYSIWYG. Those who prefer more of the content management prefer CMS&#8217;s like Drupal, Joomla. Those who prefer more customization via programing and code, prefer Radiant. This topic could not close and is still open for discussion.. Do comment in your views &#8211; I am a radiant fan <img src='http://s1.wp.com/wp-includes/images/smilies/icon_wink.gif' alt=';)' class='wp-smiley' /> </p>
<h4>What about testing? Cucumber, Rspec, others?</h4>
<p>Usually its still adhoc &#8211; testing is expensive for smaller firms &#8212; so adhoc blackbox testing is what is done. I opined that cucumber and rspec ROCK! Cucumber is great for scenario testing and testing controller logic and views. Rspec is great for Direct Model Access and Cucumber can make great use of Webrat for browser testing.</p>
<h4>In Rpsec, when do we use mocks and stubs?</h4>
<p>It was suggested that mocks and stubs should be used when there are no ready model and code. If the code is ready, its probably just enough not to use mocks and stubs directly. Comments welcome on this!</p>
<h4>How do you do stress testing?</h4>
<p>Stress testing, concurrency testing and performance testing can be done using http-perf. It was interesting to note that ____ have actually done their own implementation for stress and concurrency testing. I recommended they open source it.</p>
<h4>How are events, scheduled job and delayed jobs handled?</h4>
<p>This was my domain <img src='http://s0.wp.com/wp-includes/images/smilies/icon_smile.gif' alt=':)' class='wp-smiley' />  Using delayed_job is the way to go. Following the leaders (github) and using Redis and resque would be great too but definitely not backgrounDrb or direct cron!</p>
<h4>What project management tools do you use? Pivotal Tracker, Trac, Mingle?</h4>
<p>Pivotal tracker suits startup needs. Mingle rocks but becomes expensive. Scott ? <img src='http://s1.wp.com/wp-includes/images/smilies/icon_wink.gif' alt=';)' class='wp-smiley' />  Dhaval from TW mentioned how easy it was to co-ordinate an &#8216;mingle&#8217; with their 200 strong team over distributed geographies.</p>
<h4>Which SCM do you use? git, svn, cvs?</h4>
<p>People have been very comfortable with git and more and more are migrating from svn to git.  It was heartening to see that nobody uses CVS <img src='http://s0.wp.com/wp-includes/images/smilies/icon_smile.gif' alt=':)' class='wp-smiley' />  Jaju (I have have misspelt) gave an excellent brief about how code and diffs can be squished and &#8216;diff&#8217;ed with another repository before the final merge and push to the master. Dhaval gave an idea about how they effectively used git for managing their 1GB source code (wow!)</p>
<p>Some pending questions &#8211; probably in next meet-up</p>
<ol>
<li>Which hosting service do you use and why?</li>
<li>TDD or BDD?</li>
</ol>
<p>Suggestions are welcome!</p>
<br />  <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gocomments/gautamrege.wordpress.com/105/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/comments/gautamrege.wordpress.com/105/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godelicious/gautamrege.wordpress.com/105/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/delicious/gautamrege.wordpress.com/105/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gofacebook/gautamrege.wordpress.com/105/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/facebook/gautamrege.wordpress.com/105/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gotwitter/gautamrege.wordpress.com/105/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/twitter/gautamrege.wordpress.com/105/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gostumble/gautamrege.wordpress.com/105/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/stumble/gautamrege.wordpress.com/105/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godigg/gautamrege.wordpress.com/105/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/digg/gautamrege.wordpress.com/105/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/goreddit/gautamrege.wordpress.com/105/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/reddit/gautamrege.wordpress.com/105/" /></a> <img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=gautamrege.wordpress.com&amp;blog=9042943&amp;post=105&amp;subd=gautamrege&amp;ref=&amp;feed=1" width="1" height="1" />]]></content:encoded>
			<wfw:commentRss>http://gautamrege.wordpress.com/2009/12/20/pune-rails-meetup-2/feed/</wfw:commentRss>
		<slash:comments>21</slash:comments>
	
		<media:content url="http://1.gravatar.com/avatar/5c07bd3a48ed2565bf1b872620bca3e9?s=96&#38;d=identicon&#38;r=G" medium="image">
			<media:title type="html">gautamrege</media:title>
		</media:content>
	</item>
		<item>
		<title>Migrating an existing deployment to Heroku</title>
		<link>http://gautamrege.wordpress.com/2009/11/20/migrating-an-existing-deployment-to-heroku/</link>
		<comments>http://gautamrege.wordpress.com/2009/11/20/migrating-an-existing-deployment-to-heroku/#comments</comments>
		<pubDate>Fri, 20 Nov 2009 14:18:30 +0000</pubDate>
		<dc:creator>Gautam Rege</dc:creator>
				<category><![CDATA[Ruby On Rails]]></category>
		<category><![CDATA[backgrounDrb]]></category>
		<category><![CDATA[deployment]]></category>
		<category><![CDATA[ferret]]></category>
		<category><![CDATA[heroku]]></category>

		<guid isPermaLink="false">http://gautamrege.wordpress.com/?p=97</guid>
		<description><![CDATA[It was fun &#8212; pure unadulterated fun!! Now, I started looking at heroku since our current deployment on a linode was getting a little bulky. Our client has been complaining of &#8216;suddenly things slowing down&#8217; and &#8216;site not working&#8217;. The site is used at a hit rate of 36 Requests per minute and we need [...]<img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=gautamrege.wordpress.com&amp;blog=9042943&amp;post=97&amp;subd=gautamrege&amp;ref=&amp;feed=1" width="1" height="1" />]]></description>
			<content:encoded><![CDATA[<p>It was fun &#8212; pure unadulterated fun!!</p>
<p>Now, I started looking at heroku since our current deployment on a linode was getting a little bulky. Our client has been complaining of &#8216;suddenly things slowing down&#8217; and &#8216;site not working&#8217;. The site is used at a hit rate of 36 Requests per minute and we need to keep our hosting costs down &#8212; so what is the solution???</p>
<p>Currently, its hosted on a linode (740MB) memory and and nginx + 3 thin cluster. There is monit which ensures that ANY thin server going above 140MB is restarted. BackgrounDrb is taking a lot of memory too ( an unavoidable 160MB) and we have ferret to make things more complicated !! <img src='http://s0.wp.com/wp-includes/images/smilies/icon_smile.gif' alt=':)' class='wp-smiley' /> </p>
<p>Enter Heroku &#8211; first thing that got me hooked was a &#8216;git push heroku&#8217; DEPLOYS your application! Fantastic. I have been a capistrano freak till now and loved it &#8211; but its all gone now! (wonder if thats good or bad though).  LoL <img src='http://s0.wp.com/wp-includes/images/smilies/icon_smile.gif' alt=':)' class='wp-smiley' /> </p>
<p>So, to get started, you sign-up on heroku and follow instructions on your My Apps page:</p>
<pre>$ heroku create
$ git init &amp;&amp; git add . &amp;&amp; git commit -m"initial checkins"
$ git push heroku</pre>
<p>I used the Blossom account (5 MB space) and was pleasantly surprised to see it work &#8216;out of the box&#8217;. It created some wierd named sub-domain for me which I changed using</p>
<pre>$ heroku rename &lt;new-name&gt;</pre>
<p>Digging deeper, I wanted to deploy the application &#8216;as is&#8217; but that was not to be:</p>
<h3>Setup Woes</h3>
<p>Heroku uses PostGres and we had used MySQL &#8211; you need to ensure that there are no special data types being used. As goes Murphy&#8217;s law &#8211; we had used blob and had to change that the bytea (bytearray in PG). The interesting thing I found was that there is NO way to drop the database and re-create it. The answer lies in:</p>
<pre>$ heroku rake db:schema:load</pre>
<p>Production environment is assumed. I was not sure which environment I am in till I issued the command (after reading up) that I was in production mode:</p>
<pre>$ heroku config
RACK_ENV =&gt; production</pre>
<p>I was also curious to see how I get the logs and check the console and it really ROCKS:</p>
<pre>$ heroku logs
$ heroku console</pre>
<p>Alas I could not find a way to access the dbconsole (like what I do sometimes with script/dbconsole -p). Well, that is the way it is!</p>
<h3>Ferret Woes</h3>
<p><span style="font-weight:normal;font-size:13px;">Heroku does not use ferret &#8211; it uses solr and sunspot. I had to install these additional gems using the gem manifest i.e. the .gems file located at RAILS_ROOT.</span></p>
<pre>rupport
acts_as_ferret
prawn
$ git commit
$ git push heroku</pre>
<p><span style="font-weight:normal;font-size:13px;">Since acts_as_ferret is installed, it loads the Rails models and &#8216;expects&#8217; the database to be in place. So, I had to comment out ALL the references to acts_as_ferret to be able to run a </span></p>
<pre><span style="font-weight:normal;font-size:13px;">$ heroku rake db:migrate</span></pre>
<p><span style="font-size:small;">So far so good. Now, since ferret requires to index files and heroku mounts the deployment on a read-only filesystem, we need to tweak the configurations to ensure that the index is created in tmp/ (the are where we can write stuff). Add the following lines to the config/environments/production.rb</span></p>
<pre>require 'acts_as_ferret'
ActsAsFerret.index_dir = "#{RAILS_ROOT}/tmp/index"</pre>
<p>Now, default ferret production environment is to start a Drb server on 9010 port &#8212; and Heroku will not allow this! So, we have to comment out all the configuration in config/ferret_server.yml to ensure that this loads like it does in development. I hate this but no alternative for now. I do plan to migrate to the WebSolr that Heroku is offering but its at 20$ per month! Lets see how that works out.</p>
<p>This should at least get you started on ferret &#8211; phew!</p>
<h3>BackgrounDrb woes</h3>
<p>BackgrounDrb comes with its own baggage I must say. Heroku proposes the use of DelayedJob (yippee) and I have just this plan, so rather than even try to figure out a way to get backgrounDrb to work on Heroku, I simply commented out the config/backgroundrb.yml settings (to ensure it does not get initialized).</p>
<p>I also had to comment out all the MiddleMan references in the controller. The backgrounDrb workers are easily  modified so that they can work as DelayedJob objects <img src='http://s1.wp.com/wp-includes/images/smilies/icon_wink.gif' alt=';)' class='wp-smiley' /> . I have mentioned this in my earlier posts <a href="http://gautamrege.wordpress.com/2009/11/04/moving-from-backgroundrb-to-delayedjob/">Moving from BackgrounDrb to DelayedJob</a></p>
<p>Once this was done, I did not face any problems and after some quick code fixes, git commits and git push&#8217;es, I was able to get my heroku application up and running.</p>
<p>All in a days work! Thats really amazing. Now, the next step is to get WebSolr  and DelayedJob integrated and see if I can move onto a bigger storage setup &#8212; a couple of months will let me know if this move was right.</p>
<br />  <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gocomments/gautamrege.wordpress.com/97/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/comments/gautamrege.wordpress.com/97/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godelicious/gautamrege.wordpress.com/97/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/delicious/gautamrege.wordpress.com/97/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gofacebook/gautamrege.wordpress.com/97/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/facebook/gautamrege.wordpress.com/97/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gotwitter/gautamrege.wordpress.com/97/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/twitter/gautamrege.wordpress.com/97/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gostumble/gautamrege.wordpress.com/97/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/stumble/gautamrege.wordpress.com/97/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godigg/gautamrege.wordpress.com/97/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/digg/gautamrege.wordpress.com/97/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/goreddit/gautamrege.wordpress.com/97/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/reddit/gautamrege.wordpress.com/97/" /></a> <img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=gautamrege.wordpress.com&amp;blog=9042943&amp;post=97&amp;subd=gautamrege&amp;ref=&amp;feed=1" width="1" height="1" />]]></content:encoded>
			<wfw:commentRss>http://gautamrege.wordpress.com/2009/11/20/migrating-an-existing-deployment-to-heroku/feed/</wfw:commentRss>
		<slash:comments>1</slash:comments>
	
		<media:content url="http://1.gravatar.com/avatar/5c07bd3a48ed2565bf1b872620bca3e9?s=96&#38;d=identicon&#38;r=G" medium="image">
			<media:title type="html">gautamrege</media:title>
		</media:content>
	</item>
		<item>
		<title>RPCFN#3 Short-circuit</title>
		<link>http://gautamrege.wordpress.com/2009/11/20/rpcfn3-short-circuit/</link>
		<comments>http://gautamrege.wordpress.com/2009/11/20/rpcfn3-short-circuit/#comments</comments>
		<pubDate>Fri, 20 Nov 2009 13:33:56 +0000</pubDate>
		<dc:creator>Gautam Rege</dc:creator>
				<category><![CDATA[Ruby On Rails]]></category>
		<category><![CDATA[rpcfn]]></category>
		<category><![CDATA[RubyLearning]]></category>

		<guid isPermaLink="false">http://gautamrege.wordpress.com/?p=88</guid>
		<description><![CDATA[It was great to see so many solutions for the problem statement I had set. After an initial &#8216;shock&#8217; from all electrical engineers, the problem was clearly understood as a variant of the &#8216;shortest path algorithm&#8217;. I hope I was able to derive a laugh from the cryptic clue &#8216;short-circuit&#8217;. Speaking of &#8216;derive&#8217;, I did [...]<img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=gautamrege.wordpress.com&amp;blog=9042943&amp;post=88&amp;subd=gautamrege&amp;ref=&amp;feed=1" width="1" height="1" />]]></description>
			<content:encoded><![CDATA[<p>It was great to see so many solutions for the problem statement I had set. After an initial &#8216;shock&#8217; from all electrical engineers, the problem was clearly understood as a variant of the &#8216;shortest path algorithm&#8217;. I hope I was able to derive a laugh from the cryptic clue &#8216;short-circuit&#8217;.</p>
<p>Speaking of &#8216;derive&#8217;, I did see most solutions going into a class implementation of  &#8217;class Graph&#8217; or &#8216;class Vector&#8217;. Though its pretty cool to see a complete packaged solution, I believe this was a slight overkill. This was NOT the basis of judging but I do feel that ruby has its essence in getting the job done in far lesser code. i.e. less LOC. So, I personally did not foresee 3-4 classes with inheritance in them.. I do totally agree its an excellent way to show-case one&#8217;s skills  ;)</p>
<p>Djikstra&#8217;s algorithm seems to be the popular hit for solving this problem &#8211; however, I do feel a recursive solution than an iterative one is more appropriate for this. Again this is just an opinion but to get a sense of the power of ruby programing, a recursive program probably paints a better picture. Its also very concise and readable.</p>
<p>A lot of effort was spent in &#8216;initializing&#8217; the data-structure. This was really nice to see &#8212; unlike me, who took a short-cut. The aim was to see the algorithm but I was really proud to see &#8216;complete&#8217; solutions. Test cases were written in most solutions and it was a pleasure to see them run.</p>
<p>It was interesting to see various forms of Infinity:</p>
<pre>Infinity = 1 &lt;&lt; 64
Infinity = 1 &lt;&lt; 32
Infinity = 1.0 / 0 # simple and ideal
Infinity = 1000000 # incorrect</pre>
<p>It was interesting to note that very few catered for multiple shortest paths, though the question was raised in the comments earlier. Not trying to be a hypocrite here, I should say that I too did not implement multiple shortest paths &#8211; LoL.</p>
<p>My solution to the problem is provided at <a href="http://github.com/gautamrege/short_circuit">http://github.com/gautamrege/short_circuit</a> and its merely a representation of my style of programing. Creating a gem was for kicks but lib/short_circuit.rb has the core code. It was great fun AND learning while doing this and I realized that I will always be a student.</p>
<p>Cheers!</p>
<br />  <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gocomments/gautamrege.wordpress.com/88/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/comments/gautamrege.wordpress.com/88/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godelicious/gautamrege.wordpress.com/88/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/delicious/gautamrege.wordpress.com/88/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gofacebook/gautamrege.wordpress.com/88/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/facebook/gautamrege.wordpress.com/88/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gotwitter/gautamrege.wordpress.com/88/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/twitter/gautamrege.wordpress.com/88/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gostumble/gautamrege.wordpress.com/88/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/stumble/gautamrege.wordpress.com/88/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godigg/gautamrege.wordpress.com/88/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/digg/gautamrege.wordpress.com/88/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/goreddit/gautamrege.wordpress.com/88/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/reddit/gautamrege.wordpress.com/88/" /></a> <img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=gautamrege.wordpress.com&amp;blog=9042943&amp;post=88&amp;subd=gautamrege&amp;ref=&amp;feed=1" width="1" height="1" />]]></content:encoded>
			<wfw:commentRss>http://gautamrege.wordpress.com/2009/11/20/rpcfn3-short-circuit/feed/</wfw:commentRss>
		<slash:comments>5</slash:comments>
	
		<media:content url="http://1.gravatar.com/avatar/5c07bd3a48ed2565bf1b872620bca3e9?s=96&#38;d=identicon&#38;r=G" medium="image">
			<media:title type="html">gautamrege</media:title>
		</media:content>
	</item>
		<item>
		<title>Capistrano + Nginx + Thin deployment on Linode</title>
		<link>http://gautamrege.wordpress.com/2009/11/10/capistrano-nginx-thin-deployment-on-linode/</link>
		<comments>http://gautamrege.wordpress.com/2009/11/10/capistrano-nginx-thin-deployment-on-linode/#comments</comments>
		<pubDate>Tue, 10 Nov 2009 12:58:16 +0000</pubDate>
		<dc:creator>Gautam Rege</dc:creator>
				<category><![CDATA[nginx]]></category>
		<category><![CDATA[Ruby On Rails]]></category>
		<category><![CDATA[capistrano]]></category>
		<category><![CDATA[linode]]></category>
		<category><![CDATA[thin]]></category>

		<guid isPermaLink="false">http://gautamrege.wordpress.com/?p=72</guid>
		<description><![CDATA[This was long lost post I had written about 8 months ago (converted from wiki to HTML &#8211; so pardon typos if any) Terminologies Capistrano is a ruby gem which helps in remote deployment. As against widely known convention, Capistrano can be used for any deployment, not just a rails app! Nginx is a web-proxy [...]<img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=gautamrege.wordpress.com&amp;blog=9042943&amp;post=72&amp;subd=gautamrege&amp;ref=&amp;feed=1" width="1" height="1" />]]></description>
			<content:encoded><![CDATA[<p>This was long lost post I had written about 8 months ago (converted from wiki to HTML &#8211; so pardon typos if any)</p>
<h2>Terminologies</h2>
<p><strong>Capistrano</strong> is a ruby gem which helps in remote deployment. As against widely known convention, Capistrano can be used for <strong>any</strong> deployment, not just a rails app!</p>
<p><strong>Nginx</strong> is a web-proxy server. This is simply a light weight HTTP web-server which received requests on HTTP and passes them to other applications. This is way more preferable than Application servers like Apache! Moreover, nginx is very easily configurable and can support multiple domain-names very easily. It has an in-build load-balancer which can send requests to apps based on its internal load-balancing mechanism.</p>
<p><strong>Thin</strong> is the next-generation lean, mean rails server. Its much faster, lighter in memory than mongrel. Its has an internal event based mechanism for request processing and a very high concurrency performance ratio than other rails servers.</p>
<p><strong>Linode</strong> is a VPS (a Virtual Private Server) that is hosted by <a href="http://www.linode.com">www.linode.com</a>. As the name suggests <img src='http://s1.wp.com/wp-includes/images/smilies/icon_wink.gif' alt=';)' class='wp-smiley' /> , its a &#8220;Linux Node&#8221;.  We are using Ubuntu 8.10 (Tip: To find Ubuntu release, issue command: lsb_release -a) <strong>NOTE:</strong> In the linode we had, it was a raw machine with no packages installed. Please read <a href="http://wiki.rubyonrails.org/getting-started/installation/linux">Linode RoR package installation</a> for details.</p>
<h2>Steps</h2>
<p><strong>Capistrano Configuration</strong> Follow the steps provided by Capistrano for basic instructions: <a href="http://www.capify.org/getting-started/from-the-beginning">Capistrano &#8211; From The Beginning</a> Some modifications that you may need (as I needed for deployment):</p>
<ul>
<li>Edit Capfile and add the following to it. This ensures that remote capistrano deployment does not fork a remote shell using command &#8220;sh -c&#8221;. Some hosting servers do not allow remote shells.</li>
<pre>default_run_options[:shell] = false</pre>
<li>In addition to changes mentioned in Capistrano tutorial, add the following to config/deploy.rb. This ensures that &#8220;sudo&#8221; is not used (default for Capistrano) and the user is &#8220;root&#8221;. Not usually a good practice.. but what the hell!</li>
<pre>set :use_sudo, false            set :user, "root"</pre>
<li> Since capistrano uses default script/spin and script/process/reaper, we need to override the deploy:start, deploy:stop and deploy:restart to ensure that we can start/stop the thin service and the ferret_server. I know that in deply:restart, there is a copy-paste involved but I am trying to find out how to invoke a rake task from another rake task.</li>
</ul>
<pre>namespace :deploy do
    desc "Custom AceMoney deployment: stop."
    task :stop, :roles =&gt; :app do

        invoke_command "cd #{current_path};./script/ferret_server -e production stop"
        invoke_command "service thin stop"
    end

    desc "Custom AceMoney deployment: start."
    task :start, :roles =&gt; :app do

        invoke_command "cd #{current_path};./script/ferret_server -e production start"
        invoke_command "service thin start"
    end

    # Need to define this restart ALSO as 'cap deploy' uses it
    # (Gautam) I dont know how to call tasks within tasks.
    desc "Custom AceMoney deployment: restart."
    task :restart, :roles =&gt; :app do

        invoke_command "cd #{current_path};./script/ferret_server -e production stop"
        invoke_command "service thin stop"
        invoke_command "cd #{current_path};./script/ferret_server -e production start"
        invoke_command "service thin start"
    end
end</pre>
<p><span style="font-family:Georgia, 'Times New Roman', 'Bitstream Charter', Times, serif;line-height:19px;white-space:normal;font-size:13px;"><strong>Thin Configuraion</strong> I looked up most of the default configuration of Thin and Nginx on Ubunto at <a href="http://newwiki.rubyonrails.org/deployment/nginx-thin">Nginx + Thin</a>. Some extra configuration or differences are mentioned below. </span></p>
<ul>
<li><span style="font-family:Georgia, 'Times New Roman', 'Bitstream Charter', Times, serif;line-height:19px;white-space:normal;font-size:13px;">The init script for starting thin and nginx during startup is configured during package installation. Leave them as they are.</span></li>
<li><span style="font-family:Georgia, 'Times New Roman', 'Bitstream Charter', Times, serif;line-height:19px;white-space:normal;font-size:13px;">The following command generates the /etc/thin/acemoney.yml for 3 server starting from port 3000. Note that the -c option specifies the BASEDIR of the rails app. Do NOT change any settings in this file as far as possible.</span></li>
<pre><span style="font-family:Georgia, 'Times New Roman', 'Bitstream Charter', Times, serif;line-height:19px;white-space:normal;font-size:13px;">thin config -C /etc/thin/acemoney.yml -c /home/josh/current --servers 3 -e production -p 3000</span></pre>
<li><span style="font-family:Georgia, 'Times New Roman', 'Bitstream Charter', Times, serif;line-height:19px;white-space:normal;font-size:13px;">Starting and stopping thin is as simple as</span></li>
<pre><span style="font-family:Georgia, 'Times New Roman', 'Bitstream Charter', Times, serif;line-height:19px;white-space:normal;font-size:13px;">service thin start</span>
<span style="font-family:Georgia, 'Times New Roman', 'Bitstream Charter', Times, serif;line-height:19px;white-space:normal;font-size:13px;">service thin stop</span></pre>
<li><span style="font-family:Georgia, 'Times New Roman', 'Bitstream Charter', Times, serif;line-height:19px;white-space:normal;font-size:13px;">This will read the acemoney.yml file and spawn the 3 thin processes. I noticed that each thin server took about 31MB in memory to start with and with caching went upto ~70MB. On the contrary, a mongrel server (tested earlier) started with 31MB but exceeded 110MB later! </span></li>
</ul>
<p><strong>Nginx Configuration</strong> Installation on nginx is simple on Ubuntu <img src='http://s1.wp.com/wp-includes/images/smilies/icon_wink.gif' alt=';)' class='wp-smiley' /> </p>
<pre>apt-get install nginx</pre>
<p>Configure the base /etc/nginx/nginx.conf. The default configuration are fine but I added / edited a few more for as recommended at <a href="http://articles.slicehost.com/2009/3/5/ubuntu-intrepid-nginx-configuration">Nginx Configuration</a></p>
<pre>        worker_processes  4;

        gzip_comp_level 2;
        gzip_proxied any;
        gzip_types  text/plain text/html text/css application/x-javascript
                    text/xml application/xml application/xml+rss text/javascript;</pre>
<p>According to this configuration above, nginx will spawn 4 worker threads and each worker thread can process 1024 connections (default setting). So, nginx can now process ~4000 concurrent HTTP requests !!! See performance article of thin at <a href="http://www.rubyinside.com/thin-a-ruby-http-daemon-thats-faster-than-mongrel-688.html"><span style="color:#000000;"><span style="text-decoration:none;">Thin Server</span></span></a></p>
<p>Configure the domainname, in our case acemoney.in. Ensure that acemoney.in &#8220;A record&#8221; entry points to this server! Check this by doing a nslookup or a ping for the server. In /etc/nginx/sites-available create a file by the domainname to be hosted. So I added /etc/nginx/sites-available/acemoney.in. In /etc/nginx/sites-enabled create a symbolic link to this file.</p>
<pre><span style="font-family:Georgia, 'Times New Roman', 'Bitstream Charter', Times, serif;line-height:19px;white-space:normal;font-size:13px;">ln -s /etc/nginx/sites-available/acemoney.in /etc/nginx/sites-enabled/acemoney.in </span></pre>
<p><span style="font-family:Georgia, 'Times New Roman', 'Bitstream Charter', Times, serif;line-height:19px;white-space:normal;font-size:13px;"> </span><span style="font-family:Georgia, 'Times New Roman', 'Bitstream Charter', Times, serif;line-height:19px;white-space:normal;font-size:13px;">Now add the contents in /etc/nginx/sites-available/acemoney.in <strong>This</strong> is the key configuration to hook up nginx with thin.</span></p>
<p><span style="font-family:Georgia, 'Times New Roman', 'Bitstream Charter', Times, serif;font-size:small;"><span style="line-height:19px;white-space:normal;"> </span></span></p>
<p><span style="font-family:Georgia, 'Times New Roman', 'Bitstream Charter', Times, serif;font-size:small;"> </span></p>
<pre>upstream thin {
     server 127.0.0.1:3000;
     server 127.0.0.1:3001;
     server 127.0.0.1:3002;
}

server {
    listen 80;
    server_name acemoney.in;

    root /home/josh/current/public;

    location / {
      proxy_set_header X-Real-IP $remote_addr;
      proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
      proxy_set_header Host $http_host;
      proxy_redirect false;

      if (-f $request_filename/index.html) {
        rewrite (.*) $1/index.html break;
      }
      if (-f $request_filename.html) {
        rewrite (.*) $1.html break;
      }
      if (!-f $request_filename) {
        proxy_pass http://thin;
        break;
      }
    }

    error_page 500 502 503 504 /50x.html;
    location = /50x.html {
      root html;
    }
}</pre>
<p><span style="font-family:Georgia, 'Times New Roman', 'Bitstream Charter', Times, serif;line-height:19px;white-space:normal;font-size:13px;">To analyze this configuration, here are some details: </span></p>
<p><span style="font-family:Georgia, 'Times New Roman', 'Bitstream Charter', Times, serif;line-height:19px;white-space:normal;font-size:13px;">The following lines tell nginx to listen on port 80 for HTTP requests to acemoney.in. The &#8216;root&#8217; is the public directory for our rails app deployed at /home/josh/current! </span></p>
<pre>server {
    listen 80;
    server_name acemoney.in;

    root /home/josh/current/public;</pre>
<p><span style="font-family:Georgia, 'Times New Roman', 'Bitstream Charter', Times, serif;line-height:19px;white-space:normal;font-size:13px;"> Now, nginx will try to process all HTTP requests and try to give the response.. for static HTML&#8217;s it will automatically give the data from the &#8216;root&#8217;. If it cannot find the HTML file, it will &#8216;proxy_pass&#8217; it to thin. &#8220;thin&#8221; in the code below is an &#8216;upstream&#8217; directive that tells nginx where to forward the current request it cannot directly serve.</span> <span style="font-family:Georgia, 'Times New Roman', 'Bitstream Charter', Times, serif;font-size:small;"> </span></p>
<pre>if (!-f $request_filename) {
        proxy_pass http://thin;
        break;
      }</pre>
<p><span style="font-family:Georgia, 'Times New Roman', 'Bitstream Charter', Times, serif;line-height:19px;white-space:normal;font-size:13px;">The upstream code is where load-balancing plays a role in nginx. The following code tells nginx which all processes are running on which different ports and it forwards requests to <strong>any</strong> of the servers based on its internal load balancing algorithm. The servers can be on different machines (i.e. different IP addresses) if needed. In AceMoney, we have started 3 thin servers on 3 different ports! </span> <span style="font-family:Georgia, 'Times New Roman', 'Bitstream Charter', Times, serif;font-size:small;"> </span></p>
<pre>upstream thin {
     server 127.0.0.1:3000;
     server 127.0.0.1:3001;
     server 127.0.0.1:3002;
}</pre>
<p><span style="font-family:Georgia, 'Times New Roman', 'Bitstream Charter', Times, serif;line-height:19px;white-space:normal;font-size:13px;"><strong>Performance Statistics</strong></span> <span style="font-family:Georgia, 'Times New Roman', 'Bitstream Charter', Times, serif;line-height:19px;white-space:normal;font-size:13px;"> Nothing is complete without them. Here is what I found out for 3 thin servers and 1 ferret_server.</span></p>
<pre>top - 14:06:10 up 7 days, 22:58,  2 users,  load average: 0.00, 0.00, 0.00
Tasks:  84 total,   1 running,  83 sleeping,   0 stopped,   0 zombie
Cpu0  :  0.0%us,  0.0%sy,  0.0%ni,100.0%id,  0.0%wa,  0.0%hi,  0.0%si,  0.0%st
Cpu1  :  0.0%us,  0.0%sy,  0.0%ni,100.0%id,  0.0%wa,  0.0%hi,  0.0%si,  0.0%st
Cpu2  :  0.0%us,  0.0%sy,  0.0%ni,100.0%id,  0.0%wa,  0.0%hi,  0.0%si,  0.0%st
Cpu3  :  0.0%us,  0.0%sy,  0.0%ni,100.0%id,  0.0%wa,  0.0%hi,  0.0%si,  0.0%st
Mem:    553176k total,   530868k used,    22308k free,    16196k buffers
Swap:   524280k total,     2520k used,   521760k free,    87280k cached

  PID USER      PR  NI  VIRT  RES  SHR S %CPU %MEM    TIME+  COMMAND
12424 mysql     18   0  127m  42m 5520 S    0  7.9   0:23.01 mysqld
18338 root      15   0 77572  70m 4392 S    0 13.1   0:06.79 thin
18348 root      15   0 71176  64m 4388 S    0 11.9   0:06.51 thin
18343 root      15   0 68964  62m 4384 S    0 11.5   0:07.20 thin
18375 root      18   0 70912  54m 2660 S    0 10.0   2:34.24 ruby
 8141 www-data  15   0  5176 1736  820 S    0  0.3   0:00.07 nginx
 8142 www-data  15   0  5176 1724  816 S    0  0.3   0:00.01 nginx
 8144 www-data  15   0  5152 1720  816 S    0  0.3   0:00.06 nginx
 8143 www-data  15   0  5156 1656  784 S    0  0.3   0:00.00 nginx</pre>
<p><span style="font-family:Georgia, 'Times New Roman', 'Bitstream Charter', Times, serif;line-height:19px;white-space:normal;font-size:13px;">As can be seen: </span></p>
<ul>
<li><span style="font-family:Georgia, 'Times New Roman', 'Bitstream Charter', Times, serif;line-height:19px;white-space:normal;font-size:13px;">Each thin server takes around 70M</span></li>
<li><span style="font-family:Georgia, 'Times New Roman', 'Bitstream Charter', Times, serif;line-height:19px;white-space:normal;font-size:13px;">The Mysql server takes 41M</span></li>
<li><span style="font-family:Georgia, 'Times New Roman', 'Bitstream Charter', Times, serif;line-height:19px;white-space:normal;font-size:13px;">Ruby process (18375 above) is the ferret_serve which takes 54M</span></li>
<li><span style="font-family:Georgia, 'Times New Roman', 'Bitstream Charter', Times, serif;line-height:19px;white-space:normal;font-size:13px;"> 4 nginx threads take about 1.7K in memory. </span></li>
</ul>
<pre><span style="font-family:Georgia, 'Times New Roman', 'Bitstream Charter', Times, serif;line-height:19px;white-space:normal;font-size:13px;"> Overall: (3 thin server cluster + Mysql + ferret): <strong>300MB</strong></span></pre>
<br />  <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gocomments/gautamrege.wordpress.com/72/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/comments/gautamrege.wordpress.com/72/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godelicious/gautamrege.wordpress.com/72/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/delicious/gautamrege.wordpress.com/72/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gofacebook/gautamrege.wordpress.com/72/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/facebook/gautamrege.wordpress.com/72/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gotwitter/gautamrege.wordpress.com/72/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/twitter/gautamrege.wordpress.com/72/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gostumble/gautamrege.wordpress.com/72/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/stumble/gautamrege.wordpress.com/72/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godigg/gautamrege.wordpress.com/72/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/digg/gautamrege.wordpress.com/72/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/goreddit/gautamrege.wordpress.com/72/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/reddit/gautamrege.wordpress.com/72/" /></a> <img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=gautamrege.wordpress.com&amp;blog=9042943&amp;post=72&amp;subd=gautamrege&amp;ref=&amp;feed=1" width="1" height="1" />]]></content:encoded>
			<wfw:commentRss>http://gautamrege.wordpress.com/2009/11/10/capistrano-nginx-thin-deployment-on-linode/feed/</wfw:commentRss>
		<slash:comments>6</slash:comments>
	
		<media:content url="http://1.gravatar.com/avatar/5c07bd3a48ed2565bf1b872620bca3e9?s=96&#38;d=identicon&#38;r=G" medium="image">
			<media:title type="html">gautamrege</media:title>
		</media:content>
	</item>
	</channel>
</rss>
