<?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>Binary Doodles &#187; How-To</title>
	<atom:link href="http://nithinbekal.com/category/how-to/feed/" rel="self" type="application/rss+xml" />
	<link>http://nithinbekal.com</link>
	<description>Ruby on Rails, Web 2.0, Wordpress and more...</description>
	<lastBuildDate>Fri, 30 Jul 2010 17:49:23 +0000</lastBuildDate>
	<generator>http://wordpress.org/?v=2.9.1</generator>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
			<item>
		<title>Rails: Avoid multiple level nested resource routes</title>
		<link>http://nithinbekal.com/2010/05/14/rails-avoid-multiple-level-nested-resource-routes/</link>
		<comments>http://nithinbekal.com/2010/05/14/rails-avoid-multiple-level-nested-resource-routes/#comments</comments>
		<pubDate>Fri, 14 May 2010 15:47:19 +0000</pubDate>
		<dc:creator>Nithin Bekal</dc:creator>
				<category><![CDATA[How-To]]></category>
		<category><![CDATA[Ruby]]></category>
		<category><![CDATA[Ruby on Rails]]></category>
		<category><![CDATA[Rails]]></category>
		<category><![CDATA[REST]]></category>

		<guid isPermaLink="false">http://nithinbekal.com/?p=335</guid>
		<description><![CDATA[While generating RESTful routes in rails, it is easy to get carried away and generate many levels of nested resources for every level of has_many associations. For instance, I recently wrote something like this in my routes file:
  # in config/routes.rb
  map.resources :first_resources do &#124;first&#124;
    first.resources :second_resources do &#124;second&#124;
  [...]]]></description>
			<content:encoded><![CDATA[<p>While generating RESTful routes in rails, it is easy to get carried away and generate many levels of nested resources for every level of has_many associations. For instance, I recently wrote something like this in my routes file:</p>
<pre>  # in config/routes.rb
  map.resources :first_resources do |first|
    first.resources :second_resources do |second|
      second.resources :third_resources
    end
  end</pre>
<p>Here FirstResouce has_many SecondResources and SecondResource has_many ThirdResources. Now imagine how you would get the path to edit the third level resource. You&#8217;d have to write something like this:</p>
<pre>edit_first_resource_second_resource_third_resource_path(@first_resource, \
    @second_resource, @third_resource)</pre>
<p>Yes, that&#8217;s how bad it would look when the routes are written for the innermost resource in the routes.</p>
<p>When I found myself doing something similar a few days ago, I decided to look for a better way to do this, and it amazes me how I missed this simple (and universally used) approach to writing nested resource routes.</p>
<p>Let&#8217;s take the example of a school where each course would have many batches, and each batch would have many exams. </p>
<pre># app/models/course.rb
class Course < ActiveRecord::Base
  has_many :batches
end

# app/models/batch.rb
class Batch < ActiveRecord::Base
  belongs_to :course
  has_many :exams
end

# exam.rb
class Exam < ActiveRecord::Base
  belongs_to :batch
end</pre>
<p>Writing the routes with two levels of nesting would give me something like this:</p>
<pre>  # config/routes.rb
  map.resources :courses do |course|
    course.resources :batches do |batch|
      batch.resources :exams
    end
  end</pre>
<p>The route to edit an exam object @exam (belonging to batch @batch which in turn belongs to course @course) would look like this:</p>
<pre>edit_course_batch_exam_path(@course, @batch, @exam)</pre>
<p>This is way too long and rather than make it easy to understand the path, it is going to make it even more confusing when somebody tries to understand the path. The url is going to be something like <code>http://domain.com/courses/1/batches/1/exams/1/edit</code>.</p>
<p>The best solution in this case is to nest the resources to just one level so that batches a nested within courses (e.g. http://domain.com/courses/1/batches) and exams are nested only within batches (e.g. http://domain.com/batches/1/exams). Using a rails shortcut to define nested routes, we could write the routes like this:</p>
<pre>  # in config/routes.rb
  map.resources :courses, :has_many => :batches
  map.resources :batches, :has_many => :exams</pre>
<p>Now if you wanted to edit an exam resource, you could just write <code>edit_batch_exam(@batch, @exam)</code> without having to worry about specifying the course object in the route. If you needed the course object within the exams controller, all you need to do is write a before filter that loads the batch and course as shown here:</p>
<pre># app/controllers/exams_controller.rb
class ExamsController < ApplicationController
  before_filter :load_batch_and_course

  # RESTful actions

  private
  def load_batch_and_course
    @batch = Batch.find(params[:batch_id])
    @course = @batch.course
  end
end</pre>
<p>Since we can get the course_id from the batch, there is no need for us to have the course_id in the route. This makes the routes much easier to understand.</p>
<p>Have you come across any situation where nesting more than one level is absolutely necessary? (I couldn't imagine any such situation off the top of my head.) How many levels of nested resources are okay with you? Do leave a comment and tell me what you think.</p>
]]></content:encoded>
			<wfw:commentRss>http://nithinbekal.com/2010/05/14/rails-avoid-multiple-level-nested-resource-routes/feed/</wfw:commentRss>
		<slash:comments>1</slash:comments>
		</item>
		<item>
		<title>How-to: Setting up Ubuntu 9.10 on Virtualbox</title>
		<link>http://nithinbekal.com/2010/04/30/how-to-setting-up-ubuntu-9-10-on-virtualbox/</link>
		<comments>http://nithinbekal.com/2010/04/30/how-to-setting-up-ubuntu-9-10-on-virtualbox/#comments</comments>
		<pubDate>Fri, 30 Apr 2010 14:20:04 +0000</pubDate>
		<dc:creator>Nithin Bekal</dc:creator>
				<category><![CDATA[How-To]]></category>
		<category><![CDATA[Operating Systems]]></category>
		<category><![CDATA[Ubuntu]]></category>
		<category><![CDATA[Vitualbox]]></category>

		<guid isPermaLink="false">http://nithinbekal.com/?p=326</guid>
		<description><![CDATA[I&#8217;ve just been setting up Ubuntu as a virtual OS in my Windows machine using Sun Virtualbox. I did run into a couple of problems initially, so I&#8217;m listing out the steps involved in acse somebody else needs some help with the same.
Downlaod Virtualbox from here and install it. You will obviously need Ubuntu as [...]]]></description>
			<content:encoded><![CDATA[<p>I&#8217;ve just been setting up Ubuntu as a virtual OS in my Windows machine using Sun Virtualbox. I did run into a couple of problems initially, so I&#8217;m listing out the steps involved in acse somebody else needs some help with the same.</p>
<p>Downlaod Virtualbox from <a href="http://www.virtualbox.org/wiki/Downloads">here</a> and install it. You will obviously need Ubuntu as well, and you can get the Ubuntu ISO from <a href="http://www.ubuntu.com/getubuntu/download">here</a>.</p>
<p>Open Virtualbox and click on new to set up a new virtual machine. On clicking next, you will be prompted for the following details: operating system &#8212; Linux, version &#8212; Ubuntu, and name for the virtual machine, e.g. &#8220;ubuntu&#8221;.</p>
<p>In the next setting, set the base memory size. The recommended value will already be selected, but you can increase it a little if you have a lot of memory. (I set 512MB on my 2G machine.)</p>
<p>Now you&#8217;ll be prompted for a virtual hard disk, and since you haven&#8217;t already created one, select the option to created a new virtual hard disk. Set the storage type to &#8220;dynamically expanding&#8221;. Set the location, and the size to something like 8GB and click finish.</p>
<p>Now that you&#8217;ve created the VM and the virtual hard disk, you need to install Ubuntu. For this right click on the VM in the sidebar and go to settings. Here, in the storage tab, click on the CD/DVD icon and set the ubuntu installation CD ISO as the device. (Use your CD/DVD drive as the device if you&#8217;re installing from a CD and not from ISO.)</p>
<p>On starting the virtual machine, the CD gets booetd, and you can now install Ubuntu into the VM as you would do in case of a normal Ubuntu installation. Once installed, you can use this VM to boot into Ubuntu.</p>
<p>Since I work mostly on ruby,  needed to install a ruby and rails environment on the virtual machine. I&#8217;m not going to post all the steps here, but there&#8217;s an awesome <a href="http://www.hackido.com/2009/04/install-ruby-rails-on-ubuntu-904-jaunty.html">post on setting up a ruby and rails environment on Ubuntu on hackido.com</a>.</p>
]]></content:encoded>
			<wfw:commentRss>http://nithinbekal.com/2010/04/30/how-to-setting-up-ubuntu-9-10-on-virtualbox/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Moving SVN repository to another server</title>
		<link>http://nithinbekal.com/2010/04/14/moving-svn-repository-to-another-server/</link>
		<comments>http://nithinbekal.com/2010/04/14/moving-svn-repository-to-another-server/#comments</comments>
		<pubDate>Wed, 14 Apr 2010 15:38:32 +0000</pubDate>
		<dc:creator>Nithin Bekal</dc:creator>
				<category><![CDATA[How-To]]></category>
		<category><![CDATA[Subversion]]></category>
		<category><![CDATA[SVN]]></category>

		<guid isPermaLink="false">http://nithinbekal.com/?p=313</guid>
		<description><![CDATA[I had to move an SVN repository for one of my projects from one hosting account to another today. I don&#8217;t know much about handling SVN and it took me a bit of searching before I was able to do it, so i&#8217;ve written the steps here for anyone else who might be in the [...]]]></description>
			<content:encoded><![CDATA[<p>I had to move an SVN repository for one of my projects from one hosting account to another today. I don&#8217;t know much about handling SVN and it took me a bit of searching before I was able to do it, so i&#8217;ve written the steps here for anyone else who might be in the same situation. You need to have SSH access on both servers to do this.</p>
<p>Go to <code>~/svn/</code> or wherever you have your SVN repos and dump the repo using the <code>svnadmin dump</code> command:</p>
<pre>$ svnadmin dump myproject > myproject.dump
  Dumping revision 0
  Dumping revision 1
  ...
  Dumping revision 46</pre>
<p>You now have the dump of the repo, which you can upload to the other server where you want to import the repository. Now, in the svn folder of that serer, do this:</p>
<pre>$ mkdir myproject
$ svnadmin create myproject
$ svnadmin load myproject < myproject.dump</pre>
<p>Importing the repository like this keeps all the revisions intact and you can continue using the repository at the new server.</p>
]]></content:encoded>
			<wfw:commentRss>http://nithinbekal.com/2010/04/14/moving-svn-repository-to-another-server/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Rails: Thinking Sphinx plugin for search</title>
		<link>http://nithinbekal.com/2009/12/25/rails-thinking-sphinx-plugin-for-search/</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>
]]></content:encoded>
			<wfw:commentRss>http://nithinbekal.com/2009/12/25/rails-thinking-sphinx-plugin-for-search/feed/</wfw:commentRss>
		<slash:comments>4</slash:comments>
		</item>
		<item>
		<title>Rails: Importing data from spreadsheets into database</title>
		<link>http://nithinbekal.com/2009/12/09/rails-importing-data-from-spreadsheets-into-database/</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>
]]></content:encoded>
			<wfw:commentRss>http://nithinbekal.com/2009/12/09/rails-importing-data-from-spreadsheets-into-database/feed/</wfw:commentRss>
		<slash:comments>12</slash:comments>
		</item>
		<item>
		<title>JavaScript: How to create a simple countdown timer</title>
		<link>http://nithinbekal.com/2009/12/06/javascript-how-to-create-a-simple-countdown-timer/</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>
]]></content:encoded>
			<wfw:commentRss>http://nithinbekal.com/2009/12/06/javascript-how-to-create-a-simple-countdown-timer/feed/</wfw:commentRss>
		<slash:comments>11</slash:comments>
		</item>
		<item>
		<title>How to use Notepad++ to edit files via FTP</title>
		<link>http://nithinbekal.com/2009/11/21/how-to-use-notepad-to-edit-files-via-ftp/</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>
]]></content:encoded>
			<wfw:commentRss>http://nithinbekal.com/2009/11/21/how-to-use-notepad-to-edit-files-via-ftp/feed/</wfw:commentRss>
		<slash:comments>8</slash:comments>
		</item>
		<item>
		<title>How to create a simple datepicker using jQuery</title>
		<link>http://nithinbekal.com/2009/08/09/how-to-create-a-simple-datepicker-using-jquery/</link>
		<comments>http://nithinbekal.com/2009/08/09/how-to-create-a-simple-datepicker-using-jquery/#comments</comments>
		<pubDate>Sun, 09 Aug 2009 14:33:00 +0000</pubDate>
		<dc:creator>Nithin Bekal</dc:creator>
				<category><![CDATA[Featured]]></category>
		<category><![CDATA[How-To]]></category>
		<category><![CDATA[Javascript]]></category>
		<category><![CDATA[jQuery]]></category>
		<category><![CDATA[Datepicker]]></category>

		<guid isPermaLink="false">http://nithinbekal.com/2009/08/09/how-to-create-a-simple-datepicker-using-jquery/</guid>
		<description><![CDATA[jQuery allows you to easily create a datepicker and customize it according to your requirements. Here&#8217;s a quick look at how you can get started with using the jQuery datepicker.
The jQuery website has a nice application called Themeroller that lets you customize the interface for jQuery UI widgets. There are also plenty of themes available [...]]]></description>
			<content:encoded><![CDATA[<p>jQuery allows you to easily create a datepicker and customize it according to your requirements. Here&#8217;s a quick look at how you can get started with using the jQuery datepicker.</p>
<p>The jQuery website has a nice application called <a href="http://jqueryui.com/themeroller/">Themeroller</a> that lets you customize the interface for jQuery UI widgets. There are also plenty of themes available in the gallery that you can download and use directly. Copy the stylesheet, images, the jQuery file and the jQuery-UI files into the appropriate directories and link them in the header of your HTML file.</p>
<p>Now let&#8217;s create a simple form that contains the text field that you want to convert into a datepicker.</p>
<pre>&lt;form action="index" method="get"&gt;
  &lt;input id="date-pick" name="date-pick" type="text" value="" /&gt;
  &lt;input id="date-submit" name="date-submit" type="submit" value="Go!" /&gt;
&lt;/form&gt;</pre>
<p>To convert the input field with the id <code>date-pick</code> into a datepicker, write the following jQuery code in the head section of your HTML.</p>
<pre>$(function(){
  $("#date-pick").datepicker();
});</pre>
<div class="separator" style="float: right; width: 250px;"><a style="margin-left: 1em; margin-right: 1em;" href="http://2.bp.blogspot.com/_SPbUIiu4sfA/Sn7XP4QC2SI/AAAAAAAACAg/Q9rZReomeAE/s1600-h/datepicker.png"><img src="http://2.bp.blogspot.com/_SPbUIiu4sfA/Sn7XP4QC2SI/AAAAAAAACAg/Q9rZReomeAE/s320/datepicker.png" border="0" alt="" /></a></div>
<p>That&#8217;s it! The input field that you created now works as a popup datepicker. A calendar showing the current month appears whenever you focus on the <code>#date-pick</code> field and the date you click on appears as text in the field.</p>
<p>There are tons of options to customize the datepicker, such as changing the date format sent to the server or using a different language for the calendar. You can explore these options in the <a href="http://docs.jquery.com/UI/Datepicker">jQuery UI documentation for the datepicker</a>.</p>
]]></content:encoded>
			<wfw:commentRss>http://nithinbekal.com/2009/08/09/how-to-create-a-simple-datepicker-using-jquery/feed/</wfw:commentRss>
		<slash:comments>2</slash:comments>
		</item>
	</channel>
</rss>
