<?xml version="1.0" encoding="UTF-8"?>
<?xml-stylesheet type="text/xsl" media="screen" href="/~d/styles/atom10full.xsl"?><?xml-stylesheet type="text/css" media="screen" href="http://feeds.feedburner.com/~d/styles/itemcontent.css"?><feed xmlns="http://www.w3.org/2005/Atom" xmlns:openSearch="http://a9.com/-/spec/opensearch/1.1/" xmlns:georss="http://www.georss.org/georss" xmlns:gd="http://schemas.google.com/g/2005" xmlns:thr="http://purl.org/syndication/thread/1.0" xmlns:feedburner="http://rssnamespace.org/feedburner/ext/1.0" gd:etag="W/&quot;CUMCR3c4eip7ImA9WhVREkk.&quot;"><id>tag:blogger.com,1999:blog-4462497484400593443</id><updated>2012-03-20T06:37:46.932-05:00</updated><category term="ruby" /><category term="firefox" /><category term="i18n" /><category term="rspec" /><category term="ruby rails active_resource filter_param" /><category term="rails configuration" /><category term="japanese" /><category term="git" /><category term="java" /><category term="yml" /><category term="dropbox" /><category term="truecrypt" /><category term="rails migrations" /><category term="rails tips/tricks" /><category term="ruby rails app_constants" /><category term="thunderbird" /><category term="ruby rails active_record validations" /><category term="rails http_streaming" /><title>vijay's technical spot</title><subtitle type="html">Some random learnings on technologies that I am exposed to on a day-to-day basis.</subtitle><link rel="http://schemas.google.com/g/2005#feed" type="application/atom+xml" href="http://vijaysspot.blogspot.com/feeds/posts/default" /><link rel="alternate" type="text/html" href="http://vijaysspot.blogspot.com/" /><author><name>Vijay Aravamudhan</name><uri>http://www.blogger.com/profile/05637309012758011714</uri><email>noreply@blogger.com</email><gd:image rel="http://schemas.google.com/g/2005#thumbnail" width="16" height="16" src="http://img2.blogblog.com/img/b16-rounded.gif" /></author><generator version="7.00" uri="http://www.blogger.com">Blogger</generator><openSearch:totalResults>15</openSearch:totalResults><openSearch:startIndex>1</openSearch:startIndex><openSearch:itemsPerPage>25</openSearch:itemsPerPage><atom10:link xmlns:atom10="http://www.w3.org/2005/Atom" rel="self" type="application/atom+xml" href="http://feeds.feedburner.com/VijaysTechnicalSpot" /><feedburner:info uri="vijaystechnicalspot" /><atom10:link xmlns:atom10="http://www.w3.org/2005/Atom" rel="hub" href="http://pubsubhubbub.appspot.com/" /><entry gd:etag="W/&quot;CkMMSHY9eSp7ImA9WhRSFks.&quot;"><id>tag:blogger.com,1999:blog-4462497484400593443.post-2676485993367994084</id><published>2011-11-18T05:13:00.001-06:00</published><updated>2011-11-18T17:54:49.861-06:00</updated><app:edited xmlns:app="http://www.w3.org/2007/app">2011-11-18T17:54:49.861-06:00</app:edited><category scheme="http://www.blogger.com/atom/ns#" term="rails http_streaming" /><title>Why is HTTP Streaming a joke on Rails 3.1?</title><content type="html">&lt;div dir="ltr" style="text-align: left;" trbidi="on"&gt;
I have been trying to convert a Rails 3.1 app to use HTTP Streaming. The interesting fact about this app, and others that I have been working on for the past few years is that most of the models are ActiveResource models - not ActiveRecord. In this context, having the controller logic evaluated lazily takes on more importance - but the phrase "Rails 3.1 supports HTTP Streaming" leaves a lot to be desired.

&lt;br /&gt;
&lt;br /&gt;
I first tried to follow Ryan Bates' excellent &lt;a href="http://railscasts.com/episodes/266-http-streaming"&gt;rails cast&lt;/a&gt;. The tips are good, and I was able to get streaming working in a basic rails app ie one that uses ARecord quite easily.
The key to streaming is the lazy evaluation of any logic that takes time - namely hitting the database (ARecord) or webservices (AResource). For ARecord, the Rails developers have piggy-backed on ActiveRelation's proxy (scoped) method for lazy evaluation. This is fine for ARecord. But does not work for AResource. This is the place where Rails breaks down.

&lt;br /&gt;
&lt;br /&gt;
What would have been better is if Rails had implemented a way for ALL such instance variables to be defined inside a lambda or Proc (in the controller) - so that the lambda is defined but not evaluated right then and there. And the second piece of the puzzle would have been for the getter of these instance variables (usually used in the views) to automatically evaluate the block the first time around that they were invoked (should only do the eval once).

&lt;br /&gt;
&lt;br /&gt;
One other thing to note is that any logic (instance variables that get assigned in the controller using the '@' symbol) that depend on the above lazy loaded values/attributes have to also be lazy loaded. This can be done using the method outlined &lt;a href="http://ilikestuffblog.com/2010/09/23/ruby-on-rails-bedtime-stories/"&gt;here&lt;/a&gt; (this is one of the cleaner methods - and I am not sure whether the author was the first one to do it this way - I found other sites with the same way of tackling the problem).&lt;/div&gt;&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/4462497484400593443-2676485993367994084?l=vijaysspot.blogspot.com' alt='' /&gt;&lt;/div&gt;
&lt;p&gt;&lt;a href="http://feedads.g.doubleclick.net/~a/CgHwZ42B5POJmEBJo3VEp7zPFIY/0/da"&gt;&lt;img src="http://feedads.g.doubleclick.net/~a/CgHwZ42B5POJmEBJo3VEp7zPFIY/0/di" border="0" ismap="true"&gt;&lt;/img&gt;&lt;/a&gt;&lt;br/&gt;
&lt;a href="http://feedads.g.doubleclick.net/~a/CgHwZ42B5POJmEBJo3VEp7zPFIY/1/da"&gt;&lt;img src="http://feedads.g.doubleclick.net/~a/CgHwZ42B5POJmEBJo3VEp7zPFIY/1/di" border="0" ismap="true"&gt;&lt;/img&gt;&lt;/a&gt;&lt;/p&gt;&lt;img src="http://feeds.feedburner.com/~r/VijaysTechnicalSpot/~4/XNImJTABDIo" height="1" width="1"/&gt;</content><link rel="replies" type="application/atom+xml" href="http://vijaysspot.blogspot.com/feeds/2676485993367994084/comments/default" title="Post Comments" /><link rel="replies" type="text/html" href="http://vijaysspot.blogspot.com/2011/11/why-is-http-streaming-joke-on-rails-31.html#comment-form" title="0 Comments" /><link rel="edit" type="application/atom+xml" href="http://www.blogger.com/feeds/4462497484400593443/posts/default/2676485993367994084?v=2" /><link rel="self" type="application/atom+xml" href="http://www.blogger.com/feeds/4462497484400593443/posts/default/2676485993367994084?v=2" /><link rel="alternate" type="text/html" href="http://feedproxy.google.com/~r/VijaysTechnicalSpot/~3/XNImJTABDIo/why-is-http-streaming-joke-on-rails-31.html" title="Why is HTTP Streaming a joke on Rails 3.1?" /><author><name>Vijay Aravamudhan</name><uri>http://www.blogger.com/profile/05637309012758011714</uri><email>noreply@blogger.com</email><gd:image rel="http://schemas.google.com/g/2005#thumbnail" width="16" height="16" src="http://img2.blogblog.com/img/b16-rounded.gif" /></author><thr:total>0</thr:total><feedburner:origLink>http://vijaysspot.blogspot.com/2011/11/why-is-http-streaming-joke-on-rails-31.html</feedburner:origLink></entry><entry gd:etag="W/&quot;AkIBRnY6eCp7ImA9WhdaGUk.&quot;"><id>tag:blogger.com,1999:blog-4462497484400593443.post-5870923806271132267</id><published>2011-10-29T23:22:00.003-05:00</published><updated>2011-10-29T23:22:37.810-05:00</updated><app:edited xmlns:app="http://www.w3.org/2007/app">2011-10-29T23:22:37.810-05:00</app:edited><category scheme="http://www.blogger.com/atom/ns#" term="ruby rails active_record validations" /><title>Active Record Validator</title><content type="html">As your rails project sees multiple releases, you probably have new migrations that were run on your database. This coupled with Rails' default (IMHO, incorrect) attitude of not enforcing foreign key constraints at the db level might cause your old data to become invalid based on new ActiveRecord validations (unless your incremental migrations have taken this into consideration and massaged your data correctly).

In our project, we had created a home-grown solution called ActiveRecordValidator. This would find all records in each table in your database (it was intelligent enough to handle STI, etc and also had a mechanism where you could specify some tables that you did not want to process - for eg audit tables, etc), and invoke valid? on them. If there were any errors, these were printed out to stderr. Progress was printed to stderr. This proved very useful for us, even in development/test so as to validate that all our reference table data was correct. When run against a snapshot of our production database (we setup a run every week against this snapshot data), it would inform us of data that would become invalid when the next production deploy happened. Our development iteration had an ongoing story card to fix such invalid data after talking to our SMEs.

Since this code was done for a client, I could not open source it, but found something similar: &lt;a href="https://github.com/vraravam/active_sanity"&gt;active_sanity&lt;/a&gt;.&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/4462497484400593443-5870923806271132267?l=vijaysspot.blogspot.com' alt='' /&gt;&lt;/div&gt;
&lt;p&gt;&lt;a href="http://feedads.g.doubleclick.net/~a/H1kKoC5RzA0HmC4TdrG7SZZg5Hc/0/da"&gt;&lt;img src="http://feedads.g.doubleclick.net/~a/H1kKoC5RzA0HmC4TdrG7SZZg5Hc/0/di" border="0" ismap="true"&gt;&lt;/img&gt;&lt;/a&gt;&lt;br/&gt;
&lt;a href="http://feedads.g.doubleclick.net/~a/H1kKoC5RzA0HmC4TdrG7SZZg5Hc/1/da"&gt;&lt;img src="http://feedads.g.doubleclick.net/~a/H1kKoC5RzA0HmC4TdrG7SZZg5Hc/1/di" border="0" ismap="true"&gt;&lt;/img&gt;&lt;/a&gt;&lt;/p&gt;&lt;img src="http://feeds.feedburner.com/~r/VijaysTechnicalSpot/~4/de0iHWhjz9M" height="1" width="1"/&gt;</content><link rel="replies" type="application/atom+xml" href="http://vijaysspot.blogspot.com/feeds/5870923806271132267/comments/default" title="Post Comments" /><link rel="replies" type="text/html" href="http://vijaysspot.blogspot.com/2011/10/active-record-validator.html#comment-form" title="0 Comments" /><link rel="edit" type="application/atom+xml" href="http://www.blogger.com/feeds/4462497484400593443/posts/default/5870923806271132267?v=2" /><link rel="self" type="application/atom+xml" href="http://www.blogger.com/feeds/4462497484400593443/posts/default/5870923806271132267?v=2" /><link rel="alternate" type="text/html" href="http://feedproxy.google.com/~r/VijaysTechnicalSpot/~3/de0iHWhjz9M/active-record-validator.html" title="Active Record Validator" /><author><name>Vijay Aravamudhan</name><uri>http://www.blogger.com/profile/05637309012758011714</uri><email>noreply@blogger.com</email><gd:image rel="http://schemas.google.com/g/2005#thumbnail" width="16" height="16" src="http://img2.blogblog.com/img/b16-rounded.gif" /></author><thr:total>0</thr:total><feedburner:origLink>http://vijaysspot.blogspot.com/2011/10/active-record-validator.html</feedburner:origLink></entry><entry gd:etag="W/&quot;C0cGSHc7fyp7ImA9WhRSFks.&quot;"><id>tag:blogger.com,1999:blog-4462497484400593443.post-6897145853471720261</id><published>2011-10-29T23:02:00.002-05:00</published><updated>2011-11-18T18:03:49.907-06:00</updated><app:edited xmlns:app="http://www.w3.org/2007/app">2011-11-18T18:03:49.907-06:00</app:edited><category scheme="http://www.blogger.com/atom/ns#" term="ruby rails app_constants" /><title>Application constants and accessing these from within Rails.configure block</title><content type="html">&lt;div dir="ltr" style="text-align: left;" trbidi="on"&gt;
Around 4 years ago, when I was on my first ruby project, we came up with a solution to extract all application constants into a yaml file grouped by the rails environment. This concept was not new - but I did not find any plugin that had this functionality. After some time, I came to know about &lt;a href="https://github.com/leonardoborges/app_constants"&gt;app_constants&lt;/a&gt; from my colleague, Leornado Borges. I have since used this gem in a couple of projects, but am missing one of the functionalities that our home-grown solution had: Our plugin had a method that could be invoked for any environment (we were calling this as part of our rspec suite for every CI run), that would take the aggregate of all the keys in every environment, and list out those keys that were not present in all the environments. This provided us with a way to quickly determine if a developer had added a key, but had forgotten to add it into the test/cucumber/uat/production environments. This was also invoked during deployment to production - so that if the yml file is being overwritten by your deployment tool, then we can be sure that any missing keys are caught during your deployment window - rather than at runtime by your user! (I think I will fork app_constants and implement this functionality - unless leonardo beats me to it!)

&lt;br /&gt;
&lt;br /&gt;
Note: If you are using this gem to extract your constants, but are using these constants within your environment initialization file, you might get an error. The way around this is to extract those specific lines into config.after_initialize blocks.

&lt;br /&gt;
&lt;br /&gt;
For eg:
&lt;br /&gt;
&lt;pre&gt;    config.after_initialize do
      # Enable serving of images, stylesheets, and JavaScripts from an asset server
      config.action_controller.asset_host = "http://#{AppConstants.ASSET_HOST}"
      config.action_mailer.asset_host = "http://#{AppConstants.ASSET_HOST}"
    end
&lt;/pre&gt;
&lt;/div&gt;&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/4462497484400593443-6897145853471720261?l=vijaysspot.blogspot.com' alt='' /&gt;&lt;/div&gt;
&lt;p&gt;&lt;a href="http://feedads.g.doubleclick.net/~a/_7_8j12yAJXRTlUB92A6tz8NOqs/0/da"&gt;&lt;img src="http://feedads.g.doubleclick.net/~a/_7_8j12yAJXRTlUB92A6tz8NOqs/0/di" border="0" ismap="true"&gt;&lt;/img&gt;&lt;/a&gt;&lt;br/&gt;
&lt;a href="http://feedads.g.doubleclick.net/~a/_7_8j12yAJXRTlUB92A6tz8NOqs/1/da"&gt;&lt;img src="http://feedads.g.doubleclick.net/~a/_7_8j12yAJXRTlUB92A6tz8NOqs/1/di" border="0" ismap="true"&gt;&lt;/img&gt;&lt;/a&gt;&lt;/p&gt;&lt;img src="http://feeds.feedburner.com/~r/VijaysTechnicalSpot/~4/l_IUq6U-WzE" height="1" width="1"/&gt;</content><link rel="replies" type="application/atom+xml" href="http://vijaysspot.blogspot.com/feeds/6897145853471720261/comments/default" title="Post Comments" /><link rel="replies" type="text/html" href="http://vijaysspot.blogspot.com/2011/10/application-constants-and-accessing.html#comment-form" title="0 Comments" /><link rel="edit" type="application/atom+xml" href="http://www.blogger.com/feeds/4462497484400593443/posts/default/6897145853471720261?v=2" /><link rel="self" type="application/atom+xml" href="http://www.blogger.com/feeds/4462497484400593443/posts/default/6897145853471720261?v=2" /><link rel="alternate" type="text/html" href="http://feedproxy.google.com/~r/VijaysTechnicalSpot/~3/l_IUq6U-WzE/application-constants-and-accessing.html" title="Application constants and accessing these from within Rails.configure block" /><author><name>Vijay Aravamudhan</name><uri>http://www.blogger.com/profile/05637309012758011714</uri><email>noreply@blogger.com</email><gd:image rel="http://schemas.google.com/g/2005#thumbnail" width="16" height="16" src="http://img2.blogblog.com/img/b16-rounded.gif" /></author><thr:total>0</thr:total><feedburner:origLink>http://vijaysspot.blogspot.com/2011/10/application-constants-and-accessing.html</feedburner:origLink></entry><entry gd:etag="W/&quot;C0YFR3s5fyp7ImA9WhRSFks.&quot;"><id>tag:blogger.com,1999:blog-4462497484400593443.post-7860971058690140852</id><published>2011-10-29T21:22:00.002-05:00</published><updated>2011-11-18T18:05:16.527-06:00</updated><app:edited xmlns:app="http://www.w3.org/2007/app">2011-11-18T18:05:16.527-06:00</app:edited><category scheme="http://www.blogger.com/atom/ns#" term="ruby rails active_resource filter_param" /><title>ActiveResource filter params</title><content type="html">&lt;div dir="ltr" style="text-align: left;" trbidi="on"&gt;
&lt;script src="https://gist.github.com/1319094.js?file=active_resource_filtered_logger.rb"&gt;
&lt;/script&gt;
&lt;br /&gt;
&lt;div dir="ltr" style="text-align: left;" trbidi="on"&gt;
Rails provides a way to filter action controller params from being logged. But if your app is talking to a webservice and passing these sensitive parameters, and you have turned on logged for ActiveResource::Base, then these sensitive params are anyways logged! To overcome this, I wrote this snippet:&lt;br /&gt;
&lt;a href="https://gist.github.com/1319094.js?file=active_resource_filtered_logger.rb"&gt;https://gist.github.com/1319094.js&lt;/a&gt; &lt;br /&gt;
This can obviously be improved by separating out the params to be filtered between your ActionController::Base params and ActiveResource::Base params - but I leave that up to you...(this works for me)&lt;br /&gt;
&lt;script src="https://gist.github.com/1319094.js?file=active_resource_filtered_logger.rb"&gt;
&lt;br&gt;
&lt;/script&gt;&lt;/div&gt;
&lt;script src="https://gist.github.com/1319094.js?file=active_resource_filtered_logger.rb"&gt;
&lt;/script&gt;&lt;/div&gt;&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/4462497484400593443-7860971058690140852?l=vijaysspot.blogspot.com' alt='' /&gt;&lt;/div&gt;
&lt;p&gt;&lt;a href="http://feedads.g.doubleclick.net/~a/M2MrPQffBx0vWCZw_FPu2GKttT0/0/da"&gt;&lt;img src="http://feedads.g.doubleclick.net/~a/M2MrPQffBx0vWCZw_FPu2GKttT0/0/di" border="0" ismap="true"&gt;&lt;/img&gt;&lt;/a&gt;&lt;br/&gt;
&lt;a href="http://feedads.g.doubleclick.net/~a/M2MrPQffBx0vWCZw_FPu2GKttT0/1/da"&gt;&lt;img src="http://feedads.g.doubleclick.net/~a/M2MrPQffBx0vWCZw_FPu2GKttT0/1/di" border="0" ismap="true"&gt;&lt;/img&gt;&lt;/a&gt;&lt;/p&gt;&lt;img src="http://feeds.feedburner.com/~r/VijaysTechnicalSpot/~4/ntgjlzhNGQo" height="1" width="1"/&gt;</content><link rel="replies" type="application/atom+xml" href="http://vijaysspot.blogspot.com/feeds/7860971058690140852/comments/default" title="Post Comments" /><link rel="replies" type="text/html" href="http://vijaysspot.blogspot.com/2011/10/activeresource-filter-params.html#comment-form" title="0 Comments" /><link rel="edit" type="application/atom+xml" href="http://www.blogger.com/feeds/4462497484400593443/posts/default/7860971058690140852?v=2" /><link rel="self" type="application/atom+xml" href="http://www.blogger.com/feeds/4462497484400593443/posts/default/7860971058690140852?v=2" /><link rel="alternate" type="text/html" href="http://feedproxy.google.com/~r/VijaysTechnicalSpot/~3/ntgjlzhNGQo/activeresource-filter-params.html" title="ActiveResource filter params" /><author><name>Vijay Aravamudhan</name><uri>http://www.blogger.com/profile/05637309012758011714</uri><email>noreply@blogger.com</email><gd:image rel="http://schemas.google.com/g/2005#thumbnail" width="16" height="16" src="http://img2.blogblog.com/img/b16-rounded.gif" /></author><thr:total>0</thr:total><feedburner:origLink>http://vijaysspot.blogspot.com/2011/10/activeresource-filter-params.html</feedburner:origLink></entry><entry gd:etag="W/&quot;C0MDQ388eSp7ImA9WhdVGEg.&quot;"><id>tag:blogger.com,1999:blog-4462497484400593443.post-2781059103713835137</id><published>2011-09-24T03:04:00.002-05:00</published><updated>2011-09-24T03:04:32.171-05:00</updated><app:edited xmlns:app="http://www.w3.org/2007/app">2011-09-24T03:04:32.171-05:00</app:edited><category scheme="http://www.blogger.com/atom/ns#" term="ruby" /><category scheme="http://www.blogger.com/atom/ns#" term="yml" /><title>Yaml - Yes? No? Maybe?</title><content type="html">Another interesting thing I found out this past week: the default yaml ruby library auto-converts keys with yes/true/ etc to the boolean true. I kind of expected that yaml might play around with the values - but I didnt expect that I would find such behavior with keys!

Anyways, the way to fix it is to explicitly make the key a string!&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/4462497484400593443-2781059103713835137?l=vijaysspot.blogspot.com' alt='' /&gt;&lt;/div&gt;
&lt;p&gt;&lt;a href="http://feedads.g.doubleclick.net/~a/jrSOUc5WKPHvVv4UeZTG-IkVeF8/0/da"&gt;&lt;img src="http://feedads.g.doubleclick.net/~a/jrSOUc5WKPHvVv4UeZTG-IkVeF8/0/di" border="0" ismap="true"&gt;&lt;/img&gt;&lt;/a&gt;&lt;br/&gt;
&lt;a href="http://feedads.g.doubleclick.net/~a/jrSOUc5WKPHvVv4UeZTG-IkVeF8/1/da"&gt;&lt;img src="http://feedads.g.doubleclick.net/~a/jrSOUc5WKPHvVv4UeZTG-IkVeF8/1/di" border="0" ismap="true"&gt;&lt;/img&gt;&lt;/a&gt;&lt;/p&gt;&lt;img src="http://feeds.feedburner.com/~r/VijaysTechnicalSpot/~4/-cBLfoSNBfk" height="1" width="1"/&gt;</content><link rel="replies" type="application/atom+xml" href="http://vijaysspot.blogspot.com/feeds/2781059103713835137/comments/default" title="Post Comments" /><link rel="replies" type="text/html" href="http://vijaysspot.blogspot.com/2011/09/yaml-yes-no-maybe.html#comment-form" title="0 Comments" /><link rel="edit" type="application/atom+xml" href="http://www.blogger.com/feeds/4462497484400593443/posts/default/2781059103713835137?v=2" /><link rel="self" type="application/atom+xml" href="http://www.blogger.com/feeds/4462497484400593443/posts/default/2781059103713835137?v=2" /><link rel="alternate" type="text/html" href="http://feedproxy.google.com/~r/VijaysTechnicalSpot/~3/-cBLfoSNBfk/yaml-yes-no-maybe.html" title="Yaml - Yes? No? Maybe?" /><author><name>Vijay Aravamudhan</name><uri>http://www.blogger.com/profile/05637309012758011714</uri><email>noreply@blogger.com</email><gd:image rel="http://schemas.google.com/g/2005#thumbnail" width="16" height="16" src="http://img2.blogblog.com/img/b16-rounded.gif" /></author><thr:total>0</thr:total><feedburner:origLink>http://vijaysspot.blogspot.com/2011/09/yaml-yes-no-maybe.html</feedburner:origLink></entry><entry gd:etag="W/&quot;Ck4HR3czeip7ImA9WhdVGEg.&quot;"><id>tag:blogger.com,1999:blog-4462497484400593443.post-3365618105326109959</id><published>2011-09-24T02:55:00.000-05:00</published><updated>2011-09-24T02:55:36.982-05:00</updated><app:edited xmlns:app="http://www.w3.org/2007/app">2011-09-24T02:55:36.982-05:00</app:edited><category scheme="http://www.blogger.com/atom/ns#" term="ruby" /><category scheme="http://www.blogger.com/atom/ns#" term="japanese" /><category scheme="http://www.blogger.com/atom/ns#" term="yml" /><category scheme="http://www.blogger.com/atom/ns#" term="i18n" /><title>yaml and japanese - translate.rb</title><content type="html">I had an interesting problem which grew incrementally a couple of weeks ago - and I wanted to share the experience. The problem statement was simple enough: we needed to internationalize the application that I am working on. Since this seemed simple enough with the rails-i18n gem, I wanted to generate the corresponding yml files from a master one automatically by invoking the google translator service. This seemed simple enough - but there was something I did not take into account. And that was: that the default yaml library does not have the ability to store content in languages like japanese. The way it bypasses this is to convert all such characters into unicode and store it (while writing to the yml file) - but this does not play nice when the same file is read in by rails. Enter the ya2yaml gem. This gem was written (not by me) to solve exactly this problem!
Finally, I could invoke the google translator service and write the yml file directly - and my site now shows up with katakana characters correctly!

To help others with the same problem, here is the &lt;a href="https://gist.github.com/1126964"&gt;code&lt;/a&gt;.
&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/4462497484400593443-3365618105326109959?l=vijaysspot.blogspot.com' alt='' /&gt;&lt;/div&gt;
&lt;p&gt;&lt;a href="http://feedads.g.doubleclick.net/~a/8vy9T4FXMAHl3SNQlqoz4vPR0pM/0/da"&gt;&lt;img src="http://feedads.g.doubleclick.net/~a/8vy9T4FXMAHl3SNQlqoz4vPR0pM/0/di" border="0" ismap="true"&gt;&lt;/img&gt;&lt;/a&gt;&lt;br/&gt;
&lt;a href="http://feedads.g.doubleclick.net/~a/8vy9T4FXMAHl3SNQlqoz4vPR0pM/1/da"&gt;&lt;img src="http://feedads.g.doubleclick.net/~a/8vy9T4FXMAHl3SNQlqoz4vPR0pM/1/di" border="0" ismap="true"&gt;&lt;/img&gt;&lt;/a&gt;&lt;/p&gt;&lt;img src="http://feeds.feedburner.com/~r/VijaysTechnicalSpot/~4/IpUfGGeXO8I" height="1" width="1"/&gt;</content><link rel="replies" type="application/atom+xml" href="http://vijaysspot.blogspot.com/feeds/3365618105326109959/comments/default" title="Post Comments" /><link rel="replies" type="text/html" href="http://vijaysspot.blogspot.com/2011/09/yaml-and-japanese-translaterb.html#comment-form" title="0 Comments" /><link rel="edit" type="application/atom+xml" href="http://www.blogger.com/feeds/4462497484400593443/posts/default/3365618105326109959?v=2" /><link rel="self" type="application/atom+xml" href="http://www.blogger.com/feeds/4462497484400593443/posts/default/3365618105326109959?v=2" /><link rel="alternate" type="text/html" href="http://feedproxy.google.com/~r/VijaysTechnicalSpot/~3/IpUfGGeXO8I/yaml-and-japanese-translaterb.html" title="yaml and japanese - translate.rb" /><author><name>Vijay Aravamudhan</name><uri>http://www.blogger.com/profile/05637309012758011714</uri><email>noreply@blogger.com</email><gd:image rel="http://schemas.google.com/g/2005#thumbnail" width="16" height="16" src="http://img2.blogblog.com/img/b16-rounded.gif" /></author><thr:total>0</thr:total><feedburner:origLink>http://vijaysspot.blogspot.com/2011/09/yaml-and-japanese-translaterb.html</feedburner:origLink></entry><entry gd:etag="W/&quot;A04FRnk_fip7ImA9WhZTGE4.&quot;"><id>tag:blogger.com,1999:blog-4462497484400593443.post-6015168597702946998</id><published>2011-03-22T19:25:00.000-05:00</published><updated>2011-03-22T19:25:17.746-05:00</updated><app:edited xmlns:app="http://www.w3.org/2007/app">2011-03-22T19:25:17.746-05:00</app:edited><category scheme="http://www.blogger.com/atom/ns#" term="java" /><title>junitRunner</title><content type="html">I have almost given up on working on Java for the past 3+ years, but I am currently assigned to a project that is heavily into Java. When I landed here, I was pleasantly surprised to see most of the devs using &lt;a href="http://eclipse.org/"&gt;Eclipse&lt;/a&gt;. The daily workflow involved running a lot of junit tests, and when I was pairing with a dev, I noticed that he ran the tests using the mouse (all tests in a suite), and then reran only a specific failed test - using his mouse. This was exactly the usecase for the &lt;a href="http://sourceforge.net/projects/junitrunner/"&gt;junitrunner&lt;/a&gt; eclipse plugin!&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/4462497484400593443-6015168597702946998?l=vijaysspot.blogspot.com' alt='' /&gt;&lt;/div&gt;
&lt;p&gt;&lt;a href="http://feedads.g.doubleclick.net/~a/tm1cCTnvLFtJr1afx0cpTmZ6SQ0/0/da"&gt;&lt;img src="http://feedads.g.doubleclick.net/~a/tm1cCTnvLFtJr1afx0cpTmZ6SQ0/0/di" border="0" ismap="true"&gt;&lt;/img&gt;&lt;/a&gt;&lt;br/&gt;
&lt;a href="http://feedads.g.doubleclick.net/~a/tm1cCTnvLFtJr1afx0cpTmZ6SQ0/1/da"&gt;&lt;img src="http://feedads.g.doubleclick.net/~a/tm1cCTnvLFtJr1afx0cpTmZ6SQ0/1/di" border="0" ismap="true"&gt;&lt;/img&gt;&lt;/a&gt;&lt;/p&gt;&lt;img src="http://feeds.feedburner.com/~r/VijaysTechnicalSpot/~4/pvXN_5CaPyU" height="1" width="1"/&gt;</content><link rel="replies" type="application/atom+xml" href="http://vijaysspot.blogspot.com/feeds/6015168597702946998/comments/default" title="Post Comments" /><link rel="replies" type="text/html" href="http://vijaysspot.blogspot.com/2011/03/junitrunner.html#comment-form" title="0 Comments" /><link rel="edit" type="application/atom+xml" href="http://www.blogger.com/feeds/4462497484400593443/posts/default/6015168597702946998?v=2" /><link rel="self" type="application/atom+xml" href="http://www.blogger.com/feeds/4462497484400593443/posts/default/6015168597702946998?v=2" /><link rel="alternate" type="text/html" href="http://feedproxy.google.com/~r/VijaysTechnicalSpot/~3/pvXN_5CaPyU/junitrunner.html" title="junitRunner" /><author><name>Vijay Aravamudhan</name><uri>http://www.blogger.com/profile/05637309012758011714</uri><email>noreply@blogger.com</email><gd:image rel="http://schemas.google.com/g/2005#thumbnail" width="16" height="16" src="http://img2.blogblog.com/img/b16-rounded.gif" /></author><thr:total>0</thr:total><feedburner:origLink>http://vijaysspot.blogspot.com/2011/03/junitrunner.html</feedburner:origLink></entry><entry gd:etag="W/&quot;CkQMRX89fip7ImA9WhRSF00.&quot;"><id>tag:blogger.com,1999:blog-4462497484400593443.post-969867568751512793</id><published>2011-03-18T22:49:00.000-05:00</published><updated>2011-11-19T04:59:44.166-06:00</updated><app:edited xmlns:app="http://www.w3.org/2007/app">2011-11-19T04:59:44.166-06:00</app:edited><category scheme="http://www.blogger.com/atom/ns#" term="ruby" /><category scheme="http://www.blogger.com/atom/ns#" term="rspec" /><title>Stubbing constants for tests</title><content type="html">&lt;div dir="ltr" style="text-align: left;" trbidi="on"&gt;
Yesterday, I read a blog post about &lt;a href="http://techie.lucaspr.im/stubbing-class-constants-when-testing/"&gt;stubbing class constants for testing&lt;/a&gt;. I think using the before(:all) and after(:all) hooks are not the best way to achieve this. The reasons being that:&lt;br /&gt;
1) This happens for all test methods in that spec file - and is not limited to the [typically] few test methods that &lt;i&gt;do&lt;/i&gt; need overridden values.&lt;br /&gt;
2) Ruby has an elegant mechanism with closures and 'yield', which is not being used.&lt;br /&gt;
&lt;br /&gt;
Instead of the method suggested above, IMHO, this is better:&lt;br /&gt;
&lt;script src="https://gist.github.com/877198.js?file=gistfile1.rb"&gt;
&lt;/script&gt;&lt;br /&gt;
&lt;br /&gt;
The above code block ensures that as soon as the block returns, the constants are reset to the old values thus making each test clean up after itself.&lt;/div&gt;&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/4462497484400593443-969867568751512793?l=vijaysspot.blogspot.com' alt='' /&gt;&lt;/div&gt;
&lt;p&gt;&lt;a href="http://feedads.g.doubleclick.net/~a/p8PiaENwFTbTLlK3u8Wxxz8dNgo/0/da"&gt;&lt;img src="http://feedads.g.doubleclick.net/~a/p8PiaENwFTbTLlK3u8Wxxz8dNgo/0/di" border="0" ismap="true"&gt;&lt;/img&gt;&lt;/a&gt;&lt;br/&gt;
&lt;a href="http://feedads.g.doubleclick.net/~a/p8PiaENwFTbTLlK3u8Wxxz8dNgo/1/da"&gt;&lt;img src="http://feedads.g.doubleclick.net/~a/p8PiaENwFTbTLlK3u8Wxxz8dNgo/1/di" border="0" ismap="true"&gt;&lt;/img&gt;&lt;/a&gt;&lt;/p&gt;&lt;img src="http://feeds.feedburner.com/~r/VijaysTechnicalSpot/~4/Oc77ZfwFC8g" height="1" width="1"/&gt;</content><link rel="replies" type="application/atom+xml" href="http://vijaysspot.blogspot.com/feeds/969867568751512793/comments/default" title="Post Comments" /><link rel="replies" type="text/html" href="http://vijaysspot.blogspot.com/2011/03/stubbing-constants-for-tests.html#comment-form" title="0 Comments" /><link rel="edit" type="application/atom+xml" href="http://www.blogger.com/feeds/4462497484400593443/posts/default/969867568751512793?v=2" /><link rel="self" type="application/atom+xml" href="http://www.blogger.com/feeds/4462497484400593443/posts/default/969867568751512793?v=2" /><link rel="alternate" type="text/html" href="http://feedproxy.google.com/~r/VijaysTechnicalSpot/~3/Oc77ZfwFC8g/stubbing-constants-for-tests.html" title="Stubbing constants for tests" /><author><name>Vijay Aravamudhan</name><uri>http://www.blogger.com/profile/05637309012758011714</uri><email>noreply@blogger.com</email><gd:image rel="http://schemas.google.com/g/2005#thumbnail" width="16" height="16" src="http://img2.blogblog.com/img/b16-rounded.gif" /></author><thr:total>0</thr:total><feedburner:origLink>http://vijaysspot.blogspot.com/2011/03/stubbing-constants-for-tests.html</feedburner:origLink></entry><entry gd:etag="W/&quot;CE4HSXY-fip7ImA9WhZTE0U.&quot;"><id>tag:blogger.com,1999:blog-4462497484400593443.post-4923519758785539503</id><published>2011-03-17T12:23:00.001-05:00</published><updated>2011-03-17T12:28:58.856-05:00</updated><app:edited xmlns:app="http://www.w3.org/2007/app">2011-03-17T12:28:58.856-05:00</app:edited><category scheme="http://www.blogger.com/atom/ns#" term="git" /><title>Keep your local git checkout clean</title><content type="html">In my previous project, active development always happened in trunk except for certain scenarios: spikes, fixing bugs on production release branches, completing some unfinished work on the next production release branch, etc. This caused a lot of our dev pairing machines to have multiple branches. And since we used to rotate pairs very often (every morning), whenever I went to pair on a different machine, I would first run this script:&lt;br /&gt;
&lt;br /&gt;
&lt;script src="https://gist.github.com/874724.js?file=gistfile1.rb"&gt;&lt;/script&gt;&lt;br /&gt;
&lt;br /&gt;
The reason was very simple. When I am working on master, and the machine had multiple other branches (some of them having local changes, while others not), each time I did a push to the remote origin, it would complain (since git tries to push all local branches that track remotes, by default). Of course, we could have written our commit [rake] task in such a way that it deciphered the current branch and only pushed that. But, IMHO, its better to have a clean workspace rather than finding ways to bypass it. I know others who have a different opinion - the most common one being git is a DVCS and that's how it is supposed to work. That may be the case - everyone is entitled to their opinions. Mine is just that my workspace should be clean.&lt;br /&gt;
&lt;br /&gt;
The above script will go through all the local branches, and pull from their respective remotes. If there is no merge conflict (by parsing the status message), then it would revert back to the master branch and delete the other local branch. This step is repeated for each locally existing branch.&lt;br /&gt;
&lt;br /&gt;
This script and some more that I used to loop through and maintain multiple git repositories are shared through my &lt;a href="https://github.com/vraravam/"&gt;github account&lt;/a&gt;.&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/4462497484400593443-4923519758785539503?l=vijaysspot.blogspot.com' alt='' /&gt;&lt;/div&gt;
&lt;p&gt;&lt;a href="http://feedads.g.doubleclick.net/~a/w8ONfojyCJplRBUzDNq2tkv9M8U/0/da"&gt;&lt;img src="http://feedads.g.doubleclick.net/~a/w8ONfojyCJplRBUzDNq2tkv9M8U/0/di" border="0" ismap="true"&gt;&lt;/img&gt;&lt;/a&gt;&lt;br/&gt;
&lt;a href="http://feedads.g.doubleclick.net/~a/w8ONfojyCJplRBUzDNq2tkv9M8U/1/da"&gt;&lt;img src="http://feedads.g.doubleclick.net/~a/w8ONfojyCJplRBUzDNq2tkv9M8U/1/di" border="0" ismap="true"&gt;&lt;/img&gt;&lt;/a&gt;&lt;/p&gt;&lt;img src="http://feeds.feedburner.com/~r/VijaysTechnicalSpot/~4/9YquyOUMRqI" height="1" width="1"/&gt;</content><link rel="replies" type="application/atom+xml" href="http://vijaysspot.blogspot.com/feeds/4923519758785539503/comments/default" title="Post Comments" /><link rel="replies" type="text/html" href="http://vijaysspot.blogspot.com/2011/03/keep-your-local-git-checkout-clean.html#comment-form" title="0 Comments" /><link rel="edit" type="application/atom+xml" href="http://www.blogger.com/feeds/4462497484400593443/posts/default/4923519758785539503?v=2" /><link rel="self" type="application/atom+xml" href="http://www.blogger.com/feeds/4462497484400593443/posts/default/4923519758785539503?v=2" /><link rel="alternate" type="text/html" href="http://feedproxy.google.com/~r/VijaysTechnicalSpot/~3/9YquyOUMRqI/keep-your-local-git-checkout-clean.html" title="Keep your local git checkout clean" /><author><name>Vijay Aravamudhan</name><uri>http://www.blogger.com/profile/05637309012758011714</uri><email>noreply@blogger.com</email><gd:image rel="http://schemas.google.com/g/2005#thumbnail" width="16" height="16" src="http://img2.blogblog.com/img/b16-rounded.gif" /></author><thr:total>0</thr:total><feedburner:origLink>http://vijaysspot.blogspot.com/2011/03/keep-your-local-git-checkout-clean.html</feedburner:origLink></entry><entry gd:etag="W/&quot;DEQNSXoyfyp7ImA9WhZTE04.&quot;"><id>tag:blogger.com,1999:blog-4462497484400593443.post-7595220023247661754</id><published>2011-03-16T23:33:00.000-05:00</published><updated>2011-03-16T23:33:18.497-05:00</updated><app:edited xmlns:app="http://www.w3.org/2007/app">2011-03-16T23:33:18.497-05:00</app:edited><category scheme="http://www.blogger.com/atom/ns#" term="rails tips/tricks" /><title>Destroy does not actually mean destroy!</title><content type="html">When I started learning Ruby and Rails, I was fascinated with the rails scaffold generated code. There I was typing away to glory to come up with a webpage on a Java stack barely managing to keep it following a pattern, and here was a simple command line script which when invoked with the correct parameters, would generate the same for me in Ruby - wow!&lt;br /&gt;
&lt;br /&gt;
And then I learned the first step - dont trust the generated code implicitly. Case in point: we had a [business/domain] scenario where the destroy action on an ActiveRecord would need to verify that some condition was satisfied, and if these conditions were not met, the destroy action would raise an error. The scenario in our case was that the entity was in use in some other relationships, and until those were deleted first, this entity could not be destroyed.&lt;br /&gt;
&lt;br /&gt;
For the case of the entity creation, Rails provides a convenient callback mechanism called validations. The same is the case for updates. But for destroys, Rails assumes that all is well. This is carried on into the code generated for the controllers specifically for the destroy action. It just returns a 200 status code. But, as evidenced in our case, that is not always the case, and we had to manually edit all such scaffold-generated code to "fix" the issue.&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/4462497484400593443-7595220023247661754?l=vijaysspot.blogspot.com' alt='' /&gt;&lt;/div&gt;
&lt;p&gt;&lt;a href="http://feedads.g.doubleclick.net/~a/WK3BMPTmJFSsuPPZXOWJLfYCqFE/0/da"&gt;&lt;img src="http://feedads.g.doubleclick.net/~a/WK3BMPTmJFSsuPPZXOWJLfYCqFE/0/di" border="0" ismap="true"&gt;&lt;/img&gt;&lt;/a&gt;&lt;br/&gt;
&lt;a href="http://feedads.g.doubleclick.net/~a/WK3BMPTmJFSsuPPZXOWJLfYCqFE/1/da"&gt;&lt;img src="http://feedads.g.doubleclick.net/~a/WK3BMPTmJFSsuPPZXOWJLfYCqFE/1/di" border="0" ismap="true"&gt;&lt;/img&gt;&lt;/a&gt;&lt;/p&gt;&lt;img src="http://feeds.feedburner.com/~r/VijaysTechnicalSpot/~4/9pnolwfEiSc" height="1" width="1"/&gt;</content><link rel="replies" type="application/atom+xml" href="http://vijaysspot.blogspot.com/feeds/7595220023247661754/comments/default" title="Post Comments" /><link rel="replies" type="text/html" href="http://vijaysspot.blogspot.com/2011/03/destroy-does-not-actually-mean-destroy.html#comment-form" title="0 Comments" /><link rel="edit" type="application/atom+xml" href="http://www.blogger.com/feeds/4462497484400593443/posts/default/7595220023247661754?v=2" /><link rel="self" type="application/atom+xml" href="http://www.blogger.com/feeds/4462497484400593443/posts/default/7595220023247661754?v=2" /><link rel="alternate" type="text/html" href="http://feedproxy.google.com/~r/VijaysTechnicalSpot/~3/9pnolwfEiSc/destroy-does-not-actually-mean-destroy.html" title="Destroy does not actually mean destroy!" /><author><name>Vijay Aravamudhan</name><uri>http://www.blogger.com/profile/05637309012758011714</uri><email>noreply@blogger.com</email><gd:image rel="http://schemas.google.com/g/2005#thumbnail" width="16" height="16" src="http://img2.blogblog.com/img/b16-rounded.gif" /></author><thr:total>0</thr:total><feedburner:origLink>http://vijaysspot.blogspot.com/2011/03/destroy-does-not-actually-mean-destroy.html</feedburner:origLink></entry><entry gd:etag="W/&quot;Ak4CQXszcCp7ImA9WhZTFEo.&quot;"><id>tag:blogger.com,1999:blog-4462497484400593443.post-496332330795886293</id><published>2011-03-16T23:13:00.003-05:00</published><updated>2011-03-18T15:09:20.588-05:00</updated><app:edited xmlns:app="http://www.w3.org/2007/app">2011-03-18T15:09:20.588-05:00</app:edited><category scheme="http://www.blogger.com/atom/ns#" term="firefox" /><category scheme="http://www.blogger.com/atom/ns#" term="thunderbird" /><title>Backing up Firefox and Thunderbird profiles</title><content type="html">I have been using Firefox and Thunderbird for the past 10 years or so - since the time when hard drive space was a precious commodity. As I started using more than one machine (or when I completely trashed my OS and had to reinstall it from scratch), I came across a need to copy and maintain these profiles. Since I wanted them to be in some "known" location, and since both these excellent mozilla products provide a way to edit an ini file and thus "move" the profile folders, I have been doing that as well for the past several years. (For more information on where to find your profile directory for your OS, and what to change, please look &lt;a href="http://kb.mozillazine.org/Profiles.ini_file"&gt;here&lt;/a&gt;.)&lt;br /&gt;
&lt;br /&gt;
I ran across an initial version of this script &lt;a href="http://ubuntuforums.org/showthread.php?t=1088094&amp;page=4"&gt;here&lt;/a&gt;&lt;br /&gt;
As I started experimenting with bash scripts, I enhanced the above script (that would check if the program/application was running currently, and if not, it would do some common house-cleaning within these profile folders), with some new functionality, like delete some cache folders, etc. &lt;b&gt;This cleanup should never be run when the application is in use - so be warned.&lt;/b&gt; Once the cleaning was done, I also added a cmd-line switch that would go ahead and create a tgz file for backups.&lt;br /&gt;
&lt;br /&gt;
In case anyone is interested, here is the script:&lt;br /&gt;
&lt;script src="https://gist.github.com/873815.js?file=gistfile1.eclass"&gt;&lt;/script&gt;&lt;br /&gt;
&lt;br /&gt;
This script has been written in bash, and so can be run on windows if you use &lt;a href="http://www.cygwin.com/"&gt;cygwin&lt;/a&gt;.&lt;br /&gt;
&lt;br /&gt;
You can of course take the script and modify it as you wish. Just be warned (again) that if you do edit it, dont remove the check for skipping the house-cleaning if the application is running. Also, if you end up making any changes, I would appreciate it if you could send me the changes to be incorporated into my copy.&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/4462497484400593443-496332330795886293?l=vijaysspot.blogspot.com' alt='' /&gt;&lt;/div&gt;
&lt;p&gt;&lt;a href="http://feedads.g.doubleclick.net/~a/FzC7bijmpZBk09KveX0nrUK5tWU/0/da"&gt;&lt;img src="http://feedads.g.doubleclick.net/~a/FzC7bijmpZBk09KveX0nrUK5tWU/0/di" border="0" ismap="true"&gt;&lt;/img&gt;&lt;/a&gt;&lt;br/&gt;
&lt;a href="http://feedads.g.doubleclick.net/~a/FzC7bijmpZBk09KveX0nrUK5tWU/1/da"&gt;&lt;img src="http://feedads.g.doubleclick.net/~a/FzC7bijmpZBk09KveX0nrUK5tWU/1/di" border="0" ismap="true"&gt;&lt;/img&gt;&lt;/a&gt;&lt;/p&gt;&lt;img src="http://feeds.feedburner.com/~r/VijaysTechnicalSpot/~4/5quBZ09Ii4U" height="1" width="1"/&gt;</content><link rel="replies" type="application/atom+xml" href="http://vijaysspot.blogspot.com/feeds/496332330795886293/comments/default" title="Post Comments" /><link rel="replies" type="text/html" href="http://vijaysspot.blogspot.com/2011/03/backing-up-firefox-and-thunderbird.html#comment-form" title="0 Comments" /><link rel="edit" type="application/atom+xml" href="http://www.blogger.com/feeds/4462497484400593443/posts/default/496332330795886293?v=2" /><link rel="self" type="application/atom+xml" href="http://www.blogger.com/feeds/4462497484400593443/posts/default/496332330795886293?v=2" /><link rel="alternate" type="text/html" href="http://feedproxy.google.com/~r/VijaysTechnicalSpot/~3/5quBZ09Ii4U/backing-up-firefox-and-thunderbird.html" title="Backing up Firefox and Thunderbird profiles" /><author><name>Vijay Aravamudhan</name><uri>http://www.blogger.com/profile/05637309012758011714</uri><email>noreply@blogger.com</email><gd:image rel="http://schemas.google.com/g/2005#thumbnail" width="16" height="16" src="http://img2.blogblog.com/img/b16-rounded.gif" /></author><thr:total>0</thr:total><feedburner:origLink>http://vijaysspot.blogspot.com/2011/03/backing-up-firefox-and-thunderbird.html</feedburner:origLink></entry><entry gd:etag="W/&quot;DkUFRXw6fSp7ImA9WhZTE04.&quot;"><id>tag:blogger.com,1999:blog-4462497484400593443.post-2214332039165783630</id><published>2011-03-16T22:53:00.000-05:00</published><updated>2011-03-16T22:56:54.215-05:00</updated><app:edited xmlns:app="http://www.w3.org/2007/app">2011-03-16T22:56:54.215-05:00</app:edited><category scheme="http://www.blogger.com/atom/ns#" term="truecrypt" /><category scheme="http://www.blogger.com/atom/ns#" term="dropbox" /><title>Git &gt; TrueCrypt &gt; Dropbox: A truly geeky way to backup your home folder across machines and OSes</title><content type="html">I was searching for ways to backup and sync up my profiles across different machines and across different *nix based OSes that I use (Mac OSX and Ubuntu). The stuff I wanted to sync was stuff like my .zshrc, .vimrc, .irbrc, .ssh, etc. At the same time, there were my firefox and thunderbird profiles that needed to be synced up as well (disregarding the fact that I use some add-ons for these which are OS-specific). Since some of these folders also contained sensitive information, any storage/sync mechanism that I arrived at would need to hold the data in an encrypted fashion. Lastly, I thought it would be good to have a historical backup of these same files/folders.&lt;br /&gt;
&lt;br /&gt;
When I was in India on an assignment for my employer (&lt;a href="http://www.thoughtworks.com"&gt;Thoughtworks&lt;/a&gt;), I had some time during the evenings to play around with these requirements and came up with a geeky solution. I would create a git repository (most of the stuff I was storing were ASCII files, not binaries. This was important since git does not scale well for binary files. Next this git repository would go into a &lt;a href="http://www.truecrypt.org"&gt;TrueCrypt&lt;/a&gt; container which was configured with sufficient space. Finally, the whole TrueCrypt container [file] would go into my &lt;a href="http://www.dropbox.com"&gt;DropBox&lt;/a&gt; account. Done! This would solve all my problems (at least I thought so at that time, but...)&lt;br /&gt;
&lt;br /&gt;
There are some obvious limitations of this approach:&lt;br /&gt;
&lt;ul&gt;&lt;li&gt;The TrueCrypt container once created, cannot be dynamically made to expand&lt;/li&gt;
&lt;li&gt;Even if the TC file were recreated with a higher storage capacity, it would still need to adhere to the size of my dropbox account (they currently give 2GB free for the basic/free account)&lt;/li&gt;
&lt;li&gt;Syncing a 1.5GB file across three machines - all of them wireless - was seriously overloading my home DSL setup!&lt;/li&gt;
&lt;/ul&gt;&lt;br /&gt;
Enter &lt;a href="http://sparkleshare.org/"&gt;SparkleShare&lt;/a&gt; - the syncing software where you can store the data not on the cloud, but on your own drives! This was featured on one of the ubuntu blogs a few days ago - and it uses the same pattern for storing the data: your data/files/folders are actually encrypted (in lieu of my TrueCrypt step) and stored inside a git repo on whatever network storage device you configure! Yay!&lt;br /&gt;
The only hiccup right now is that their software is still in beta for both Mac and Linux - but maybe I will try it out sometime soon and post my review/experiences.&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/4462497484400593443-2214332039165783630?l=vijaysspot.blogspot.com' alt='' /&gt;&lt;/div&gt;
&lt;p&gt;&lt;a href="http://feedads.g.doubleclick.net/~a/LH3EdYxULpjqwzpZ0GIsDj7T9HI/0/da"&gt;&lt;img src="http://feedads.g.doubleclick.net/~a/LH3EdYxULpjqwzpZ0GIsDj7T9HI/0/di" border="0" ismap="true"&gt;&lt;/img&gt;&lt;/a&gt;&lt;br/&gt;
&lt;a href="http://feedads.g.doubleclick.net/~a/LH3EdYxULpjqwzpZ0GIsDj7T9HI/1/da"&gt;&lt;img src="http://feedads.g.doubleclick.net/~a/LH3EdYxULpjqwzpZ0GIsDj7T9HI/1/di" border="0" ismap="true"&gt;&lt;/img&gt;&lt;/a&gt;&lt;/p&gt;&lt;img src="http://feeds.feedburner.com/~r/VijaysTechnicalSpot/~4/CI0D6c8eg24" height="1" width="1"/&gt;</content><link rel="replies" type="application/atom+xml" href="http://vijaysspot.blogspot.com/feeds/2214332039165783630/comments/default" title="Post Comments" /><link rel="replies" type="text/html" href="http://vijaysspot.blogspot.com/2011/03/git-truecrypt-dropbox-truly-geeky-way.html#comment-form" title="2 Comments" /><link rel="edit" type="application/atom+xml" href="http://www.blogger.com/feeds/4462497484400593443/posts/default/2214332039165783630?v=2" /><link rel="self" type="application/atom+xml" href="http://www.blogger.com/feeds/4462497484400593443/posts/default/2214332039165783630?v=2" /><link rel="alternate" type="text/html" href="http://feedproxy.google.com/~r/VijaysTechnicalSpot/~3/CI0D6c8eg24/git-truecrypt-dropbox-truly-geeky-way.html" title="Git &gt; TrueCrypt &gt; Dropbox: A truly geeky way to backup your home folder across machines and OSes" /><author><name>Vijay Aravamudhan</name><uri>http://www.blogger.com/profile/05637309012758011714</uri><email>noreply@blogger.com</email><gd:image rel="http://schemas.google.com/g/2005#thumbnail" width="16" height="16" src="http://img2.blogblog.com/img/b16-rounded.gif" /></author><thr:total>2</thr:total><feedburner:origLink>http://vijaysspot.blogspot.com/2011/03/git-truecrypt-dropbox-truly-geeky-way.html</feedburner:origLink></entry><entry gd:etag="W/&quot;Ck4BRH88cCp7ImA9Wx9aFU0.&quot;"><id>tag:blogger.com,1999:blog-4462497484400593443.post-1174103108699367630</id><published>2011-03-07T06:29:00.000-06:00</published><updated>2011-03-07T06:29:15.178-06:00</updated><app:edited xmlns:app="http://www.w3.org/2007/app">2011-03-07T06:29:15.178-06:00</app:edited><category scheme="http://www.blogger.com/atom/ns#" term="rails configuration" /><title>externalizing configurations across different rails environments</title><content type="html">In all the rails projects that I have worked on during the past 3 years, I have come across a pattern where some configurations need to be externalized. These configurations could include sensitive information (authentication passwords for a 3rd party system), application runtime information (like number of items to show in a paginated list), environment-specific information (like development vs uat vs production). To accomplish this, it is very trivial to write a Registry module that would load up a few yaml files into a hash in memory. Each file is loaded and if the same key exists from a previous file, the new value would super-impose the one in memory - so that ultimately, there is one "master" copy that the application runtime would use. (This concept has also been prevalent for more than a decade in the Java world - I used it in 2000). As I said before, this is pretty trivial to write. While browsing in github, I came across this project: https://github.com/lukeredpath/simpleconfig - which has almost exactly the same features, in a cleaner way! Now onto forking that project and converting it into a gem...&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/4462497484400593443-1174103108699367630?l=vijaysspot.blogspot.com' alt='' /&gt;&lt;/div&gt;
&lt;p&gt;&lt;a href="http://feedads.g.doubleclick.net/~a/MiEbuYqRKjfa8pei6F8UWBijUJ4/0/da"&gt;&lt;img src="http://feedads.g.doubleclick.net/~a/MiEbuYqRKjfa8pei6F8UWBijUJ4/0/di" border="0" ismap="true"&gt;&lt;/img&gt;&lt;/a&gt;&lt;br/&gt;
&lt;a href="http://feedads.g.doubleclick.net/~a/MiEbuYqRKjfa8pei6F8UWBijUJ4/1/da"&gt;&lt;img src="http://feedads.g.doubleclick.net/~a/MiEbuYqRKjfa8pei6F8UWBijUJ4/1/di" border="0" ismap="true"&gt;&lt;/img&gt;&lt;/a&gt;&lt;/p&gt;&lt;img src="http://feeds.feedburner.com/~r/VijaysTechnicalSpot/~4/VdCGkYsQBUk" height="1" width="1"/&gt;</content><link rel="replies" type="application/atom+xml" href="http://vijaysspot.blogspot.com/feeds/1174103108699367630/comments/default" title="Post Comments" /><link rel="replies" type="text/html" href="http://vijaysspot.blogspot.com/2011/03/externalizing-configurations-across.html#comment-form" title="0 Comments" /><link rel="edit" type="application/atom+xml" href="http://www.blogger.com/feeds/4462497484400593443/posts/default/1174103108699367630?v=2" /><link rel="self" type="application/atom+xml" href="http://www.blogger.com/feeds/4462497484400593443/posts/default/1174103108699367630?v=2" /><link rel="alternate" type="text/html" href="http://feedproxy.google.com/~r/VijaysTechnicalSpot/~3/VdCGkYsQBUk/externalizing-configurations-across.html" title="externalizing configurations across different rails environments" /><author><name>Vijay Aravamudhan</name><uri>http://www.blogger.com/profile/05637309012758011714</uri><email>noreply@blogger.com</email><gd:image rel="http://schemas.google.com/g/2005#thumbnail" width="16" height="16" src="http://img2.blogblog.com/img/b16-rounded.gif" /></author><thr:total>0</thr:total><feedburner:origLink>http://vijaysspot.blogspot.com/2011/03/externalizing-configurations-across.html</feedburner:origLink></entry><entry gd:etag="W/&quot;DUMCQX4zeSp7ImA9Wx9bGUg.&quot;"><id>tag:blogger.com,1999:blog-4462497484400593443.post-196176710004576300</id><published>2011-02-28T22:55:00.000-06:00</published><updated>2011-02-28T23:31:00.081-06:00</updated><app:edited xmlns:app="http://www.w3.org/2007/app">2011-02-28T23:31:00.081-06:00</app:edited><category scheme="http://www.blogger.com/atom/ns#" term="rails migrations" /><title>Consolidating rails migrations</title><content type="html">With the meteoric rise in adoption of rails as a framework to develop business applications, we as developers need to also remember that these same codebases need some amount of love/house-cleaning from time to time. One of the areas that I want to highlight is database migrations.&lt;br /&gt;
&lt;br /&gt;
As new releases of the app is deployed to production, and development of new features (needing new migrations) continues, it would be a good practice to consolidate previously run migrations into a single file. The idea is simple:&lt;br /&gt;
&lt;ul&gt;&lt;li&gt;Use the [default] VERSION environment variable to specify the migration till which you want to consolidate&lt;/li&gt;
&lt;li&gt;Drop, create and migrate the database till this version&lt;/li&gt;
&lt;li&gt;Copy the resulting schema.rb file into the migration (replacing the old content of the 'self.up' method) in migration with that same version number&lt;/li&gt;
&lt;li&gt;Typically you will never go below this migration, so raise an 'ActiveRecord::IrreversibleMigration' exception in the corresponding 'self.down' method&lt;/li&gt;
&lt;li&gt;Delete older migrations (prior to the specified one)&lt;/li&gt;
&lt;li&gt;Commit into your scm&lt;/li&gt;
&lt;/ul&gt;&lt;br /&gt;
At my previous client, we implemented a rake task to accomplish these steps in an automated fashion. Once a release went to production and after a couple of days of "settling down", this rake task was run with the version of the [production] db.&lt;br /&gt;
&lt;br /&gt;
The advantage of doing this is:&lt;br /&gt;
&lt;ul&gt;&lt;li&gt;Typically, as design evolves, you might rename/drop columns, drop tables, add seed data, etc which are all collapsed into a single step&lt;/li&gt;
&lt;li&gt;The number of files that need to be evaluated and run (each time the db is recreated, typically, when running tests) is smaller, and thus taking [fractionally] less amount of time&lt;/li&gt;
&lt;li&gt;Forces you, the developer, to maintain seed data outside migrations&lt;/li&gt;
&lt;/ul&gt;&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/4462497484400593443-196176710004576300?l=vijaysspot.blogspot.com' alt='' /&gt;&lt;/div&gt;
&lt;p&gt;&lt;a href="http://feedads.g.doubleclick.net/~a/WIH9DfiTLq67y8xRiM6gS4KJ4HM/0/da"&gt;&lt;img src="http://feedads.g.doubleclick.net/~a/WIH9DfiTLq67y8xRiM6gS4KJ4HM/0/di" border="0" ismap="true"&gt;&lt;/img&gt;&lt;/a&gt;&lt;br/&gt;
&lt;a href="http://feedads.g.doubleclick.net/~a/WIH9DfiTLq67y8xRiM6gS4KJ4HM/1/da"&gt;&lt;img src="http://feedads.g.doubleclick.net/~a/WIH9DfiTLq67y8xRiM6gS4KJ4HM/1/di" border="0" ismap="true"&gt;&lt;/img&gt;&lt;/a&gt;&lt;/p&gt;&lt;img src="http://feeds.feedburner.com/~r/VijaysTechnicalSpot/~4/ytEWTg7HwnI" height="1" width="1"/&gt;</content><link rel="replies" type="application/atom+xml" href="http://vijaysspot.blogspot.com/feeds/196176710004576300/comments/default" title="Post Comments" /><link rel="replies" type="text/html" href="http://vijaysspot.blogspot.com/2011/02/consolidating-rails-migrations.html#comment-form" title="0 Comments" /><link rel="edit" type="application/atom+xml" href="http://www.blogger.com/feeds/4462497484400593443/posts/default/196176710004576300?v=2" /><link rel="self" type="application/atom+xml" href="http://www.blogger.com/feeds/4462497484400593443/posts/default/196176710004576300?v=2" /><link rel="alternate" type="text/html" href="http://feedproxy.google.com/~r/VijaysTechnicalSpot/~3/ytEWTg7HwnI/consolidating-rails-migrations.html" title="Consolidating rails migrations" /><author><name>Vijay Aravamudhan</name><uri>http://www.blogger.com/profile/05637309012758011714</uri><email>noreply@blogger.com</email><gd:image rel="http://schemas.google.com/g/2005#thumbnail" width="16" height="16" src="http://img2.blogblog.com/img/b16-rounded.gif" /></author><thr:total>0</thr:total><feedburner:origLink>http://vijaysspot.blogspot.com/2011/02/consolidating-rails-migrations.html</feedburner:origLink></entry><entry gd:etag="W/&quot;D08NRXo8fip7ImA9WhZTE04.&quot;"><id>tag:blogger.com,1999:blog-4462497484400593443.post-2895857379955600506</id><published>2011-02-27T02:03:00.003-06:00</published><updated>2011-03-16T23:24:54.476-05:00</updated><app:edited xmlns:app="http://www.w3.org/2007/app">2011-03-16T23:24:54.476-05:00</app:edited><category scheme="http://www.blogger.com/atom/ns#" term="rails tips/tricks" /><title>Rails tricks: Require correctly</title><content type="html">&lt;div dir="ltr" style="text-align: left;" trbidi="on"&gt;On one of my previous projects, we noticed some strange (to us) behavior: any extra spec behavior (extra methods, config.before(:all), etc) was being loaded/defined more than once while running the whole suite of tests, but when we tried to run a single spec class (ie all tests defined within one file), this behavior was not evident. Digging further, we found that this was caused by requiring the spec_helper. As each spec file is being "processed", the require statement at the top of the file got triggered, and when a new file (at a different relative directory) was encountered, the spec_helper line would usually trigger this scenario. For eg:&lt;br /&gt;
&lt;br /&gt;
&lt;code&gt;&lt;br /&gt;
spec/a_spec.rb: require File.dirname(__FILE__) + '/spec_helper'&lt;br /&gt;
spec/models/b_spec.rb: require File.dirname(__FILE__) + '/../spec_helper'&lt;br /&gt;
spec/lib/level1/c.rb: require File.dirname(__FILE__) + '/../../spec_helper'&lt;br /&gt;
&lt;/code&gt;&lt;br /&gt;
&lt;br /&gt;
To solve this, we resorted to using the fully expanded path to the spec_helper - since this would resolve to the same file each time. In this case, the above files were changed so:&lt;br /&gt;
&lt;br /&gt;
&lt;code&gt;&lt;br /&gt;
spec/a_spec.rb: require File.expand_path('spec_helper', File.dirname(__FILE__))&lt;br /&gt;
spec/models/b_spec.rb: require File.expand_path('../spec_helper', File.dirname(__FILE__))&lt;br /&gt;
spec/lib/level1/c.rb: require File.expand_path('../../spec_helper', File.dirname(__FILE__))&lt;br /&gt;
&lt;/code&gt;&lt;br /&gt;
&lt;/div&gt;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
UPDATE: My good friend and colleague &lt;a href="http://blog.brianguthrie.com/"&gt;Brian Guthrie&lt;/a&gt; corrected me saying that this situation can be avoided if the load path is set correctly (to include the spec folder) through the rake task before actually invoking rspec. That sounds reasonable, but I have yet to try it out - and unfortunately, I have moved on from the project where this was sorely needed.&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/4462497484400593443-2895857379955600506?l=vijaysspot.blogspot.com' alt='' /&gt;&lt;/div&gt;
&lt;p&gt;&lt;a href="http://feedads.g.doubleclick.net/~a/jQowmNUwVjgSo8Sp0n0WxzLpkz8/0/da"&gt;&lt;img src="http://feedads.g.doubleclick.net/~a/jQowmNUwVjgSo8Sp0n0WxzLpkz8/0/di" border="0" ismap="true"&gt;&lt;/img&gt;&lt;/a&gt;&lt;br/&gt;
&lt;a href="http://feedads.g.doubleclick.net/~a/jQowmNUwVjgSo8Sp0n0WxzLpkz8/1/da"&gt;&lt;img src="http://feedads.g.doubleclick.net/~a/jQowmNUwVjgSo8Sp0n0WxzLpkz8/1/di" border="0" ismap="true"&gt;&lt;/img&gt;&lt;/a&gt;&lt;/p&gt;&lt;img src="http://feeds.feedburner.com/~r/VijaysTechnicalSpot/~4/dO_YAzpOIYo" height="1" width="1"/&gt;</content><link rel="replies" type="application/atom+xml" href="http://vijaysspot.blogspot.com/feeds/2895857379955600506/comments/default" title="Post Comments" /><link rel="replies" type="text/html" href="http://vijaysspot.blogspot.com/2011/02/rails-tricks-require-correctly.html#comment-form" title="0 Comments" /><link rel="edit" type="application/atom+xml" href="http://www.blogger.com/feeds/4462497484400593443/posts/default/2895857379955600506?v=2" /><link rel="self" type="application/atom+xml" href="http://www.blogger.com/feeds/4462497484400593443/posts/default/2895857379955600506?v=2" /><link rel="alternate" type="text/html" href="http://feedproxy.google.com/~r/VijaysTechnicalSpot/~3/dO_YAzpOIYo/rails-tricks-require-correctly.html" title="Rails tricks: Require correctly" /><author><name>Vijay Aravamudhan</name><uri>http://www.blogger.com/profile/05637309012758011714</uri><email>noreply@blogger.com</email><gd:image rel="http://schemas.google.com/g/2005#thumbnail" width="16" height="16" src="http://img2.blogblog.com/img/b16-rounded.gif" /></author><thr:total>0</thr:total><feedburner:origLink>http://vijaysspot.blogspot.com/2011/02/rails-tricks-require-correctly.html</feedburner:origLink></entry></feed>

