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

<channel>
	<title>andHapp</title>
	<atom:link href="http://www.andhapp.com/blog/feed/" rel="self" type="application/rss+xml" />
	<link>http://www.andhapp.com/blog</link>
	<description>Victory is mine</description>
	<lastBuildDate>Sun, 27 Nov 2011 20:04:35 +0000</lastBuildDate>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=3.0.1</generator>
		<item>
		<title>Shiny new bundler and my is_bot gem</title>
		<link>http://www.andhapp.com/blog/2011/11/27/shiny-new-bundler-and-my-is_bot-gem/</link>
		<comments>http://www.andhapp.com/blog/2011/11/27/shiny-new-bundler-and-my-is_bot-gem/#comments</comments>
		<pubDate>Sun, 27 Nov 2011 20:04:35 +0000</pubDate>
		<dc:creator>andhapp</dc:creator>
		
		<guid isPermaLink="false">http://www.andhapp.com/blog/?p=491</guid>
		<description><![CDATA[If you haven&#8217;t already installed the release candidate of superfast bundler, then I feel sorry for you. It&#8217;s hard to put your faith in me but here&#8217;s an article that might change your heart. It&#8217;s super simple, just do: gem &#8230; <a href="http://www.andhapp.com/blog/2011/11/27/shiny-new-bundler-and-my-is_bot-gem/">Continue reading <span class="meta-nav">&#8594;</span></a>]]></description>
			<content:encoded><![CDATA[<p>If you haven&#8217;t already installed the release candidate of superfast bundler, then I feel sorry for you. It&#8217;s hard to put your faith in me but here&#8217;s an <a href="http://patshaughnessy.net/2011/10/14/why-bundler-1-1-will-be-much-faster">article</a> that might change your heart. It&#8217;s super simple, just do:</p>
<pre>
gem install bundler --pre
</pre>
<p>Last year, I released a gem called is_bot (which is just a trivial way to fool the spammers). I have been using it in several projects and keep updating it with new releases of the Rails. Few months back when <a href="http://blog.rubygems.org/2011/08/31/shaving-the-yaml-yak.html">rubygems</a> was having trouble with Syck yaml parser, I released a version (0.3.3) of my is_bot gem. As a result, this version of is_bot suffered from the same issue and it gave me error messages on subsequent installs. Since then, I have released three more versions of the gem and the current version stands at 0.3.6.</p>
<p>Now, the earlier version of bundler was quite forgiving and I could hack the cached gemspec file to install it. But the new version of bundler, simply rejects it. I was quite surprised to see the error message I get from bundler when I tried installing the current version (0.3.6). Because, it doesn&#8217;t say anything about the 0.3.6 version but complains about 0.3.3 version. I thought I was going crazy. I even specified the version of the gem to 0.3.6 in my Gemfile but still it complained about 0.3.3 version. I know, I know that bundler needs to download the &#8216;Big Index&#8217; for dependency resolution but I never had this problem with the earlier versions of bundler, then why now. Why my gem? </p>
<p>So, I did more investigation and ran the following command to see what exactly does bundler get back when it hits the <a href="http://guides.rubygems.org/rubygems-org-api/#misc">rubygems&#8217;s endpoint</a>:</p>
<pre>
ruby -ropen-uri -rpp -e \
  'pp Marshal.load(open("https://rubygems.org/api/v1/dependencies?gems=is_bot"))'
</pre>
<p>and this returns something like this:</p>
<pre>
[{:platform=>"ruby",
  :name=>"is_bot",
  :dependencies=>[["rspec", ">= 0"], ["rails", "= 3.1.1"]],
  :number=>"0.3.6"},
 {:platform=>"ruby",
  :name=>"is_bot",
  :dependencies=>[["rspec", ">= 0"], ["rails", "= 3.1.1"]],
  :number=>"0.3.5"},
 {:platform=>"ruby",
  :name=>"is_bot",
  :dependencies=>
   [["rspec", ">= 0"],
    ["rails", "#<YAML::Syck::DefaultKey:0xbd36f20> 3.1.0.rc6"]],
  :number=>"0.3.3"},
 {:platform=>"ruby",
  :name=>"is_bot",
  :dependencies=>[["rspec", "= 2.6.0"], ["rails", "= 3.1.0.rc5"]],
  :number=>"0.3.2"},
 {:platform=>"ruby",
  :name=>"is_bot",
  :dependencies=>[["rspec", "= 2.6.0"], ["rails", "= 3.1.0.rc4"]],
  :number=>"0.3.1"},
 {:platform=>"ruby",
  :name=>"is_bot",
  :dependencies=>
   [["sqlite3", "= 1.3.3"], ["rspec", "= 2.6.0"], ["rails", "= 3.1.0.rc4"]],
  :number=>"0.3.0"},
 {:platform=>"ruby",
  :name=>"is_bot",
  :dependencies=>
   [["sqlite3", "= 1.3.3"], ["rspec", "= 2.4.0"], ["rails", "= 3.0.3"]],
  :number=>"0.2.0"},
 {:platform=>"ruby", :name=>"is_bot", :dependencies=>[], :number=>"0.1.0"}]
</pre>
<p>And you can see &#8220;YAML::Syck::DefaultKey:0xbd36f20&#8243; bit that results in illformed gemspec error. I guess the earlier versions of Bundler had a fix for this issue, but the latest rc version loads up this information and straight-away complains about the illformed gemspec. That&#8217;s all good but what&#8217;s the solution for this issue. Simple! Yank the 0.3.3 version of the gem and you are good to go. Another solution would be to regenerate the gemspec for 0.3.3 again, which I hope rubygems stores uncorrupted. </p>
<p>Phew.</p>
]]></content:encoded>
			<wfw:commentRss>http://www.andhapp.com/blog/2011/11/27/shiny-new-bundler-and-my-is_bot-gem/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Getting Clearance test suite to green</title>
		<link>http://www.andhapp.com/blog/2011/04/27/getting-clearance-test-suite-to-green/</link>
		<comments>http://www.andhapp.com/blog/2011/04/27/getting-clearance-test-suite-to-green/#comments</comments>
		<pubDate>Wed, 27 Apr 2011 14:40:29 +0000</pubDate>
		<dc:creator>andhapp</dc:creator>
				<category><![CDATA[Programming]]></category>
		<category><![CDATA[bundler]]></category>
		<category><![CDATA[cucumber]]></category>

		<guid isPermaLink="false">http://www.andhapp.com/blog/?p=486</guid>
		<description><![CDATA[The title could be slightly misleading but I am not talking about installing clearance in your Rails application. This post is just a small note to myself since I had considerable difficulties in getting the clearance gem&#8217;s test suite working &#8230; <a href="http://www.andhapp.com/blog/2011/04/27/getting-clearance-test-suite-to-green/">Continue reading <span class="meta-nav">&#8594;</span></a>]]></description>
			<content:encoded><![CDATA[<p>The title could be slightly misleading but I am not talking about installing clearance in your Rails application. This post is just a small note to myself since I had considerable difficulties in getting the clearance gem&#8217;s test suite working in my local environment. It&#8217;s a very trivial detail that I missed or rather overlooked whilst trying to get them working. For readers who don&#8217;t know, <a href="https://github.com/thoughtbot/clearance/">Clearance</a> is a Rails authentication engine and is developed by ThoughtBot and let me tell you that they love Cucumber. For testing the engine, Clearance uses <a href="https://github.com/aslakhellesoy/aruba">Aruba</a>, i.e. CLI steps for Cucumber.</p>
<p>The background story is that I have been quite interested in Clearance for quite a while now and am quite active in the ML and do chime in with my opinions and I just updated my local fork after a while and ran the specs and features. My preferred approach when bug fixing or adding any features or just code browsing any library is to install the dependencies in the vendor directory via bundler. I could use rvm gemsets and install the dependencies there but I usually don&#8217;t go for that approach. </p>
<p>So, I did exactly the same for clearance and installed the dependencies to vendor directory and ran the specs and features. Specs ran without any issues but with features I got a weird <strong>&#8220;bundler can&#8217;t be found&#8221;</strong> error. I was stumbled because I do have bundler installed on my machine. Anyways, after hours of debugging I figured the root of the cause. Below is the cucumber feature that does the background work in testing the engine(*taken from <a href="https://github.com/thoughtbot/clearance/blob/master/features/integration.feature">Clearance repository</a>):</p>
<pre>
When I successfully run "rails new testapp"
    And I cd to "testapp"
    And I remove the file "public/index.html"
    And I remove the file "app/views/layouts/application.html.erb"
    And I configure ActionMailer to use "localhost" as a host
    And I configure a root route
    And I add the "cucumber-rails" gem
    And I add the "capybara" gem
    And I add the "rspec-rails" gem
    And I add the "factory_girl_rails" gem
    And I add the "dynamic_form" gem
    And I add the "database_cleaner" gem
    And I add the "clearance" gem from this project
    And I add the "diesel" gem
    And I run "bundle install --local"
    And I successfully run "rails generate cucumber:install"
    And I disable Capybara Javascript emulation
    And I successfully run "rails generate clearance:features"
</pre>
<p>and you can see it creates a new rails app and installs the dependencies as part of the feature.</p>
<p>To run the test suite I used the following command:</p>
<pre>
bundle exec rake cucumber
</pre>
<p>because I installed all my dependencies in vendor and for them to be in the LOAD_PATH ran rake scoped via bundler. Now, when it came to running the CLI steps it complained about bundler&#8217;s absence because it was not installed to vendor as it was not in the Gemfile. </p>
<p>I did not use:</p>
<pre>
rake cucumber
</pre>
<p>because then bundler path would not kick in and the features would fail straight-away. So, how can we get this to work. Simple. Just create a new gemset for all the clearance development dependencies and get bundler to install it to the gemset as opposed to vendor and then run the features using:</p>
<pre>
rake cucumber
</pre>
<p>And they will be green. Phew. It took me a while to figure this out but I am so relieved I did.</p>
]]></content:encoded>
			<wfw:commentRss>http://www.andhapp.com/blog/2011/04/27/getting-clearance-test-suite-to-green/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>ActiveModel API and Parameter Object design pattern</title>
		<link>http://www.andhapp.com/blog/2011/04/17/activemodel-api-and-parameter-object-design-pattern/</link>
		<comments>http://www.andhapp.com/blog/2011/04/17/activemodel-api-and-parameter-object-design-pattern/#comments</comments>
		<pubDate>Sun, 17 Apr 2011 13:39:40 +0000</pubDate>
		<dc:creator>andhapp</dc:creator>
				<category><![CDATA[Programming]]></category>
		<category><![CDATA[Rails ActiveModel DesignPatterns]]></category>

		<guid isPermaLink="false">http://www.andhapp.com/blog/?p=483</guid>
		<description><![CDATA[About 3 months ago, I was working on this piece of code which had some &#8220;virtual models&#8221;. Virtual models are the entities that are well defined models except they are never persisted to the database. They are just kept in &#8230; <a href="http://www.andhapp.com/blog/2011/04/17/activemodel-api-and-parameter-object-design-pattern/">Continue reading <span class="meta-nav">&#8594;</span></a>]]></description>
			<content:encoded><![CDATA[<p>About 3 months ago, I was working on this piece of code which had some &#8220;virtual models&#8221;. Virtual models are the entities that are well defined models except they are never persisted to the database. They are just kept in memory and discarded. You could by all means persist them but I didn&#8217;t have to do it at the time.</p>
<p>The application had a search interface (that allowed users to search across the application). We all know any user interaction needs robust validations and it was same for this application as well.  The interface allowed users to select 4 (or 5) different filters to search across. So. the task was to capture the user supplied search filters and validate them and if valid search the and display the results based on it. There are several ways to solve this problem but I think with ActiveModel API the task at hand becomes really really easy.</p>
<p>ActiveModel API makes a <a href="http://yehudakatz.com/2010/01/10/activemodel-make-any-ruby-object-feel-like-activerecord/">ruby object feel like activerecord</a>. This essentially means creating one &#8220;Search&#8221; virtual model (object) and use ActiveModel API and add validations to it. And all the search filters are defined on the Search model itself which is in line with <a href="http://www.refactoring.com/catalog/introduceParameterObject.html">Martin Fowler&#8217;s Parameter Object design pattern</a>. Well, better designed code promotes better practices.</p>
<p>Sorry, for absence of any code in this post as I did this ages ago and was for a client project. Please leave comments if you need any clarifications.</p>
]]></content:encoded>
			<wfw:commentRss>http://www.andhapp.com/blog/2011/04/17/activemodel-api-and-parameter-object-design-pattern/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>What I learnt by presenting at SRUG</title>
		<link>http://www.andhapp.com/blog/2011/04/10/what-i-learnt-by-presenting-at-srug/</link>
		<comments>http://www.andhapp.com/blog/2011/04/10/what-i-learnt-by-presenting-at-srug/#comments</comments>
		<pubDate>Sun, 10 Apr 2011 19:24:40 +0000</pubDate>
		<dc:creator>andhapp</dc:creator>
				<category><![CDATA[Presentation]]></category>
		<category><![CDATA[ruby]]></category>
		<category><![CDATA[Srug]]></category>

		<guid isPermaLink="false">http://www.andhapp.com/blog/?p=480</guid>
		<description><![CDATA[I always wanted to do a technical presentation and it finally happened on 29th March 2011 at Woking. I just think putting yourself in front of 20-30 people and to respond to their queries is a courageous task and I &#8230; <a href="http://www.andhapp.com/blog/2011/04/10/what-i-learnt-by-presenting-at-srug/">Continue reading <span class="meta-nav">&#8594;</span></a>]]></description>
			<content:encoded><![CDATA[<p>I always wanted to do a technical presentation and it finally happened on 29th March 2011 at Woking. I just think putting yourself in front of 20-30 people and to respond to their queries is a courageous task and I am quite pleased to have experienced it now. Well, it all started off with a simple email from the SRUG organiser and I dived head first. Since it was my first ever presentation, I was more inclined to pick an easy topic. I am thankful there that there is a <a href="http://surreyrubyists.uservoice.com/forums/100459-what-do-you-want-to-see-at-srug-">Surrey Ruby User Group&#8217;s Uservoice page</a> with several preferred topics and I decided to go for &#8220;Creating Gems&#8221;. You can find my presentation <a href="https://github.com/andhapp/srug-presentation">&#8220;Creating Gems&#8221;</a> on github. I used <a href="https://github.com/schacon/showoff">showoff</a> gem along with a simple screencast. </p>
<p>So, now here&#8217;s what I learnt from the whole experience. This is my personal feedback on my performance:</p>
<ul>
<li>Always, always and always carry all the equipment you might need on the day. For example: I did not have a Mini DV to VGA adapter to hook up with the projector which meant I had to go second.
</li>
<li>Check your presentation on different resolutions. Projector&#8217;s resolution can spoil the whole presentation. It works on my machine would just not cut it.
</li>
<li>I am still quite new to showoff gem and I should have spent more time exploring it. It&#8217;s quite amazing and you can do a ton of stuff with it but I still need to delve into it a bit more.
</li>
<li>Use an iPad to do your presentations. Jon (the fellow presenter on the night) was using an iPad and the whole experience was just amazing. </li>
</ul>
<p>and now on the funny side:</p>
<p>There&#8217;s a twitter user called <a href="http://twitter.com/killallclients">killallclients</a>. Hilarious stories in that stream and ofcourse you know that such presentations are amazing for networking and meeting people who could offer you work in the future. I was quite disappointed by my presentation and I am working on improving it next time.</p>
]]></content:encoded>
			<wfw:commentRss>http://www.andhapp.com/blog/2011/04/10/what-i-learnt-by-presenting-at-srug/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Trunkly Chrome extension</title>
		<link>http://www.andhapp.com/blog/2011/03/16/trunkly-chrome-extension/</link>
		<comments>http://www.andhapp.com/blog/2011/03/16/trunkly-chrome-extension/#comments</comments>
		<pubDate>Wed, 16 Mar 2011 06:41:46 +0000</pubDate>
		<dc:creator>andhapp</dc:creator>
				<category><![CDATA[Programming]]></category>
		<category><![CDATA[Chrome]]></category>

		<guid isPermaLink="false">http://www.andhapp.com/blog/?p=476</guid>
		<description><![CDATA[Yahoo announced quite a while ago that delicious (their bookmarking tool) will be shut down and I started looking for alternatives. There are few things I am looking for in a bookmarking tool: 1. I don&#8217;t want to pay for &#8230; <a href="http://www.andhapp.com/blog/2011/03/16/trunkly-chrome-extension/">Continue reading <span class="meta-nav">&#8594;</span></a>]]></description>
			<content:encoded><![CDATA[<p><a href="http://www.yahoo.com">Yahoo</a> announced quite a while ago that <a href="http://www.delicious.com/">delicious</a> (their bookmarking tool) will be shut down and I started looking for alternatives. There are few things I am looking for in a bookmarking tool:</p>
<p>1. I don&#8217;t want to pay for it.<br />
2. It should have a nice interface to work with.<br />
3. It should have a browser extension for example: delicious Firefox extension was a pleasure to use.<br />
4. It should have a nice API to I can build my own extensions (provided none exists) or may be a desktop app.<br />
5. and I don&#8217;t want to pay for it. <img src='http://www.andhapp.com/blog/wp-includes/images/smilies/icon_surprised.gif' alt=':o' class='wp-smiley' /> )</p>
<p>Luckily, there is another similar bookmarking tool known as <a href="http://trunk.ly/">Trunkly</a> which ticks most of my requirements except that I could not find a browser extension for the same. So, as I said, I scratched my own itch and built one for Chrome. One thing that must be said is that writing an extension for Chrome is the easiest thing I have done in a while. The documentation is amazing and if you can read the documentation and follow the samples then writing an extension will be a walk in the park.</p>
<p>At the moment, the code is very young and it uses HTML5 localStorage to save the API key which might <a href="http://www.nczonline.net/blog/2010/04/13/towards-more-secure-client-side-data-storage/">not be secure</a> due to all sorts of reason but this is early days and I plan to change it in the later iterations or perhasp use the web database. The extension is not hosted in the Chrome store yet or anywhere else and if you do want to try it out just download the zip and load it in Chrome. The <a href="https://github.com/andhapp/trunkly-chrome">code</a> is hosted on github and if anyone wants to improve it or hack it, please go ahead.</p>
]]></content:encoded>
			<wfw:commentRss>http://www.andhapp.com/blog/2011/03/16/trunkly-chrome-extension/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Fonts and copyright issues</title>
		<link>http://www.andhapp.com/blog/2011/01/30/fonts-and-copyright-issues/</link>
		<comments>http://www.andhapp.com/blog/2011/01/30/fonts-and-copyright-issues/#comments</comments>
		<pubDate>Sun, 30 Jan 2011 13:16:58 +0000</pubDate>
		<dc:creator>andhapp</dc:creator>
				<category><![CDATA[Design]]></category>
		<category><![CDATA[copyright]]></category>
		<category><![CDATA[font]]></category>

		<guid isPermaLink="false">http://www.andhapp.com/blog/?p=470</guid>
		<description><![CDATA[I have always wondered what the implications are in using a font on your site. Since I own a mac can I just use any font that comes with and create an image and use it on my site. Does &#8230; <a href="http://www.andhapp.com/blog/2011/01/30/fonts-and-copyright-issues/">Continue reading <span class="meta-nav">&#8594;</span></a>]]></description>
			<content:encoded><![CDATA[<p>I have always wondered what the implications are in using a font on your site. Since I own a mac can I just use any font that comes with and create an image and use it on my site. Does owning a Mac or PC or any other machine for that matter give me the right to use the system fonts? I never had to face any sort of copyright issues but I just got thinking the other day and started researching a little bit and it&#8217;s quite straight forward.</p>
<p>The person who creates the font is the rightful owner and it&#8217;s up to him to let it be used freely or license it out. Every font actually has different sorts of licenses attached to it. The fonts that come with your Mac or PC are licensed to be used on that machine. Let us say if you want to use the same fonts and put them on the server then they are not licensed to be used there which means to put them on the server requires one to buy a license for it. </p>
<p>However, if you create an image using a font on your system and then use it as your logo then are you breaking any copyright laws? Once you have created a graphic using the font you are the owner of the graphic and are using(or distributing) it as a graphic and not as a font. But, be aware that this depends from font to font and one should read the terms and conditions of the license before using it. It does get a bit complicated, I must say.  Anyways, while researching I found a really nice site with a <a href="http://www.fontsquirrel.com/fonts/list/mostdownloaded">collection of fonts</a> that one can use and majority of them do not have a hefty price tag attached to them. </p>
<p>Please make sure you consult a lawyer regarding any complex copyright issues to protect yourself from massive payouts later.</p>
]]></content:encoded>
			<wfw:commentRss>http://www.andhapp.com/blog/2011/01/30/fonts-and-copyright-issues/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Designer code meet</title>
		<link>http://www.andhapp.com/blog/2011/01/07/designer-code-meet/</link>
		<comments>http://www.andhapp.com/blog/2011/01/07/designer-code-meet/#comments</comments>
		<pubDate>Fri, 07 Jan 2011 06:47:41 +0000</pubDate>
		<dc:creator>andhapp</dc:creator>
				<category><![CDATA[Programming]]></category>
		<category><![CDATA[Kata]]></category>
		<category><![CDATA[Refactoring]]></category>
		<category><![CDATA[ruby]]></category>

		<guid isPermaLink="false">http://www.andhapp.com/blog/?p=465</guid>
		<description><![CDATA[Do you write Designer code? Well, this was the topic of Chris Parsons&#8217;s (eden developments) talk on Thursday evening. The presentation was top-notch and so was the exercise afterwards. I was lucky enough to pair up with James Adams (from &#8230; <a href="http://www.andhapp.com/blog/2011/01/07/designer-code-meet/">Continue reading <span class="meta-nav">&#8594;</span></a>]]></description>
			<content:encoded><![CDATA[<p>Do you write Designer code? </p>
<p>Well, this was the topic of <a href="https://github.com/chrismdp">Chris Parsons&#8217;s</a> (<a href="http://edendevelopment.co.uk/">eden developments</a>) talk on Thursday evening. The presentation was top-notch and so was the exercise afterwards. I was lucky enough to pair up with <a href="https://github.com/lazyatom">James Adams</a> (from <a href="http://gofreerange.com/">Go Free Range</a>) and a ruby stalwart. We ended up refactoring some nasty piece of code into designer code pretty quickly. It was a really nice experience after all. If you would like to have a go then, it lives in Chris&#8217;s <a href="https://github.com/chrismdp/checkout-kata">checkout-kata repository</a> under <a href="https://github.com/chrismdp/checkout-kata/tree/obfuscated">obfuscated branch</a>. </p>
<p>The problem is our own <a href="http://codekata.pragprog.com/2007/01/kata_nine_back_.html">checkout problem</a>, which I am sure you have come across before.</p>
]]></content:encoded>
			<wfw:commentRss>http://www.andhapp.com/blog/2011/01/07/designer-code-meet/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Rails inflections and the word &#8216;Equipment&#8217;</title>
		<link>http://www.andhapp.com/blog/2010/11/20/rails-inflections-and-the-word-equipment/</link>
		<comments>http://www.andhapp.com/blog/2010/11/20/rails-inflections-and-the-word-equipment/#comments</comments>
		<pubDate>Sat, 20 Nov 2010 21:46:08 +0000</pubDate>
		<dc:creator>andhapp</dc:creator>
				<category><![CDATA[Programming]]></category>
		<category><![CDATA[Rant]]></category>
		<category><![CDATA[Rails]]></category>

		<guid isPermaLink="false">http://www.andhapp.com/blog/?p=460</guid>
		<description><![CDATA[I was in two minds about this post&#8217;s title. On one hand, I think this should be called &#8220;Why googling is not the answer to every question?&#8221; and on the other hand the current title will probably interest more people. &#8230; <a href="http://www.andhapp.com/blog/2010/11/20/rails-inflections-and-the-word-equipment/">Continue reading <span class="meta-nav">&#8594;</span></a>]]></description>
			<content:encoded><![CDATA[<p>I was in two minds about this post&#8217;s title. On one hand, I think this should be called &#8220;Why googling is not the answer to every question?&#8221; and on the other hand the current title will probably interest more people. Rails inflections is not the main focus of this post. This post is a consequence of Rails inflections and attempts to highlight some of the things that are wrong with the way developers work now a days.</p>
<p>Last week, I had to create a model called &#8216;Equipment&#8217;. I know now that &#8216;Equipment&#8217; is uncountable therefore when it comes to creating a table rails will not tabelize resulting in a table with name &#8220;equipment&#8221;. But few days ago, I was surprised and straight-away <a href="http://www.google.co.uk/search?q=equipments&#038;ie=utf-8&#038;oe=utf-8&#038;aq=t&#038;rls=org.mozilla:en-US:official&#038;client=firefox-a">googled</a> the word &#8216;equipments&#8217; and results confirmed my doubts that this is a bug in Rails. Silly me. </p>
<p>I went through the code and found it in the <a href="https://github.com/rails/rails/blob/master/activesupport/lib/active_support/inflections.rb#L54">inflections</a> file and found that the &#8216;equipment&#8217; word defined as uncountable. Now, I was even more surprised. If the word &#8220;equipments&#8221; exist (as confirmed by Google) then why on earth will Rails do otherwise. There is only one place that could resolve my dilemma, yes you got it right, Oxford dictionary. I looked it up and &#8220;Equipment&#8221; is an uncountable noun just like &#8220;information&#8221;. </p>
<p>Now, this little research basically highlights two things:</p>
<p>1. Google is just a search engine. Think about what you are doing and then take an intelligent decision.<br />
2. Don&#8217;t assume that Rails is behaving incorrectly and leave it at that. Investigate and read the code. That will improve your understanding. I have seen several code bases where developers have actually just assumed what they are told and carried on. </p>
<p>Few weeks ago, John Nunemaker spoke about &#8216;<a href="http://railstips.org/blog/archives/2010/10/14/stop-googling/">Stop Googling</a>&#8216;. If I have a bug, I will clone the code and start looking into it. In last few weeks, I have read the code bases from <a href="http://www.andhapp.com/blog/2010/10/10/using-cucumber-092-and-cucumber-rails-032-with-i18n/">rspec and cucumber</a>, <a href="https://github.com/thoughtbot/clearance">clearance</a>, <a href="https://github.com/rails/rails">rails</a>, <a href="https://github.com/wayneeseguin/rvm">rvm</a> and <a href="https://github.com/railsdog/spree">spree</a> and found various good and bad things in them. This also takes me one step closer to <a href="http://railscasts.com/give_back">giving something back to the open source community</a>. But will talk about it more in my next post.</p>
]]></content:encoded>
			<wfw:commentRss>http://www.andhapp.com/blog/2010/11/20/rails-inflections-and-the-word-equipment/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Comment multiple lines in MacVim</title>
		<link>http://www.andhapp.com/blog/2010/11/20/comment-multiple-lines-in-macvim/</link>
		<comments>http://www.andhapp.com/blog/2010/11/20/comment-multiple-lines-in-macvim/#comments</comments>
		<pubDate>Sat, 20 Nov 2010 21:19:32 +0000</pubDate>
		<dc:creator>andhapp</dc:creator>
				<category><![CDATA[Programming]]></category>
		<category><![CDATA[Mac]]></category>
		<category><![CDATA[MacVim]]></category>
		<category><![CDATA[vim]]></category>

		<guid isPermaLink="false">http://www.andhapp.com/blog/?p=457</guid>
		<description><![CDATA[Commenting multiple lines is mostly used when one is debugging and quickly wants to take a piece of code out, just to put it back again. Here&#8217;s how one can achieve in the same in MacVim. 1. Press &#8216;V&#8217; on &#8230; <a href="http://www.andhapp.com/blog/2010/11/20/comment-multiple-lines-in-macvim/">Continue reading <span class="meta-nav">&#8594;</span></a>]]></description>
			<content:encoded><![CDATA[<p>Commenting multiple lines is mostly used when one is debugging and quickly wants to take a piece of code out, just to put it back again. Here&#8217;s how one can achieve in the same in MacVim. </p>
<p>1. Press &#8216;V&#8217; on your keyboard and use the arrow key to select the code snippet to be commented out.<br />
2. Then press &#8216;:&#8217; which will automatically change that to something like this:</p>
<pre>
:'<,'>
</pre>
<p>3. Then just type in this command and press Enter.</p>
<pre>
:'<,'>s/^/#/g
</pre>
<p>Now, to uncomment them just follow steps 1 and 2 and then enter the following command:</p>
<pre>
:'<,'>s/^#//g
</pre>
]]></content:encoded>
			<wfw:commentRss>http://www.andhapp.com/blog/2010/11/20/comment-multiple-lines-in-macvim/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Moving this blog from Dreamhost to Linode</title>
		<link>http://www.andhapp.com/blog/2010/11/14/moving-this-blog-from-dreamhost-to-linode/</link>
		<comments>http://www.andhapp.com/blog/2010/11/14/moving-this-blog-from-dreamhost-to-linode/#comments</comments>
		<pubDate>Sun, 14 Nov 2010 22:27:32 +0000</pubDate>
		<dc:creator>andhapp</dc:creator>
				<category><![CDATA[Programming]]></category>
		<category><![CDATA[dreamhost]]></category>
		<category><![CDATA[fastcgi]]></category>
		<category><![CDATA[linode]]></category>
		<category><![CDATA[MySql]]></category>
		<category><![CDATA[nginx]]></category>
		<category><![CDATA[PHP]]></category>
		<category><![CDATA[WordPress]]></category>

		<guid isPermaLink="false">http://www.andhapp.com/blog/?p=440</guid>
		<description><![CDATA[This post is in continuation to my earlier post which simply mentions the move of this blog from Dreamhost to Linode and this post is an attempt to expound on a little bit of the details and the experience. This &#8230; <a href="http://www.andhapp.com/blog/2010/11/14/moving-this-blog-from-dreamhost-to-linode/">Continue reading <span class="meta-nav">&#8594;</span></a>]]></description>
			<content:encoded><![CDATA[<p>This post is in continuation to my earlier <a href="http://www.andhapp.com/blog/2010/11/07/moving-from-dreamhost-to-linode/">post</a> which simply mentions the move of this blog from Dreamhost to Linode and this post is an attempt to expound on a little bit of the details and the experience.</p>
<p>This was not just a move from shared hosting a.k.a Dreamhost to a vps solution a.k.a Linode, but it was also a move from Apache to Nginx + fastcgi. Yes, now I am actually running the WordPress blog on Nginx. It&#8217;s just a matter of choice really. There is nothing wrong with Apache. It&#8217;s just that I have been using Nginx with Passenger for Rails deployment and decided to keep everything under one hood. </p>
<h3>Say NO to CentOS</h3>
<p>If you are like me (not very bright), you will instantly google &#8220;setting up nginx with fastcgi&#8221; and like always google will not disappoint you. But this information overload becomes a pain in the back side, sometimes. Why? Well, if something worked for someone does not mean it will work for you and then how long ago was it and has something changed since then and so on and so forth. CentOS has outdated packages and in several cases broken. Also, most of the results you found whilst googling suggest creating a startup script for php with fastcgi and refers to the use of start-stop-daemon and CentOS does not have one. Therefore, to keep it simple just go with ubuntu. Trust me. However, if you insist on installing CentOS then <a href="http://centos.org/modules/newbb/viewtopic.php?topic_id=24207&#038;forum=40">here</a> are few <a href="http://florent.clairambault.fr/get-start-stop-daemon-on-any-linux">workarounds</a> for the start-stop-daemon problem.</p>
<h3>Install dependencies manually</h3>
<p>What exactly do you need to run this blog? PHP, MySql, and Nginx along with fastcgi and the most important, configure Nginx to proxy all the .php requests via the fastcgi server. Here&#8217;s a <a href="http://tomasz.sterna.tv/2009/04/php-fastcgi-with-nginx-on-ubuntu/">link</a> that I found extremely helpful in installing all the above mentioned softwares. However, my nginx.config is slightly different from the one mentioned in the link. Here&#8217;s how mine looks:</p>
<pre>
server {
        listen          80;
        server_name     &lt;server_name&gt;;

        root            &lt;document_root&gt;;
        index           index.php index.html;

        location ~ \.php$ {
        	include	        &lt;location_of_fastcgi_config file&gt;;
		fastcgi_pass    127.0.0.1:9000;
        	fastcgi_index   index.php;
		keepalive_timeout 0;

        }
    }	
</pre>
<p>Replace the values in &#8220;&lt;&#8230;&gt;&#8221; with your own specific values. I create a new fastcgi_config file for each domain and the only value I change is the document root. Here&#8217;s an example:</p>
<pre>
fastcgi_param  GATEWAY_INTERFACE  CGI/1.1;
fastcgi_param  SERVER_SOFTWARE    nginx;
fastcgi_param  QUERY_STRING       $query_string;
fastcgi_param  REQUEST_METHOD     $request_method;
fastcgi_param  CONTENT_TYPE       $content_type;
fastcgi_param  CONTENT_LENGTH     $content_length;
fastcgi_param  SCRIPT_FILENAME    &lt;document_root&gt;$fastcgi_script_name;
fastcgi_param  SCRIPT_NAME        $fastcgi_script_name;
fastcgi_param  REQUEST_URI        $request_uri;
fastcgi_param  DOCUMENT_URI       $document_uri;
fastcgi_param  DOCUMENT_ROOT	  &lt;document_root&gt;;
fastcgi_param  SERVER_PROTOCOL    $server_protocol;
fastcgi_param  REMOTE_ADDR        $remote_addr;
fastcgi_param  REMOTE_PORT        $remote_port;
fastcgi_param  SERVER_ADDR        $server_addr;
fastcgi_param  SERVER_PORT        $server_port;
fastcgi_param  SERVER_NAME        $server_name;
</pre>
<p>You can read <a href="http://wiki.nginx.org/NginxFcgiExample">here</a> for more information on the nginx fastcgi. Creating a new config file for each domain is just stupid and you can just pass the values of dynamic variables like DOCUMENT_ROOT or SCRIPT_FILENAME from within nginx but I could not get it to work.</p>
<h3>Install dependencies via Chef</h3>
<p>I think installing everything manually is a bit backward and one could always use <a href="http://wiki.opscode.com/display/chef/Home">Chef</a>. In my next post, I will talk about my experience of setting up an entire server using Chef. Chef&#8217;s wiki is amazing and takes you through each and every step. Give it a try. </p>
<h3>Gotchas</h3>
<ul>
<li>Make sure you restart fastcgi_server as I totally forgot and it never picked up mysql.</li>
<li>Also, add mysql.so and mysqli.so to your php.ini file and restart the php_fastcgi server for it to pick up the changes. It&#8217;s most probably in /etc/php5/cgi directory.</li>
<p>It took me quite sometime to really get everything working and I was tempted to just give up and just use apache. But I stood my ground and finally cracked it. I hope it helps you in your own endeavours.</p>
]]></content:encoded>
			<wfw:commentRss>http://www.andhapp.com/blog/2010/11/14/moving-this-blog-from-dreamhost-to-linode/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
	</channel>
</rss>

