<?xml version="1.0" encoding="UTF-8"?>
<?xml-stylesheet type="text/xsl" media="screen" href="/~d/styles/rss2full.xsl"?><?xml-stylesheet type="text/css" media="screen" href="http://feeds.feedburner.com/~d/styles/itemcontent.css"?><rss xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:wfw="http://wellformedweb.org/CommentAPI/" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:atom="http://www.w3.org/2005/Atom" xmlns:sy="http://purl.org/rss/1.0/modules/syndication/" xmlns:slash="http://purl.org/rss/1.0/modules/slash/" xmlns:feedburner="http://rssnamespace.org/feedburner/ext/1.0" version="2.0">

<channel>
	<title>Binary Doodles</title>
	
	<link>http://nithinbekal.com</link>
	<description>Ruby on Rails, Web 2.0, Wordpress and more...</description>
	<lastBuildDate>Mon, 01 Mar 2010 18:28:28 +0000</lastBuildDate>
	<generator>http://wordpress.org/?v=2.9.1</generator>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
			<atom10:link xmlns:atom10="http://www.w3.org/2005/Atom" rel="self" type="application/rss+xml" href="http://feeds.feedburner.com/BinaryDoodles" /><feedburner:info uri="binarydoodles" /><atom10:link xmlns:atom10="http://www.w3.org/2005/Atom" rel="hub" href="http://pubsubhubbub.appspot.com/" /><feedburner:emailServiceId>BinaryDoodles</feedburner:emailServiceId><feedburner:feedburnerHostname>http://feedburner.google.com</feedburner:feedburnerHostname><item>
		<title>Rails: SEO friendly URLs using to_param</title>
		<link>http://feedproxy.google.com/~r/BinaryDoodles/~3/KghEigzad8Q/</link>
		<comments>http://nithinbekal.com/2010/03/01/rails-seo-friendly-urls-using-to_param/#comments</comments>
		<pubDate>Mon, 01 Mar 2010 18:28:28 +0000</pubDate>
		<dc:creator>Nithin Bekal</dc:creator>
				<category><![CDATA[Ruby on Rails]]></category>
		<category><![CDATA[Ruby]]></category>

		<guid isPermaLink="false">http://nithinbekal.com/?p=233</guid>
		<description><![CDATA[I&#8217;ve wondered about how rails websites like Railscasts created SEO friendly URLs. I read this post by Obie Fernandez which explains how to do this.
I&#8217;ve never had to use SEO friendly URLs in my projects so far and I assumed that generating these URLs is very complicated and some plugin might be at work. And [...]]]></description>
			<content:encoded><![CDATA[<p>I&#8217;ve wondered about how rails websites like <a href="http://railscasts.com/">Railscasts</a> created SEO friendly URLs. I read <a href="http://www.jroller.com/obie/entry/seo_optimization_of_urls_in">this post by Obie Fernandez</a> which explains how to do this.</p>
<p>I&#8217;ve never had to use SEO friendly URLs in my projects so far and I assumed that generating these URLs is very complicated and some plugin might be at work. And like always, Rails proved me wrong and I&#8217;m amazed at how simple this is.</p>
<p>Suppose you had a RESTful resource called posts that had title and content fields. If you wanted the post page URLs to contain text from the title, you just have to add this <code>to_param</code> method to the Post model:</p>
<pre>
class Post
  # other stuff here

  def to_param
    "#{id}-#{title.gsub(/[^a-z0-9]+/i, '-')}"
  end
end
</pre>
<p>Now if you had a post whose title was &#8220;SEO friendly URLs&#8221;, and in your view you had <code>&lt;%= link_to @post.title, @post %&gt;</code> where @post is an instance of the Post model representing the &#8220;SEO friendly URLs&#8221; post. This will generate the following path: <code>/posts/1-SEO-friendly-URLs</code>.</p>
<p>As explained in Obie&#8217;s post, this will only work if you pass an instance of Post as the id parameter and the actual id itself. You don&#8217;t have to change anything in the controller to make this work.</p>
<p>This is just another one of those little tricks I discovered in rails that originally looked difficult but is actually incredibly easy to accomplish.</p>
<img src="http://feeds.feedburner.com/~r/BinaryDoodles/~4/KghEigzad8Q" height="1" width="1"/>]]></content:encoded>
			<wfw:commentRss>http://nithinbekal.com/2010/03/01/rails-seo-friendly-urls-using-to_param/feed/</wfw:commentRss>
		<slash:comments>1</slash:comments>
		<feedburner:origLink>http://nithinbekal.com/2010/03/01/rails-seo-friendly-urls-using-to_param/</feedburner:origLink></item>
		<item>
		<title>Why I prefer Twitter to Buzz</title>
		<link>http://feedproxy.google.com/~r/BinaryDoodles/~3/4bqeEXkii3k/</link>
		<comments>http://nithinbekal.com/2010/02/23/why-i-prefer-twitter-to-buzz/#comments</comments>
		<pubDate>Tue, 23 Feb 2010 16:56:53 +0000</pubDate>
		<dc:creator>Nithin Bekal</dc:creator>
				<category><![CDATA[Uncategorized]]></category>
		<category><![CDATA[Google]]></category>
		<category><![CDATA[Google Buzz]]></category>
		<category><![CDATA[Microblogging]]></category>
		<category><![CDATA[Social Networking]]></category>
		<category><![CDATA[Twitter]]></category>

		<guid isPermaLink="false">http://nithinbekal.com/?p=228</guid>
		<description><![CDATA[Google has never been much of a heavyweight in the social networking market. Their latest attempt to dethrone Twitter and Facebook is through Buzz, which turns Gmail into a social networking site. My initial impression about Buzz was positive, but having looked at it for the past week, I have had to change my opinion. Here's a list of reasons why I don''t like Buzz and would much rather prefer to continue using Twitter.]]></description>
			<content:encoded><![CDATA[<p>Google has never been much of a heavyweight in the social networking market. Orkut is still endemic to India and Brazil and can hardly be considered competition to Twitter and Facebook. Jaiku, a micro-blogging service almost exactly like Twitter, has been abandoned by Google. Their latest attempt to dethrone Twitter and Facebook is through Buzz, which turns Gmail into a social networking site.</p>
<p>My initial impression about Buzz was positive, but having looked at it for the past week, I have had to change my opinion. Here&#8217;s a list of reasons why I don&#8221;t like Buzz and would much rather prefer to continue using Twitter.</p>
<p><b>Comments on a Buzz</b></p>
<p>This is the one feature that really puts me off. Not that I am against users being able to react to their friend&#8217;s Buzz, but every time someone posts a comment on a buzz, it appears on my page even if the commenter isn&#8217;t someone I follow. Twitter handles this much more elegantly by showing only the replies by people who I am following. How could the Buzz team have missed something so obvious?</p>
<p><b>Can&#8217;t tweet through Buzz</b></p>
<p>I might have considered Buzz as an option if it automatically posted my buzzes to Twitter. But this hasn&#8217;t happened, and only tweets from Twitter are imported into Buzz and even that seems buggy. I saw a tweet posted weeks ago by a friend imported into Buzz.</p>
<p><b>No Facebook integration</b></p>
<p>To be honest, I wouldn&#8217;t really use this feature, but a lot of other people would and giving us a choice would have been a nice thing to do rather than ignore Facebook completely.</p>
<p><b>Not everybody deserves a microblogging audience</b></p>
<p>I&#8217;m sorry I sound so arrogant here but that&#8217;s my honest opinion. With Buzz, Google has made microblogging easily accessible to people who otherwise wouldn&#8217;t bother with microblogging and therefore never joined twitter. Now all those hundreds of people have a microblogging service within their mailbox and we&#8217;re flooded with absolutely boring, pointless and quite often incomprehensible statuses. There are plenty of people like that in Twitter, but at least Twitter &#8212; unlike Buzz &#8212; didn&#8217;t assume that I would want to follow them.</p>
<p><b>Assumptions</b></p>
<p>As someone who develops web applications, I know that assumptions are a good thing. Sometimes you have to make choices for your users so their work is reduced. But you must also know where to draw the line. As a user I don&#8217;t at all appreciate that Google decided who I should follow and who should follow me and what I should share with my followers. I believe Google has changed this since then, but it did damage the first impression.</p>
<p><b>Too many features</b></p>
<p>One thing I felt about Buzz was that it was trying to beat Twitter by giving users more features. There&#8217;s comment, like, email and reply by chat features, along with others such as report abuse and link to post hidden nearby. Twitter neatly handles all these using two simple options &#8211; reply and retweet.</p>
<p>Buzz is going to be one Google product that will be hard to sell to me. Apart from the absence of spam bots, there isn&#8217;t much I like about it and I&#8217;m convinced that I&#8217;m better off using Twitter. This post is mostly a Twitter user&#8217;s perspective of Buzz, but I suppose it doesn&#8217;t have much to offer to the Facebook crowd as well. I&#8217;m not actually going to disable Buzz yet, and am watching how it&#8217;s going to be improved. But for the time being, my Buzz followers will only see little activity on my account apart from my tweets automatically fetched into Buzz.</p>
<p>What is your take on Buzz? What social networking sites do you use and how does Buzz compare to those?</p>
<img src="http://feeds.feedburner.com/~r/BinaryDoodles/~4/4bqeEXkii3k" height="1" width="1"/>]]></content:encoded>
			<wfw:commentRss>http://nithinbekal.com/2010/02/23/why-i-prefer-twitter-to-buzz/feed/</wfw:commentRss>
		<slash:comments>4</slash:comments>
		<feedburner:origLink>http://nithinbekal.com/2010/02/23/why-i-prefer-twitter-to-buzz/</feedburner:origLink></item>
		<item>
		<title>RubyConf India 2010</title>
		<link>http://feedproxy.google.com/~r/BinaryDoodles/~3/CKA-C5W686Q/</link>
		<comments>http://nithinbekal.com/2010/02/11/rubyconf-india-2010/#comments</comments>
		<pubDate>Thu, 11 Feb 2010 15:19:41 +0000</pubDate>
		<dc:creator>Nithin Bekal</dc:creator>
				<category><![CDATA[Ruby on Rails]]></category>
		<category><![CDATA[Ruby]]></category>
		<category><![CDATA[RubyConf India]]></category>

		<guid isPermaLink="false">http://nithinbekal.com/?p=216</guid>
		<description><![CDATA[I registered for RubyConf India 2010 this morning. I was interested in the event anyway, but when the proposal for a presentation on Project Fedena by Arvind was selected that definitely made up my mind. The rest of Team Fedena &#8211; developers Aslam and Ralu, and designer Jaseem &#8211; have also decided to travel to [...]]]></description>
			<content:encoded><![CDATA[<p>I registered for RubyConf India 2010 this morning. I was interested in the event anyway, but when the proposal for a presentation on Project Fedena by Arvind was selected that definitely made up my mind. The rest of Team Fedena &#8211; developers Aslam and Ralu, and designer Jaseem &#8211; have also decided to travel to Bangalore for the event to be held on March 20-21.</p>
<p>This is the first edition of RubyConf India and there were surprisingly few tickets &#8212; just 150. I was worried we wouldn&#8217;t manage to get tickets, but registering early in the morning helped. From the number of mentions it has been getting on twitter today, I guess it will be sold out before the end of the day.</p>
<p>Apart from keynote addresses by Chad Fowler and Ola Bini, there are quite a few big names speaking at the event. So I&#8217;m even more delighted that Fedena will also be presented there. I&#8217;ve been working on the Fedena developer community all week and we&#8217;ll hopefully have projectfedena.org ready by the time we leave for Bangalore.</p>
<p style="text-align: center;"><a href="http://rubyconfindia.org"><img class="aligncenter" src="http://rubyconfindia.org/stock/rubyconf-badges/RubyConf2010/270X185_attending.jpg" alt="I'm attending RubyConf India 2010" width="270" height="185" /></a></p>
<img src="http://feeds.feedburner.com/~r/BinaryDoodles/~4/CKA-C5W686Q" height="1" width="1"/>]]></content:encoded>
			<wfw:commentRss>http://nithinbekal.com/2010/02/11/rubyconf-india-2010/feed/</wfw:commentRss>
		<slash:comments>4</slash:comments>
		<feedburner:origLink>http://nithinbekal.com/2010/02/11/rubyconf-india-2010/</feedburner:origLink></item>
		<item>
		<title>Wordpress: wp_monochrome theme</title>
		<link>http://feedproxy.google.com/~r/BinaryDoodles/~3/RFfMD6ZV45E/</link>
		<comments>http://nithinbekal.com/2010/02/08/wordpress-wp_monochrome-theme/#comments</comments>
		<pubDate>Mon, 08 Feb 2010 15:57:34 +0000</pubDate>
		<dc:creator>Nithin Bekal</dc:creator>
				<category><![CDATA[Wordpress]]></category>

		<guid isPermaLink="false">http://nithinbekal.com/?p=196</guid>
		<description><![CDATA[wp_monochrome is my first attempt at designing a wordpress theme. I&#8217;m using it on this blog right now, so if you&#8217;re reading this from a feed reader, you might want to drop by and see what it looks like.
It is a simple theme composed almost entirely of shades of grey. The theme works fine in [...]]]></description>
			<content:encoded><![CDATA[<p>wp_monochrome is my first attempt at designing a wordpress theme. I&#8217;m using it on this blog right now, so if you&#8217;re reading this from a feed reader, you might want to drop by and see what it looks like.</p>
<p>It is a simple theme composed almost entirely of shades of grey. The theme works fine in all modern browsers and (surprise, surprise) even works on Internet Explorer 6 except for the archives/categories/pages dropdowns in the header.</p>
<p>I&#8217;ve used HTML5 in the theme and some CSS3 features like border-radius in some places, so it looks slightly different in mozilla- and webkit-based browsers. I&#8217;ve seen a huge improvement in the loading time of my blog when compared to themes I&#8217;ve used earlier.</p>
<p>I did plan to keep a theme options page initially, but I&#8217;ve been incredibly busy for a while now and never got around to doing that. Hopefully, I&#8217;ll be able to provide some simple theme options in v0.2. Top priority is for choosing to display full posts or excerpts in the front page and a twitter feed in the right side of the header.</p>
<p>I&#8217;m looking for thoughts on how I could improve this theme and also on the HTML5 semantics I&#8217;ve used here. Please do take a look at the theme and leave a comment about it.</p>
<p><a href="http://files.nithinbekal.com/wordpress/themes/wp_monochrome.zip">Download the theme.</a></p>
<img src="http://feeds.feedburner.com/~r/BinaryDoodles/~4/RFfMD6ZV45E" height="1" width="1"/>]]></content:encoded>
			<wfw:commentRss>http://nithinbekal.com/2010/02/08/wordpress-wp_monochrome-theme/feed/</wfw:commentRss>
		<slash:comments>3</slash:comments>
		<feedburner:origLink>http://nithinbekal.com/2010/02/08/wordpress-wp_monochrome-theme/</feedburner:origLink></item>
		<item>
		<title>Rails: Thinking Sphinx plugin for search</title>
		<link>http://feedproxy.google.com/~r/BinaryDoodles/~3/x8AdAF9LQR8/</link>
		<comments>http://nithinbekal.com/2009/12/25/rails-thinking-sphinx-plugin-for-search/#comments</comments>
		<pubDate>Fri, 25 Dec 2009 11:20:57 +0000</pubDate>
		<dc:creator>Nithin Bekal</dc:creator>
				<category><![CDATA[How-To]]></category>
		<category><![CDATA[Ruby on Rails]]></category>
		<category><![CDATA[MySQL]]></category>
		<category><![CDATA[PostgreSQL]]></category>
		<category><![CDATA[Rails plugins]]></category>
		<category><![CDATA[Search]]></category>
		<category><![CDATA[SQL]]></category>

		<guid isPermaLink="false">http://nithinbekal.com/?p=179</guid>
		<description><![CDATA[Just a couple of weeks into being a rails developer, I made the one really, really, really big blunder &#8212; I used a find_by_sql in a search page. (Oh, please&#8230; stop booing. I was a newbie then.) Now, I&#8217;ve realized that I might have to modify the search to add yet another column, and well&#8230; [...]]]></description>
			<content:encoded><![CDATA[<p>Just a couple of weeks into being a rails developer, I made the one really, really, really big blunder &#8212; I used a find_by_sql in a search page. (Oh, please&#8230; stop booing. I was a newbie then.) Now, I&#8217;ve realized that I might have to modify the search to add yet another column, and well&#8230; extending a find_by_sql query for a fourth column (yeah, it was searching 3 columns already) would be stupid and incredibly ugly.</p>
<p>I came across Thinking Sphinx plugin for full text search over MySQL and Postgres databases. It connects ActiveRecord to the Sphinx search engine and lets you perform searches over multiple columns and even multiple models easily.</p>
<p>Things went rather smoothly when I tried using the plugin and I managed to set it up and running within a few minutes. Here&#8217;s how I set up an example application and tested sphinx.</p>
<ol>
<li> Download sphinx from <a href="http://sphinxsearch.com/downloads.html">here</a>. If you&#8217;re on windows, you just have to extract the exe files to ruby/bin directory. On, Linux/Mac, you&#8217;ll have to compile the source. (See instructions <a href="http://freelancing-god.github.com/ts/en/installing_sphinx.html" target="_blank">here</a>.)</li>
<li> Install the thinking_sphinx plugin like this:
<pre>script/plugin install git://github.com/freelancing-god/thinking-sphinx.git</pre>
<p>You might run into trouble on Windows with the script/plugin install, so you can use this instead.</p>
<pre>ruby script/plugin install http://github.com/freelancing-god/thinking-sphinx.git/</pre>
</li>
<li> For this example, let&#8217;s quickly set up a Post model through scaffolding.
<pre>ruby script/generate scaffold Post title:string body:text</pre>
</li>
<li> Now we&#8217;ll set up the indexes for the posts model like this:
<pre>  define_index do
    indexes title, body
  end</pre>
</li>
<li> In the index method in PostsController, change <code>Post.all</code> to this:
<pre>Post.search(params[:search])</pre>
</li>
<li> Add a simple search form in articles/index.
<pre>
&lt;% form_tag posts_path, :method =&gt; 'get' do %&gt;
  &lt;p&gt;
    &lt;%= text_field_tag :search, params[:search] %&gt;
    &lt;%= submit_tag "Search", :name =&gt; nil %&gt;
  &lt;/p&gt;
&lt;% end %&gt;
</pre>
</li>
<li> Now we have to run a couple of rake commands to get sphinx to work. To get sphinx to process the data, run this rake task:
<pre>rake thinking_sphinx:index</pre>
<p>To start the sphinx server:</p>
<pre>rake thinking_sphinx:start</pre>
</li>
<li> Now if you search for something using the form, the page returns the posts matching your query.</li>
</ol>
<p>It also allows you to search across multiple models that are related. For example, if a post has many comments, you could change define_index to search comments as well.</p>
<pre>  define_index do
    indexes title, body
    indexes comments.body :as => :comments_body
  end</pre>
<p>Sphinx also has support for delta indexing, which means that rather than index the entire table, it can index only those rows that have been added since the last index. You need to schedule the indexing according to your application&#8217;s requirement. There&#8217;s a nice little gem called <a href="http://github.com/javan/whenever">whenever</a> that will allow you to schedule the rake tasks in ruby.</p>
<p>What plugins have you used for full text search in rails? Have you tried Sphinx? Or ferret or solr? I&#8217;ve mostly heard people saying sphnx is better than solr or ferret. What do you think?</p>
<p>Update. I&#8217;ve put the <a href="http://github.com/nithinbekal/sphinx_example">source code for this example on github</a>.</p>
<img src="http://feeds.feedburner.com/~r/BinaryDoodles/~4/x8AdAF9LQR8" height="1" width="1"/>]]></content:encoded>
			<wfw:commentRss>http://nithinbekal.com/2009/12/25/rails-thinking-sphinx-plugin-for-search/feed/</wfw:commentRss>
		<slash:comments>4</slash:comments>
		<feedburner:origLink>http://nithinbekal.com/2009/12/25/rails-thinking-sphinx-plugin-for-search/</feedburner:origLink></item>
		<item>
		<title>Rails: Importing data from spreadsheets into database</title>
		<link>http://feedproxy.google.com/~r/BinaryDoodles/~3/JZ0NdBLSBuk/</link>
		<comments>http://nithinbekal.com/2009/12/09/rails-importing-data-from-spreadsheets-into-database/#comments</comments>
		<pubDate>Wed, 09 Dec 2009 18:26:57 +0000</pubDate>
		<dc:creator>Nithin Bekal</dc:creator>
				<category><![CDATA[How-To]]></category>
		<category><![CDATA[Ruby on Rails]]></category>
		<category><![CDATA[Rake]]></category>
		<category><![CDATA[Ruby]]></category>

		<guid isPermaLink="false">http://nithinbekal.com/?p=118</guid>
		<description><![CDATA[Recently I was trying to find ways to import data from excel spreadsheets into the database in a rails project. We needed to save the data from the client&#8217;s excel file into the database. Here&#8217;s how it can be done using a rake task.

The file will have to be in CSV format, so you&#8217;ll have [...]]]></description>
			<content:encoded><![CDATA[<p>Recently I was trying to find ways to import data from excel spreadsheets into the database in a rails project. We needed to save the data from the client&#8217;s excel file into the database. Here&#8217;s how it can be done using a rake task.</p>
<ol>
<li>The file will have to be in CSV format, so you&#8217;ll have to open it with any spreadsheet application like Microsoft Excel (or Google Docs in my case) and save it as CSV. Put the file in your project folder.
</li>
<li><code>FasterCSV</code> is a ruby gem that lets you easily parse CSV files and is a faster alternative to ruby&#8217;s standard CSV library. Install it using the command:
<pre>
gem install fastercsv
</pre>
</li>
<li>Create a rake task that reads the CSV file using the fastercsv gem and saves the data in the database. Your code should look something like this:
<pre>
namespace :db do

  desc "load user data from csv"
  task :load_csv_data  => :environment do
    require 'fastercsv'

    FasterCSV.foreach("data.csv") do |row|
      User.create(
        :user_name => row[0],
        :email => row[1],
        :password => row[2]
      )
    end
  end
end
</pre>
<p>You can replace the User model here with whatever model you&#8217;re importing from the CSV file.</li>
<li>Save the task as a rake file in lib/tasks folder and name it import_csv_data.rake or something to that effect.</li>
<li>Go to the shell and run the task by:
<pre>
rake db:load_csv_data
</pre>
</li>
</ol>
<p>When I came across this problem, my first reaction was to look for a ruby library that reads spreadsheets directly. But that&#8217;s a challenge for another day. For this particular project we can manually save the spreadsheets as CSV.</p>
<p>I did find a library called <code>roo</code> (<a href="http://roo.rubyforge.org/">http://roo.rubyforge.org/</a>) that can access the contents of a spreadsheet directly and it might be worth looking into if you need to read an uploaded spreadsheet directly.</p>
<p>Have you had to do something similar in your projects? What other method would you suggest to accomplish this task?</p>
<img src="http://feeds.feedburner.com/~r/BinaryDoodles/~4/JZ0NdBLSBuk" height="1" width="1"/>]]></content:encoded>
			<wfw:commentRss>http://nithinbekal.com/2009/12/09/rails-importing-data-from-spreadsheets-into-database/feed/</wfw:commentRss>
		<slash:comments>5</slash:comments>
		<feedburner:origLink>http://nithinbekal.com/2009/12/09/rails-importing-data-from-spreadsheets-into-database/</feedburner:origLink></item>
		<item>
		<title>JavaScript: How to create a simple countdown timer</title>
		<link>http://feedproxy.google.com/~r/BinaryDoodles/~3/1CO5EtMX5tk/</link>
		<comments>http://nithinbekal.com/2009/12/06/javascript-how-to-create-a-simple-countdown-timer/#comments</comments>
		<pubDate>Sun, 06 Dec 2009 13:03:53 +0000</pubDate>
		<dc:creator>Nithin Bekal</dc:creator>
				<category><![CDATA[How-To]]></category>
		<category><![CDATA[Javascript]]></category>

		<guid isPermaLink="false">http://nithinbekal.com/?p=128</guid>
		<description><![CDATA[Create a simple countdown timer using javascript and HTML that counts down to an event. This example used in this tutorial counts down to the FIFA world cup 2010.]]></description>
			<content:encoded><![CDATA[<p>After yet another disappointing performance yesterday by the football (soccer, if you&#8217;re American) club I support, Liverpool, this was my tweet:</p>
<blockquote><p>I&#8217;ve already started counting days until FIFA world cup. Football season seem practically over for Liverpool. :(</p></blockquote>
<p>I actually did count the days, but being a web developer, I ended up writing javascript code to do the dirty work for me. ;-) I&#8217;ve never really done much with javascript date and time, so I&#8217;m not sure if there&#8217;s a better way to do this, but this works. Follow these steps to create a countdown timer for FIFA World Cup 2010. It&#8217;s easy to customize it for anything else.</p>
<p>First, we have to create a div with id as &#8220;worldcup_countdown_time&#8221; where you want to display the countdown timer. This div will be modified by our script to display the time remaining for the World Cup kick off.</p>
<pre>&lt;div id="worldcup_countdown_time"&gt; &lt;/div&gt;</pre>
<p>Now let&#8217;s write the script that will calculate the number of days, hours, seconds and minutes left for kick off. We&#8217;ll write each of the steps first and then put it all in a function called <code>updateWCTime()</code>.</p>
<p>First we have to calculate the time difference between the current time and the time of kickoff. Here, <code>now</code> is the current time, and <code>kickoff</code> is the kickoff time. We store the difference (which we get in milliseconds) in a variable called <code>diff</code>.</p>
<pre>
    now = new Date();
    kickoff = new Date.parse("June 11, 2010 11:30:00");
    diff = kickoff - now;
</pre>
<p>We find the time left till kickoff in terms of days, minutes, hours and seconds as shown below. We use the <code>Math.floor</code> function to get the absolute values in the variables. It returns the highest integer that&#8217;s less then the floating point value.</p>
<pre>
    days  = Math.floor( diff / (1000*60*60*24) );
    hours = Math.floor( diff / (1000*60*60) );
    mins  = Math.floor( diff / (1000*60) );
    secs  = Math.floor( diff / 1000 );
</pre>
<p>Now these variables will give us the exact number of hours, minutes and seconds left, but that&#8217;s not exactly what we want. If the remaining time were a day and 7 hours, we would have the value 31 (24+7) in the <code>minutes</code> variable. But what we want is the value 1 in the <code>day</code> variable, and the value 7 in the <code>hours</code>. Let&#8217;s create another set of variables to do that.</p>
<pre>
    dd = days;
    hh = hours - days  * 24;
    mm = mins  - hours * 60;
    ss = secs  - mins  * 60;
</pre>
<p>Now that the time has been calculated, you have to update the div you created at the beginning.</p>
<pre>
    document.getElementById("worldcup_countdown_time")
        .innerHTML =
            dd + ' days ' +
            hh + ' hours ' +
            mm + ' minutes ' +
            ss + ' seconds';
</pre>
<p><b>Putting it all together</b></p>
<p>Now, to make the countdown timer work, let&#8217;s put it all together.</p>
<pre>
function updateWCTime() {
	now      = new Date();
	kickoff  = new Date.parse("June 11, 2010 11:30:00");
	diff = kickoff - now;

	days  = Math.floor( diff / (1000*60*60*24) );
	hours = Math.floor( diff / (1000*60*60) );
	mins  = Math.floor( diff / (1000*60) );
	secs  = Math.floor( diff / 1000 );

	dd = days;
	hh = hours - days  * 24;
	mm = mins  - hours * 60;
	ss = secs  - mins  * 60;

        document.getElementById("worldcup_countdown_time")
            .innerHTML =
                dd + ' days  +
                hh + ' hours ' +
                mm + ' minutes ' +
                ss + ' seconds';
}
setInterval('updateWCTime()', 1000 );
</pre>
<p>The last line in the above code creates a timer that calls the <code>updateWCTime()</code> every 1000ms to refresh the timer every second.</p>
<p>Put this script in a .js file and include it in your HTML page to turn the dv with id &#8220;worldcup_countdown_time&#8221; into a countdown timer that counts down to the world cup kickoff time. There you go, you have a working countdown timer ready now with something like the following diplayed in the div:</p>
<pre>186 days 17 hours 12 minutes 14 seconds</pre>
<p>To count down to some other event, you can easily change the value in the <code>kickoff</code> variable to the date that you want to use.</p>
<p>Update. I&#8217;ve put up <a href="http://gist.github.com/299417">the code on gihub</a> where you can also <a href="http://gist.github.com/gists/299417/download">download it as tar.gz</a>.</p>
<img src="http://feeds.feedburner.com/~r/BinaryDoodles/~4/1CO5EtMX5tk" height="1" width="1"/>]]></content:encoded>
			<wfw:commentRss>http://nithinbekal.com/2009/12/06/javascript-how-to-create-a-simple-countdown-timer/feed/</wfw:commentRss>
		<slash:comments>10</slash:comments>
		<feedburner:origLink>http://nithinbekal.com/2009/12/06/javascript-how-to-create-a-simple-countdown-timer/</feedburner:origLink></item>
		<item>
		<title>Preview: Google Chrome OS</title>
		<link>http://feedproxy.google.com/~r/BinaryDoodles/~3/OjcxJGnTlBk/</link>
		<comments>http://nithinbekal.com/2009/12/03/preview-google-chrome-os/#comments</comments>
		<pubDate>Thu, 03 Dec 2009 17:33:41 +0000</pubDate>
		<dc:creator>Nithin Bekal</dc:creator>
				<category><![CDATA[Featured]]></category>
		<category><![CDATA[Operating Systems]]></category>
		<category><![CDATA[Google]]></category>
		<category><![CDATA[Google Chrome OS]]></category>

		<guid isPermaLink="false">http://nithinbekal.com/?p=91</guid>
		<description><![CDATA[Yesterday, after looking around Google&#8217;s Chrome OS, I felt exactly the way I felt when I got an invite to preview Google&#8217;s other big launch this year, Google Wave &#8212; underwhelmed. Chrome OS is a work in progress and there&#8217;s a long way to go yet, but as of now, it&#8217;s little more than a [...]]]></description>
			<content:encoded><![CDATA[<p>Yesterday, after looking around Google&#8217;s Chrome OS, I felt exactly the way I felt when I got an invite to preview Google&#8217;s other big launch this year, Google Wave &#8212; underwhelmed. Chrome OS is a work in progress and there&#8217;s a long way to go yet, but as of now, it&#8217;s little more than a glorified web browser.</p>
<p>I downloaded on of the many Chrome OS torrents available and loaded it using Sun&#8217;s Virtualbox. (<a href="http://www.techcrunch.com/2009/11/19/guide-install-google-chrome-os/">Techcrunch has a great article on how to do this</a>.) I timed it at 11 seconds to boot up, and it will obviously be much faster when it&#8217;s not being loaded through a virtual machine.</p>
<p>I was asked to log in to my Google account once the OS boots up. Strangely enough, the mouse seemed to be disabled in this login screen, and shift-tab to move back from password field to username too didn&#8217;t seem to work when I accidentally typed the wrong username. (Anyone else seen the same problem?)</p>
<div id="attachment_92" class="wp-caption aligncenter" style="width: 310px"><a href="http://nithinbekal.com/blog/wp-content/uploads/2009/12/chrome-os-1.png"><img src="http://nithinbekal.com/blog/wp-content/uploads/2009/12/chrome-os-1-300x226.png" alt="Google Chrome OS login screen" title="chrome-os-1" width="300" height="226" class="size-medium wp-image-92" /></a><p class="wp-caption-text">Google Chrome OS login screen</p></div>
<div id="attachment_93" class="wp-caption aligncenter" style="width: 310px"><a href="http://nithinbekal.com/blog/wp-content/uploads/2009/12/chrome-os-2.png"><img src="http://nithinbekal.com/blog/wp-content/uploads/2009/12/chrome-os-2-300x225.png" alt="Google Chrome OS signing in." title="chrome-os-2" width="300" height="225" class="size-medium wp-image-93" /></a><p class="wp-caption-text">Google Chrome OS signing in.</p></div>
<p>Once signed in, it opened the Chrome browser straight away, and quite helpfully, opened Gmail and Google calendar for me. No complaints there; Gmail is usually the first thing I check after switching on my computer.</p>
<div id="attachment_95" class="wp-caption aligncenter" style="width: 310px"><a href="http://nithinbekal.com/blog/wp-content/uploads/2009/12/chrome-os-4.png"><img src="http://nithinbekal.com/blog/wp-content/uploads/2009/12/chrome-os-4-300x224.png" alt="Chrome OS running Google search engine" title="chrome-os-4" width="300" height="224" class="size-medium wp-image-95" /></a><p class="wp-caption-text">Chrome OS running Google search engine</p></div>
<p>The Chrome OS is just the Chrome browser running on top of a linux kernel; there&#8217;s nothing in it apart from the browser. There is an app menu that displays the available apps (all web based, to be accessed on the cloud) and that&#8217;s the closest Chrome gets to having a desktop screen comparable to one in a conventional OS.</p>
<div id="attachment_96" class="wp-caption aligncenter" style="width: 310px"><a href="http://nithinbekal.com/blog/wp-content/uploads/2009/12/chrome-os-3.png"><img src="http://nithinbekal.com/blog/wp-content/uploads/2009/12/chrome-os-3-300x224.png" alt="Chrome OS app menu" title="chrome-os-3" width="300" height="224" class="size-medium wp-image-96" /></a><p class="wp-caption-text">Chrome OS app menu</p></div>
<p>Google Chrome OS is without doubt a great idea, but the way the OS depends on the cloud could render it useless in some conditions. Netbooks are mainly used for accessing the web, but they should be able to function even when there is no internet connection.</p>
<p>For instance, let&#8217;s take the case where I want to give a powerpoint presentation. Let&#8217;s assume I am one of those who live exclusively on the cloud, and create the presentation on Google Docs. I turn up for the presentation with my shiny Chrome OS netbook and &#8212; bam &#8212; internet connection suddenly dies. Bummer! I should have know Murphy&#8217;s law was lurking around the corner and now I wish I had OpenOffice or Word and a local copy of the presentation with me.</p>
<p>No matter how far we move into the cloud, I would still expect an OS to contain some apps that work even without an internet connection. Offline features are supposedly on their way, so it&#8217;s likely that the OS will have some offline applications available when it hits the market. With Google Gears, and also HTML5 having offline features, we might soon see Google Docs working on it even without an internet connection (and hopefully able to save files locally ad sync them later).</p>
<p>Like I mentioned before, Chrome OS is a work in progress and it&#8217;s not fair to judge it in it&#8217;s current form. I&#8217;m expecting great things from Google here, but haven&#8217;t been convinced so far that this could be a better alternative to Windows XP on netbooks.</p>
<p>Have you tried the Chrome OS yet? Do you think Google can really hope to grab a chunk of this market with an OS whose only major advantage is that it boots up incredibly fast? If you were to buy a netbook, which OS would you prefer?</p>
<img src="http://feeds.feedburner.com/~r/BinaryDoodles/~4/OjcxJGnTlBk" height="1" width="1"/>]]></content:encoded>
			<wfw:commentRss>http://nithinbekal.com/2009/12/03/preview-google-chrome-os/feed/</wfw:commentRss>
		<slash:comments>8</slash:comments>
		<feedburner:origLink>http://nithinbekal.com/2009/12/03/preview-google-chrome-os/</feedburner:origLink></item>
		<item>
		<title>How to use Notepad++ to edit files via FTP</title>
		<link>http://feedproxy.google.com/~r/BinaryDoodles/~3/F6poHDNGyTw/</link>
		<comments>http://nithinbekal.com/2009/11/21/how-to-use-notepad-to-edit-files-via-ftp/#comments</comments>
		<pubDate>Sat, 21 Nov 2009 17:22:36 +0000</pubDate>
		<dc:creator>Nithin Bekal</dc:creator>
				<category><![CDATA[Featured]]></category>
		<category><![CDATA[How-To]]></category>
		<category><![CDATA[IDEs and Editors]]></category>
		<category><![CDATA[FTP]]></category>
		<category><![CDATA[Notepad++]]></category>
		<category><![CDATA[Programming]]></category>
		<category><![CDATA[Text editors]]></category>

		<guid isPermaLink="false">http://nithinbekal.com/?p=50</guid>
		<description><![CDATA[For a few days now, I&#8217;ve been working on a wordpress based website where I have to edit quite a few files directly on the server. I used wordpress&#8217; theme and plugin editors for the first day, but it soon became too difficult to edit the files that way and I had to look for [...]]]></description>
			<content:encoded><![CDATA[<p>For a few days now, I&#8217;ve been working on a wordpress based website where I have to edit quite a few files directly on the server. I used wordpress&#8217; theme and plugin editors for the first day, but it soon became too difficult to edit the files that way and I had to look for an editor that would allow me to edit files live on the server.</p>
<p>Notepad++ has a great plugin called FTP_synchronize that allows you to edit your files directly on the server. With the plugin installed, editing files on the server doesn&#8217;t feel any different from editing files on the local machine.</p>
<p>Here&#8217;s a list of steps on how to set up Notepad++ to edit files through FTP.</p>
<ol>
<li>If you don&#8217;t already have Notapad++ installed, <a href="http://notepad-plus.sourceforge.net/uk/download.php" target="_blank">download the binaries from here</a> and install.</li>
<li>Download the FTP_synchronize plugin from <a href="http://sourceforge.net/apps/mediawiki/notepad-plus/index.php?title=Plugin_Central" target="_blank">here</a> and install it by copying the DLL into Notepad++&#8217;s plugins folder. (You&#8217;ll have to restart Notepad++ to be able to use the plugin.) </li>
<li>Open the FTP_Synchronize interface by clicking the &#8220;Show FTP folders&#8221; button or from the Plugins option in the menubar.
<p><img src="http://nithinbekal.com/blog/wp-content/uploads/2009/11/npp_ftp1-300x131.jpg" alt="npp_ftp1" title="npp_ftp1" width="300" height="131" class="aligncenter size-medium wp-image-53" />
</li>
<li>Click on settings on the FTP folders interface, and enter the login details. The address is your domain name, and the username is the one your hosting provider gives you. (In Bluehost, for instance, it&#8217;s usually (not always) the first 8 characters of your main domain&#8217;s name.) Set the port to 21.
<p><img src="http://nithinbekal.com/blog/wp-content/uploads/2009/11/npp-ftp2-299x300.jpg" alt="npp-ftp2" title="npp-ftp2" width="299" height="300" class="aligncenter size-medium wp-image-56" />
</li>
<li>Now click on the connect button and choose the FTP profile you&#8217;ve created. The folder you&#8217;ve selected in the settings gets loaded in the FTP synchronize sidebar, and you can edit the files on the server the same way you would use an IDE to edit a project stored locally. FTP Synchronize automatically syncs your files when you hit Ctrl+S.</li>
</ol>
<p>It&#8217;s been working great for me so far, and unless you&#8217;re editing unusually large files, Ctrl+S synchronizes the file almost instantaneously. The only thing that irritated me about the plugin was that it wouldn&#8217;t alert me when the FTP connection gets disconnected, so more than once I&#8217;ve wondered why there was no change on the site when I changed some code.</p>
<p>How do you edit files on the server? Is there a better option I could use? I&#8217;ve heard that the feature&#8217;s been added to NetBeans, but haven&#8217;t really checked it out. Should I be trying it out?</p>
<img src="http://feeds.feedburner.com/~r/BinaryDoodles/~4/F6poHDNGyTw" height="1" width="1"/>]]></content:encoded>
			<wfw:commentRss>http://nithinbekal.com/2009/11/21/how-to-use-notepad-to-edit-files-via-ftp/feed/</wfw:commentRss>
		<slash:comments>5</slash:comments>
		<feedburner:origLink>http://nithinbekal.com/2009/11/21/how-to-use-notepad-to-edit-files-via-ftp/</feedburner:origLink></item>
		<item>
		<title>New home for this blog</title>
		<link>http://feedproxy.google.com/~r/BinaryDoodles/~3/6QryowoJQTM/</link>
		<comments>http://nithinbekal.com/2009/11/11/new-home-for-this-blog/#comments</comments>
		<pubDate>Wed, 11 Nov 2009 16:20:43 +0000</pubDate>
		<dc:creator>Nithin Bekal</dc:creator>
				<category><![CDATA[Uncategorized]]></category>
		<category><![CDATA[Blogging]]></category>
		<category><![CDATA[Wordpress]]></category>

		<guid isPermaLink="false">http://nithinbekal.com/?p=47</guid>
		<description><![CDATA[I have moved this blog from its old location on blogspot (http://binarydoodles.blogspot.com) to my own domain, http://nithinbekal.com/.
The posts were moved to the new location a few days ago, but I wasn&#8217;t sure what to do with the feeds and that caused quite a bit of delay. I&#8217;ve set up the Feedburner Feedsmith plugin to use [...]]]></description>
			<content:encoded><![CDATA[<p>I have moved this blog from its old location on blogspot (<a href="http://binarydoodles.blogspot.com">http://binarydoodles.blogspot.com</a>) to my own domain, <a href="http://nithinbekal.com/">http://nithinbekal.com/</a>.</p>
<p>The posts were moved to the new location a few days ago, but I wasn&#8217;t sure what to do with the feeds and that caused quite a bit of delay. I&#8217;ve set up the Feedburner Feedsmith plugin to use the same old feedburner feed with this blog, but I&#8217;m not sure if it&#8217;s working fine. My apologies to all my subscribers if all my older posts are listed again on your feed reader.</p>
<p>Does anybody know the best way to transfer feeds from blogger blogs to a self hosted wordpress site? Have you moved your blog to a new location? If so, how did you transfer the feeds to the new blog?</p>
<img src="http://feeds.feedburner.com/~r/BinaryDoodles/~4/6QryowoJQTM" height="1" width="1"/>]]></content:encoded>
			<wfw:commentRss>http://nithinbekal.com/2009/11/11/new-home-for-this-blog/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		<feedburner:origLink>http://nithinbekal.com/2009/11/11/new-home-for-this-blog/</feedburner:origLink></item>
	</channel>
</rss>
