<?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>Amit Yadav &#187; Ruby on Rails</title>
	<atom:link href="http://www.amityadav.name/category/ror/feed/" rel="self" type="application/rss+xml" />
	<link>http://www.amityadav.name</link>
	<description>Things to know for effective coding</description>
	<lastBuildDate>Fri, 19 Aug 2011 17:51:59 +0000</lastBuildDate>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=3.3.1</generator>
		<item>
		<title>Fast-track your Web apps with Ruby on Rails</title>
		<link>http://www.amityadav.name/fast-track-your-web-apps-with-ruby-on-rails/</link>
		<comments>http://www.amityadav.name/fast-track-your-web-apps-with-ruby-on-rails/#comments</comments>
		<pubDate>Wed, 29 Jun 2011 03:29:23 +0000</pubDate>
		<dc:creator>Amit</dc:creator>
				<category><![CDATA[Featured]]></category>
		<category><![CDATA[Ruby on Rails]]></category>
		<category><![CDATA[Rails]]></category>
		<category><![CDATA[ror]]></category>
		<category><![CDATA[Ruby]]></category>

		<guid isPermaLink="false">http://www.amityadav.name/?p=809</guid>
		<description><![CDATA[Fast-track your Web apps with Ruby on Rails Ruby on Rails is a recent entry into the world of Web application development that is rapidly gaining mindshare, even while still in beta versions. Rails succeeds by automating the creation of the most common types of Web applications while not straightjacketing you if you want to [...]]]></description>
			<content:encoded><![CDATA[<p><a href="http://www.ibm.com/developerworks/opensource/library/l-rubyrails/index.html" target="_blank"><strong>Fast-track your Web apps with Ruby on Rails</strong></a></p>
<div id="">Ruby on Rails is a recent entry into the world of Web application development that is rapidly gaining mindshare, even while still in beta versions. Rails succeeds by automating the creation of the most common types of Web applications while not straightjacketing you if you want to add custom or atypical requirements. Moreover, compared to many Free Software libraries that perform individual aspects of a Web application, Rails contains a nicely integrated set of tools for all aspects.</div>
<p><a class="a2a_dd a2a_target addtoany_share_save" href="http://www.addtoany.com/share_save#url=http%3A%2F%2Fwww.amityadav.name%2Ffast-track-your-web-apps-with-ruby-on-rails%2F&amp;title=Fast-track%20your%20Web%20apps%20with%20Ruby%20on%20Rails" id="wpa2a_2"><img src="http://www.amityadav.name/wp-content/plugins/add-to-any/share_save_171_16.gif" width="171" height="16" alt="Share"/></a></p>]]></content:encoded>
			<wfw:commentRss>http://www.amityadav.name/fast-track-your-web-apps-with-ruby-on-rails/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Difference between delete and destroy in ActiveRecord</title>
		<link>http://www.amityadav.name/difference-between-delete-and-destroy-in-activerecord/</link>
		<comments>http://www.amityadav.name/difference-between-delete-and-destroy-in-activerecord/#comments</comments>
		<pubDate>Wed, 29 Jun 2011 03:26:20 +0000</pubDate>
		<dc:creator>Amit</dc:creator>
				<category><![CDATA[Ruby on Rails]]></category>
		<category><![CDATA[Rails]]></category>
		<category><![CDATA[ror]]></category>
		<category><![CDATA[Ruby]]></category>

		<guid isPermaLink="false">http://www.amityadav.name/?p=805</guid>
		<description><![CDATA[To delete a particular record we will go for delete or destroy methods.But according to the names both looks very similar, but the functionality wise both are different. so lets check the difference between delete and destroy methods in Active Record. Now first check what the delete method will do: Delete method deletes the row [...]]]></description>
			<content:encoded><![CDATA[<p><span class="postbody">To delete a particular record we will go for delete or destroy methods.But according to the names both looks very similar, but the functionality wise both are different. so lets check the difference between delete and destroy methods in Active Record. </span></p>
<p>Now first check what the delete method will do:</p>
<p>Delete method deletes the row with a primary key matching the id argument, using a SQL DELETE statement, and returns the number of rows deleted. Active Record objects are not instantiated, so the object&lsquo;s callbacks are not executed, including any :dependent association options or Observer methods.</p>
<p>You can delete multiple rows at once by passing an Array of ids.</p>
<p>It is much faster than the destroy method, skipping callbacks might bypass business logic in your application that makes the function to work fast.</p>
<p><strong>example:</strong> <br />
	Delete a single row <br />
	user.delete(1)</p>
<p>Delete multiple rows <br />
	user.delete([2,3,4])</p>
<p><u><strong>Destroy method: </strong></u><br />
	The destroy method makes the SQL call to the database and destroys the row in the table that contains it. It does still allow you to manipulate the object in the application as long as it&rsquo;s still in scope (i.e) the callbacks and <br />
	filters are allowed even after destroying the object.</p>
<p><strong>example :</strong> <br />
	Destroy a single object <br />
	User.destroy(1)</p>
<p>Destroy multiple objects <br />
	users= [1,2,3] <br />
	User.destroy(users) </p>
<p><a class="a2a_dd a2a_target addtoany_share_save" href="http://www.addtoany.com/share_save#url=http%3A%2F%2Fwww.amityadav.name%2Fdifference-between-delete-and-destroy-in-activerecord%2F&amp;title=Difference%20between%20delete%20and%20destroy%20in%20ActiveRecord" id="wpa2a_4"><img src="http://www.amityadav.name/wp-content/plugins/add-to-any/share_save_171_16.gif" width="171" height="16" alt="Share"/></a></p>]]></content:encoded>
			<wfw:commentRss>http://www.amityadav.name/difference-between-delete-and-destroy-in-activerecord/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>About Rails3 and MVC architecture</title>
		<link>http://www.amityadav.name/about-rails3-and-mvc-architecture/</link>
		<comments>http://www.amityadav.name/about-rails3-and-mvc-architecture/#comments</comments>
		<pubDate>Wed, 29 Jun 2011 03:25:19 +0000</pubDate>
		<dc:creator>Amit</dc:creator>
				<category><![CDATA[Ruby on Rails]]></category>
		<category><![CDATA[mvc]]></category>
		<category><![CDATA[rails3]]></category>
		<category><![CDATA[ror]]></category>

		<guid isPermaLink="false">http://www.amityadav.name/?p=803</guid>
		<description><![CDATA[Rails 3: Rails is a framework to develop web applications in Ruby. And the web application in Rails will be simpler and faster than in other languages. As, rails is an opinionated software, in the development process of an application, rails will do assumptions about our requirements and will generate the required code for the [...]]]></description>
			<content:encoded><![CDATA[<p><strong><u><span class="postbody">Rails 3:</span></u></strong><br />
	Rails is a framework to develop web applications in Ruby. And the web application in Rails will be simpler and faster than in other languages. As, rails is an opinionated software, in the development process of an application, rails will do assumptions about our requirements and will generate the required code for the application at various stages, with a little interaction of the developer for few specifications.</p>
<p>Rails has a philosophy includes the following:</p>
<p><u>1) DRY: (Don&#39;t Repeat Yourself) </u><br />
	In rails, it suggests that writing the same code again and again for several times is not a good process. Instead of writing the same code again and again, we can partition that particular part of code in to a seperate block or function or something else and can reuse it whenever and wherever we need it in the current application.</p>
<p><u>2) Convention over Configuration: </u><br />
	In rails, almost the process of development will be done using the conventions instead of a * configuration settings for our application. If we follow the conventions (guidelines of rails) in development process, everything will be taken care by rails about our application.</p>
<p><u>3) REST: (Representational State Transfer) </u><br />
	In rails, REST will have two main features. They are: <br />
	a) Using resource identifiers like URLs to represent the resources of our application. <br />
	b) Transferring the representations of the state of a particular resource among system components. <br />
	REST will be useful for routing in our applications for the specification of path for a particular resource. And REST consists of HTTP verbose for our application like: <br />
	a) POST b) GET c) PUT d) DELETE.</p>
<p><u>MVC architecture: </u><br />
	The MVC architecture in Rails application has:</p>
<p>1) Model: <br />
	Model will consist of the data about our applications and is used to manipulate the content of models (tables). It will contain the validations, rules and set of guidelines to manipulate our models.</p>
<p>2) View: <br />
	View will consist of the templates of html pages, which will be visible for public/user. It will purely concentrate on the representation of data our application.</p>
<p>3) Controller: <br />
	Controller is the thing which will have the control over both Model and View. The Controller will receive the requests from the user (from views) and will send that request to respective model to have the information, and will pass the data to the users in form of a view.</p>
<p>The representation of MVC Architecture will be as follows:</p>
<p>View&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8211;Controller&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8211;Model <br />
	(User interface)&#8212;&#8212;&#8212;&#8212;&#8211;(Controllers)&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;(Databases)</p>
<p><a class="a2a_dd a2a_target addtoany_share_save" href="http://www.addtoany.com/share_save#url=http%3A%2F%2Fwww.amityadav.name%2Fabout-rails3-and-mvc-architecture%2F&amp;title=About%20Rails3%20and%20MVC%20architecture" id="wpa2a_6"><img src="http://www.amityadav.name/wp-content/plugins/add-to-any/share_save_171_16.gif" width="171" height="16" alt="Share"/></a></p>]]></content:encoded>
			<wfw:commentRss>http://www.amityadav.name/about-rails3-and-mvc-architecture/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Mutable and Immutable Objects</title>
		<link>http://www.amityadav.name/mutable-and-immutable-objects/</link>
		<comments>http://www.amityadav.name/mutable-and-immutable-objects/#comments</comments>
		<pubDate>Wed, 29 Jun 2011 03:23:43 +0000</pubDate>
		<dc:creator>Amit</dc:creator>
				<category><![CDATA[Featured]]></category>
		<category><![CDATA[Ruby on Rails]]></category>
		<category><![CDATA[mutable]]></category>
		<category><![CDATA[non-mutable]]></category>
		<category><![CDATA[Rails]]></category>
		<category><![CDATA[ror]]></category>
		<category><![CDATA[Ruby]]></category>

		<guid isPermaLink="false">http://www.amityadav.name/?p=801</guid>
		<description><![CDATA[Mutable objects : 1)Mutable objects are objects whose state can change. 2)In Ruby, Mutability is a property of an instance. 3)Any instance can become immutable by calling the &#34;freeze&#34;. Immutable objects : 1)Immutable objects are objects whose state never changes after creation. 2)Immutable objects are thread-safe(A piece of code is called as thread-safe ,if it [...]]]></description>
			<content:encoded><![CDATA[<p><span class="postbody"><u><strong>Mutable objects : </strong></u><br />
	1)Mutable objects are objects whose state can change. <br />
	2)In Ruby, Mutability is a property of an instance. <br />
	3)Any instance can become immutable by calling the &quot;freeze&quot;. </span></p>
<p><u><strong>Immutable objects : </strong></u><br />
	1)Immutable objects are objects whose state never changes after creation.</p>
<p>2)Immutable objects are thread-safe(A piece of code is called as thread-safe ,if it functions correctly during simultaneous execution by multiple threads).</p>
<p><u><em>Freezing Objects: </em></u><br />
	1:The freeze method in class Object prevents you from changing an object, effectively turning an object into a constant. <br />
	2:After we freeze an object, an attempt to modify the freezed object, results in TypeError. <br />
	3: freeze operates on an object reference, not on a variable. <br />
	4:This means that any operation resulting in a new object.</p>
<p>Example: <br />
	str = &#39;A simple string. &#39; <br />
	str.freeze <br />
	begin <br />
	str &lt;&lt; &#39;An attempt to modify.&#39; <br />
	rescue =&gt; err <br />
	puts &quot;#{err.class} #{err}&quot; <br />
	end</p>
<p># The output is &#8211; TypeError can&#39;t modify frozen string</p>
<p><a class="a2a_dd a2a_target addtoany_share_save" href="http://www.addtoany.com/share_save#url=http%3A%2F%2Fwww.amityadav.name%2Fmutable-and-immutable-objects%2F&amp;title=Mutable%20and%20Immutable%20Objects" id="wpa2a_8"><img src="http://www.amityadav.name/wp-content/plugins/add-to-any/share_save_171_16.gif" width="171" height="16" alt="Share"/></a></p>]]></content:encoded>
			<wfw:commentRss>http://www.amityadav.name/mutable-and-immutable-objects/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>FFMPEG get video file duration: Ruby</title>
		<link>http://www.amityadav.name/ffmpeg-get-video-file-duration-ruby/</link>
		<comments>http://www.amityadav.name/ffmpeg-get-video-file-duration-ruby/#comments</comments>
		<pubDate>Tue, 10 Mar 2009 09:51:58 +0000</pubDate>
		<dc:creator>Amit</dc:creator>
				<category><![CDATA[Ruby on Rails]]></category>
		<category><![CDATA[ffmpeg]]></category>
		<category><![CDATA[Rails]]></category>
		<category><![CDATA[Ruby]]></category>

		<guid isPermaLink="false">http://www.amityadav.name/?p=228</guid>
		<description><![CDATA[  ?View Code RUBY1 2 3 4 5 6 7 8 9 10 11 12 13 14 def get_video_file_duration&#40;inputFilename&#41; command = &#34;ffmpeg -i &#34; + inputFilename.to_s + &#34; 2&#62;&#38;amp;1 &#124; grep 'Duration' &#124; cut -d ' ' -f 4 &#124; sed s/,//&#34; output = `#{command}` &#160; if output =~ /&#40;&#91;\d&#93;&#91;\d&#93;&#41;:&#40;&#91;\d&#93;&#91;\d&#93;&#41;:&#40;&#91;\d&#93;&#91;\d&#93;&#41;.&#40;&#91;\d&#93;+&#41;/ duration = &#40;&#40;$1.to_i * 60 [...]]]></description>
			<content:encoded><![CDATA[<p> </p>

<div class="wp_codebox_msgheader wp_codebox_hide"><span class="right"><sup><a href="http://www.ericbess.com/ericblog/2008/03/03/wp-codebox/#examples" target="_blank" title="WP-CodeBox HowTo?"><span style="color: #99cc00">?</span></a></sup></span><span class="left"><a href="javascript:;" onclick="javascript:showCodeTxt('p228code2'); return false;">View Code</a> RUBY</span><div class="codebox_clear"></div></div><div class="wp_codebox"><table><tr id="p2282"><td class="line_numbers"><pre>1
2
3
4
5
6
7
8
9
10
11
12
13
14
</pre></td><td class="code" id="p228code2"><pre class="ruby" style="font-family:monospace;"><span style="color:#9966CC; font-weight:bold;">def</span> get_video_file_duration<span style="color:#006600; font-weight:bold;">&#40;</span>inputFilename<span style="color:#006600; font-weight:bold;">&#41;</span>
            command = <span style="color:#996600;">&quot;ffmpeg -i &quot;</span>
                             <span style="color:#006600; font-weight:bold;">+</span> inputFilename.<span style="color:#9900CC;">to_s</span> <span style="color:#006600; font-weight:bold;">+</span> <span style="color:#996600;">&quot; 
                             2&gt;&amp;amp;1 | grep 'Duration' 
                             | cut -d ' ' -f 4 | sed s/,//&quot;</span>
                             output = <span style="color:#996600;">`#{command}`</span>
&nbsp;
          <span style="color:#9966CC; font-weight:bold;">if</span> output =~ <span style="color:#006600; font-weight:bold;">/</span><span style="color:#006600; font-weight:bold;">&#40;</span><span style="color:#006600; font-weight:bold;">&#91;</span>\d<span style="color:#006600; font-weight:bold;">&#93;</span><span style="color:#006600; font-weight:bold;">&#91;</span>\d<span style="color:#006600; font-weight:bold;">&#93;</span><span style="color:#006600; font-weight:bold;">&#41;</span>:<span style="color:#006600; font-weight:bold;">&#40;</span><span style="color:#006600; font-weight:bold;">&#91;</span>\d<span style="color:#006600; font-weight:bold;">&#93;</span><span style="color:#006600; font-weight:bold;">&#91;</span>\d<span style="color:#006600; font-weight:bold;">&#93;</span><span style="color:#006600; font-weight:bold;">&#41;</span>:<span style="color:#006600; font-weight:bold;">&#40;</span><span style="color:#006600; font-weight:bold;">&#91;</span>\d<span style="color:#006600; font-weight:bold;">&#93;</span><span style="color:#006600; font-weight:bold;">&#91;</span>\d<span style="color:#006600; font-weight:bold;">&#93;</span><span style="color:#006600; font-weight:bold;">&#41;</span>.<span style="color:#006600; font-weight:bold;">&#40;</span><span style="color:#006600; font-weight:bold;">&#91;</span>\d<span style="color:#006600; font-weight:bold;">&#93;</span><span style="color:#006600; font-weight:bold;">+</span><span style="color:#006600; font-weight:bold;">&#41;</span><span style="color:#006600; font-weight:bold;">/</span>
               duration = <span style="color:#006600; font-weight:bold;">&#40;</span><span style="color:#006600; font-weight:bold;">&#40;</span>$<span style="color:#006666;">1</span>.<span style="color:#9900CC;">to_i</span> <span style="color:#006600; font-weight:bold;">*</span> <span style="color:#006666;">60</span> <span style="color:#006600; font-weight:bold;">+</span> $<span style="color:#006666;">2</span>.<span style="color:#9900CC;">to_i</span><span style="color:#006600; font-weight:bold;">&#41;</span> <span style="color:#006600; font-weight:bold;">*</span> <span style="color:#006666;">60</span> <span style="color:#006600; font-weight:bold;">+</span> $<span style="color:#006666;">3</span>.<span style="color:#9900CC;">to_i</span><span style="color:#006600; font-weight:bold;">&#41;</span> <span style="color:#006600; font-weight:bold;">*</span> <span style="color:#006666;">10</span> <span style="color:#006600; font-weight:bold;">+</span> $<span style="color:#006666;">4</span>.<span style="color:#9900CC;">to_i</span>
          <span style="color:#9966CC; font-weight:bold;">end</span>
&nbsp;
          <span style="color:#008000; font-style:italic;">#return duration.to_s</span>
          <span style="color:#0000FF; font-weight:bold;">return</span> <span style="color:#996600;">&quot;#{$2}:#{$3}&quot;</span>
 <span style="color:#9966CC; font-weight:bold;">end</span></pre></td></tr></table></div>

<p> </p>
<div class="zemanta-pixie" style="margin-top:10px;height:15px"><img class="zemanta-pixie-img" src="http://img.zemanta.com/pixy.gif?x-id=f71479c7-4c3a-4dbb-971a-19dcf2453b6c" style="border:none;float:right"><span class="zem-script more-related"><script type="text/javascript" src="http://static.zemanta.com/readside/loader.js" defer="defer"></script></span></div>
<p><a class="a2a_dd a2a_target addtoany_share_save" href="http://www.addtoany.com/share_save#url=http%3A%2F%2Fwww.amityadav.name%2Fffmpeg-get-video-file-duration-ruby%2F&amp;title=FFMPEG%20get%20video%20file%20duration%3A%20Ruby" id="wpa2a_10"><img src="http://www.amityadav.name/wp-content/plugins/add-to-any/share_save_171_16.gif" width="171" height="16" alt="Share"/></a></p>]]></content:encoded>
			<wfw:commentRss>http://www.amityadav.name/ffmpeg-get-video-file-duration-ruby/feed/</wfw:commentRss>
		<slash:comments>3</slash:comments>
		</item>
		<item>
		<title>My Google Knol articles</title>
		<link>http://www.amityadav.name/my-google-knol-articles/</link>
		<comments>http://www.amityadav.name/my-google-knol-articles/#comments</comments>
		<pubDate>Mon, 23 Feb 2009 05:17:14 +0000</pubDate>
		<dc:creator>Amit</dc:creator>
				<category><![CDATA[General]]></category>
		<category><![CDATA[Ruby on Rails]]></category>
		<category><![CDATA[Add new tag]]></category>
		<category><![CDATA[google knol]]></category>
		<category><![CDATA[Rails]]></category>
		<category><![CDATA[Ruby]]></category>

		<guid isPermaLink="false">http://www.amityadav.name/?p=215</guid>
		<description><![CDATA[Ruby on Rails implementation of OpenId Ruby on Rails implementation for Paypal &#124; Download Code Ruby on Rails implementation for Authorize.net]]></description>
			<content:encoded><![CDATA[<p><a title="Ruby on Rails implementation of OpenId" href="http://knol.google.com/k/amit-yadav/ruby-on-rails-implementation-of-openid/u73tenkicdbm/6#" target="_blank">Ruby on Rails implementation of OpenId</a></p>
<p><a title="Ruby on Rails implementation for Paypal" href="http://knol.google.com/k/amit-yadav/ruby-on-rails-implementation-for-paypal/u73tenkicdbm/3" target="_blank">Ruby on Rails implementation for Paypal</a> | <a href="/payment_gateway.rar">Download Code</a></p>
<p><a title="Ruby on Rails implementation for Authorize.net" href="http://knol.google.com/k/amit-yadav/ruby-on-rails-implementation-for/u73tenkicdbm/4" target="_blank">Ruby on Rails implementation for Authorize.net</a></p>
<p><a class="a2a_dd a2a_target addtoany_share_save" href="http://www.addtoany.com/share_save#url=http%3A%2F%2Fwww.amityadav.name%2Fmy-google-knol-articles%2F&amp;title=My%20Google%20Knol%20articles" id="wpa2a_12"><img src="http://www.amityadav.name/wp-content/plugins/add-to-any/share_save_171_16.gif" width="171" height="16" alt="Share"/></a></p>]]></content:encoded>
			<wfw:commentRss>http://www.amityadav.name/my-google-knol-articles/feed/</wfw:commentRss>
		<slash:comments>6</slash:comments>
		</item>
		<item>
		<title>How to Create a File Upload Progress Bar in Rails, Passenger, Prototype and Low Pro</title>
		<link>http://www.amityadav.name/how-to-create-a-file-upload-progress-bar-in-rails-passenger-prototype-and-low-pro/</link>
		<comments>http://www.amityadav.name/how-to-create-a-file-upload-progress-bar-in-rails-passenger-prototype-and-low-pro/#comments</comments>
		<pubDate>Tue, 17 Feb 2009 07:49:57 +0000</pubDate>
		<dc:creator>Amit</dc:creator>
				<category><![CDATA[Ruby on Rails]]></category>

		<guid isPermaLink="false">http://www.amityadav.name/?p=208</guid>
		<description><![CDATA[How to Create a File Upload Progress Bar in Rails, Passenger, Prototype and Low Pro from Erik Andrejko on Vimeo.]]></description>
			<content:encoded><![CDATA[<p><object classid="clsid:d27cdb6e-ae6d-11cf-96b8-444553540000" width="400" height="302" codebase="http://download.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=6,0,40,0"><param name="allowfullscreen" value="true" /><param name="allowscriptaccess" value="always" /><param name="src" value="http://vimeo.com/moogaloop.swf?clip_id=2754792&amp;server=vimeo.com&amp;show_title=1&amp;show_byline=1&amp;show_portrait=0&amp;color=&amp;fullscreen=1" /><embed type="application/x-shockwave-flash" width="400" height="302" src="http://vimeo.com/moogaloop.swf?clip_id=2754792&amp;server=vimeo.com&amp;show_title=1&amp;show_byline=1&amp;show_portrait=0&amp;color=&amp;fullscreen=1" allowscriptaccess="always" allowfullscreen="true"></embed></object><br />
<a href="http://vimeo.com/2754792">How to Create a File Upload Progress Bar in Rails, Passenger, Prototype and Low Pro</a> from <a href="http://vimeo.com/user1001525">Erik Andrejko</a> on <a href="http://vimeo.com">Vimeo</a>.</p>
<p><a class="a2a_dd a2a_target addtoany_share_save" href="http://www.addtoany.com/share_save#url=http%3A%2F%2Fwww.amityadav.name%2Fhow-to-create-a-file-upload-progress-bar-in-rails-passenger-prototype-and-low-pro%2F&amp;title=How%20to%20Create%20a%20File%20Upload%20Progress%20Bar%20in%20Rails%2C%20Passenger%2C%20Prototype%20and%20Low%20Pro" id="wpa2a_14"><img src="http://www.amityadav.name/wp-content/plugins/add-to-any/share_save_171_16.gif" width="171" height="16" alt="Share"/></a></p>]]></content:encoded>
			<wfw:commentRss>http://www.amityadav.name/how-to-create-a-file-upload-progress-bar-in-rails-passenger-prototype-and-low-pro/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Rails flash messages helper</title>
		<link>http://www.amityadav.name/rails-flash-messages-helper/</link>
		<comments>http://www.amityadav.name/rails-flash-messages-helper/#comments</comments>
		<pubDate>Tue, 17 Feb 2009 07:49:05 +0000</pubDate>
		<dc:creator>Amit</dc:creator>
				<category><![CDATA[Ruby on Rails]]></category>
		<category><![CDATA[Adobe Flash]]></category>
		<category><![CDATA[Data Formats]]></category>
		<category><![CDATA[FAQs  Help  and Tutorials]]></category>
		<category><![CDATA[Flash]]></category>
		<category><![CDATA[HTML]]></category>
		<category><![CDATA[Markup Languages]]></category>
		<category><![CDATA[Multimedia]]></category>
		<category><![CDATA[Web]]></category>

		<guid isPermaLink="false">http://www.amityadav.name/?p=204</guid>
		<description><![CDATA[display_flash(:error) # to display a specific flash message display_flash # to display all flash messages ?View Code RUBY1 2 3 4 5 6 7 8 9 10 11 12 13 # Methods added to this helper will be available to all templates in the application. module ApplicationHelper FLASH_TYPES = &#91;:error, :warning, :success, :message&#93; def display_flash&#40;type [...]]]></description>
			<content:encoded><![CDATA[<p>display_flash(:error) # to display a specific flash message<br />
display_flash # to display all flash messages</p>
<div class="zemanta-pixie" style="margin-top: 10px; height: 15px;"><a class="zemanta-pixie-a" title="Zemified by Zemanta" href="http://reblog.zemanta.com/zemified/ffe347df-3e6c-4ef5-9aa0-d78b7728bc11/"></a></div>

<div class="wp_codebox_msgheader wp_codebox_hide"><span class="right"><sup><a href="http://www.ericbess.com/ericblog/2008/03/03/wp-codebox/#examples" target="_blank" title="WP-CodeBox HowTo?"><span style="color: #99cc00">?</span></a></sup></span><span class="left"><a href="javascript:;" onclick="javascript:showCodeTxt('p204code4'); return false;">View Code</a> RUBY</span><div class="codebox_clear"></div></div><div class="wp_codebox"><table><tr id="p2044"><td class="line_numbers"><pre>1
2
3
4
5
6
7
8
9
10
11
12
13
</pre></td><td class="code" id="p204code4"><pre class="ruby" style="font-family:monospace;"><span style="color:#008000; font-style:italic;"># Methods added to this helper will be available to all templates in the application.</span>
<span style="color:#9966CC; font-weight:bold;">module</span> ApplicationHelper
  FLASH_TYPES = <span style="color:#006600; font-weight:bold;">&#91;</span><span style="color:#ff3333; font-weight:bold;">:error</span>, <span style="color:#ff3333; font-weight:bold;">:warning</span>, <span style="color:#ff3333; font-weight:bold;">:success</span>, <span style="color:#ff3333; font-weight:bold;">:message</span><span style="color:#006600; font-weight:bold;">&#93;</span>
  <span style="color:#9966CC; font-weight:bold;">def</span> display_flash<span style="color:#006600; font-weight:bold;">&#40;</span>type = <span style="color:#0000FF; font-weight:bold;">nil</span><span style="color:#006600; font-weight:bold;">&#41;</span>
    html = <span style="color:#996600;">&quot;&quot;</span>
    <span style="color:#9966CC; font-weight:bold;">if</span> type.<span style="color:#0000FF; font-weight:bold;">nil</span>?
      FLASH_TYPES.<span style="color:#9900CC;">each</span> <span style="color:#006600; font-weight:bold;">&#123;</span> <span style="color:#006600; font-weight:bold;">|</span>name<span style="color:#006600; font-weight:bold;">|</span> html <span style="color:#006600; font-weight:bold;">&amp;</span>lt;<span style="color:#006600; font-weight:bold;">&amp;</span>lt; display_flash<span style="color:#006600; font-weight:bold;">&#40;</span>name<span style="color:#006600; font-weight:bold;">&#41;</span> <span style="color:#006600; font-weight:bold;">&#125;</span>
    <span style="color:#9966CC; font-weight:bold;">else</span>
      <span style="color:#0000FF; font-weight:bold;">return</span> flash<span style="color:#006600; font-weight:bold;">&#91;</span>type<span style="color:#006600; font-weight:bold;">&#93;</span>.<span style="color:#9900CC;">blank</span>? ? <span style="color:#996600;">&quot;&quot;</span> : <span style="color:#996600;">&quot;#{flash[type]}&quot;</span>
    <span style="color:#9966CC; font-weight:bold;">end</span>
    html
  <span style="color:#9966CC; font-weight:bold;">end</span>
<span style="color:#9966CC; font-weight:bold;">end</span></pre></td></tr></table></div>

<p><a class="a2a_dd a2a_target addtoany_share_save" href="http://www.addtoany.com/share_save#url=http%3A%2F%2Fwww.amityadav.name%2Frails-flash-messages-helper%2F&amp;title=Rails%20flash%20messages%20helper" id="wpa2a_16"><img src="http://www.amityadav.name/wp-content/plugins/add-to-any/share_save_171_16.gif" width="171" height="16" alt="Share"/></a></p>]]></content:encoded>
			<wfw:commentRss>http://www.amityadav.name/rails-flash-messages-helper/feed/</wfw:commentRss>
		<slash:comments>2</slash:comments>
		</item>
		<item>
		<title>Beauty of Maths</title>
		<link>http://www.amityadav.name/beauty-of-maths/</link>
		<comments>http://www.amityadav.name/beauty-of-maths/#comments</comments>
		<pubDate>Tue, 22 Jul 2008 04:26:38 +0000</pubDate>
		<dc:creator>Amit</dc:creator>
				<category><![CDATA[Ruby on Rails]]></category>
		<category><![CDATA[maths]]></category>

		<guid isPermaLink="false">http://www.amityadav.name/beauty-of-maths/</guid>
		<description><![CDATA[1 x 8 + 1 = 9 12 x 8 + 2 = 98 123 x 8 + 3 = 987 1234 x 8 + 4 = 9876 12345 x 8 + 5 = 98765 123456 x 8 + 6 = 987654 1234567 x 8 + 7 = 9876543 12345678 x 8 + 8 = [...]]]></description>
			<content:encoded><![CDATA[<p><span style="font-size: x-small;">1 x 8 + 1 = 9<br />
12 x 8 + 2 = 98<br />
123 x 8 + 3 = 987<br />
1234 x 8 + 4 = 9876<br />
12345 x 8 + 5 = 98765<br />
123456 x 8 + 6 = 987654<br />
1234567 x 8 + 7 = 9876543<br />
12345678 x 8 + 8 = 98765432<br />
123456789 x 8 + 9 = 987654321</span></p>
<p><span style="font-size: x-small;">1 x 9 + 2 = 11<br />
12 x 9 + 3 = 111<br />
123 x 9 + 4 = 1111<br />
1234 x 9 + 5 = 11111<br />
12345 x 9 + 6 = 111111<br />
123456 x 9 + 7 = 1111111<br />
1234567 x 9 + 8 = 11111111<br />
12345678 x 9 + 9 = 111111111<br />
123456789 x 9 +10= 1111111111</span></p>
<p><span style="font-size: x-small;">9 x 9 + 7 = 88<br />
98 x 9 + 6 = 888<br />
987 x 9 + 5 = 8888<br />
9876 x 9 + 4 = 88888<br />
98765 x 9 + 3 = 888888<br />
987654 x 9 + 2 = 8888888<br />
9876543 x 9 + 1 = 88888888<br />
98765432 x 9 + 0 = 888888888</span></p>
<p><a class="a2a_dd a2a_target addtoany_share_save" href="http://www.addtoany.com/share_save#url=http%3A%2F%2Fwww.amityadav.name%2Fbeauty-of-maths%2F&amp;title=Beauty%20of%20Maths" id="wpa2a_18"><img src="http://www.amityadav.name/wp-content/plugins/add-to-any/share_save_171_16.gif" width="171" height="16" alt="Share"/></a></p>]]></content:encoded>
			<wfw:commentRss>http://www.amityadav.name/beauty-of-maths/feed/</wfw:commentRss>
		<slash:comments>1</slash:comments>
		</item>
		<item>
		<title>Installing mod_rails(Passenger)</title>
		<link>http://www.amityadav.name/installing-mod_railspassenger/</link>
		<comments>http://www.amityadav.name/installing-mod_railspassenger/#comments</comments>
		<pubDate>Mon, 14 Jul 2008 04:49:19 +0000</pubDate>
		<dc:creator>Amit</dc:creator>
				<category><![CDATA[Ruby on Rails]]></category>
		<category><![CDATA[globallogic]]></category>
		<category><![CDATA[mod_rails]]></category>
		<category><![CDATA[passenger]]></category>
		<category><![CDATA[Rails]]></category>

		<guid isPermaLink="false">http://www.amityadav.name/installing-mod_railspassenger/</guid>
		<description><![CDATA[Mod_rails has come to rescue people form tedious rails application development. With mod_rails the work has become a lot easier, you do not have to worry about different things just few steps and your application is up and running, ofcourse there are options to modify the deployment to your needs. There are few prerequisites for [...]]]></description>
			<content:encoded><![CDATA[<p><font size="2">Mod_rails has come to rescue people form tedious rails application development. With mod_rails the work has become a lot easier, you do not have to worry about different things just few steps and your application is up and running, ofcourse  there are options to modify the deployment to your needs.</font></p>
<p><font size="2"> There are few prerequisites for mod_rails to work, first you need Apache and secondly you need Ruby and Rubygems.</font></p>
<p><font size="2"> <strong>Step 1</strong>: We need to update rubygems<br />
<font color="#993300"><strong>sudo gem update</strong></font></font></p>
<p><font size="2"> <strong>Step 2</strong>: We need to install mod_rails(passenger)<br />
<font color="#993300"><strong>sudo gem install passenger</strong></font></font></p>
<p><font size="2"> <strong>Step 3</strong>: Now we need to install Apache2 headers<br />
<font color="#993300"><strong>sudo aptitude install apache2-prefork-dev</strong></font><br />
</font></p>
<p><font size="2"> <strong>Step 4:</strong> Now we need to install Apache2 module<br />
<font color="#993300"><strong>sudo passenger-install-apache2-module</strong></font></font></p>
<p><font size="2"> There will be a screen which takes you further. If there are any dependencies that are needed then it will be asked for on this screen.</font></p>
<p><font size="2">After successful installation there is just one thing left, we need to copy some lines to the Apache2 main config file , open the file &#8220;apache2.conf&#8221; in a text editor and then paste these lines at the end of the file:<br />
<font color="#993300"><strong>LoadModule passenger_module /usr/lib/ruby/gems/1.8/gems/passenger-1.0.4/ext/apache2/mod_passenger.so<br />
RailsSpawnServer /usr/lib/ruby/gems/1.8/gems/passenger-1.0.4/bin/passenger-spawn-server<br />
RailsRuby /usr/bin/ruby1.8</strong></font></font></p>
<p><font size="2">Restart Apache<br />
<strong><font color="#993300">sudo service apache2 restart</font></strong></font></p>
<p><font size="2">Done!! </font></p>
<p><a class="a2a_dd a2a_target addtoany_share_save" href="http://www.addtoany.com/share_save#url=http%3A%2F%2Fwww.amityadav.name%2Finstalling-mod_railspassenger%2F&amp;title=Installing%20mod_rails%28Passenger%29" id="wpa2a_20"><img src="http://www.amityadav.name/wp-content/plugins/add-to-any/share_save_171_16.gif" width="171" height="16" alt="Share"/></a></p>]]></content:encoded>
			<wfw:commentRss>http://www.amityadav.name/installing-mod_railspassenger/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Compile &amp; install Nginx web server</title>
		<link>http://www.amityadav.name/compile-install-nginx-web-server/</link>
		<comments>http://www.amityadav.name/compile-install-nginx-web-server/#comments</comments>
		<pubDate>Mon, 23 Jun 2008 05:25:42 +0000</pubDate>
		<dc:creator>Amit</dc:creator>
				<category><![CDATA[Ruby on Rails]]></category>
		<category><![CDATA[nginx]]></category>
		<category><![CDATA[Ruby]]></category>

		<guid isPermaLink="false">http://www.amityadav.name/compile-install-nginx-web-server/</guid>
		<description><![CDATA[?View Code RUBY1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 # See: # - http://en.wikipedia.org/wiki/Nginx # - http://wiki.codemongers.com/NginxGettingStarted # [...]]]></description>
			<content:encoded><![CDATA[
<div class="wp_codebox_msgheader wp_codebox_hide"><span class="right"><sup><a href="http://www.ericbess.com/ericblog/2008/03/03/wp-codebox/#examples" target="_blank" title="WP-CodeBox HowTo?"><span style="color: #99cc00">?</span></a></sup></span><span class="left"><a href="javascript:;" onclick="javascript:showCodeTxt('p53code6'); return false;">View Code</a> RUBY</span><div class="codebox_clear"></div></div><div class="wp_codebox"><table><tr id="p536"><td class="line_numbers"><pre>1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
</pre></td><td class="code" id="p53code6"><pre class="ruby" style="font-family:monospace;"> <span style="color:#008000; font-style:italic;"># See:</span>
<span style="color:#008000; font-style:italic;"># - http://en.wikipedia.org/wiki/Nginx</span>
<span style="color:#008000; font-style:italic;"># - http://wiki.codemongers.com/NginxGettingStarted</span>
<span style="color:#008000; font-style:italic;"># - http://wiki.codemongers.com/NginxInstallOptions</span>
<span style="color:#008000; font-style:italic;"># - http://wiki.codemongers.com/NginxCommandLine</span>
<span style="color:#008000; font-style:italic;"># - http://wiki.codemongers.com/NginxConfiguration</span>
&nbsp;
export PATH=<span style="color:#996600;">&quot;/usr/local/bin:/usr/local/sbin:/usr/bin:/bin:/usr/sbin:/sbin&quot;</span>
&nbsp;
mkdir <span style="color:#006600; font-weight:bold;">-</span><span style="color:#CC0066; font-weight:bold;">p</span> ~<span style="color:#006600; font-weight:bold;">/</span>Desktop<span style="color:#006600; font-weight:bold;">/</span>Nginx
cd ~<span style="color:#006600; font-weight:bold;">/</span>Desktop<span style="color:#006600; font-weight:bold;">/</span>Nginx
&nbsp;
curl <span style="color:#006600; font-weight:bold;">-</span>L <span style="color:#006600; font-weight:bold;">-</span>O http:<span style="color:#006600; font-weight:bold;">//</span>sysoev.<span style="color:#9900CC;">ru</span><span style="color:#006600; font-weight:bold;">/</span>nginx<span style="color:#006600; font-weight:bold;">/</span>nginx<span style="color:#006600; font-weight:bold;">-</span>0.7.2.<span style="color:#9900CC;">tar</span>.<span style="color:#9900CC;">gz</span>
tar <span style="color:#006600; font-weight:bold;">-</span>xzf nginx<span style="color:#006600; font-weight:bold;">-</span>0.7.2.<span style="color:#9900CC;">tar</span>.<span style="color:#9900CC;">gz</span>
&nbsp;
curl <span style="color:#006600; font-weight:bold;">-</span>L <span style="color:#006600; font-weight:bold;">-</span>O http:<span style="color:#006600; font-weight:bold;">//</span>downloads.<span style="color:#9900CC;">sourceforge</span>.<span style="color:#9900CC;">net</span><span style="color:#006600; font-weight:bold;">/</span>pcre<span style="color:#006600; font-weight:bold;">/</span>pcre<span style="color:#006600; font-weight:bold;">-</span><span style="color:#006666;">7.7</span>.<span style="color:#9900CC;">tar</span>.<span style="color:#9900CC;">gz</span>
tar <span style="color:#006600; font-weight:bold;">-</span>xzf pcre<span style="color:#006600; font-weight:bold;">-</span><span style="color:#006666;">7.7</span>.<span style="color:#9900CC;">tar</span>.<span style="color:#9900CC;">gz</span>
&nbsp;
cd ~<span style="color:#006600; font-weight:bold;">/</span>Desktop<span style="color:#006600; font-weight:bold;">/</span>Nginx<span style="color:#006600; font-weight:bold;">/</span>nginx<span style="color:#006600; font-weight:bold;">-</span>0.7.2
.<span style="color:#006600; font-weight:bold;">/</span>configure <span style="color:#006600; font-weight:bold;">--</span>help
.<span style="color:#006600; font-weight:bold;">/</span>configure <span style="color:#006600; font-weight:bold;">--</span>prefix=<span style="color:#006600; font-weight:bold;">/</span>usr<span style="color:#006600; font-weight:bold;">/</span>local<span style="color:#006600; font-weight:bold;">/</span>nginx <span style="color:#006600; font-weight:bold;">--</span>sbin<span style="color:#006600; font-weight:bold;">-</span>path=<span style="color:#006600; font-weight:bold;">/</span>usr<span style="color:#006600; font-weight:bold;">/</span>local<span style="color:#006600; font-weight:bold;">/</span>sbin <span style="color:#006600; font-weight:bold;">--</span>with<span style="color:#006600; font-weight:bold;">-</span>debug <span style="color:#006600; font-weight:bold;">--</span>with<span style="color:#006600; font-weight:bold;">-</span>http_ssl_module <span style="color:#006600; font-weight:bold;">--</span>with<span style="color:#006600; font-weight:bold;">-</span>pcre=..<span style="color:#006600; font-weight:bold;">/</span>pcre<span style="color:#006600; font-weight:bold;">-</span><span style="color:#006666;">7.7</span>
make
sudo make install
&nbsp;
which nginx
otool <span style="color:#006600; font-weight:bold;">-</span>L <span style="color:#006600; font-weight:bold;">/</span>usr<span style="color:#006600; font-weight:bold;">/</span>local<span style="color:#006600; font-weight:bold;">/</span>sbin<span style="color:#006600; font-weight:bold;">/</span>nginx
<span style="color:#CC0066; font-weight:bold;">open</span> <span style="color:#006600; font-weight:bold;">/</span>usr<span style="color:#006600; font-weight:bold;">/</span>local<span style="color:#006600; font-weight:bold;">/</span>nginx
<span style="color:#CC0066; font-weight:bold;">open</span> <span style="color:#006600; font-weight:bold;">-</span>e <span style="color:#006600; font-weight:bold;">/</span>usr<span style="color:#006600; font-weight:bold;">/</span>local<span style="color:#006600; font-weight:bold;">/</span>nginx<span style="color:#006600; font-weight:bold;">/</span>conf<span style="color:#006600; font-weight:bold;">/</span>nginx.<span style="color:#9900CC;">conf</span>
&nbsp;
nginx <span style="color:#006600; font-weight:bold;">-</span>v
nginx <span style="color:#006600; font-weight:bold;">-</span>V
sudo nginx <span style="color:#008000; font-style:italic;"># start server</span>
sudo nginx <span style="color:#006600; font-weight:bold;">-</span>t
&nbsp;
<span style="color:#CC0066; font-weight:bold;">open</span> http:<span style="color:#006600; font-weight:bold;">//</span>localhost:<span style="color:#006666;">80</span>
<span style="color:#CC0066; font-weight:bold;">open</span> http:<span style="color:#006600; font-weight:bold;">//</span>localhost:<span style="color:#006666;">80</span><span style="color:#006600; font-weight:bold;">/</span>50x.<span style="color:#9900CC;">html</span>
&nbsp;
sudo nano <span style="color:#006600; font-weight:bold;">/</span>usr<span style="color:#006600; font-weight:bold;">/</span>local<span style="color:#006600; font-weight:bold;">/</span>nginx<span style="color:#006600; font-weight:bold;">/</span>conf<span style="color:#006600; font-weight:bold;">/</span>nginx.<span style="color:#9900CC;">conf</span> <span style="color:#008000; font-style:italic;"># editing ... server { listen 8080; ...</span>
&nbsp;
<span style="color:#008000; font-style:italic;"># reload configuration</span>
sudo kill <span style="color:#006600; font-weight:bold;">-</span>HUP <span style="color:#996600;">`cat /usr/local/nginx/logs/nginx.pid`</span>
&nbsp;
<span style="color:#008000; font-style:italic;"># stop server</span>
sudo kill <span style="color:#006600; font-weight:bold;">-</span><span style="color:#006666;">15</span> $<span style="color:#006600; font-weight:bold;">&#40;</span>ps <span style="color:#006600; font-weight:bold;">-</span>auxxx <span style="color:#006600; font-weight:bold;">|</span> egrep <span style="color:#996600;">&quot;[n]ginx.*master&quot;</span> <span style="color:#006600; font-weight:bold;">|</span> awk <span style="color:#996600;">'{ print $2 }'</span><span style="color:#006600; font-weight:bold;">&#41;</span> <span style="color:#006666;">2</span><span style="color:#006600; font-weight:bold;">&amp;</span>gt;<span style="color:#006600; font-weight:bold;">/</span>dev<span style="color:#006600; font-weight:bold;">/</span>null</pre></td></tr></table></div>

<p><a class="a2a_dd a2a_target addtoany_share_save" href="http://www.addtoany.com/share_save#url=http%3A%2F%2Fwww.amityadav.name%2Fcompile-install-nginx-web-server%2F&amp;title=Compile%20%26%23038%3B%20install%20Nginx%20web%20server" id="wpa2a_22"><img src="http://www.amityadav.name/wp-content/plugins/add-to-any/share_save_171_16.gif" width="171" height="16" alt="Share"/></a></p>]]></content:encoded>
			<wfw:commentRss>http://www.amityadav.name/compile-install-nginx-web-server/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Create a Hash from two Array objects</title>
		<link>http://www.amityadav.name/create-a-hash-from-two-array-objects/</link>
		<comments>http://www.amityadav.name/create-a-hash-from-two-array-objects/#comments</comments>
		<pubDate>Mon, 23 Jun 2008 04:37:17 +0000</pubDate>
		<dc:creator>Amit</dc:creator>
				<category><![CDATA[Ruby on Rails]]></category>

		<guid isPermaLink="false">http://www.amityadav.name/create-a-hash-from-two-array-objects/</guid>
		<description><![CDATA[Requires Ruby 1.8.7 or higher. ?View Code RUBY1 2 3 4 5 6 keys = &#91;1,2,&#91;3,4&#93;&#93; &#91;1, 2, &#91;3, 4&#93;&#93; values = &#91;'a','b',&#91;'c','d'&#93;&#93; &#91;&#34;a&#34;, &#34;b&#34;, &#91;&#34;c&#34;, &#34;d&#34;&#93;&#93; Hash&#91; * keys.zip&#40;values&#41;.flatten&#40;1&#41; &#93; &#123;1=&#38;gt;&#34;a&#34;, &#91;3, 4&#93; =&#38;gt; &#91;&#34;c&#34;, &#34;d&#34;&#93;, 2 =&#38;gt; &#34;b&#34;&#125;]]></description>
			<content:encoded><![CDATA[<p>Requires Ruby 1.8.7 or higher.</p>

<div class="wp_codebox_msgheader"><span class="right"><sup><a href="http://www.ericbess.com/ericblog/2008/03/03/wp-codebox/#examples" target="_blank" title="WP-CodeBox HowTo?"><span style="color: #99cc00">?</span></a></sup></span><span class="left"><a href="javascript:;" onclick="javascript:showCodeTxt('p52code8'); return false;">View Code</a> RUBY</span><div class="codebox_clear"></div></div><div class="wp_codebox"><table><tr id="p528"><td class="line_numbers"><pre>1
2
3
4
5
6
</pre></td><td class="code" id="p52code8"><pre class="ruby" style="font-family:monospace;">keys = <span style="color:#006600; font-weight:bold;">&#91;</span><span style="color:#006666;">1</span>,<span style="color:#006666;">2</span>,<span style="color:#006600; font-weight:bold;">&#91;</span><span style="color:#006666;">3</span>,<span style="color:#006666;">4</span><span style="color:#006600; font-weight:bold;">&#93;</span><span style="color:#006600; font-weight:bold;">&#93;</span>
<span style="color:#006600; font-weight:bold;">&#91;</span><span style="color:#006666;">1</span>, <span style="color:#006666;">2</span>, <span style="color:#006600; font-weight:bold;">&#91;</span><span style="color:#006666;">3</span>, <span style="color:#006666;">4</span><span style="color:#006600; font-weight:bold;">&#93;</span><span style="color:#006600; font-weight:bold;">&#93;</span>
values = <span style="color:#006600; font-weight:bold;">&#91;</span><span style="color:#996600;">'a'</span>,<span style="color:#996600;">'b'</span>,<span style="color:#006600; font-weight:bold;">&#91;</span><span style="color:#996600;">'c'</span>,<span style="color:#996600;">'d'</span><span style="color:#006600; font-weight:bold;">&#93;</span><span style="color:#006600; font-weight:bold;">&#93;</span>
<span style="color:#006600; font-weight:bold;">&#91;</span><span style="color:#996600;">&quot;a&quot;</span>, <span style="color:#996600;">&quot;b&quot;</span>, <span style="color:#006600; font-weight:bold;">&#91;</span><span style="color:#996600;">&quot;c&quot;</span>, <span style="color:#996600;">&quot;d&quot;</span><span style="color:#006600; font-weight:bold;">&#93;</span><span style="color:#006600; font-weight:bold;">&#93;</span>
<span style="color:#CC00FF; font-weight:bold;">Hash</span><span style="color:#006600; font-weight:bold;">&#91;</span> <span style="color:#006600; font-weight:bold;">*</span> keys.<span style="color:#9900CC;">zip</span><span style="color:#006600; font-weight:bold;">&#40;</span>values<span style="color:#006600; font-weight:bold;">&#41;</span>.<span style="color:#9900CC;">flatten</span><span style="color:#006600; font-weight:bold;">&#40;</span><span style="color:#006666;">1</span><span style="color:#006600; font-weight:bold;">&#41;</span> <span style="color:#006600; font-weight:bold;">&#93;</span>
<span style="color:#006600; font-weight:bold;">&#123;</span><span style="color:#006666;">1</span>=<span style="color:#006600; font-weight:bold;">&amp;</span>gt;<span style="color:#996600;">&quot;a&quot;</span>, <span style="color:#006600; font-weight:bold;">&#91;</span><span style="color:#006666;">3</span>, <span style="color:#006666;">4</span><span style="color:#006600; font-weight:bold;">&#93;</span> =<span style="color:#006600; font-weight:bold;">&amp;</span>gt; <span style="color:#006600; font-weight:bold;">&#91;</span><span style="color:#996600;">&quot;c&quot;</span>, <span style="color:#996600;">&quot;d&quot;</span><span style="color:#006600; font-weight:bold;">&#93;</span>, <span style="color:#006666;">2</span> =<span style="color:#006600; font-weight:bold;">&amp;</span>gt; <span style="color:#996600;">&quot;b&quot;</span><span style="color:#006600; font-weight:bold;">&#125;</span></pre></td></tr></table></div>

<p><a class="a2a_dd a2a_target addtoany_share_save" href="http://www.addtoany.com/share_save#url=http%3A%2F%2Fwww.amityadav.name%2Fcreate-a-hash-from-two-array-objects%2F&amp;title=Create%20a%20Hash%20from%20two%20Array%20objects" id="wpa2a_24"><img src="http://www.amityadav.name/wp-content/plugins/add-to-any/share_save_171_16.gif" width="171" height="16" alt="Share"/></a></p>]]></content:encoded>
			<wfw:commentRss>http://www.amityadav.name/create-a-hash-from-two-array-objects/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>File Upload Helpers</title>
		<link>http://www.amityadav.name/file-upload-helpers/</link>
		<comments>http://www.amityadav.name/file-upload-helpers/#comments</comments>
		<pubDate>Mon, 16 Jun 2008 04:45:02 +0000</pubDate>
		<dc:creator>Amit</dc:creator>
				<category><![CDATA[Ruby on Rails]]></category>

		<guid isPermaLink="false">http://www.amityadav.name/file-upload-helpers/</guid>
		<description><![CDATA[Handy little helpers to check if a file was provided to a controller, and to save it. ?View Code RUBY1 2 3 4 5 6 7 8 9 10 11 def file_provided? &#91;StringIO, Tempfile&#93;.include?&#40;@file.class&#41; and @file.size.nonzero? end &#160; def save_file if @file.is_a? Tempfile FileUtils.cp&#40;@file.path, path&#41; elsif @file.is_a? StringIO File.open&#40;path, &#34;wb&#34;&#41; &#123; &#124;disk_file&#124; disk_file &#38;lt;&#38;lt; @file.read [...]]]></description>
			<content:encoded><![CDATA[<p>Handy little helpers to check if a file was provided to a controller, and to save it.</p>

<div class="wp_codebox_msgheader"><span class="right"><sup><a href="http://www.ericbess.com/ericblog/2008/03/03/wp-codebox/#examples" target="_blank" title="WP-CodeBox HowTo?"><span style="color: #99cc00">?</span></a></sup></span><span class="left"><a href="javascript:;" onclick="javascript:showCodeTxt('p51code10'); return false;">View Code</a> RUBY</span><div class="codebox_clear"></div></div><div class="wp_codebox"><table><tr id="p5110"><td class="line_numbers"><pre>1
2
3
4
5
6
7
8
9
10
11
</pre></td><td class="code" id="p51code10"><pre class="ruby" style="font-family:monospace;"> <span style="color:#9966CC; font-weight:bold;">def</span> file_provided?
   <span style="color:#006600; font-weight:bold;">&#91;</span><span style="color:#CC00FF; font-weight:bold;">StringIO</span>, <span style="color:#CC00FF; font-weight:bold;">Tempfile</span><span style="color:#006600; font-weight:bold;">&#93;</span>.<span style="color:#9966CC; font-weight:bold;">include</span>?<span style="color:#006600; font-weight:bold;">&#40;</span>@file.<span style="color:#9966CC; font-weight:bold;">class</span><span style="color:#006600; font-weight:bold;">&#41;</span> <span style="color:#9966CC; font-weight:bold;">and</span> <span style="color:#0066ff; font-weight:bold;">@file</span>.<span style="color:#9900CC;">size</span>.<span style="color:#9900CC;">nonzero</span>?
 <span style="color:#9966CC; font-weight:bold;">end</span> 
&nbsp;
 <span style="color:#9966CC; font-weight:bold;">def</span> save_file
   <span style="color:#9966CC; font-weight:bold;">if</span> <span style="color:#0066ff; font-weight:bold;">@file</span>.<span style="color:#9900CC;">is_a</span>? <span style="color:#CC00FF; font-weight:bold;">Tempfile</span>
     <span style="color:#CC00FF; font-weight:bold;">FileUtils</span>.<span style="color:#9900CC;">cp</span><span style="color:#006600; font-weight:bold;">&#40;</span>@file.<span style="color:#9900CC;">path</span>, path<span style="color:#006600; font-weight:bold;">&#41;</span>
   <span style="color:#9966CC; font-weight:bold;">elsif</span> <span style="color:#0066ff; font-weight:bold;">@file</span>.<span style="color:#9900CC;">is_a</span>? <span style="color:#CC00FF; font-weight:bold;">StringIO</span>
     <span style="color:#CC00FF; font-weight:bold;">File</span>.<span style="color:#CC0066; font-weight:bold;">open</span><span style="color:#006600; font-weight:bold;">&#40;</span>path, <span style="color:#996600;">&quot;wb&quot;</span><span style="color:#006600; font-weight:bold;">&#41;</span> <span style="color:#006600; font-weight:bold;">&#123;</span> <span style="color:#006600; font-weight:bold;">|</span>disk_file<span style="color:#006600; font-weight:bold;">|</span> disk_file <span style="color:#006600; font-weight:bold;">&amp;</span>lt;<span style="color:#006600; font-weight:bold;">&amp;</span>lt; <span style="color:#0066ff; font-weight:bold;">@file</span>.<span style="color:#9900CC;">read</span> <span style="color:#006600; font-weight:bold;">&#125;</span>
   <span style="color:#9966CC; font-weight:bold;">end</span>
 <span style="color:#9966CC; font-weight:bold;">end</span></pre></td></tr></table></div>

<p><a class="a2a_dd a2a_target addtoany_share_save" href="http://www.addtoany.com/share_save#url=http%3A%2F%2Fwww.amityadav.name%2Ffile-upload-helpers%2F&amp;title=File%20Upload%20Helpers" id="wpa2a_26"><img src="http://www.amityadav.name/wp-content/plugins/add-to-any/share_save_171_16.gif" width="171" height="16" alt="Share"/></a></p>]]></content:encoded>
			<wfw:commentRss>http://www.amityadav.name/file-upload-helpers/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Renaming your .rhtml to .erb on EdgeRails</title>
		<link>http://www.amityadav.name/renaming-your-rhtml-to-erb-on-edgerails/</link>
		<comments>http://www.amityadav.name/renaming-your-rhtml-to-erb-on-edgerails/#comments</comments>
		<pubDate>Mon, 16 Jun 2008 04:43:20 +0000</pubDate>
		<dc:creator>Amit</dc:creator>
				<category><![CDATA[Ruby on Rails]]></category>
		<category><![CDATA[Ruby]]></category>

		<guid isPermaLink="false">http://www.amityadav.name/renaming-your-rhtml-to-erb-on-edgerails/</guid>
		<description><![CDATA[?View Code RUBY1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 ## just slap this in your rake file or in lib/tasks &#160; namespace 'views' do desc 'Renames all your rhtml views to erb' task 'rename' do Dir.glob&#40;'app/views/**/*.rhtml'&#41;.each do &#124;file&#124; puts `svn mv [...]]]></description>
			<content:encoded><![CDATA[
<div class="wp_codebox_msgheader"><span class="right"><sup><a href="http://www.ericbess.com/ericblog/2008/03/03/wp-codebox/#examples" target="_blank" title="WP-CodeBox HowTo?"><span style="color: #99cc00">?</span></a></sup></span><span class="left"><a href="javascript:;" onclick="javascript:showCodeTxt('p50code12'); return false;">View Code</a> RUBY</span><div class="codebox_clear"></div></div><div class="wp_codebox"><table><tr id="p5012"><td class="line_numbers"><pre>1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
</pre></td><td class="code" id="p50code12"><pre class="ruby" style="font-family:monospace;"><span style="color:#008000; font-style:italic;">## just slap this in your rake file or in lib/tasks</span>
&nbsp;
namespace <span style="color:#996600;">'views'</span> <span style="color:#9966CC; font-weight:bold;">do</span>
  desc <span style="color:#996600;">'Renames all your rhtml views to erb'</span>
  task <span style="color:#996600;">'rename'</span> <span style="color:#9966CC; font-weight:bold;">do</span>
    <span style="color:#CC00FF; font-weight:bold;">Dir</span>.<span style="color:#9900CC;">glob</span><span style="color:#006600; font-weight:bold;">&#40;</span><span style="color:#996600;">'app/views/**/*.rhtml'</span><span style="color:#006600; font-weight:bold;">&#41;</span>.<span style="color:#9900CC;">each</span> <span style="color:#9966CC; font-weight:bold;">do</span> <span style="color:#006600; font-weight:bold;">|</span>file<span style="color:#006600; font-weight:bold;">|</span>
      <span style="color:#CC0066; font-weight:bold;">puts</span> <span style="color:#996600;">`svn mv #{file} #{file.gsub(/<span style="color:#000099;">\.</span>rhtml$/, '.erb')}`</span>
    <span style="color:#9966CC; font-weight:bold;">end</span>
  <span style="color:#9966CC; font-weight:bold;">end</span>
 <span style="color:#9966CC; font-weight:bold;">end</span>
&nbsp;
 <span style="color:#008000; font-style:italic;">## or if you have rhtml and rxml you could probably use the following (untested)</span>
&nbsp;
 namespace <span style="color:#996600;">'views'</span> <span style="color:#9966CC; font-weight:bold;">do</span>
   desc <span style="color:#996600;">'Renames all your rhtml views to erb'</span>
   task <span style="color:#996600;">'rename'</span> <span style="color:#9966CC; font-weight:bold;">do</span>
     <span style="color:#CC00FF; font-weight:bold;">Dir</span>.<span style="color:#9900CC;">glob</span><span style="color:#006600; font-weight:bold;">&#40;</span><span style="color:#996600;">'app/views/**/*.rhtml'</span><span style="color:#006600; font-weight:bold;">&#41;</span>.<span style="color:#9900CC;">each</span> <span style="color:#9966CC; font-weight:bold;">do</span> <span style="color:#006600; font-weight:bold;">|</span>file<span style="color:#006600; font-weight:bold;">|</span>
       <span style="color:#CC0066; font-weight:bold;">puts</span> <span style="color:#996600;">`svn mv #{file} #{file.gsub(/<span style="color:#000099;">\.</span>(rhtml|rxml)$/, '.erb')}`</span>
     <span style="color:#9966CC; font-weight:bold;">end</span>
   <span style="color:#9966CC; font-weight:bold;">end</span>
 <span style="color:#9966CC; font-weight:bold;">end</span></pre></td></tr></table></div>

<p><a class="a2a_dd a2a_target addtoany_share_save" href="http://www.addtoany.com/share_save#url=http%3A%2F%2Fwww.amityadav.name%2Frenaming-your-rhtml-to-erb-on-edgerails%2F&amp;title=Renaming%20your%20.rhtml%20to%20.erb%20on%20EdgeRails" id="wpa2a_28"><img src="http://www.amityadav.name/wp-content/plugins/add-to-any/share_save_171_16.gif" width="171" height="16" alt="Share"/></a></p>]]></content:encoded>
			<wfw:commentRss>http://www.amityadav.name/renaming-your-rhtml-to-erb-on-edgerails/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Automatically tagging releases with capistrano</title>
		<link>http://www.amityadav.name/automatically-tagging-releases-with-capistrano/</link>
		<comments>http://www.amityadav.name/automatically-tagging-releases-with-capistrano/#comments</comments>
		<pubDate>Mon, 16 Jun 2008 04:36:26 +0000</pubDate>
		<dc:creator>Amit</dc:creator>
				<category><![CDATA[Ruby on Rails]]></category>
		<category><![CDATA[capistrano]]></category>

		<guid isPermaLink="false">http://www.amityadav.name/automatically-tagging-releases-with-capistrano/</guid>
		<description><![CDATA[Even though Capistrano “tags” each release by creating a new folder on the production server(s), it might be interesting to have a historical perspective in your repository anyway. This makes it easier to know exactly what went up for a release. I would like to share the following Capistrano recipe for your pleasure: config/deploy.rb ?View [...]]]></description>
			<content:encoded><![CDATA[<div class="content">Even though Capistrano “tags” each release by creating a new  folder on the production server(s), it might be interesting to have a historical  perspective in your repository anyway. This makes it easier to know exactly what  went up for a release. I would like to share the following Capistrano recipe for  your pleasure: config/deploy.rb</p>

<div class="wp_codebox_msgheader"><span class="right"><sup><a href="http://www.ericbess.com/ericblog/2008/03/03/wp-codebox/#examples" target="_blank" title="WP-CodeBox HowTo?"><span style="color: #99cc00">?</span></a></sup></span><span class="left"><a href="javascript:;" onclick="javascript:showCodeTxt('p49code14'); return false;">View Code</a> RUBY</span><div class="codebox_clear"></div></div><div class="wp_codebox"><table><tr id="p4914"><td class="line_numbers"><pre>1
2
3
4
5
6
7
8
</pre></td><td class="code" id="p49code14"><pre class="ruby" style="font-family:monospace;"> <span style="color:#CC0066; font-weight:bold;">require</span> ‘uri‘
 task <span style="color:#ff3333; font-weight:bold;">:after_deploy</span> <span style="color:#9966CC; font-weight:bold;">do</span>
   source = repository
   dest = <span style="color:#CC00FF; font-weight:bold;">URI</span>.<span style="color:#9900CC;">parse</span><span style="color:#006600; font-weight:bold;">&#40;</span>repository<span style="color:#006600; font-weight:bold;">&#41;</span>.<span style="color:#9900CC;">merge</span><span style="color:#006600; font-weight:bold;">&#40;</span>“..<span style="color:#006600; font-weight:bold;">/</span>releases<span style="color:#006600; font-weight:bold;">/</span><span style="color:#008000; font-style:italic;">#{File.basename(release_path)}“)</span>
   cmd = “svn copy –revision=<span style="color:#008000; font-style:italic;">#{revision} –quiet –message \”Auto tagging release #{release_path}\” #{source} #{dest}“</span>
   <span style="color:#CC0066; font-weight:bold;">puts</span> cmd
   <span style="color:#996600;">`#{cmd}`</span>
 <span style="color:#9966CC; font-weight:bold;">end</span></pre></td></tr></table></div>

<p>First, we  start by requiring uri, because Subversion does not like relative URLs. Next, we  find the location into which to tag the release, and finally, we just do it.  Simple, effective. Enjoy !</p></div>
<p><a class="a2a_dd a2a_target addtoany_share_save" href="http://www.addtoany.com/share_save#url=http%3A%2F%2Fwww.amityadav.name%2Fautomatically-tagging-releases-with-capistrano%2F&amp;title=Automatically%20tagging%20releases%20with%20capistrano" id="wpa2a_30"><img src="http://www.amityadav.name/wp-content/plugins/add-to-any/share_save_171_16.gif" width="171" height="16" alt="Share"/></a></p>]]></content:encoded>
			<wfw:commentRss>http://www.amityadav.name/automatically-tagging-releases-with-capistrano/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Exporting development data to fixture files for your test (Ruby)</title>
		<link>http://www.amityadav.name/exporting-development-data-to-fixture-files-for-your-test-ruby/</link>
		<comments>http://www.amityadav.name/exporting-development-data-to-fixture-files-for-your-test-ruby/#comments</comments>
		<pubDate>Thu, 12 Jun 2008 05:09:06 +0000</pubDate>
		<dc:creator>Amit</dc:creator>
				<category><![CDATA[Ruby on Rails]]></category>

		<guid isPermaLink="false">http://www.amityadav.name/exporting-development-data-to-fixture-files-for-your-test-ruby/</guid>
		<description><![CDATA[For your unit &#38; functional tests you have to provide input data to your test files and you do that through fixtures. The script below extracts the data from the development data base and puts it to the fixture file for each table. ?View Code RUBY1 2 3 4 5 6 7 8 9 10 [...]]]></description>
			<content:encoded><![CDATA[<p>For your unit &amp; functional tests you have to provide input data to your test files and you do that through fixtures. The script below extracts the data from the development data base and puts it to the fixture file for each table.</p>

<div class="wp_codebox_msgheader"><span class="right"><sup><a href="http://www.ericbess.com/ericblog/2008/03/03/wp-codebox/#examples" target="_blank" title="WP-CodeBox HowTo?"><span style="color: #99cc00">?</span></a></sup></span><span class="left"><a href="javascript:;" onclick="javascript:showCodeTxt('p44code16'); return false;">View Code</a> RUBY</span><div class="codebox_clear"></div></div><div class="wp_codebox"><table><tr id="p4416"><td class="line_numbers"><pre>1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
</pre></td><td class="code" id="p44code16"><pre class="ruby" style="font-family:monospace;">namespace <span style="color:#ff3333; font-weight:bold;">:db</span> <span style="color:#9966CC; font-weight:bold;">do</span>
  desc <span style="color:#996600;">'Create YAML test fixtures from data in an existing database.
  Defaults to development database. Set RAILS_ENV to override.'</span>
&nbsp;
  task <span style="color:#ff3333; font-weight:bold;">:extract_fixtures</span> =<span style="color:#006600; font-weight:bold;">&amp;</span>gt; <span style="color:#ff3333; font-weight:bold;">:environment</span> <span style="color:#9966CC; font-weight:bold;">do</span>
    sql = <span style="color:#996600;">&quot;SELECT * FROM %s&quot;</span>
    skip_tables = <span style="color:#006600; font-weight:bold;">&#91;</span><span style="color:#996600;">&quot;schema_info&quot;</span>, <span style="color:#996600;">&quot;sessions&quot;</span><span style="color:#006600; font-weight:bold;">&#93;</span>
    <span style="color:#6666ff; font-weight:bold;">ActiveRecord::Base</span>.<span style="color:#9900CC;">establish_connection</span>
    tables = ENV<span style="color:#006600; font-weight:bold;">&#91;</span><span style="color:#996600;">'FIXTURES'</span><span style="color:#006600; font-weight:bold;">&#93;</span> ? ENV<span style="color:#006600; font-weight:bold;">&#91;</span><span style="color:#996600;">'FIXTURES'</span><span style="color:#006600; font-weight:bold;">&#93;</span>.<span style="color:#CC0066; font-weight:bold;">split</span><span style="color:#006600; font-weight:bold;">&#40;</span><span style="color:#006600; font-weight:bold;">/</span>,<span style="color:#006600; font-weight:bold;">/</span><span style="color:#006600; font-weight:bold;">&#41;</span> : <span style="color:#6666ff; font-weight:bold;">ActiveRecord::Base</span>.<span style="color:#9900CC;">connection</span>.<span style="color:#9900CC;">tables</span> <span style="color:#006600; font-weight:bold;">-</span> skip_tables
    tables.<span style="color:#9900CC;">each</span> <span style="color:#9966CC; font-weight:bold;">do</span> <span style="color:#006600; font-weight:bold;">|</span>table_name<span style="color:#006600; font-weight:bold;">|</span>
      i = <span style="color:#996600;">&quot;000&quot;</span>
      <span style="color:#CC00FF; font-weight:bold;">File</span>.<span style="color:#CC0066; font-weight:bold;">open</span><span style="color:#006600; font-weight:bold;">&#40;</span><span style="color:#996600;">&quot;#{RAILS_ROOT}/test/fixtures/#{table_name}.yml&quot;</span>, <span style="color:#996600;">'w'</span><span style="color:#006600; font-weight:bold;">&#41;</span> <span style="color:#9966CC; font-weight:bold;">do</span> <span style="color:#006600; font-weight:bold;">|</span>file<span style="color:#006600; font-weight:bold;">|</span>
        data = <span style="color:#6666ff; font-weight:bold;">ActiveRecord::Base</span>.<span style="color:#9900CC;">connection</span>.<span style="color:#9900CC;">select_all</span><span style="color:#006600; font-weight:bold;">&#40;</span>sql <span style="color:#006600; font-weight:bold;">%</span> table_name<span style="color:#006600; font-weight:bold;">&#41;</span>
        file.<span style="color:#9900CC;">write</span> data.<span style="color:#9900CC;">inject</span><span style="color:#006600; font-weight:bold;">&#40;</span><span style="color:#006600; font-weight:bold;">&#123;</span><span style="color:#006600; font-weight:bold;">&#125;</span><span style="color:#006600; font-weight:bold;">&#41;</span> <span style="color:#006600; font-weight:bold;">&#123;</span> <span style="color:#006600; font-weight:bold;">|</span>hash, record<span style="color:#006600; font-weight:bold;">|</span>
          hash<span style="color:#006600; font-weight:bold;">&#91;</span><span style="color:#996600;">&quot;#{table_name}_#{i.succ!}&quot;</span><span style="color:#006600; font-weight:bold;">&#93;</span> = record
          hash
        <span style="color:#006600; font-weight:bold;">&#125;</span>.<span style="color:#9900CC;">to_yaml</span>
      <span style="color:#9966CC; font-weight:bold;">end</span>
    <span style="color:#9966CC; font-weight:bold;">end</span>
  <span style="color:#9966CC; font-weight:bold;">end</span>
<span style="color:#9966CC; font-weight:bold;">end</span></pre></td></tr></table></div>

<p><a class="a2a_dd a2a_target addtoany_share_save" href="http://www.addtoany.com/share_save#url=http%3A%2F%2Fwww.amityadav.name%2Fexporting-development-data-to-fixture-files-for-your-test-ruby%2F&amp;title=Exporting%20development%20data%20to%20fixture%20files%20for%20your%20test%20%28Ruby%29" id="wpa2a_32"><img src="http://www.amityadav.name/wp-content/plugins/add-to-any/share_save_171_16.gif" width="171" height="16" alt="Share"/></a></p>]]></content:encoded>
			<wfw:commentRss>http://www.amityadav.name/exporting-development-data-to-fixture-files-for-your-test-ruby/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>shame.rake</title>
		<link>http://www.amityadav.name/shamerake/</link>
		<comments>http://www.amityadav.name/shamerake/#comments</comments>
		<pubDate>Thu, 12 Jun 2008 05:03:34 +0000</pubDate>
		<dc:creator>Amit</dc:creator>
				<category><![CDATA[Ruby on Rails]]></category>

		<guid isPermaLink="false">http://www.amityadav.name/shamerake/</guid>
		<description><![CDATA[If you’ve ever been working on a Rails application and found yourself [stupidly] slipping in your testing, We have just the tool for you. Using rake and rubyosa, you can now automatically post your Code to Test Ratio as your iChat status message—meaning you can now use shame and self-humiliation to keep you motivated. After [...]]]></description>
			<content:encoded><![CDATA[<p>If you’ve ever been working on a Rails application and found yourself [stupidly] slipping in your testing, We have just the tool for you. Using rake and rubyosa, you can now automatically post your Code to Test Ratio as your iChat status message—meaning you can now use shame and self-humiliation to keep you motivated. After you’ve installed rubyosa, add shame.rake to your lib/tasks directory. The file contains:</p>

<div class="wp_codebox_msgheader"><span class="right"><sup><a href="http://www.ericbess.com/ericblog/2008/03/03/wp-codebox/#examples" target="_blank" title="WP-CodeBox HowTo?"><span style="color: #99cc00">?</span></a></sup></span><span class="left"><a href="javascript:;" onclick="javascript:showCodeTxt('p43code18'); return false;">View Code</a> RUBY</span><div class="codebox_clear"></div></div><div class="wp_codebox"><table><tr id="p4318"><td class="line_numbers"><pre>1
2
3
4
5
6
7
8
9
10
11
12
</pre></td><td class="code" id="p43code18"><pre class="ruby" style="font-family:monospace;"><span style="color:#CC0066; font-weight:bold;">require</span> <span style="color:#996600;">'rbosa'</span>
<span style="color:#CC0066; font-weight:bold;">require</span> <span style="color:#996600;">'code_statistics'</span>
&nbsp;
task <span style="color:#ff3333; font-weight:bold;">:shame</span> <span style="color:#9966CC; font-weight:bold;">do</span>
  stats = CodeStatistics.<span style="color:#9900CC;">new</span><span style="color:#006600; font-weight:bold;">&#40;</span><span style="color:#006600; font-weight:bold;">*</span>STATS_DIRECTORIES<span style="color:#006600; font-weight:bold;">&#41;</span>
  code  = stats.<span style="color:#9900CC;">send</span> <span style="color:#ff3333; font-weight:bold;">:calculate_code</span>
  tests = stats.<span style="color:#9900CC;">send</span> <span style="color:#ff3333; font-weight:bold;">:calculate_tests</span>
  ichat = OSA.<span style="color:#9900CC;">app</span><span style="color:#006600; font-weight:bold;">&#40;</span><span style="color:#996600;">'ichat'</span><span style="color:#006600; font-weight:bold;">&#41;</span>
  msg = <span style="color:#996600;">&quot;Code To Test Ratio: 1:#{sprintf(&quot;</span><span style="color:#006600; font-weight:bold;">%</span>.1f<span style="color:#996600;">&quot;, tests.to_f/code)}&quot;</span>
  ichat.<span style="color:#9900CC;">status_message</span> = msg
  <span style="color:#ff6633; font-weight:bold;">$stderr</span>.<span style="color:#CC0066; font-weight:bold;">puts</span> <span style="color:#006600; font-weight:bold;">%|</span>iChat status set to: <span style="color:#008000; font-style:italic;">#{msg.inspect}|</span>
<span style="color:#9966CC; font-weight:bold;">end</span></pre></td></tr></table></div>

<p><a class="a2a_dd a2a_target addtoany_share_save" href="http://www.addtoany.com/share_save#url=http%3A%2F%2Fwww.amityadav.name%2Fshamerake%2F&amp;title=shame.rake" id="wpa2a_34"><img src="http://www.amityadav.name/wp-content/plugins/add-to-any/share_save_171_16.gif" width="171" height="16" alt="Share"/></a></p>]]></content:encoded>
			<wfw:commentRss>http://www.amityadav.name/shamerake/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Simple method to find age of person</title>
		<link>http://www.amityadav.name/simple-method-to-find-age-of-person/</link>
		<comments>http://www.amityadav.name/simple-method-to-find-age-of-person/#comments</comments>
		<pubDate>Thu, 12 Jun 2008 04:56:06 +0000</pubDate>
		<dc:creator>Amit</dc:creator>
				<category><![CDATA[Ruby on Rails]]></category>

		<guid isPermaLink="false">http://www.amityadav.name/simple-method-to-find-age-of-person/</guid>
		<description><![CDATA[?View Code RUBY1 2 3 def age &#40;&#40;Time.now - birthday&#41; / &#40;60*60*24&#41;/365.2422&#41;.to_i end]]></description>
			<content:encoded><![CDATA[
<div class="wp_codebox_msgheader"><span class="right"><sup><a href="http://www.ericbess.com/ericblog/2008/03/03/wp-codebox/#examples" target="_blank" title="WP-CodeBox HowTo?"><span style="color: #99cc00">?</span></a></sup></span><span class="left"><a href="javascript:;" onclick="javascript:showCodeTxt('p42code20'); return false;">View Code</a> RUBY</span><div class="codebox_clear"></div></div><div class="wp_codebox"><table><tr id="p4220"><td class="line_numbers"><pre>1
2
3
</pre></td><td class="code" id="p42code20"><pre class="ruby" style="font-family:monospace;"><span style="color:#9966CC; font-weight:bold;">def</span> age
   <span style="color:#006600; font-weight:bold;">&#40;</span><span style="color:#006600; font-weight:bold;">&#40;</span><span style="color:#CC00FF; font-weight:bold;">Time</span>.<span style="color:#9900CC;">now</span> <span style="color:#006600; font-weight:bold;">-</span> birthday<span style="color:#006600; font-weight:bold;">&#41;</span> <span style="color:#006600; font-weight:bold;">/</span> <span style="color:#006600; font-weight:bold;">&#40;</span><span style="color:#006666;">60</span><span style="color:#006600; font-weight:bold;">*</span><span style="color:#006666;">60</span><span style="color:#006600; font-weight:bold;">*</span><span style="color:#006666;">24</span><span style="color:#006600; font-weight:bold;">&#41;</span><span style="color:#006600; font-weight:bold;">/</span><span style="color:#006666;">365.2422</span><span style="color:#006600; font-weight:bold;">&#41;</span>.<span style="color:#9900CC;">to_i</span>
<span style="color:#9966CC; font-weight:bold;">end</span></pre></td></tr></table></div>

<p><a class="a2a_dd a2a_target addtoany_share_save" href="http://www.addtoany.com/share_save#url=http%3A%2F%2Fwww.amityadav.name%2Fsimple-method-to-find-age-of-person%2F&amp;title=Simple%20method%20to%20find%20age%20of%20person" id="wpa2a_36"><img src="http://www.amityadav.name/wp-content/plugins/add-to-any/share_save_171_16.gif" width="171" height="16" alt="Share"/></a></p>]]></content:encoded>
			<wfw:commentRss>http://www.amityadav.name/simple-method-to-find-age-of-person/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Rails Image Cropping</title>
		<link>http://www.amityadav.name/rails-image-cropping/</link>
		<comments>http://www.amityadav.name/rails-image-cropping/#comments</comments>
		<pubDate>Wed, 09 Apr 2008 13:12:53 +0000</pubDate>
		<dc:creator>Amit</dc:creator>
				<category><![CDATA[Ruby on Rails]]></category>
		<category><![CDATA[crop]]></category>
		<category><![CDATA[Rails]]></category>

		<guid isPermaLink="false">http://www.amityadav.name/rails-image-cropping/</guid>
		<description><![CDATA[I was looking for an UI for image cropping utility for my project and came across this, it was using php as its backend but i changed it to use rails as its backend. The UI is simple and can be incorporated with different backend solutions. Here is the code.]]></description>
			<content:encoded><![CDATA[<p align="justify">I was looking for an UI for image cropping utility for my project and came across <a title="Image Crop UI" href="http://www.dhtmlgoodies.com/index.html?whichScript=image-crop" target="_blank">this</a>, it was using php as its backend but i changed it to use rails as its backend. The UI is simple and can be incorporated with different backend solutions.</p>
<p align="justify"><a title="Here" href="http://www.amityadav.name/wp-content/image_crop.rar"></a><a href="http://www.amityadav.name/wp-content/uploads/2009/01/image_crop.rar">Here</a> is the code.</p>
<p><a class="a2a_dd a2a_target addtoany_share_save" href="http://www.addtoany.com/share_save#url=http%3A%2F%2Fwww.amityadav.name%2Frails-image-cropping%2F&amp;title=Rails%20Image%20Cropping" id="wpa2a_38"><img src="http://www.amityadav.name/wp-content/plugins/add-to-any/share_save_171_16.gif" width="171" height="16" alt="Share"/></a></p>]]></content:encoded>
			<wfw:commentRss>http://www.amityadav.name/rails-image-cropping/feed/</wfw:commentRss>
		<slash:comments>4</slash:comments>
		</item>
		<item>
		<title>Rails Cheatsheets</title>
		<link>http://www.amityadav.name/rails-cheatsheets/</link>
		<comments>http://www.amityadav.name/rails-cheatsheets/#comments</comments>
		<pubDate>Fri, 04 Apr 2008 11:48:41 +0000</pubDate>
		<dc:creator>Amit</dc:creator>
				<category><![CDATA[cheatsheet]]></category>
		<category><![CDATA[Ruby on Rails]]></category>
		<category><![CDATA[Rails]]></category>
		<category><![CDATA[rails cheatsheet]]></category>
		<category><![CDATA[Ruby]]></category>

		<guid isPermaLink="false">http://www.amityadav.name/rails-cheatsheets/</guid>
		<description><![CDATA[Here are the rails cheatsheet&#8217;s which will help you to get a good overview of how things work in RAILS. Full Ruby on Rails cheatsheet Rails Assertions RJS Cheatsheet REST Cheatsheet Rails Refrence Rails Migration Rails File Cheatsheet Form Helpers Asserts in Rails Active Record cheatsheet rubyonrails-cheatsheet.pdf]]></description>
			<content:encoded><![CDATA[<p>Here are the rails cheatsheet&#8217;s which will help you to get a good overview of how things work in RAILS.</p>
<p><a href="http://www.amityadav.name/rails-cheatsheets/full-ruby-on-rails-cheatsheet/" rel="attachment wp-att-18" title="Full Ruby on Rails cheatsheet">Full Ruby on Rails cheatsheet</a></p>
<p><a href="http://www.amityadav.name/rails-cheatsheets/rails-assertions/" rel="attachment wp-att-17" title="Rails Assertions">Rails Assertions</a></p>
<p><a href="http://www.amityadav.name/rails-cheatsheets/rails-assertions/" rel="attachment wp-att-17" title="Rails Assertions"></a><a href="http://www.amityadav.name/rails-cheatsheets/rjs-cheatsheet/" rel="attachment wp-att-16" title="RJS Cheatsheet">RJS Cheatsheet</a></p>
<p><a href="http://www.amityadav.name/rails-cheatsheets/rest-cheatsheet/" rel="attachment wp-att-15" title="REST Cheatsheet">REST Cheatsheet</a></p>
<p><a href="http://www.amityadav.name/rails-cheatsheets/rest-cheatsheet/" rel="attachment wp-att-15" title="REST Cheatsheet"></a><a href="http://www.amityadav.name/rails-cheatsheets/rails-refrence/" rel="attachment wp-att-14" title="Rails Refrence">Rails Refrence</a></p>
<p><a href="http://www.amityadav.name/rails-cheatsheets/rails-refrence/" rel="attachment wp-att-14" title="Rails Refrence"></a><a href="http://www.amityadav.name/rails-cheatsheets/rails-migration/" rel="attachment wp-att-13" title="Rails Migration">Rails Migration</a></p>
<p><a href="http://www.amityadav.name/rails-cheatsheets/rails-migration/" rel="attachment wp-att-13" title="Rails Migration"></a><a href="http://www.amityadav.name/rails-cheatsheets/rails-file-cheatsheet/" rel="attachment wp-att-12" title="Rails File Cheatsheet">Rails File Cheatsheet</a></p>
<p><a href="http://www.amityadav.name/rails-cheatsheets/rails-file-cheatsheet/" rel="attachment wp-att-12" title="Rails File Cheatsheet"></a><a href="http://www.amityadav.name/rails-cheatsheets/form-helpers/" rel="attachment wp-att-11" title="Form Helpers">Form Helpers</a></p>
<p><a href="http://www.amityadav.name/rails-cheatsheets/asserts-in-rails/" rel="attachment wp-att-10" title="Asserts in Rails">Asserts in Rails</a></p>
<p><a href="http://www.amityadav.name/rails-cheatsheets/active-record-cheatsheet/" rel="attachment wp-att-9" title="Active Record cheatsheet">Active Record cheatsheet</a></p>
<p><a href="http://www.amityadav.name/rails-cheatsheets/8/" rel="attachment wp-att-8" title="rubyonrails-cheatsheet.pdf">rubyonrails-cheatsheet.pdf</a></p>
<p><a class="a2a_dd a2a_target addtoany_share_save" href="http://www.addtoany.com/share_save#url=http%3A%2F%2Fwww.amityadav.name%2Frails-cheatsheets%2F&amp;title=Rails%20Cheatsheets" id="wpa2a_40"><img src="http://www.amityadav.name/wp-content/plugins/add-to-any/share_save_171_16.gif" width="171" height="16" alt="Share"/></a></p>]]></content:encoded>
			<wfw:commentRss>http://www.amityadav.name/rails-cheatsheets/feed/</wfw:commentRss>
		<slash:comments>1</slash:comments>
		</item>
	</channel>
</rss>

