<?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>Veerasundar &#187; Web</title>
	<atom:link href="http://veerasundar.com/blog/category/web2/feed/" rel="self" type="application/rss+xml" />
	<link>http://veerasundar.com/blog</link>
	<description>Java, web and design</description>
	<lastBuildDate>Wed, 16 May 2012 07:13:40 +0000</lastBuildDate>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=3.3.2</generator>
		<item>
		<title>Scroll to top &#8211; JavaScript bookmarklet</title>
		<link>http://veerasundar.com/blog/2012/05/scroll-to-top-javascript-bookmarklet/</link>
		<comments>http://veerasundar.com/blog/2012/05/scroll-to-top-javascript-bookmarklet/#comments</comments>
		<pubDate>Tue, 01 May 2012 16:01:02 +0000</pubDate>
		<dc:creator>Veera</dc:creator>
				<category><![CDATA[How To]]></category>
		<category><![CDATA[Web]]></category>
		<category><![CDATA[bookmark]]></category>
		<category><![CDATA[bookmarklet]]></category>
		<category><![CDATA[javascript]]></category>
		<category><![CDATA[navigate]]></category>
		<category><![CDATA[tip]]></category>
		<category><![CDATA[toolbar]]></category>
		<category><![CDATA[top]]></category>

		<guid isPermaLink="false">http://veerasundar.com/blog/?p=3028</guid>
		<description><![CDATA[So, tell me, how many times have you annoyed with very long pages (such as this blog) and wished for a single click way to jump to top of the page!? If your answer is many, then this tip might give you some relief &#8211; add a bookmarklet to your bookmarks toolbar that jumps to [...]]]></description>
			<content:encoded><![CDATA[<p></p><p>So, tell me, how many times have you annoyed with very long pages (such as this blog) and wished for a single click way to jump to top of the page!? If your answer is <em>many, </em>then this tip might give you some relief &#8211; <strong>add a bookmarklet to your bookmarks toolbar that jumps to the top of the page for you.</strong></p>
<p>Here&#8217;s the dead simple way to do it. Just drag this link to your bookmarks toolbar: <a href="javascript:window.scrollTo(0,0);">^</a></p>
<p>Here are the manual steps:</p>
<ol>
<li>Add a new bookmark.</li>
<li>In the <em>name </em>field, enter either ^ or UP or *whatever*!</li>
<li>In the location/URL field, enter: <em>javascript:window.scrollTo(0,0);</em></li>
<li>Save it.</li>
</ol>
<p>Happy jumping around!</p>
]]></content:encoded>
			<wfw:commentRss>http://veerasundar.com/blog/2012/05/scroll-to-top-javascript-bookmarklet/feed/</wfw:commentRss>
		<slash:comments>7</slash:comments>
		</item>
		<item>
		<title>Open sourcing Twikural &#8211; an App Engine project</title>
		<link>http://veerasundar.com/blog/2012/04/open-sourcing-twikural-an-app-engine-project/</link>
		<comments>http://veerasundar.com/blog/2012/04/open-sourcing-twikural-an-app-engine-project/#comments</comments>
		<pubDate>Mon, 16 Apr 2012 10:27:40 +0000</pubDate>
		<dc:creator>Veera</dc:creator>
				<category><![CDATA[Java]]></category>
		<category><![CDATA[Web]]></category>
		<category><![CDATA[app-engine]]></category>
		<category><![CDATA[code]]></category>
		<category><![CDATA[github]]></category>
		<category><![CDATA[open-source]]></category>
		<category><![CDATA[project]]></category>
		<category><![CDATA[thirukural]]></category>
		<category><![CDATA[twikural]]></category>

		<guid isPermaLink="false">http://veerasundar.com/blog/?p=2993</guid>
		<description><![CDATA[tldr; https://github.com/vraa/twikural It all started when I asked the following question to my twitter friends: Juts checking: If there&#8217;s a service that sends you a Thirukkural every day, would you be signing up for it? — Veera (@vraa) January 31, 2012 My idea was simple: to send out Thirukural poems everyday to the people that are [...]]]></description>
			<content:encoded><![CDATA[<p></p><p><strong>tldr; <a href="https://github.com/vraa/twikural">https://github.com/vraa/twikural</a></strong></p>
<p>It all started when I asked the following question to my twitter friends:</p>
<blockquote class="twitter-tweet tw-align-center"><p>Juts checking: If there&#8217;s a service that sends you a Thirukkural every day, would you be signing up for it?</p>
<p>— Veera (@vraa) <a href="https://twitter.com/vraa/status/164394058238799873" data-datetime="2012-01-31T17:06:12+00:00">January 31, 2012</a></p></blockquote>
<p>My idea was simple: to send out Thirukural poems everyday to the people that are signing up for the service. Instead of sending it to email addresses, I decided to use Twitter and Facebook as my medium since that&#8217;s where most of the people are hanging out these days.</p>
<p>There were few tweeples responding to it positively. Even though there are already few other alternative services available, I decided to move on and build it as I thought the new service will be different and be a learning experience.</p>
<p>It took a weekend to code the 80% of the site and I hosted it on App Engine platform. And the site is live for the past few weeks &#8211; <a href="http://twikural.veerasundar.com">http://twikural.veerasundar.com</a></p>
<p style="text-align: center;"><a href="http://twikural.veerasundar.com"><img class="aligncenter  wp-image-2997" title="twikural" src="http://veerasundar.com/blog/wp-content/uploads/2012/04/twikural.png" alt="" width="608" height="250" /></a></p>
<p>Now, the service has <a href="https://twitter.com/#!/twikural">31 followers in Twitter</a> and <a href="https://www.facebook.com/twikural">37 Likes in Facebook</a>. It has already sent out 120 Thirukurals till date. <img src='http://veerasundar.com/blog/wp-includes/images/smilies/icon_smile.gif' alt=':)' class='wp-smiley' /> </p>
<p>And, I&#8217;m now open sourcing the code. The project is now <a href="https://github.com/vraa/twikural">hosted @ Github</a>. You are welcomed to check it out and if you&#8217;d like to contribute, feel free to send a pull request / contact me.</p>
<p>I would like to thank my fellow tweeples &#8211; <a href="https://twitter.com/#!/iGhillli">@iGhillli</a>, <a href="https://twitter.com/#!/anandhame">@anandhame</a>, <a href="https://twitter.com/#!/mgobi_php">@mgobi_php</a>   for their continuous support to this project.</p>
]]></content:encoded>
			<wfw:commentRss>http://veerasundar.com/blog/2012/04/open-sourcing-twikural-an-app-engine-project/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>How to reset Auto Increment back to 1 in XAMPP MySQL using phpMyAdmin</title>
		<link>http://veerasundar.com/blog/2012/04/how-to-reset-auto-increment-back-to-1-in-xampp-mysql-using-phpmyadmin/</link>
		<comments>http://veerasundar.com/blog/2012/04/how-to-reset-auto-increment-back-to-1-in-xampp-mysql-using-phpmyadmin/#comments</comments>
		<pubDate>Fri, 13 Apr 2012 11:56:04 +0000</pubDate>
		<dc:creator>Veera</dc:creator>
				<category><![CDATA[How To]]></category>
		<category><![CDATA[PHP]]></category>
		<category><![CDATA[Web]]></category>
		<category><![CDATA[id]]></category>
		<category><![CDATA[increment]]></category>
		<category><![CDATA[mysql]]></category>
		<category><![CDATA[phpmyadmin]]></category>
		<category><![CDATA[query]]></category>
		<category><![CDATA[reset]]></category>
		<category><![CDATA[sql]]></category>
		<category><![CDATA[table]]></category>
		<category><![CDATA[xampp]]></category>

		<guid isPermaLink="false">http://veerasundar.com/blog/?p=2984</guid>
		<description><![CDATA[When you delete every records from a table, which has an AUTO Increment ID field, the delete option will not reset the Auto Increment number. For example, if the table had 5 rows, and you deleted all the rows (either one by one or through delete from tablename where 1;), and then if you insert a new [...]]]></description>
			<content:encoded><![CDATA[<p></p><p>When you delete every records from a table, which has an AUTO Increment ID field, the <em>delete</em> option will not reset the<em> Auto Increment </em>number. For example, if the table had 5 rows, and you deleted all the rows (either one by one or through <em>delete from tablename where 1;</em>), and then if you insert a new row, it will get a ID value as <strong>6 </strong>not as <strong>1</strong>. Because the auto increment value is not reset.</p>
<p>The easiest way to reset the auto increment number is to use the query <strong>truncate tablename; </strong>which removes all the rows from that table and resets the auto increment back to 1.</p>
<p>But if you want to do it visually, phpMyAdmin provides options for that:</p>
<p style="text-align: center;"><img class="aligncenter  wp-image-2988" title="auto-increment-mysql" src="http://veerasundar.com/blog/wp-content/uploads/2012/04/auto-increment.png" alt="" width="670" height="492" /></p>
<ol>
<li>In phpMyAdmin, open the table for which you want to reset the auto increment number.</li>
<li>Then go to: <strong>Operations -&gt; Table Options. </strong></li>
<li>Reset the <strong>AUTO_INCREMENT </strong>field to whichever value you want and save the changes.</li>
</ol>
<p>That&#8217;s it. The next time, when you insert new records, they will start from the auto increment number you set above.</p>
]]></content:encoded>
			<wfw:commentRss>http://veerasundar.com/blog/2012/04/how-to-reset-auto-increment-back-to-1-in-xampp-mysql-using-phpmyadmin/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>WordPress plugin to show the posts and comments count in the sidebar</title>
		<link>http://veerasundar.com/blog/2012/03/wordpress-plugin-to-show-the-posts-and-comments-count-in-the-sidebar/</link>
		<comments>http://veerasundar.com/blog/2012/03/wordpress-plugin-to-show-the-posts-and-comments-count-in-the-sidebar/#comments</comments>
		<pubDate>Mon, 05 Mar 2012 01:58:52 +0000</pubDate>
		<dc:creator>Veera</dc:creator>
				<category><![CDATA[How To]]></category>
		<category><![CDATA[PHP]]></category>
		<category><![CDATA[Web]]></category>
		<category><![CDATA[code]]></category>
		<category><![CDATA[howto]]></category>
		<category><![CDATA[plugin]]></category>
		<category><![CDATA[stats]]></category>
		<category><![CDATA[widget]]></category>
		<category><![CDATA[wordpress]]></category>

		<guid isPermaLink="false">http://veerasundar.com/blog/?p=2926</guid>
		<description><![CDATA[As part of this blog&#8217;s re-design, I wanted to show the number of posts and comments as a widget in the sidebar. But I couldn&#8217;t find a plugin that does exactly what I wanted. So, I wrote one on my own. Below is the source code for this wordpress plug-in which you can drop it [...]]]></description>
			<content:encoded><![CDATA[<p></p><p>As part of this blog&#8217;s re-design, I wanted to show the number of posts and comments as a widget in the sidebar. But I couldn&#8217;t find a plugin that does exactly what I wanted. So, I wrote one on my own.</p>
<p>Below is the source code for this wordpress plug-in which you can drop it in your <em>plugins </em>folder and then activate it as usual. Then, in your <em>Widgets</em> section, you&#8217;ll see a new widget that you can use it in your sidebar.</p>
<h2>Source for WordPress StatsBoard plugin to display the posts and comments count:</h2>
<script src="https://gist.github.com/1976268.js"></script>
<p>You can use the plugin however the way you want, of course, at your own risk! <img src='http://veerasundar.com/blog/wp-includes/images/smilies/icon_smile.gif' alt=':)' class='wp-smiley' /> </p>
]]></content:encoded>
			<wfw:commentRss>http://veerasundar.com/blog/2012/03/wordpress-plugin-to-show-the-posts-and-comments-count-in-the-sidebar/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>How I scrape web pages</title>
		<link>http://veerasundar.com/blog/2012/02/how-i-scrap-web-pages/</link>
		<comments>http://veerasundar.com/blog/2012/02/how-i-scrap-web-pages/#comments</comments>
		<pubDate>Wed, 15 Feb 2012 14:37:02 +0000</pubDate>
		<dc:creator>Veera</dc:creator>
				<category><![CDATA[How To]]></category>
		<category><![CDATA[Web]]></category>
		<category><![CDATA[firefox]]></category>
		<category><![CDATA[javascript]]></category>
		<category><![CDATA[jquery]]></category>
		<category><![CDATA[scrap]]></category>
		<category><![CDATA[scraping]]></category>
		<category><![CDATA[scratchpad]]></category>

		<guid isPermaLink="false">http://veerasundar.com/blog/?p=2918</guid>
		<description><![CDATA[Often I need to pull some content out of web pages. Of course, I can always do a simple Ctrl+C. But many times, I want the scrapped content to be in a different format than it&#8217;s already in. So, I used to write Java code that downloads the content and do some XML parsing and then converts [...]]]></description>
			<content:encoded><![CDATA[<p></p><p>Often I need to pull some content out of web pages. Of course, I can always do a simple <em>Ctrl+C</em>. But many times, I want the scrapped content to be in a different format than it&#8217;s already in. So, I used to write Java code that downloads the content and do some XML parsing and then converts it into the format I want. But, this became a tedious process soon.</p>
<p>So, these days I figured out another easy way to do the web scraping. JQuery!</p>
<p>IMO, JQuery is the best tool to do the DOM parsing and content extraction. Of course, that&#8217;s why the JQuery library is built for.</p>
<p>But the problem here is, not all websites include JQuery with them and even if they do, you can&#8217;t just go and execute your JavaScript code in amother person&#8217;s website.</p>
<p>Thanks to Scratchpad from Firefox which solves the above problem. Starting last August, Firefox comes with a built-in webdev tool &#8211; <a title="Introducing Scratchpad" href="http://blog.mozilla.com/devtools/2011/08/15/introducing-scratchpad/" target="_blank">Scratchpad</a> that enables you to execute your own JavaScript code in the context of any website.</p>
<p>So, this is what I do to scrape any public content from any web page:</p>
<ol>
<li>Open the page in Firefox.</li>
<li>Press <strong>Shift+F4 </strong>or go to <strong>Firefox menu-&gt;Web developer-&gt;Scratchpad</strong> to open the JavaScript editor.</li>
<li>Include the below lines to add JQuery library to the current page (<a title="Add jQuery to any (or every) webpage" href="http://blogs.ischool.berkeley.edu/i290-04f09/2009/09/12/add-jquery-to-any-or-every-webpage/" target="_blank">thanks to this page</a>).
<pre class="brush:javascript">var GM_JQ = document.createElement('script');
GM_JQ.src = 'http://ajax.googleapis.com/ajax/libs/jquery/1.3.2/jquery.min.js';
GM_JQ.type = 'text/javascript';
document.getElementsByTagName('head')[0].appendChild(GM_JQ);</pre>
</li>
<li>After that I can use any valid JQuery statement to navigate through the page content and parse it.
<pre class="brush:javascript">var pages = [];
$("#Text1 table a").each(function(){
    pages.push($(this).attr('href'));
});</pre>
</li>
</ol>
<p>Caution: Some websites may prohibit web scraping. So, please make your own judgment before scraping their content! Just saying! <img src='http://veerasundar.com/blog/wp-includes/images/smilies/icon_smile.gif' alt=':)' class='wp-smiley' /> </p>
]]></content:encoded>
			<wfw:commentRss>http://veerasundar.com/blog/2012/02/how-i-scrap-web-pages/feed/</wfw:commentRss>
		<slash:comments>2</slash:comments>
		</item>
		<item>
		<title>Shortcut to console.log</title>
		<link>http://veerasundar.com/blog/2012/02/shortcut-to-console-log/</link>
		<comments>http://veerasundar.com/blog/2012/02/shortcut-to-console-log/#comments</comments>
		<pubDate>Tue, 07 Feb 2012 17:10:46 +0000</pubDate>
		<dc:creator>Veera</dc:creator>
				<category><![CDATA[How To]]></category>
		<category><![CDATA[Web]]></category>
		<category><![CDATA[code]]></category>
		<category><![CDATA[console]]></category>
		<category><![CDATA[javascript]]></category>
		<category><![CDATA[logging]]></category>

		<guid isPermaLink="false">http://veerasundar.com/blog/?p=2911</guid>
		<description><![CDATA[Sometimes, I&#8217;m just lazy to type &#8216;console.log&#8216; to print some data on the Firebug console. I often wanted to have a simple echo() function that spits whatever it gets to the console. So, in every single JavaScript project I work on, I used to have this utility method: function echo(obj){ console.log(obj); } ... echo('Hello World'); [...]]]></description>
			<content:encoded><![CDATA[<p></p><p>Sometimes, I&#8217;m just lazy to type &#8216;<em>console.log</em>&#8216; to print some data on the Firebug console. I often wanted to have a simple <em>echo() </em>function that spits whatever it gets to the console.</p>
<p>So, in every single JavaScript project I work on, I used to have this utility method:</p>
<pre class="brush:javascript">function echo(obj){
  console.log(obj);
}
...
echo('Hello World');</pre>
<p>It worked well. But there was a problem. The printed message on the console will always show the line number of <em>console.log  </em>as the source line number instead of showing the where exactly the <em>echo() </em>function is invoked.</p>
<p>There&#8217;s another way to solve this. Instead of creating a new <em>echo() </em>method, I just need to bind it to the existing <em>console.log() </em>to a variable and the logging works like a charm. Like this,</p>
<pre class="brush:javascript">window.echo = console.log.bind(console);
window.oops = console.error.bind(console);
...
echo('hello world');
...
oops('I did it again');</pre>
<p>The the methods became shorter and the correct line numbers printed on the console!</p>
]]></content:encoded>
			<wfw:commentRss>http://veerasundar.com/blog/2012/02/shortcut-to-console-log/feed/</wfw:commentRss>
		<slash:comments>1</slash:comments>
		</item>
		<item>
		<title>Backbone JS &#8211; Hello World tutorial</title>
		<link>http://veerasundar.com/blog/2012/01/backbone-js-hello-world-tutorial/</link>
		<comments>http://veerasundar.com/blog/2012/01/backbone-js-hello-world-tutorial/#comments</comments>
		<pubDate>Mon, 30 Jan 2012 15:39:11 +0000</pubDate>
		<dc:creator>Veera</dc:creator>
				<category><![CDATA[How To]]></category>
		<category><![CDATA[Web]]></category>
		<category><![CDATA[backbone]]></category>
		<category><![CDATA[helloworld]]></category>
		<category><![CDATA[javascript]]></category>
		<category><![CDATA[tutorial]]></category>

		<guid isPermaLink="false">http://veerasundar.com/blog/?p=2855</guid>
		<description><![CDATA[Backbone.js is recently getting lots of traction among the web developers because of its ability to organize the JavaScript code. It provides the structure (Model-View) around which we can build our JavaScript heavy web applications. I have started learning backbone.js for my personal project and I&#8217;m going to document my learning along the way. Let&#8217;s [...]]]></description>
			<content:encoded><![CDATA[<p></p><p><a href="http://documentcloud.github.com/backbone/">Backbone.js</a> is recently getting lots of traction among the web developers because of its ability to organize the JavaScript code. It provides the structure (Model-View) around which we can build our JavaScript heavy web applications.</p>
<p>I have started learning backbone.js for my personal project and I&#8217;m going to document my learning along the way. Let&#8217;s start with a simplest possible example: A Hello World tutorial in Backbone.js (duh!)</p>
<p>You are welcomed to point out any anti-patterns/mistakes that I made in this tutorial so that I can update the content for better.</p>
<p><a title="Backbone JS - Hello World tutorial" href="http://veerasundar.com/app/hello-backbone/" target="_blank">Demo</a> | <a title="Fork the source code in GitHub" href="https://github.com/vraa/hello-backbone" target="_blank">Source code</a></p>
<h2>The need for Backbone.js</h2>
<p>Generally, we use JavaScript to handle UI events (<em>click</em>, <em>keypress</em>, etc), to process the UI data (<em>innerHTML,</em> etc) and to render DOM elements (<em>appendChild, </em>etc).</p>
<p>Without a framework like Backbone.js, each developer would implement the above logic in his/her own coding style. This might cause some maintenance issues if multiple developers are involved.</p>
<p>Backbone.js provides a structure to do the above operations so that it is easy to write a maintainable code with less effort.</p>
<p>With Backbone, you get the following constructs:</p>
<ol>
<li><strong>Model </strong>- used to represent your application data. For example, an <em>Employee</em> model.</li>
<li><strong>Collection </strong>- used to hold a list of your model objects. For example, an <em>Employees </em>collection which contains a list of <em>Employee </em>model.</li>
<li><strong>Views </strong>- each model &amp; collection can be associated with a Backbone view. You can also create a view for an existing DOM element so that the view can respond to events generated from that DOM element.</li>
</ol>
<p>That said, Let&#8217;s start building our application step by step.</p>
<h2>0. Requirement</h2>
<p>Our requirement is to <a href="http://veerasundar.com/app/hello-backbone/" target="_blank">create a application</a> that gets a name from the user and says &#8216;Hello {name}&#8217; and appends it to a list.</p>
<h2>1. Create the User Interface</h2>
<p>Let&#8217;s create our user interface first.</p>
<pre class="brush:html">	&lt;body&gt;
		&lt;header&gt;
			&lt;h1&gt;Backbone JS - Hello World Tutorial!&lt;/h1&gt;
			&lt;h5&gt;&amp;lt;= &lt;a href='#'&gt;back to the article&lt;/a&gt;&lt;/h5&gt;
		&lt;/header&gt;

		&lt;section id='UserInput'&gt;
			&lt;fieldset&gt;
				&lt;legend&gt;Enter a name and click say hello!&lt;/legend&gt;
				&lt;input type="text" name="hello" placeholder="your friend name" value="veera" /&gt; &amp;#160; &lt;button&gt;Say hello&lt;/button&gt;
			&lt;/fieldset&gt;
		&lt;/section&gt; 

		&lt;ol id="HelloList"&gt;

		&lt;/ol&gt;

		&lt;script type="text/javascript" src="jquery-1.7.1.min.js"&gt;&lt;/script&gt;
		&lt;script type="text/javascript" src="underscore-min.js"&gt;&lt;/script&gt;
		&lt;script type="text/javascript" src="backbone-min.js"&gt;&lt;/script&gt;
		&lt;script type="text/javascript" src="hello.js"&gt;&lt;/script&gt;
	&lt;/body&gt;</pre>
<p>As you can see, it&#8217;s a simple HTML document with a textbox, button to accept user input and a empty OL element to hold the list of hello messages.</p>
<h2>2. Create the Backbone Views to represent the UI elements</h2>
<p>We have two views in our UI: One that accepts user input and one that shows the accepted inputs as a list. So, we&#8217;ll create two Backbone views for this. Open the <em>hello.js </em>and type in the below code.</p>
<pre class="brush:javascript">(function($) {

	var UserInputView = Backbone.View.extend({

		el : '#UserInput',

		initialize : function() {
			this.helloListView = new HelloListView();
		},

		events : {
			'click button' : 'addToHelloCollection'
		},

		addToHelloCollection : function(e) {
		}
	});

	var HelloListView = Backbone.View.extend({

		el : '#HelloList',

	});

	new UserInputView();

})(jQuery);</pre>
<p>Because we are creating the Backbone views to represent the existing DOM elements, we can mention the elements in <em>el<strong> </strong></em>option. You can use the CSS3 selector syntax here and Backbone will find the element for you.</p>
<p>All Backbone objects has an <em>initialize() </em>function. Above we are initializing the <em>UserInputView </em>with a reference to the <em>HelloListView</em>.</p>
<p>Each view can accept a <em>events</em> object. Within this, you can specify what are all the events this view will trigger and method name to handle the event. In our case, we have a <em>click </em>event for the <em>button </em>element and a method <em>addToHelloCollection</em> to handle the click event. It is important to note that Backbone searches for the elements mentioned inside the <em>events </em>hash (in this case <em>button</em>) inside the <em>el</em>. So the <em>el</em> element should contain whatever element you give in the <em>events </em>object.</p>
<h2>3. Create Backbone Model, Collection and a view to represent the model</h2>
<p>It&#8217;s time to create a Backbone Model to hold our application data. We can map each hello message to a model. Since we have list of messages, we&#8217;ll create a Backbone Collection too. Lets look at the code.</p>
<pre class="brush:javascript">var Hello = Backbone.Model.extend({
		initialize : function() {
			this.name = 'name'
		}
	});

	var HelloView = Backbone.View.extend({
		tagName : 'li',
		render : function() {
			$(this.el).html('Hello ' + this.model.get('name'));
			return this;
		}
	});

	var HelloList = Backbone.Collection.extend({
		model : Hello
	});</pre>
<p><em>Hello</em> is the model object with a property <em>name </em>initialized to &#8216;name&#8217;. <em>HelloList</em> is the collection and we set this collection <em>model </em>property to our <em>Hello</em> model.</p>
<p>In Backbone, each Model and Collection can have it&#8217;s own view to render themselves. So, we created a <em>HelloView</em> for the <em>Hello</em> model with the <em>render() </em>method to generate the HTML output. Since this view is not associated with any existing DOM elements and Backbone needs a wrapper tag to surround the rendered output, we provide the <em>tagName </em>property with &#8216;li&#8217;. Because of this, when the <em>Hello</em> model generates its HTML code (in <em>render() </em>method), it will be surrounded by <em>li </em>tag.</p>
<h2>4. Combine everything: The final code for hello.js</h2>
<p>Lets update our <em>hello.js </em>file with this final JavaScript.</p>
<pre class="brush:javascript">(function($) {

	var UserInputView = Backbone.View.extend({

		el : '#UserInput',

		initialize : function() {
			this.helloListView = new HelloListView();
		},

		events : {
			'click button' : 'addToHelloCollection'
		},

		addToHelloCollection : function(e) {
			var hello = new Hello({
				name : this.$('input').val()
			});
			this.helloListView.collection.add(hello);
		}
	});

	var Hello = Backbone.Model.extend({
		initialize : function() {
			this.name = 'name'
		}
	});

	var HelloView = Backbone.View.extend({
		tagName : 'li',
		render : function() {
			$(this.el).html('Hello ' + this.model.get('name'));
			return this;
		}
	});

	var HelloList = Backbone.Collection.extend({
		model : Hello
	});

	var HelloListView = Backbone.View.extend({

		el : '#HelloList',

		initialize : function() {
			_.bindAll(this, 'render', 'appendToHelloUL');
			this.collection = new HelloList();
			this.collection.bind('add', this.appendToHelloUL);
		},

		render:function(){

			$.each(this.collection.models, function(i, helloModel){
				self.appendToHelloUL(helloModel);
			});
		},

		appendToHelloUL : function(helloModel) {
			var helloView = new HelloView({
				model : helloModel
			});
			$(this.el).append(helloView.render().el);
		}
	});

	new UserInputView();

})(jQuery);</pre>
<p>As you can see, we have two Backbone views:</p>
<ol>
<li><em>UserInputView</em> &#8211; which listens to the user interface events(<em>button click</em>) and update the model object with user input.</li>
<li><em>HelloListView</em> &#8211; which listens to the changes in our model(<em>add </em>event) and update the user interface with the model values.</li>
</ol>
<div>Everything starts when we create a <em>new UserInputView() </em>which triggers <em>initialize </em>function for each objects and sets up event listeners. When user interacts with the view, the respective event listeners are called and the model gets updated. Then the <em>HelloListView</em> which is listening to model changes gets triggered and the user interface is updated.</div>
<p>Well, that concludes this tutorial. You can see the <a title="Backbone JS - Hello World tutorial" href="http://veerasundar.com/app/hello-backbone/" target="_blank">completed application in action</a> or <a title="Github source" href="https://github.com/vraa/hello-backbone" target="_blank">fork the code in GitHub</a>.</p>
]]></content:encoded>
			<wfw:commentRss>http://veerasundar.com/blog/2012/01/backbone-js-hello-world-tutorial/feed/</wfw:commentRss>
		<slash:comments>2</slash:comments>
		</item>
		<item>
		<title>The Rise of the Front End Developers</title>
		<link>http://veerasundar.com/blog/2012/01/the-rise-of-the-front-end-developers/</link>
		<comments>http://veerasundar.com/blog/2012/01/the-rise-of-the-front-end-developers/#comments</comments>
		<pubDate>Tue, 24 Jan 2012 17:53:54 +0000</pubDate>
		<dc:creator>Veera</dc:creator>
				<category><![CDATA[Java]]></category>
		<category><![CDATA[Web]]></category>
		<category><![CDATA[back-end]]></category>
		<category><![CDATA[backbone]]></category>
		<category><![CDATA[front-end]]></category>
		<category><![CDATA[html]]></category>
		<category><![CDATA[javascript]]></category>
		<category><![CDATA[nodejs]]></category>
		<category><![CDATA[opinion]]></category>

		<guid isPermaLink="false">http://veerasundar.com/blog/?p=2826</guid>
		<description><![CDATA[In any web development company, there exists two different worlds; well there are more, but we&#8217;ll just focus on - front end (designers) &#38; back end (developers) The Front end guys are responsible for making something that is visible to the end users (THE LOOK). The back end guys are responsible for making the front end work [...]]]></description>
			<content:encoded><![CDATA[<p></p><p>In any web development company, there exists two different worlds; well there are <em>more,</em> but we&#8217;ll just focus on - front end (designers) &amp; back end (developers)</p>
<p>The Front end guys are responsible for making something that is visible to the end users (THE LOOK). The back end guys are responsible for making the front end work (THE FUNCTIONALITY). Together, they both deliver a complete web application/site.</p>
<p>The back end developers would typically use programming languages, such as Java/C++/Python. Apart from talking to database and processing requests, they even have an arsenal of libraries to generate the site markup (JSPs, server side templates, etc).</p>
<p>Front end guys usually fill in by writing HTML documents and CSS files (merely a <em>writer</em>) to present this markup in an visually pleasing way and back end just take these templates to populate data.</p>
<p>Front end had only one option to do any logical operations, by using <em>JavaScript </em>- which has been used for a long time just to validate forms (and do some freaky stuffs).</p>
<p>Because of this <em>cultural </em>difference, there&#8217;s always been a ego-war between these two worlds. Even the company management would rate the front end guys par below the back end developers because the front ends guys don&#8217;t do any serious programming.</p>
<p>All was going fine until the web2.0 era. Now, the front end realized that they could use JavaScript to do much more cooler stuffs than just the form validation. The development of high speed JavaScript engines (such as V8) made it possible to run complex JavaScript code right in the browser. With the introduction of technologies such as WebGL and Canvas, even graphics rendering became feasible using JavaScript.</p>
<p>But, this didn&#8217;t change anything on the server side; the server programs were still running on JVMs/Rubys/Pythons.</p>
<p>Fast forward to today: The scenario is dramatically changing. JavaScript has just sneaked its way into the servers. Now, it is no longer required that a web application needs to have a back end programming language such as Java/C++. Everything can be done using just JavaScript.</p>
<p>Thanks to <strong>node.js </strong>which made it possible to run the JavaScript on the server side. Using <strong>MongoDB, </strong>one can replace the need to have SQL code and now store JSON documents using JavaScript MongoDB connectors. The JavaScript template libraries such as <strong>{{Mustache}}/Underscore </strong>almost removed the need to have server side templates (JSPs). On the client side, JavaScript MVC frameworks such as <strong>Backbone.JS </strong>enable us to write maintainable code. And, there&#8217;s always the plain old JavaScript waiting for us to write some form validation script.</p>
<p>With that, now it is possible to do the heavy lifting just by using JavaScript. The front end JavaScript programmers no longer need to focus on just the front end. They can use their skill set to develop the web application <strong>end-to-end.</strong></p>
<p>This rise of the front end developers poses a real threat to the survival of back end developers. If you are one of that back end guy, do you already realize this threat? What&#8217;s your game plan to stay fit to survive this challenge?</p>
]]></content:encoded>
			<wfw:commentRss>http://veerasundar.com/blog/2012/01/the-rise-of-the-front-end-developers/feed/</wfw:commentRss>
		<slash:comments>10</slash:comments>
		</item>
		<item>
		<title>How to create a new image in GIMP with the size of clipboard image</title>
		<link>http://veerasundar.com/blog/2012/01/how-to-create-a-new-image-in-gimp-with-the-size-of-clipboard-image/</link>
		<comments>http://veerasundar.com/blog/2012/01/how-to-create-a-new-image-in-gimp-with-the-size-of-clipboard-image/#comments</comments>
		<pubDate>Sun, 08 Jan 2012 05:34:15 +0000</pubDate>
		<dc:creator>Veera</dc:creator>
				<category><![CDATA[How To]]></category>
		<category><![CDATA[Web]]></category>
		<category><![CDATA[Design]]></category>
		<category><![CDATA[editing]]></category>
		<category><![CDATA[gimp]]></category>
		<category><![CDATA[image]]></category>
		<category><![CDATA[linux]]></category>
		<category><![CDATA[slice]]></category>
		<category><![CDATA[slicing]]></category>
		<category><![CDATA[Ubuntu]]></category>
		<category><![CDATA[ued]]></category>
		<category><![CDATA[visual]]></category>

		<guid isPermaLink="false">http://veerasundar.com/blog/?p=2804</guid>
		<description><![CDATA[When you are designing a web page and you are given only the single visual design image file, it is vital to slice the image into multiple smaller images to get the required image parts (logo, icons etc.). In Photoshop world, slicing images is piece-of-cake. When you copy an image and choose &#8220;File-&#62;New&#8221;, Photoshop automagically [...]]]></description>
			<content:encoded><![CDATA[<p></p><p>When you are designing a web page and you are given only the single visual design image file, it is vital to slice the image into multiple smaller images to get the required image parts (logo, icons etc.).</p>
<p>In Photoshop world, slicing images is piece-of-cake. When you copy an image and choose &#8220;File-&gt;New&#8221;, Photoshop automagically sets the new image dimension as of the clipboard image.</p>
<p>But GIMP doesn&#8217;t do this! Wait&#8230;there&#8217;s another technique to achieve the same functionality in GIMP.</p>
<ol>
<li>Open the image from which you want to cut smaller images and make them as separate files.</li>
<li>Copy/Cut your required section.</li>
<li>Now go to &#8220;<em>Edit -&gt; Paste as New Image</em>&#8221; (or just <em>Ctrl+Shift+v)</em></li>
<li>Bingo! you have a new image with the same size as of the one you just cut/copied.</li>
</ol>
]]></content:encoded>
			<wfw:commentRss>http://veerasundar.com/blog/2012/01/how-to-create-a-new-image-in-gimp-with-the-size-of-clipboard-image/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Making XAMPP to serve any directory outside htdocs</title>
		<link>http://veerasundar.com/blog/2011/11/making-xampp-to-serve-any-directory-outside-htdocs/</link>
		<comments>http://veerasundar.com/blog/2011/11/making-xampp-to-serve-any-directory-outside-htdocs/#comments</comments>
		<pubDate>Tue, 22 Nov 2011 06:52:22 +0000</pubDate>
		<dc:creator>Veera</dc:creator>
				<category><![CDATA[How To]]></category>
		<category><![CDATA[Web]]></category>
		<category><![CDATA[apache]]></category>
		<category><![CDATA[howto]]></category>
		<category><![CDATA[htdocs]]></category>
		<category><![CDATA[PHP]]></category>
		<category><![CDATA[server]]></category>
		<category><![CDATA[windows]]></category>
		<category><![CDATA[xampp]]></category>

		<guid isPermaLink="false">http://veerasundar.com/blog/?p=2738</guid>
		<description><![CDATA[So, you have installed XAMPP on windows, changed its server port to a different number other than 80 and changed the MySQL root password to a more secure one. Now its the time to create some HTML files that will be served by XAMPP server. By default, XAMPP serves any file that is located under the [...]]]></description>
			<content:encoded><![CDATA[<p></p><p>So, you have installed XAMPP on windows, <a title="How to change XAMPP server port?" href="http://veerasundar.com/blog/2009/07/how-to-change-xampp-server-port/" target="_blank">changed its server port</a> to a different number other than 80 and <a title="How to change the ‘root’ password for MySQL in XAMPP?" href="http://veerasundar.com/blog/2009/01/how-to-change-the-root-password-for-mysql-in-xampp/" target="_blank">changed the MySQL <em>root</em> password</a> to a more secure one. Now its the time to create some HTML files that will be served by XAMPP server.</p>
<p>By default, XAMPP serves any file that is located under the directory <em>[xampp_installation_folder]/htdocs, </em> which means that you have to copy all your HTML/PHP files inside this directory. But what if you maintain a different folder for all your projects files and you want XAMPP to serve them too along with <em>htdocs</em>?</p>
<p>Lets make XAMPP to do this.</p>
<ol>
<li>Open the file <em>[xamp_installation_folder]/apache/conf/httpd.conf</em> in any text editor.</li>
<li>Copy below lines after the <em>htdocs </em>&lt;Directory&gt; element after changing the directory to your own folder.
<pre class="brush:xml">&lt;Directory "C:/path/to/your/folder"&gt;
    Options Indexes FollowSymLinks Includes ExecCGI
    AllowOverride All
    Order allow,deny
    Allow from all
&lt;/Directory&gt;</pre>
</li>
<li>Then search for this string: &lt;IfModule alias_module&gt;. Inside that element, add a new alias as followed:
<pre class="brush:text">Alias /yoursite/ "C:/path/to/your/folder/yoursite/"</pre>
</li>
<li>Save the file and restart the XAMPP server.</li>
</ol>
<div>After this, if you have a website named &#8216;yoursite&#8217; inside the folder <em>&#8216;c:/path/to/your/folder&#8217;</em> you can access it directly by using the URL: <em>http://localhost:8080/yoursite/ </em>(assuming you have <a title="Change XAMPP server port" href="http://veerasundar.com/blog/2009/07/how-to-change-xampp-server-port/" target="_blank">changed XAMPP port</a> to 8080).</div>
]]></content:encoded>
			<wfw:commentRss>http://veerasundar.com/blog/2011/11/making-xampp-to-serve-any-directory-outside-htdocs/feed/</wfw:commentRss>
		<slash:comments>3</slash:comments>
		</item>
	</channel>
</rss>

