<?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>Squash</title>
	<atom:link href="http://balpreetpankaj.com/blog/feed/" rel="self" type="application/rss+xml" />
	<link>http://balpreetpankaj.com/blog</link>
	<description>Just another weblog</description>
	<lastBuildDate>Mon, 10 Aug 2009 03:21:51 +0000</lastBuildDate>
	<generator>http://wordpress.org/?v=2.8.2</generator>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
			<item>
		<title>Skip Validations</title>
		<link>http://balpreetpankaj.com/blog/2009/08/09/skip-validations/</link>
		<comments>http://balpreetpankaj.com/blog/2009/08/09/skip-validations/#comments</comments>
		<pubDate>Mon, 10 Aug 2009 03:05:36 +0000</pubDate>
		<dc:creator>balpreetspankaj</dc:creator>
				<category><![CDATA[Uncategorized]]></category>

		<guid isPermaLink="false">http://balpreetpankaj.com/blog/?p=75</guid>
		<description><![CDATA[How many times have you felt like skipping validations on a particular model while writing rspec tests ?  Last night, I was trying to write rspec tests for one of my models which tested transactions of money between two users. My user model has tens of validations and I totally wanted to skip them [...]]]></description>
			<content:encoded><![CDATA[<p>How many times have you felt like skipping validations on a particular model while writing rspec tests ?  Last night, I was trying to write rspec tests for one of my models which tested transactions of money between two users. My user model has tens of validations and I totally wanted to skip them all. I just wanted to test the functionality that the money was transacted between the two users correctly. Thats when I used some of Ruby's metaprogramming capabilities to skip validations. Once I was done writing my tests (phew !!) , I decided to turn this into a Rails Plugin, enter <a href="http://github.com/balpreetspankaj/SkipValidations/tree/master">SkipValidations</a> ( <a href="http://github.com/balpreetspankaj/SkipValidations/tree/master"> http://github.com/balpreetspankaj/SkipValidations/tree/master</a>).</p>
<p>This is a very simple plugin. Just install the plugin and then use the skip_validations on any ActiveRecord::Base class and give it the list of models fr which you want no validations. Simple ! for example,</p>
<p>User.skip_validations(:user, :person) {SellRequest.match_requests } </p>
<p>will skip validations for both User and Person model while running the SellRequest.match_requests function. This plugin made my testing a lot more smoother. Hopefully this is useful for you guys too.</p>
]]></content:encoded>
			<wfw:commentRss>http://balpreetpankaj.com/blog/2009/08/09/skip-validations/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Facebook Iframe Application: Resize Iframe</title>
		<link>http://balpreetpankaj.com/blog/2009/07/24/facebook-iframe-application-resize-iframe/</link>
		<comments>http://balpreetpankaj.com/blog/2009/07/24/facebook-iframe-application-resize-iframe/#comments</comments>
		<pubDate>Fri, 24 Jul 2009 09:12:09 +0000</pubDate>
		<dc:creator>balpreetspankaj</dc:creator>
				<category><![CDATA[Facebook]]></category>
		<category><![CDATA[Facebooker]]></category>
		<category><![CDATA[Rails]]></category>
		<category><![CDATA[html]]></category>

		<guid isPermaLink="false">http://balpreetpankaj.com/blog/?p=65</guid>
		<description><![CDATA[If you are using Rails and Facebooker, and you have a resizable Iframe application and you are having problems with resizing, do the following:
a) Make sure that the Iframe is set to Resizable in the Facebook appplication settings.
b) Instead of calling just &#60;%= init_fb_connect "XFBML" %&#62; (as mentioned in all the tutorials), use
&#60;% init_fb_connect &#34;XFBML&#34; [...]]]></description>
			<content:encoded><![CDATA[<p>If you are using Rails and Facebooker, and you have a resizable Iframe application and you are having problems with resizing, do the following:</p>
<p>a) Make sure that the Iframe is set to Resizable in the Facebook appplication settings.</p>
<p>b) Instead of calling just &lt;%= init_fb_connect "XFBML" %&gt; (as mentioned in all the tutorials), use</p>
<pre class="ruby">&lt;% init_fb_connect <span style="color:#996600;">&quot;XFBML&quot;</span> <span style="color:#9966CC; font-weight:bold;">do</span> %&gt;
FB.<span style="color:#9900CC;">CanvasClient</span>.<span style="color:#9900CC;">startTimerToSizeToContent</span><span style="color:#006600; font-weight:bold;">&#40;</span><span style="color:#006600; font-weight:bold;">&#41;</span>;
&lt;% <span style="color:#9966CC; font-weight:bold;">end</span> %&gt;</pre>
<p>This should automatically resize your Iframe in the facebook canvas</p>
]]></content:encoded>
			<wfw:commentRss>http://balpreetpankaj.com/blog/2009/07/24/facebook-iframe-application-resize-iframe/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Facebooker: Creating an Iframe Application (Incorrect Signature)</title>
		<link>http://balpreetpankaj.com/blog/2009/07/24/facebooker-creating-an-iframe-application-incorrect-signature/</link>
		<comments>http://balpreetpankaj.com/blog/2009/07/24/facebooker-creating-an-iframe-application-incorrect-signature/#comments</comments>
		<pubDate>Fri, 24 Jul 2009 09:05:06 +0000</pubDate>
		<dc:creator>balpreetspankaj</dc:creator>
				<category><![CDATA[Facebook]]></category>
		<category><![CDATA[Facebooker]]></category>
		<category><![CDATA[Rails]]></category>
		<category><![CDATA[Ruby]]></category>
		<category><![CDATA[Uncategorized]]></category>

		<guid isPermaLink="false">http://balpreetpankaj.com/blog/?p=56</guid>
		<description><![CDATA[I started developing a Facebook app for one of my existing websites.  Since, I already had a working website and I prefer normal html and js over fbml and JS over FBML and FBJS, I decided to take the IFrame route. While working with my app, I ran into this bizarre problem where clicking on [...]]]></description>
			<content:encoded><![CDATA[<p>I started developing a Facebook app for one of my existing websites.  Since, I already had a working website and I prefer normal html and js over fbml and JS over FBML and FBJS, I decided to take the IFrame route. While working with my app, I ran into this bizarre problem where clicking on any link after loading the facebook app, gave me an invalid Signature exception. After digging my way through the Facebooker (Rails plugin for Facebook app dev) code, I find that the expected signature is nil inside the "verify_signature function". Turns out you need to append all your links in a Facebook iframe app with the fb_sig params. So, I created a function in Application.rb and set it as a before_filter</p>
<pre class="ruby">before_filter <span style="color:#ff3333; font-weight:bold;">:set_facebook_params</span>
ensure_application_is_installed_by_facebook_user
&nbsp;
protected
<span style="color:#9966CC; font-weight:bold;">def</span> set_facebook_params
<span style="color:#0066ff; font-weight:bold;">@fb_params</span> = params.<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:#9966CC; font-weight:bold;">do</span> |collection, pair|
collection<span style="color:#006600; font-weight:bold;">&#91;</span>pair.<span style="color:#9900CC;">first</span><span style="color:#006600; font-weight:bold;">&#93;</span> = pair.<span style="color:#9900CC;">second</span> <span style="color:#9966CC; font-weight:bold;">if</span> pair.<span style="color:#9900CC;">first</span> =~ /^fb_sig/
collection
<span style="color:#9966CC; font-weight:bold;">end</span>
<span style="color:#9966CC; font-weight:bold;">end</span></pre>
<p>The above code will extract out all the fb_sig params from the url and store it in @fb_params. Now add this hash to every url that you create inside you Iframe. This was the fix that I came in the middle of the might, and I am sure this may not be the best fix. But this works. Let me know if there is another workaround.</p>
]]></content:encoded>
			<wfw:commentRss>http://balpreetpankaj.com/blog/2009/07/24/facebooker-creating-an-iframe-application-incorrect-signature/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>SMERF and issues with MySQL</title>
		<link>http://balpreetpankaj.com/blog/2009/02/10/smerf-and-issues-with-mysql/</link>
		<comments>http://balpreetpankaj.com/blog/2009/02/10/smerf-and-issues-with-mysql/#comments</comments>
		<pubDate>Tue, 10 Feb 2009 17:41:51 +0000</pubDate>
		<dc:creator>balpreetspankaj</dc:creator>
				<category><![CDATA[Rails]]></category>
		<category><![CDATA[mysql]]></category>
		<category><![CDATA[plugins]]></category>
		<category><![CDATA[Smerf]]></category>

		<guid isPermaLink="false">http://balpreetpankaj.com/blog/?p=46</guid>
		<description><![CDATA[SMERF is the meta form generator plugin for Rails. The plugin I would say is very useful. It takes in a form definition file, defined in YAML and creates a form on the fly. These forms are associated to users and the responses to the forms are also persisted in the db. Ideal for making [...]]]></description>
			<content:encoded><![CDATA[<p><a href="http://smerf.cascadia.com.au/">SMERF</a> is the meta form generator plugin for Rails. The plugin I would say is very useful. It takes in a form definition file, defined in YAML and creates a form on the fly. These forms are associated to users and the responses to the forms are also persisted in the db. Ideal for making a quick survey for the users on your websites. I was using this plugin to create a survey for the upcoming fashion website <a href="http://www.chictini.com">chictini.com</a>, and ran into a weird issue.</p>
<p>SMERF plugin, actually parses a form definition YAML file, and creates a SmerfForm object out of it. This SmerfForm object is actually persisted in your db, for fast future accesses. Now this SmerfForm object is serialized into a text field in a MySQL table. Everything works fine when you have small forms. But as soon as your forms get bigger, you hit a MySQL issue. The max size of a text field in MySQL is 64 KB. So if the serialized data is more than 64 KB, you start getting weird errors. The serialization does nnot throw an error, neither does saving the object in DB. But when you try to access the serialized data, you basically get incomplete serialized data, which is nothing but garbage for your purposes.</p>
<p>Solution:  Change the column which stores the serialized data to longtext for MySQL. You can create a migration for this which would look like this:</p>
<pre class="ruby">&nbsp;
<span style="color:#9966CC; font-weight:bold;">class</span> UpdateColumnInSmerf &gt; <span style="color:#6666ff; font-weight:bold;">ActiveRecord::Migration</span>
<span style="color:#9966CC; font-weight:bold;">def</span> <span style="color:#0000FF; font-weight:bold;">self</span>.<span style="color:#9900CC;">up</span>
execute <span style="color:#996600;">&quot;ALTER TABLE smerf_forms MODIFY COLUMN cache LONGTEXT&quot;</span>
<span style="color:#9966CC; font-weight:bold;">end</span>
&nbsp;
<span style="color:#9966CC; font-weight:bold;">def</span> <span style="color:#0000FF; font-weight:bold;">self</span>.<span style="color:#9900CC;">down</span>
execute <span style="color:#996600;">&quot;ALTER TABLE smerf_forms MODIFY COLUMN cache TEXT&quot;</span>
<span style="color:#9966CC; font-weight:bold;">end</span>
<span style="color:#9966CC; font-weight:bold;">end</span>
&nbsp;</pre>
<p>This was was one of the annoying issues which kept me awake till 3 am.</p>
]]></content:encoded>
			<wfw:commentRss>http://balpreetpankaj.com/blog/2009/02/10/smerf-and-issues-with-mysql/feed/</wfw:commentRss>
		<slash:comments>1</slash:comments>
		</item>
		<item>
		<title>Div inside a p : Invalid HTML</title>
		<link>http://balpreetpankaj.com/blog/2009/01/28/div-inside-a-p-invalid-html/</link>
		<comments>http://balpreetpankaj.com/blog/2009/01/28/div-inside-a-p-invalid-html/#comments</comments>
		<pubDate>Wed, 28 Jan 2009 23:20:47 +0000</pubDate>
		<dc:creator>balpreetspankaj</dc:creator>
				<category><![CDATA[Rails]]></category>
		<category><![CDATA[html]]></category>
		<category><![CDATA[div]]></category>
		<category><![CDATA[p]]></category>
		<category><![CDATA[simple_captcha]]></category>
		<category><![CDATA[w3C]]></category>

		<guid isPermaLink="false">http://balpreetpankaj.com/blog/?p=38</guid>
		<description><![CDATA[I was trying to center an element using the p tag. Like :
&#60;p style="margin-left:auto; magin-right:auto; width: 50 em;"&#62;
&#60;%= show_simple_captcha %&#62;
&#60;/p&#62;
show_simple_captcha is a helper method from the simple captcha rails plugin. This view helper generates a div which helps in captcha validation. Now, this created a problem. This piece of code started to behave randomly in [...]]]></description>
			<content:encoded><![CDATA[<p>I was trying to center an element using the p tag. Like :<br />
&lt;p style="margin-left:auto; magin-right:auto; width: 50 em;"&gt;<br />
&lt;%= show_simple_captcha %&gt;<br />
&lt;/p&gt;</p>
<p>show_simple_captcha is a helper method from the simple captcha rails plugin. This view helper generates a div which helps in captcha validation. Now, this created a problem. This piece of code started to behave randomly in IE. Even the source generated in Firefox is invalid HTML. After much scratching arnd, I found that &lt;div&gt; tags are not allowed inside &lt;p&gt; tags. Strange !! I dont have a reason of the top of my head as to why this is disallowed, but this is invalid W3C HTML.</p>
]]></content:encoded>
			<wfw:commentRss>http://balpreetpankaj.com/blog/2009/01/28/div-inside-a-p-invalid-html/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>action_mailer_tls and Ruby 1.8.7</title>
		<link>http://balpreetpankaj.com/blog/2009/01/21/action_mailer_tls-and-ruby-187/</link>
		<comments>http://balpreetpankaj.com/blog/2009/01/21/action_mailer_tls-and-ruby-187/#comments</comments>
		<pubDate>Wed, 21 Jan 2009 19:13:22 +0000</pubDate>
		<dc:creator>balpreetspankaj</dc:creator>
				<category><![CDATA[Rails]]></category>
		<category><![CDATA[Ruby]]></category>
		<category><![CDATA[action_mailer_tls]]></category>
		<category><![CDATA[check_auth_args]]></category>
		<category><![CDATA[plugins]]></category>
		<category><![CDATA[ruby 1.8.7]]></category>

		<guid isPermaLink="false">http://balpreetpankaj.com/blog/?p=34</guid>
		<description><![CDATA[If you are using action_mailer_tls rails pluin and you shifted to Ruby 1.8.7, your app might break. I recently ran into this problem, coz my host providers shifted to Ruby 1.8.7 and I started getting errors when I was trying to send emails. The problem is because the check_auth_args function has changed in Ruby 1.8.7. [...]]]></description>
			<content:encoded><![CDATA[<p>If you are using action_mailer_tls rails pluin and you shifted to Ruby 1.8.7, your app might break. I recently ran into this problem, coz my host providers shifted to Ruby 1.8.7 and I started getting errors when I was trying to send emails. The problem is because the check_auth_args function has changed in Ruby 1.8.7. Now it requires only 2 args as opposed to 3. The action_mailer_tls plugin uses this function but uses three arguments. So, to get back running again, make the following changes:</p>
<p>1).  Go to your action_mailer_tls plugin installation<br />
2). Inside the do_start function, replace the call to "check_auth_args" with the following snippet:</p>
<pre class="ruby">&nbsp;
no_args = method<span style="color:#006600; font-weight:bold;">&#40;</span><span style="color:#ff3333; font-weight:bold;">:check_auth_args</span><span style="color:#006600; font-weight:bold;">&#41;</span>.<span style="color:#9900CC;">arity</span>
<span style="color:#9966CC; font-weight:bold;">if</span> no_args == <span style="color:#006666;">2</span>
  check_auth_args user, secret <span style="color:#9966CC; font-weight:bold;">if</span> user <span style="color:#9966CC; font-weight:bold;">or</span> secret
<span style="color:#9966CC; font-weight:bold;">else</span>
  check_auth_args user, secret, authtype <span style="color:#9966CC; font-weight:bold;">if</span> user <span style="color:#9966CC; font-weight:bold;">or</span> secret
<span style="color:#9966CC; font-weight:bold;">end</span>
&nbsp;</pre>
]]></content:encoded>
			<wfw:commentRss>http://balpreetpankaj.com/blog/2009/01/21/action_mailer_tls-and-ruby-187/feed/</wfw:commentRss>
		<slash:comments>3</slash:comments>
		</item>
		<item>
		<title>Ruby 1.8.7 String#chars compatibility problem with rails</title>
		<link>http://balpreetpankaj.com/blog/2008/12/31/ruby-187-stringchars-compatibility-problem-with-rails/</link>
		<comments>http://balpreetpankaj.com/blog/2008/12/31/ruby-187-stringchars-compatibility-problem-with-rails/#comments</comments>
		<pubDate>Wed, 31 Dec 2008 16:45:57 +0000</pubDate>
		<dc:creator>balpreetspankaj</dc:creator>
				<category><![CDATA[Rails]]></category>
		<category><![CDATA[Ruby]]></category>
		<category><![CDATA[ActiveSupport]]></category>

		<guid isPermaLink="false">http://balpreetpankaj.com/blog/?p=28</guid>
		<description><![CDATA[Recently, I started getting weird "LoadError" with my Rails app on Dreamhost. I had an "Article" model which contained many "Photo" models.  When the "Article" controller tried to refer to the photos in its object, I got the following error:
LoadError: Expected {full server path}/photo.rb to define Photo. 
I had a photo.rb file which had [...]]]></description>
			<content:encoded><![CDATA[<p>Recently, I started getting weird "LoadError" with my Rails app on Dreamhost. I had an "Article" model which contained many "Photo" models.  When the "Article" controller tried to refer to the photos in its object, I got the following error:<br />
<code>LoadError: Expected {full server path}/photo.rb to define Photo. </code></p>
<p>I had a photo.rb file which had class Photo defined. I was using attachment_fu plugin to implement photos. After some head scratching, I found that the error was in photo.rb file. Hence photo.rb was not loading correctly, and therefore a load error.</p>
<p>The actual error happened coz the Dreamhost guys had updated Ruby to 1.8.7 which has some incompatibility with Rails 2.0.2 that I was using. When I tried to create a Photo object on the command line, I got this error:<br />
<code>NoMethodError: undefined method '[]' for #&lt;Enumerable:enumerator&gt;&lt;/code&gt;</p>
<p>Ruby 1.8.7 has String#chars. This returns an Enumerator object but Rails 2.0.2 expects an ActiveSupport::MultiBye::Chars object.</p>
<p>We can avoid this conflict, by putting the following code in the config/initializers/ directory.</p>
<pre class="ruby"><ol><li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;"><div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp;</div></li><li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;"><div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;"><span style="color:#9966CC; font-weight:bold;">unless</span> <span style="color:#996600;">'1.9'</span>.<span style="color:#9900CC;">respond_to</span>?<span style="color:#006600; font-weight:bold;">&#40;</span><span style="color:#ff3333; font-weight:bold;">:force_encoding</span><span style="color:#006600; font-weight:bold;">&#41;</span></div></li><li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;"><div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">  <span style="color:#CC0066; font-weight:bold;">String</span>.<span style="color:#9900CC;">class_eval</span> <span style="color:#9966CC; font-weight:bold;">do</span></div></li><li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;"><div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">  <span style="color:#9966CC; font-weight:bold;">begin</span></div></li><li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;"><div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">    remove_method <span style="color:#ff3333; font-weight:bold;">:chars</span></div></li><li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;"><div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">  <span style="color:#9966CC; font-weight:bold;">rescue</span> <span style="color:#CC00FF; font-weight:bold;">NameError</span></div></li><li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;"><div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">    <span style="color:#008000; font-style:italic;"># OK</span></div></li><li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;"><div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">  <span style="color:#9966CC; font-weight:bold;">end</span></div></li><li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;"><div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;"><span style="color:#9966CC; font-weight:bold;">end</span></div></li><li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;"><div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;"><span style="color:#9966CC; font-weight:bold;">end</span></div></li><li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;"><div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp;</div></li></ol></pre>
]]></content:encoded>
			<wfw:commentRss>http://balpreetpankaj.com/blog/2008/12/31/ruby-187-stringchars-compatibility-problem-with-rails/feed/</wfw:commentRss>
		<slash:comments>3</slash:comments>
		</item>
		<item>
		<title>Insert comments in an erb file</title>
		<link>http://balpreetpankaj.com/blog/2008/12/31/insert-comments-in-an-erb-file/</link>
		<comments>http://balpreetpankaj.com/blog/2008/12/31/insert-comments-in-an-erb-file/#comments</comments>
		<pubDate>Wed, 31 Dec 2008 16:19:06 +0000</pubDate>
		<dc:creator>balpreetspankaj</dc:creator>
				<category><![CDATA[Rails]]></category>
		<category><![CDATA[Ruby]]></category>
		<category><![CDATA[Comments]]></category>
		<category><![CDATA[Erb]]></category>

		<guid isPermaLink="false">http://balpreetpankaj.com/blog/?p=23</guid>
		<description><![CDATA[How does one insert comments in an erb file. The normal http tag to insert comments do not work well when there are embedded ruby statements in the html.
&#60;!-- &#60;b&#62;Hello&#60;/b&#62;&#60;%= @article.author %&#62; --&#62;
The above statement will not stop the evaluation of article.author. Instead, @article.author will still be evaluated and placed as a comment in the [...]]]></description>
			<content:encoded><![CDATA[<p>How does one insert comments in an erb file. The normal http tag to insert comments do not work well when there are embedded ruby statements in the html.</p>
<p><code>&lt;!-- &lt;b&gt;Hello&lt;/b&gt;&lt;%= @article.author %&gt; --&gt;</code></p>
<p>The above statement will not stop the evaluation of article.author. Instead, @article.author will still be evaluated and placed as a comment in the generated html file. Say the author was Balpreet, then we have a html comment:</p>
<p>&lt;!-- &lt;b&gt;Hello&lt;/b&gt;Balpreet --&gt;</p>
<p>So, what if we want to just comment stuff out, so that the embedded ruby statements are not evaluated at all. There are basically two ways that I think we can achieve this:</p>
<p>1. Insert block level comments using embedded ruby.<br />
<code>&lt;%<br />
=begin %&gt;<br />
&lt;b&gt;Hello&lt;/b&gt;&lt;%= @article.author %&gt;&lt;%<br />
=end %&gt;</code></p>
<p>2. Insert conditional<br />
<code>&lt;% if false %&gt;<br />
&lt;b&gt;Hello&lt;/b&gt;&lt;%= @article.author %&gt;<br />
&lt;% end %&gt;</code></p>
]]></content:encoded>
			<wfw:commentRss>http://balpreetpankaj.com/blog/2008/12/31/insert-comments-in-an-erb-file/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Rfeedparser and Hpricot</title>
		<link>http://balpreetpankaj.com/blog/2008/11/15/rfeedparser-and-hpricot/</link>
		<comments>http://balpreetpankaj.com/blog/2008/11/15/rfeedparser-and-hpricot/#comments</comments>
		<pubDate>Sun, 16 Nov 2008 05:49:45 +0000</pubDate>
		<dc:creator>balpreetspankaj</dc:creator>
				<category><![CDATA[Feed Parser]]></category>
		<category><![CDATA[Ruby]]></category>
		<category><![CDATA[feedparser]]></category>
		<category><![CDATA[hpricot]]></category>
		<category><![CDATA[Mark Pilgrim]]></category>
		<category><![CDATA[rfeedparser]]></category>
		<category><![CDATA[rubygems]]></category>

		<guid isPermaLink="false">http://balpreetpankaj.com/blog/?p=19</guid>
		<description><![CDATA[RFeedParser is one of the ruby gems to parse rss feeds. Its a translation of Mark Pilgrims's Universal Feed Parser from Python into Ruby. It has a few dependencies and requires you to install a few other gems. The installation instructions are simple and the usage is simple.
One of the dependencies for this was hpricot. [...]]]></description>
			<content:encoded><![CDATA[<p><a href="http://rfeedparser.rubyforge.org/">RFeedParser</a> is one of the ruby gems to parse rss feeds. Its a translation of Mark Pilgrims's <a href="http://feedparser.org/">Universal Feed Parser</a> from Python into Ruby. It has a few dependencies and requires you to install a few other gems. The installation instructions are simple and the usage is simple.</p>
<p>One of the dependencies for this was <a href="https://code.whytheluckystiff.net/hpricot/">hpricot</a>. Everything was working fine till one day, I updated my hpricot gem and did a cleanup of my rubygems.  I started getting an error:</p>
<p><code>balpreet-pankajs-macbook:digg balpreetpankaj$ ruby bloo.rb<br />
/Library/Ruby/Site/1.8/rubygems.rb:142:in `activate': can't activate hpricot (= 0.6, runtime), already activated hpricot-0.6.164 (Gem::Exception)<br />
	from /Library/Ruby/Site/1.8/rubygems.rb:158:in `activate'<br />
	from /Library/Ruby/Site/1.8/rubygems.rb:157:in `each'<br />
	from /Library/Ruby/Site/1.8/rubygems.rb:157:in `activate'<br />
	from /Library/Ruby/Site/1.8/rubygems/custom_require.rb:31:in `require'<br />
	from /Library/Ruby/Gems/1.8/gems/activesupport-2.1.2/lib/active_support/dependencies.rb:510:in `require'<br />
	from /Library/Ruby/Gems/1.8/gems/activesupport-2.1.2/lib/active_support/dependencies.rb:355:in `new_constants_in'<br />
	from /Library/Ruby/Gems/1.8/gems/activesupport-2.1.2/lib/active_support/dependencies.rb:510:in `require'</code></p>
<p>After a little digging arnd with rubygems, I figured out that the rfeedparser has a requirement of running with a hpricot gem with version = 0.6. I changed that to >= 0.6 and things started working fine. I was using version 0.9.951 of rfeedparser. If you use rfeedparser and run into a similar problem, this is how you fix it:</p>
<p>1) Update the gemspec for rfeedparser. Go to your gem installation dir. You can find this by doing:<br />
    <code>gem env gempath</code><br />
    Then edit the $gemPATH/specifications/rfeedparser0.9.951.gemspec and update all references of hpricot from "=0.6" to ">=0.6".<br />
2). Go to $GEMPATH/gems/rfeedparser-0.9.951/lib/rfeedparser.rb and again update the reference of hpricot.</p>
<p>This should get you rolling with all new versions of hpricot.   </p>
]]></content:encoded>
			<wfw:commentRss>http://balpreetpankaj.com/blog/2008/11/15/rfeedparser-and-hpricot/feed/</wfw:commentRss>
		<slash:comments>1</slash:comments>
		</item>
		<item>
		<title>Creating a headline rotator</title>
		<link>http://balpreetpankaj.com/blog/2008/11/02/creating-a-headline-rotator/</link>
		<comments>http://balpreetpankaj.com/blog/2008/11/02/creating-a-headline-rotator/#comments</comments>
		<pubDate>Mon, 03 Nov 2008 04:46:17 +0000</pubDate>
		<dc:creator>balpreetspankaj</dc:creator>
				<category><![CDATA[javascript]]></category>
		<category><![CDATA[AdevelopedWorld.com]]></category>
		<category><![CDATA[headline rotator]]></category>
		<category><![CDATA[jquery]]></category>
		<category><![CDATA[Learning JQuery]]></category>

		<guid isPermaLink="false">http://balpreetpankaj.com/blog/?p=16</guid>
		<description><![CDATA[I was recently reading the book Learning Jquery by Jonathan Chaffer and Karl Swedberg . After reading the chapter on Rotators and Shufflers, which shows how you can create a headline rotator, I decided to implement one for my own website, adevelopedworld.com. adevelopedworld.com is a website which features social entrepreneurs from all around the world. [...]]]></description>
			<content:encoded><![CDATA[<p>I was recently reading the book <strong>Learning Jquery</strong> by <em>Jonathan Chaffer and Karl Swedberg</em> . After reading the chapter on <em>Rotators and Shufflers</em>, which shows how you can create a headline rotator, I decided to implement one for my own website, <a href="http://adevelopedworld.com">adevelopedworld.com</a>. <a href="http://adevelopedworld.com">adevelopedworld.com</a> is a website which features social entrepreneurs from all around the world. We constantly get updates from the social entrepreneurs that we have featured, and we had to manually update the homepage to show these updates. After implementing the headline rotator, we just keep adding the updates to a text file, and the homepage gets automatically updated. And to top it, the homepage looks all the more dynamic.</p>
<p>The tutorial on how to create the rotator in the book is very complete. I just had to make one change. The tutorial is based on an old version of jQuery which supported XPath expressions. XPath expressions are no longer a part of JQuery. But there are two solutions :<br />
a). Either add the XPath plugin for jQuery, OR<br />
b). Change the XPath expression to a normal jQuery selector expression.</p>
<p>I used the latter.</p>
<p>A live demo of the headline rotator can be found at <a href="http://adevelopedworld.com">adevelopedworld.com.</a></p>
]]></content:encoded>
			<wfw:commentRss>http://balpreetpankaj.com/blog/2008/11/02/creating-a-headline-rotator/feed/</wfw:commentRss>
		<slash:comments>2</slash:comments>
		</item>
	</channel>
</rss>
