<?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/"
	xmlns:georss="http://www.georss.org/georss" xmlns:geo="http://www.w3.org/2003/01/geo/wgs84_pos#" xmlns:media="http://search.yahoo.com/mrss/"
	>

<channel>
	<title>WebJukti</title>
	<atom:link href="http://ujjaini.wordpress.com/feed/" rel="self" type="application/rss+xml" />
	<link>http://ujjaini.wordpress.com</link>
	<description>Easy, efficient and handy solutions for the Web</description>
	<lastBuildDate>Thu, 19 Jan 2012 22:29:39 +0000</lastBuildDate>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.com/</generator>
<cloud domain='ujjaini.wordpress.com' port='80' path='/?rsscloud=notify' registerProcedure='' protocol='http-post' />
<image>
		<url>http://s2.wp.com/i/buttonw-com.png</url>
		<title>WebJukti</title>
		<link>http://ujjaini.wordpress.com</link>
	</image>
	<atom:link rel="search" type="application/opensearchdescription+xml" href="http://ujjaini.wordpress.com/osd.xml" title="WebJukti" />
	<atom:link rel='hub' href='http://ujjaini.wordpress.com/?pushpress=hub'/>
		<item>
		<title>How to set up Apache on Windows</title>
		<link>http://ujjaini.wordpress.com/2011/08/26/how-to-set-up-apache-on-windows/</link>
		<comments>http://ujjaini.wordpress.com/2011/08/26/how-to-set-up-apache-on-windows/#comments</comments>
		<pubDate>Fri, 26 Aug 2011 20:00:08 +0000</pubDate>
		<dc:creator>ujjaini</dc:creator>
				<category><![CDATA[Apache]]></category>

		<guid isPermaLink="false">http://ujjaini.wordpress.com/?p=716</guid>
		<description><![CDATA[1. Download Apache Go to this site-http://httpd.apache.org/download.cgi Select either Win32 Binary without crypto (no mod_ssl) (MSI Installer): httpd-2.2.19-win32-x86-no_ssl.msi [PGP] [MD5] [SHA1] Win32 Binary including OpenSSL 0.9.8r (MSI Installer): httpd-2.2.19-win32-x86-openssl-0.9.8r.msi [PGP] [MD5] [SHA1] and download it 2. Install Apache from the installer By default, Apache is installed here &#8211; C:\Program Files\Apache Software Foundation\Apache2.2 3. Test it [...]<img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=ujjaini.wordpress.com&amp;blog=7825904&amp;post=716&amp;subd=ujjaini&amp;ref=&amp;feed=1" width="1" height="1" />]]></description>
			<content:encoded><![CDATA[<p>1. <strong>Download Apache</strong></p>
<p>Go to this site-<a href="http://httpd.apache.org/download.cgi" target="_BLANK">http://httpd.apache.org/download.cgi</a></p>
<p>Select either</p>
<ul>
<li>Win32 Binary without crypto (no mod_ssl) (MSI Installer): httpd-2.2.19-win32-x86-no_ssl.msi [PGP] [MD5] [SHA1]</li>
<li>Win32 Binary including OpenSSL 0.9.8r (MSI Installer): httpd-2.2.19-win32-x86-openssl-0.9.8r.msi [PGP] [MD5] [SHA1]</li>
</ul>
<p>and download it</p>
<p>2. <strong>Install Apache </strong>from the installer<br />
By default, Apache is installed here &#8211; <em>C:\Program Files\Apache Software Foundation\Apache2.2</em></p>
<p>3. <strong>Test it</strong></p>
<p>Open a browser, and type &#8211; <em>http://localhost</em></p>
<p>It should show the line &#8211; &#8216;<em>It Works&#8217;</em></p>
<p>You are currently seeing contents of this file-</p>
<p><em>C:\Program Files\Apache Software Foundation\Apache2.2\htdocs\index.html</em></p>
<p><em>C:\Program Files\Apache Software Foundation\Apache2.2\htdocs</em> is the <span style="color:#0000ff;">document root</span> directory for Apache</p>
<p><strong>How to set up a different root directory for Apache</strong></p>
<p>1. <strong>Create a new directory.</strong></p>
<p>I have created a new folder under c drive called wwwroot</p>
<p><em>C:\wwwroot</em></p>
<p>Create an <em>index.html  </em> file under wwwroot. This is the contents of the <em>index.html </em>file</p>
<p>[sourcode]</p>
<p>&lt;head&gt;<br />
&lt;title&gt;Apache Root&lt;/title&gt;<br />
&lt;/head&gt;<br />
&lt;body&gt;<br />
TESTING APACHE NEW ROOT<br />
&lt;/body&gt;</p>
<p>[/sourcecode]</p>
<p>2. <strong>Change document root in httpd</strong></p>
<p>Go here &#8211; C:\Program Files\Apache Software Foundation\Apache2.2\conf</p>
<p>and open this file &#8211; <em>httpd</em></p>
<p>Change the following items there-</p>
<p>replace this line</p>
<p><em>DocumentRoot &#8220;C:/Program Files/Apache Software Foundation/Apache2.2/htdocs&#8221;</em></p>
<p>with this-<br />
<em>DocumentRoot &#8220;C:/wwwroot&#8221;</em></p>
<p>Also replace this line</p>
<p><em>&lt;Directory &#8220;C:/Program Files/Apache Software Foundation/Apache2.2/htdocs&#8221;&gt;  </em></p>
<p><em></em>with this -<br />
<em>&lt;Directory &#8220;C:/wwwroot&#8221;&gt;</em></p>
<p>3. <strong>Restart Apache</strong></p>
<p>Go to Start -&gt; Programs -&gt; Apache HTTP Server 2.2 -&gt; Control Apache Server -&gt; Restart</p>
<p>4. <strong>Test it</strong></p>
<p>Open a browser and type &#8211; <em>http://localhost</em><strong></strong></p>
<p>It will show the new index.html page</p>
<p><span style="color:#000080;"><strong>TROUBLESHOOTING</strong></span></p>
<p><span style="color:#003300;">************************</span></p>
<p><span style="color:#ff0000;">Forbidden</span><br />
<span style="color:#ff0000;">You don&#8217;t have permission to access on this server.</span></p>
<p>Make sure that both these lines point to the same document root</p>
<p>&lt;Directory &#8220;C:/wwwroot&#8221;&gt;</p>
<p>DocumentRoot &#8220;C:/wwwroot&#8221;</p>
<p><span style="color:#003300;">&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;</span></p>
<p><span style="color:#ff0000;">Apache fails to start</span></p>
<p><span style="color:#000000;">Make sure, both these lines are uncommented</span></p>
<p>&lt;Directory &#8220;C:/wwwroot&#8221;&gt;</p>
<p>DocumentRoot &#8220;C:/wwwroot&#8221;</p>
<br />  <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gocomments/ujjaini.wordpress.com/716/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/comments/ujjaini.wordpress.com/716/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godelicious/ujjaini.wordpress.com/716/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/delicious/ujjaini.wordpress.com/716/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gofacebook/ujjaini.wordpress.com/716/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/facebook/ujjaini.wordpress.com/716/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gotwitter/ujjaini.wordpress.com/716/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/twitter/ujjaini.wordpress.com/716/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gostumble/ujjaini.wordpress.com/716/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/stumble/ujjaini.wordpress.com/716/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godigg/ujjaini.wordpress.com/716/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/digg/ujjaini.wordpress.com/716/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/goreddit/ujjaini.wordpress.com/716/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/reddit/ujjaini.wordpress.com/716/" /></a> <img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=ujjaini.wordpress.com&amp;blog=7825904&amp;post=716&amp;subd=ujjaini&amp;ref=&amp;feed=1" width="1" height="1" />]]></content:encoded>
			<wfw:commentRss>http://ujjaini.wordpress.com/2011/08/26/how-to-set-up-apache-on-windows/feed/</wfw:commentRss>
		<slash:comments>1</slash:comments>
	
		<media:content url="http://1.gravatar.com/avatar/f47cc3c0824e42caed5f04ab77ee71ff?s=96&#38;d=identicon&#38;r=G" medium="image">
			<media:title type="html">ujjaini</media:title>
		</media:content>
	</item>
		<item>
		<title>JSONP with example</title>
		<link>http://ujjaini.wordpress.com/2011/06/14/jsonp-with-example/</link>
		<comments>http://ujjaini.wordpress.com/2011/06/14/jsonp-with-example/#comments</comments>
		<pubDate>Tue, 14 Jun 2011 21:10:29 +0000</pubDate>
		<dc:creator>ujjaini</dc:creator>
				<category><![CDATA[JSONP]]></category>

		<guid isPermaLink="false">http://ujjaini.wordpress.com/?p=656</guid>
		<description><![CDATA[What happens if we try to make an AJAX call to a different domain ? This would fail because of the Same Origin Policy for file. You would get an HTTP status value of 407 Authentication required One of the workarounds for doing this is to use JSONP. An example of how JSONP can be [...]<img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=ujjaini.wordpress.com&amp;blog=7825904&amp;post=656&amp;subd=ujjaini&amp;ref=&amp;feed=1" width="1" height="1" />]]></description>
			<content:encoded><![CDATA[<p><strong>What happens if we try to make an AJAX call to a different domain ? </strong></p>
<p>This would fail because of the Same Origin Policy for file.<br />
You would get an HTTP status value of <em><span style='color:red;'>407 Authentication required</span></em><br />
One of the workarounds for doing this is to use <strong>JSONP</strong>. </p>
<p><strong>An example of how JSONP can be used</strong><br />
<pre class="brush: plain;">
var url = 'http://github.com/api/v2/json/user/show/yui?callback=handleresponse';			
var script = document.createElement('script');
script.setAttribute('src', url);			
document.getElementsByTagName('head')[0].appendChild(script);

function handleresponse(data){	
   var user = data.user;			
   console.log(user.blog);
   console.log(user.company);
   console.log(user.followers_count);
   console.log(user.id);
}		

</pre></p>
<div style='margin-top:5px;'>
<p>In the above code</p>
<ul>
<li>We are trying to access the external url &#8211; <em>http://github.com/api/v2/json/user/show/yui?callback=handlejsonp</em></li>
<li>A callback method (<em>handlejsonp</em> ) is appended to the url  </li>
<li>We create a script dynamically in the HTML page so that its source points to the url</li>
<li>When that script is executed, we get callback data. This data  can be displayed or manipulated according to the requirement of the application </li>
</div>
<div style='margin-top:5px;'>
<strong>How to perform JSONP functionality using Jquery</strong><br />
<pre class="brush: plain;">
jQuery.getJSON(&quot;http://github.com/api/v2/json/user/show/yui?callback=?&quot;, 
	function (data) {	   
	   var user = data.user;			
	   console.log(user.blog);
	   console.log(user.company);
	   console.log(user.followers_count);
	   console.log(user.id);
	});		

</pre></p>
<p><strong>Note</strong> : Here we put ? as the callback function name instead of a real function name. This is because jQuery replaces the ? with a generated function name (like jsonp123456789)</p>
</div>
<div style='margin-top:5px;'>
<strong>How to perform JSONP functionality using YUI 3</strong><br />
<pre class="brush: plain;">
function handleJSONP(response) {    
   var user = response.user;			
   console.log(user.blog);
   console.log(user.company);
   console.log(user.followers_count);
   console.log(user.id);
 }
 
 YUI().use('jsonp', 'node', function(Y) {
 	var url = 'http://github.com/api/v2/json/user/show/yui?callback=';		
    url = url + &quot;{callback}&quot;; 
    Y.jsonp(url, handleJSONP);
});

</pre></p>
<p><strong>Note</strong> &#8211; Here the callback function is represented as<br />
<em>{callback}</em>
</div>
<br />  <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gocomments/ujjaini.wordpress.com/656/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/comments/ujjaini.wordpress.com/656/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godelicious/ujjaini.wordpress.com/656/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/delicious/ujjaini.wordpress.com/656/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gofacebook/ujjaini.wordpress.com/656/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/facebook/ujjaini.wordpress.com/656/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gotwitter/ujjaini.wordpress.com/656/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/twitter/ujjaini.wordpress.com/656/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gostumble/ujjaini.wordpress.com/656/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/stumble/ujjaini.wordpress.com/656/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godigg/ujjaini.wordpress.com/656/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/digg/ujjaini.wordpress.com/656/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/goreddit/ujjaini.wordpress.com/656/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/reddit/ujjaini.wordpress.com/656/" /></a> <img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=ujjaini.wordpress.com&amp;blog=7825904&amp;post=656&amp;subd=ujjaini&amp;ref=&amp;feed=1" width="1" height="1" />]]></content:encoded>
			<wfw:commentRss>http://ujjaini.wordpress.com/2011/06/14/jsonp-with-example/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
	
		<media:content url="http://1.gravatar.com/avatar/f47cc3c0824e42caed5f04ab77ee71ff?s=96&#38;d=identicon&#38;r=G" medium="image">
			<media:title type="html">ujjaini</media:title>
		</media:content>
	</item>
		<item>
		<title>How to take screenshots, edit, copy or upload images in FireFox</title>
		<link>http://ujjaini.wordpress.com/2011/05/27/how-to-take-screenshots-edit-copy-or-upload-online-pages-in-firefox/</link>
		<comments>http://ujjaini.wordpress.com/2011/05/27/how-to-take-screenshots-edit-copy-or-upload-online-pages-in-firefox/#comments</comments>
		<pubDate>Fri, 27 May 2011 22:12:00 +0000</pubDate>
		<dc:creator>ujjaini</dc:creator>
				<category><![CDATA[FireFox]]></category>

		<guid isPermaLink="false">http://ujjaini.wordpress.com/?p=624</guid>
		<description><![CDATA[There is a great FireFox add-on LightShot. (https://addons.mozilla.org/en-US/firefox/addon/lightshot/) for the above mentioned functions. After installation, it would appear like the above image on the navigation toolbar in FireFox I found the following pros and cons of the add-on Pros - super fast - intuitive - works very well for copying to clip board, print, selecting [...]<img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=ujjaini.wordpress.com&amp;blog=7825904&amp;post=624&amp;subd=ujjaini&amp;ref=&amp;feed=1" width="1" height="1" />]]></description>
			<content:encoded><![CDATA[<p>There is a great FireFox add-on <strong>LightShot</strong>. (<a href="https://addons.mozilla.org/en-US/firefox/addon/lightshot/">https://addons.mozilla.org/en-US/firefox/addon/lightshot/</a>) for the above mentioned functions.</p>
<p><img alt="lighshot icon" src="https://static-cdn.addons.mozilla.net/en-US/firefox/images/addon_icon/54654-32.png?modified=1302195684" title="lightshot icon" class="alignleft" width="32" height="32" /></p>
<div style="clear:both;"></div>
<div>
After installation, it would appear like the above image on the navigation toolbar in FireFox
</div>
<div style="margin-top:10px;float:left;">I found the following pros and cons of the add-on </div>
<div style="clear:both;"></div>
<div style="float:left;margin-top:5px;">
<p><strong>Pros</strong></p>
<p>- super fast<br />
- intuitive<br />
- works very well for copying to clip board, print, selecting an area on the screen and  save<br />
- works on FireFox versions 2 ~4</p>
<p><strong>Cons</strong></p>
<p>- will not work on MAC or Linux</p>
</div>
<br />  <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gocomments/ujjaini.wordpress.com/624/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/comments/ujjaini.wordpress.com/624/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godelicious/ujjaini.wordpress.com/624/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/delicious/ujjaini.wordpress.com/624/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gofacebook/ujjaini.wordpress.com/624/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/facebook/ujjaini.wordpress.com/624/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gotwitter/ujjaini.wordpress.com/624/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/twitter/ujjaini.wordpress.com/624/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gostumble/ujjaini.wordpress.com/624/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/stumble/ujjaini.wordpress.com/624/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godigg/ujjaini.wordpress.com/624/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/digg/ujjaini.wordpress.com/624/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/goreddit/ujjaini.wordpress.com/624/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/reddit/ujjaini.wordpress.com/624/" /></a> <img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=ujjaini.wordpress.com&amp;blog=7825904&amp;post=624&amp;subd=ujjaini&amp;ref=&amp;feed=1" width="1" height="1" />]]></content:encoded>
			<wfw:commentRss>http://ujjaini.wordpress.com/2011/05/27/how-to-take-screenshots-edit-copy-or-upload-online-pages-in-firefox/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
	
		<media:content url="http://1.gravatar.com/avatar/f47cc3c0824e42caed5f04ab77ee71ff?s=96&#38;d=identicon&#38;r=G" medium="image">
			<media:title type="html">ujjaini</media:title>
		</media:content>

		<media:content url="https://static-cdn.addons.mozilla.net/en-US/firefox/images/addon_icon/54654-32.png?modified=1302195684" medium="image">
			<media:title type="html">lightshot icon</media:title>
		</media:content>
	</item>
		<item>
		<title>Call function in Javascript used for Object Oriented Composition</title>
		<link>http://ujjaini.wordpress.com/2011/05/25/call-function-in-javascript-used-for-object-oriented-composition/</link>
		<comments>http://ujjaini.wordpress.com/2011/05/25/call-function-in-javascript-used-for-object-oriented-composition/#comments</comments>
		<pubDate>Wed, 25 May 2011 18:24:49 +0000</pubDate>
		<dc:creator>ujjaini</dc:creator>
				<category><![CDATA[Javascript]]></category>
		<category><![CDATA[Object Oriented Principles]]></category>

		<guid isPermaLink="false">http://ujjaini.wordpress.com/?p=603</guid>
		<description><![CDATA[The call function in JavaScript can be used in , among other ways, to implement 2 important principles of Object Orientation - Inheritance - Composition In my previous article, (Call function in JavaScript), I explained, how call can be used to achieve inheritance. Here, I wanted to show how call may be used for Composition. [...]<img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=ujjaini.wordpress.com&amp;blog=7825904&amp;post=603&amp;subd=ujjaini&amp;ref=&amp;feed=1" width="1" height="1" />]]></description>
			<content:encoded><![CDATA[<p>The <strong>call</strong> function in JavaScript can be used in , among other ways, to implement 2 important principles of Object Orientation</p>
<p>- Inheritance<br />
- Composition </p>
<p>In my previous article, (<a href='http://ujjaini.wordpress.com/2011/05/18/call-function-in-javascript'>Call function in JavaScript</a>), I explained, how <em>call</em> can be used to achieve inheritance. Here, I wanted to show how <em>call </em>may be used for <em>Composition</em>.</p>
<p><strong>What is Composition ?</strong><br />
Object composition  is a way to combine simple objects or data types into more complex ones. Composed objects are often referred to as having a &#8220;has a&#8221; relationship.<br />
(<a href='http://en.wikipedia.org/wiki/Object_composition'>http://en.wikipedia.org/wiki/Object_composition</a>)</p>
<p><strong>Example of Composition </strong><br />
<pre class="brush: plain;">
function engine(name){
   this.start = function(){
     alert('The ' + name + ' engine is starting');
   }
}

function car(name){
    engine.call(this, name);
}

var newcar = new car('volvo');
newcar.start(); // shows 'The volvo engine is starting

</pre></p>
<p>- There are 2 objects <em>car </em> and <em>engine</em>. A car is composed of, among other things, an engine. When the engine starts, the car starts too.<br />
- In the above code, from inside the constructor of <em> car</em>, we call the constructor of <em>engine</em>. If we create a new instance of <em>car</em>, it has a <em>start</em>, method which is the same method defined in <em>engine</em> class.</p>
<br />  <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gocomments/ujjaini.wordpress.com/603/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/comments/ujjaini.wordpress.com/603/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godelicious/ujjaini.wordpress.com/603/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/delicious/ujjaini.wordpress.com/603/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gofacebook/ujjaini.wordpress.com/603/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/facebook/ujjaini.wordpress.com/603/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gotwitter/ujjaini.wordpress.com/603/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/twitter/ujjaini.wordpress.com/603/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gostumble/ujjaini.wordpress.com/603/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/stumble/ujjaini.wordpress.com/603/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godigg/ujjaini.wordpress.com/603/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/digg/ujjaini.wordpress.com/603/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/goreddit/ujjaini.wordpress.com/603/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/reddit/ujjaini.wordpress.com/603/" /></a> <img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=ujjaini.wordpress.com&amp;blog=7825904&amp;post=603&amp;subd=ujjaini&amp;ref=&amp;feed=1" width="1" height="1" />]]></content:encoded>
			<wfw:commentRss>http://ujjaini.wordpress.com/2011/05/25/call-function-in-javascript-used-for-object-oriented-composition/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
	
		<media:content url="http://1.gravatar.com/avatar/f47cc3c0824e42caed5f04ab77ee71ff?s=96&#38;d=identicon&#38;r=G" medium="image">
			<media:title type="html">ujjaini</media:title>
		</media:content>
	</item>
		<item>
		<title>Call function in Javascript</title>
		<link>http://ujjaini.wordpress.com/2011/05/18/call-function-in-javascript/</link>
		<comments>http://ujjaini.wordpress.com/2011/05/18/call-function-in-javascript/#comments</comments>
		<pubDate>Wed, 18 May 2011 17:58:18 +0000</pubDate>
		<dc:creator>ujjaini</dc:creator>
				<category><![CDATA[Javascript]]></category>
		<category><![CDATA[Object Oriented Principles]]></category>

		<guid isPermaLink="false">http://ujjaini.wordpress.com/?p=583</guid>
		<description><![CDATA[The call function is used in Object Oriented Javascript to enable a class to use properties and methods of another class. In the above code- - there is a base class Person, which has a property name with a value &#8216;Anika&#8217;. - another class Author, is defined. Inside the constructor of this class, we call [...]<img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=ujjaini.wordpress.com&amp;blog=7825904&amp;post=583&amp;subd=ujjaini&amp;ref=&amp;feed=1" width="1" height="1" />]]></description>
			<content:encoded><![CDATA[<p>The call function is used in Object Oriented Javascript to enable a class to use properties and methods of another class.</p>
<p><pre class="brush: plain;">
function Person(){
    this.name = 'anika';
  }
function Author(){
   Person.call(this);
}

var aut = new Author();
alert(aut.name); // shows the value 'anika'

</pre></p>
<p>In the above code-<br />
- there is a base class <strong>Person</strong>, which has a property name with a value &#8216;Anika&#8217;.<br />
- another class <strong>Author</strong>, is defined. Inside the constructor of this class, we call the constructor for Person.<br />
- The <em>this</em> in &#8216;<em>Person.call(this)</em>&#8216; refers to an instance of Person class. So the property &#8216;name&#8217; is assigned the value of &#8216;anika&#8217;.</p>
<p>The same rule applies to functions defined in the class<br />
<pre class="brush: plain;">
function Person(){
   this.speak = function(){
     alert('person is speaking');
   }
}

function Author(){
   Person.call(this);
}

var aa = new Author();
aa.speak(); // alert box shows 'person is speaking'
</pre></p>
<p>Now, let us define a property-  &#8216;name&#8217; in &#8216;Author&#8217; class.We assign a new value to it. We will observe how call function behaves in this case -</p>
<p><pre class="brush: plain;">
function Person(){
    this.name = 'anika';
  }
function Author(){
   this.name = 'tanika';
   Person.call(this);
}

var aut = new Author();
alert(aut.name); // shows the value 'anika'

</pre></p>
<p>In the above code, inside the &#8216;Author&#8217; class constructor,<br />
- we assign &#8216;tanika&#8217; to &#8216;name&#8217; property<br />
- but when we invoke &#8216;call&#8217;, that value gets overridden by the value inside &#8216;Person&#8217; class constructor</p>
<p>Let&#8217;s see what happens if inside the &#8216;Author&#8217; class constructor, we invoke &#8216;call&#8217; first and then assign a new value to &#8216;name&#8217; property.<br />
<pre class="brush: plain;">
function Person(){
    this.name = 'anika';
  }
function Author(){  
   Person.call(this);
    this.name = 'tanika';
}

var aut = new Author();
alert(aut.name); // shows the value 'tanika'

</pre></p>
<p>In the above code,<br />
- first  &#8216;call&#8217; method is invoked and the &#8216;name&#8217; property is set to &#8216;anika&#8217;<br />
- but the same property is reset in the next line (<em>this.name = &#8216;tanika&#8217;</em>)</p>
<p>In all the above cases, we are setting the value of only ONE property &#8216;name&#8217;. But javascript would behave the same way, if we try to set the values of more than one property.</p>
<p><pre class="brush: plain;">
function Person(){
  this.name = 'anika';
  this.age = 4;
}

function Author(){   
   Person.call(this);
}

var aa = new Author();
alert(aa.name); // shows 'anika'
alert(aa.age); // shows '4'

</pre></p>
<p>Lets see how &#8216;call&#8217; behaves if we pass arguments in the constructor of a class-</p>
<p><pre class="brush: plain;">
function Person(name, age){
    this.name = name || 'anika';  // in case of empty string default value is 'anika'
    this.age = age || 4;  // in case of empty string, default value is 4
}

function Author(name, age, book){
   this.book = book;
   Person.call(this, name, age);
}

var aa = new Author('', '', 'javascript book');
alert(aa.name); // shows default value 'anika'
alert(aa.age); // shows default value '4'
alert(aa.book); // shows value 'javascript book'

</pre></p>
<p>We can override the values of the base class using &#8216;call&#8217; method-</p>
<p><pre class="brush: plain;">
function Person(name, age){
    this.name = name || 'anika';
    this.age = age || 4;
}

function Author(name, age, book){
   this.book = book;
   Person.call(this, name, age);
}

var aa = new Author('', 8, 'javascript book');
alert(aa.name); // shows default value 'anika'
alert(aa.age); // shows overridden new value '8'
alert(aa.book); // shows new value 'javascript book'


</pre></p>
<p>In all the above examples, &#8216;call&#8217; function is used for a very important feature of Object Orientation &#8211; <strong>Inheritance</strong>. But &#8216;call&#8217; may also be used for another feature &#8211; <strong>Composition</strong>. I will explain <em>Composition</em> using <em>call</em>, in the next article.</p>
<br />  <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gocomments/ujjaini.wordpress.com/583/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/comments/ujjaini.wordpress.com/583/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godelicious/ujjaini.wordpress.com/583/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/delicious/ujjaini.wordpress.com/583/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gofacebook/ujjaini.wordpress.com/583/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/facebook/ujjaini.wordpress.com/583/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gotwitter/ujjaini.wordpress.com/583/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/twitter/ujjaini.wordpress.com/583/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gostumble/ujjaini.wordpress.com/583/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/stumble/ujjaini.wordpress.com/583/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godigg/ujjaini.wordpress.com/583/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/digg/ujjaini.wordpress.com/583/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/goreddit/ujjaini.wordpress.com/583/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/reddit/ujjaini.wordpress.com/583/" /></a> <img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=ujjaini.wordpress.com&amp;blog=7825904&amp;post=583&amp;subd=ujjaini&amp;ref=&amp;feed=1" width="1" height="1" />]]></content:encoded>
			<wfw:commentRss>http://ujjaini.wordpress.com/2011/05/18/call-function-in-javascript/feed/</wfw:commentRss>
		<slash:comments>1</slash:comments>
	
		<media:content url="http://1.gravatar.com/avatar/f47cc3c0824e42caed5f04ab77ee71ff?s=96&#38;d=identicon&#38;r=G" medium="image">
			<media:title type="html">ujjaini</media:title>
		</media:content>
	</item>
		<item>
		<title>Passing parameters to anonymous functions in Javascript</title>
		<link>http://ujjaini.wordpress.com/2010/12/14/passing-parameters-to-anonymous-functions-in-javascriot/</link>
		<comments>http://ujjaini.wordpress.com/2010/12/14/passing-parameters-to-anonymous-functions-in-javascriot/#comments</comments>
		<pubDate>Tue, 14 Dec 2010 23:29:46 +0000</pubDate>
		<dc:creator>ujjaini</dc:creator>
				<category><![CDATA[Javascript]]></category>

		<guid isPermaLink="false">http://ujjaini.wordpress.com/?p=532</guid>
		<description><![CDATA[An anonymous function in javascript executes immediately eg. If we want to use global objects, we can call them directly from inside our function In a large project, there will be innumerable global objects &#8211; some created by other developers, some from third party libraries. To make our code more understandable and maintainable, we can [...]<img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=ujjaini.wordpress.com&amp;blog=7825904&amp;post=532&amp;subd=ujjaini&amp;ref=&amp;feed=1" width="1" height="1" />]]></description>
			<content:encoded><![CDATA[<p>An anonymous function in javascript executes immediately eg. </p>
<p><pre class="brush: plain;">
(function(){
	alert('This will execute immediately');
})();
</pre></p>
<p>If we want to use global objects, we can call them directly from inside our function</p>
<p><pre class="brush: plain;">
var global1 = 'GLOBAL 1';
var global2 = 'GLOBAL 2';
(function(){
	alert(global1);
	alert(global2);
})();
</pre></p>
<p>In a large project, there will be innumerable global objects &#8211; some created by other developers, some from third party libraries. To make our code more understandable and maintainable, we can pass these global objects as parameters of the anonymous function. </p>
<p><pre class="brush: plain;">
var global1 = 'GLOBAL 1';
var global2 = 'GLOBAL 2';

(function(para1, para2){
	alert(para1);
	alert(para2);
})(global1, global2);

</pre></p>
<p>In the above code, it becomes clear that  we are using only 2 global objects &#8211; &#8216;global1&#8242; and &#8216;global2&#8242;.</p>
<p>A good practical example would be when we are using 2 libraries, eg. Jquery and Yahoo. There might be functions with similar names in these two. To avoid confusion, we can write the code below -<br />
<pre class="brush: plain;">
(function($, Yahoo){
	// call a function from jquery library
	$.function1();
	// call a function from yahoo library
	Yahoo.function2();
})(Jquery, YAHOO);
</pre></p>
<br />  <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gocomments/ujjaini.wordpress.com/532/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/comments/ujjaini.wordpress.com/532/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godelicious/ujjaini.wordpress.com/532/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/delicious/ujjaini.wordpress.com/532/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gofacebook/ujjaini.wordpress.com/532/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/facebook/ujjaini.wordpress.com/532/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gotwitter/ujjaini.wordpress.com/532/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/twitter/ujjaini.wordpress.com/532/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gostumble/ujjaini.wordpress.com/532/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/stumble/ujjaini.wordpress.com/532/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godigg/ujjaini.wordpress.com/532/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/digg/ujjaini.wordpress.com/532/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/goreddit/ujjaini.wordpress.com/532/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/reddit/ujjaini.wordpress.com/532/" /></a> <img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=ujjaini.wordpress.com&amp;blog=7825904&amp;post=532&amp;subd=ujjaini&amp;ref=&amp;feed=1" width="1" height="1" />]]></content:encoded>
			<wfw:commentRss>http://ujjaini.wordpress.com/2010/12/14/passing-parameters-to-anonymous-functions-in-javascriot/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
	
		<media:content url="http://1.gravatar.com/avatar/f47cc3c0824e42caed5f04ab77ee71ff?s=96&#38;d=identicon&#38;r=G" medium="image">
			<media:title type="html">ujjaini</media:title>
		</media:content>
	</item>
		<item>
		<title>Vertical scrollbar in HTML tables</title>
		<link>http://ujjaini.wordpress.com/2010/12/13/vertical-scrollbar-in-html-tables/</link>
		<comments>http://ujjaini.wordpress.com/2010/12/13/vertical-scrollbar-in-html-tables/#comments</comments>
		<pubDate>Mon, 13 Dec 2010 05:57:48 +0000</pubDate>
		<dc:creator>ujjaini</dc:creator>
				<category><![CDATA[HTML, CSS]]></category>
		<category><![CDATA[Javascript]]></category>

		<guid isPermaLink="false">http://ujjaini.wordpress.com/?p=503</guid>
		<description><![CDATA[There are many examples on the web which show us how to add a vertical scrollbar to an HTML table. However, these don&#8217;t look same in Firefox and IE. In Firefox, the scrollbar is always on the inside of the table. In IE, the scrollbar lies on the outside of the table. I wanted to [...]<img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=ujjaini.wordpress.com&amp;blog=7825904&amp;post=503&amp;subd=ujjaini&amp;ref=&amp;feed=1" width="1" height="1" />]]></description>
			<content:encoded><![CDATA[<p>There are many examples on the web which show us how to add a vertical scrollbar to an HTML table. However, these don&#8217;t look same in Firefox and IE. In Firefox, the scrollbar is always on the <strong>inside</strong> of the table. In IE, the scrollbar lies on the <strong>outside</strong> of the table. I wanted to see how to add a vertical scrollbar which would be on the inside of the table for both browsers. There are 2 reasons for this-<br />
- uniformity among browsers<br />
- in IE, the scrollbar on the outside of the table doesn&#8217;t look good.</p>
<p>The sample table is </p>
<p><a href='http://www.webjukti.com//blog entries/table scrollbar/index.html'>here</a></p>
<p><strong>HTML file</strong></p>
<p><pre class="brush: plain;">
&lt;div class=&quot;main&quot;&gt;
			&lt;!-- Start of placeholder text --&gt;
&lt;div class=&quot;placeholder_txt&quot;&gt;
&lt;div class=&quot;text_wrapper&quot;&gt;
					&lt;strong&gt;CLICK BUTTONS TO SEE TABLES&lt;/strong&gt;&lt;/div&gt;
&lt;/div&gt;
			&lt;!-- End of placeholder text --&gt;
			&lt;!-- Start of MAIN WRAPPER --&gt;
&lt;div class=&quot;grid_wrapper&quot; style=&quot;display: none;&quot;&gt;
				&lt;!-- Start of HEADER_DIV --&gt;
&lt;div class=&quot;header_div&quot;&gt;
					&lt;!-- Start of wrapper ONLY for the table --&gt;
&lt;div class=&quot;header_table_wrapper&quot;&gt;
						&lt;!-- Start of actual table --&gt;
&lt;table class=&quot;header_table&quot; border=&quot;0&quot; cellspacing=&quot;0&quot; cellpadding=&quot;0&quot;&gt;
&lt;thead&gt;
&lt;tr&gt;
&lt;th&gt;Symbol&lt;/th&gt;
&lt;th&gt;Trade Type&lt;/th&gt;
&lt;th&gt;Price Paid&lt;/th&gt;
&lt;th&gt;Date&lt;/th&gt;
&lt;/tr&gt;
&lt;/thead&gt;
&lt;tbody&gt;&lt;/tbody&gt;
&lt;/table&gt;
						&lt;!-- End of actual table --&gt;&lt;/div&gt;
					&lt;!-- End of wrapper ONLY for the table --&gt;&lt;/div&gt;
				&lt;!-- End of HEADER_DIV --&gt;
				&lt;!-- START OF CONTENT DIV --&gt;
&lt;div class=&quot;content_div&quot;&gt;
					&lt;!--
&lt;div class='relative_div'&gt;--&gt;
						&lt;!-- Start of table for content --&gt;
&lt;table class=&quot;content_table&quot; border=&quot;0&quot; cellspacing=&quot;0&quot; cellpadding=&quot;0&quot;&gt;
&lt;tbody&gt;&lt;/tbody&gt;
&lt;/table&gt;
						&lt;!-- End of table for content --&gt;

					&lt;!--&lt;/div&gt;
--&gt;&lt;/div&gt;
				&lt;!-- END OF CONTENT DIV --&gt;&lt;/div&gt;
			&lt;!-- End of MAIN WRAPPER --&gt;
&lt;div class=&quot;button_wrapper&quot;&gt;
				&lt;input class=&quot;showScrollTable&quot; type=&quot;button&quot; value=&quot;Show Table with scroll bar&quot; /&gt;
				&lt;input class=&quot;showNoScrollTable&quot; type=&quot;button&quot; value=&quot;Show Table without scroll bar&quot; /&gt;&lt;/div&gt;
&lt;/div&gt;
</pre></p>
<p><strong>Javascript file</strong></p>
<p><pre class="brush: plain;">
 $(document).ready(function () {
	var $contentTableBody = $('table.content_table').find('tbody'), $placeholderTextDiv = $('div.placeholder_txt'),
	    $gridWrapper = $('div.grid_wrapper');
	$('input.showScrollTable').click(function(){
		$gridWrapper.show();
		$placeholderTextDiv.hide();
		$contentTableBody.empty();
		// add 18 records to table
		var $allrows = $(&quot;
&lt;td class=&quot;content_cell_1&quot;&gt; &lt;/td&gt;
  SPY
&lt;td class=&quot;content_cell_2&quot;&gt; &lt;/td&gt;
  Buy
&lt;td class=&quot;content_cell_3&quot;&gt; &lt;/td&gt;
  12
&lt;td class=&quot;content_cell_4&quot;&gt; &lt;/td&gt;
  12/09/2010
&lt;td class=&quot;content_cell_1&quot;&gt; &lt;/td&gt;
  SPY
&lt;td class=&quot;content_cell_2&quot;&gt; &lt;/td&gt;
  Buy
&lt;td class=&quot;content_cell_3&quot;&gt; &lt;/td&gt;
  12
&lt;td class=&quot;content_cell_4&quot;&gt; &lt;/td&gt;
  12/09/2010
&lt;td class=&quot;content_cell_1&quot;&gt; &lt;/td&gt;
  SPY
&lt;td class=&quot;content_cell_2&quot;&gt; &lt;/td&gt;
  Buy
&lt;td class=&quot;content_cell_3&quot;&gt; &lt;/td&gt;
  12
&lt;td class=&quot;content_cell_4&quot;&gt; &lt;/td&gt;
  12/09/2010
&lt;td class=&quot;content_cell_1&quot;&gt; &lt;/td&gt;
  SPY
&lt;td class=&quot;content_cell_2&quot;&gt; &lt;/td&gt;
  Buy
&lt;td class=&quot;content_cell_3&quot;&gt; &lt;/td&gt;
  12
&lt;td class=&quot;content_cell_4&quot;&gt; &lt;/td&gt;
  12/09/2010
&lt;td class=&quot;content_cell_1&quot;&gt; &lt;/td&gt;
  SPY
&lt;td class=&quot;content_cell_2&quot;&gt; &lt;/td&gt;
  Buy
&lt;td class=&quot;content_cell_3&quot;&gt; &lt;/td&gt;
  12
&lt;td class=&quot;content_cell_4&quot;&gt; &lt;/td&gt;
  12/09/2010
&lt;td class=&quot;content_cell_1&quot;&gt; &lt;/td&gt;
  SPY
&lt;td class=&quot;content_cell_2&quot;&gt; &lt;/td&gt;
  Buy
&lt;td class=&quot;content_cell_3&quot;&gt; &lt;/td&gt;
  12
&lt;td class=&quot;content_cell_4&quot;&gt; &lt;/td&gt;
  12/09/2010
&lt;td class=&quot;content_cell_1&quot;&gt; &lt;/td&gt;
  SPY
&lt;td class=&quot;content_cell_2&quot;&gt; &lt;/td&gt;
  Buy
&lt;td class=&quot;content_cell_3&quot;&gt; &lt;/td&gt;
  12
&lt;td class=&quot;content_cell_4&quot;&gt; &lt;/td&gt;
  12/09/2010
&lt;td class=&quot;content_cell_1&quot;&gt; &lt;/td&gt;
  SPY
&lt;td class=&quot;content_cell_2&quot;&gt; &lt;/td&gt;
  Buy
&lt;td class=&quot;content_cell_3&quot;&gt; &lt;/td&gt;
  12
&lt;td class=&quot;content_cell_4&quot;&gt; &lt;/td&gt;
  12/09/2010
&lt;td class=&quot;content_cell_1&quot;&gt; &lt;/td&gt;
  SPY
&lt;td class=&quot;content_cell_2&quot;&gt; &lt;/td&gt;
  Buy
&lt;td class=&quot;content_cell_3&quot;&gt; &lt;/td&gt;
  12
&lt;td class=&quot;content_cell_4&quot;&gt; &lt;/td&gt;
  12/09/2010
&lt;td class=&quot;content_cell_1&quot;&gt; &lt;/td&gt;
  SPY
&lt;td class=&quot;content_cell_2&quot;&gt; &lt;/td&gt;
  Buy
&lt;td class=&quot;content_cell_3&quot;&gt; &lt;/td&gt;
  12
&lt;td class=&quot;content_cell_4&quot;&gt; &lt;/td&gt;
  12/09/2010
&lt;td class=&quot;content_cell_1&quot;&gt; &lt;/td&gt;
  SPY
&lt;td class=&quot;content_cell_2&quot;&gt; &lt;/td&gt;
  Buy
&lt;td class=&quot;content_cell_3&quot;&gt; &lt;/td&gt;
  12
&lt;td class=&quot;content_cell_4&quot;&gt; &lt;/td&gt;
  12/09/2010
&lt;td class=&quot;content_cell_1&quot;&gt; &lt;/td&gt;
  SPY
&lt;td class=&quot;content_cell_2&quot;&gt; &lt;/td&gt;
  Buy
&lt;td class=&quot;content_cell_3&quot;&gt; &lt;/td&gt;
  12
&lt;td class=&quot;content_cell_4&quot;&gt; &lt;/td&gt;
  12/09/2010
&lt;td class=&quot;content_cell_1&quot;&gt; &lt;/td&gt;
  SPY
&lt;td class=&quot;content_cell_2&quot;&gt; &lt;/td&gt;
  Buy
&lt;td class=&quot;content_cell_3&quot;&gt; &lt;/td&gt;
  12
&lt;td class=&quot;content_cell_4&quot;&gt; &lt;/td&gt;
  12/09/2010
&lt;td class=&quot;content_cell_1&quot;&gt; &lt;/td&gt;
  SPY
&lt;td class=&quot;content_cell_2&quot;&gt; &lt;/td&gt;
  Buy
&lt;td class=&quot;content_cell_3&quot;&gt; &lt;/td&gt;
  12
&lt;td class=&quot;content_cell_4&quot;&gt; &lt;/td&gt;
  12/09/2010
&lt;td class=&quot;content_cell_1&quot;&gt; &lt;/td&gt;
  SPY
&lt;td class=&quot;content_cell_2&quot;&gt; &lt;/td&gt;
  Buy
&lt;td class=&quot;content_cell_3&quot;&gt; &lt;/td&gt;
  12
&lt;td class=&quot;content_cell_4&quot;&gt; &lt;/td&gt;
  12/09/2010
&lt;td class=&quot;content_cell_1&quot;&gt; &lt;/td&gt;
  SPY
&lt;td class=&quot;content_cell_2&quot;&gt; &lt;/td&gt;
  Buy
&lt;td class=&quot;content_cell_3&quot;&gt; &lt;/td&gt;
  12
&lt;td class=&quot;content_cell_4&quot;&gt; &lt;/td&gt;
  12/09/2010
&lt;td class=&quot;content_cell_1&quot;&gt; &lt;/td&gt;
  SPY
&lt;td class=&quot;content_cell_2&quot;&gt; &lt;/td&gt;
  Buy
&lt;td class=&quot;content_cell_3&quot;&gt; &lt;/td&gt;
  12
&lt;td class=&quot;content_cell_4&quot;&gt; &lt;/td&gt;
  12/09/2010
&lt;td class=&quot;content_cell_1&quot;&gt; &lt;/td&gt;
  SPY
&lt;td class=&quot;content_cell_2&quot;&gt; &lt;/td&gt;
  Buy
&lt;td class=&quot;content_cell_3&quot;&gt; &lt;/td&gt;
  12
&lt;td class=&quot;content_cell_4&quot;&gt; &lt;/td&gt;
  12/09/2010
&lt;td class=&quot;content_cell_1&quot;&gt; &lt;/td&gt;
  SPY
&lt;td class=&quot;content_cell_2&quot;&gt; &lt;/td&gt;
  Buy
&lt;td class=&quot;content_cell_3&quot;&gt; &lt;/td&gt;
  12
&lt;td class=&quot;content_cell_4&quot;&gt; &lt;/td&gt;
  12/09/2010
&quot;);
		$contentTableBody.append($allrows);
		$('.header_table_wrapper').removeClass('header_table_wrapper_noscroll');
		$('.header_table').removeClass('header_table_noscroll');
		$('.content_table').removeClass('content_table_noscroll');
		$('.content_div').removeClass('content_div_noscroll');
		for (var i=len; i--;){
	        var $cell = $(allrows[i]).find('td');
			if (!($cell.hasClass('content_cell_1'))){
				$cell.addClass('content_cell_1');
			}
			if (!($cell.hasClass('content_cell_2'))){
				$cell.addClass('content_cell_2');
			}
			if (!($cell.hasClass('content_cell_3'))){
				$cell.addClass('content_cell_3');
			}
			if (!($cell.hasClass('content_cell_4'))){
				$cell.addClass('content_cell_4');
			}
        }
     });

	$('input.showNoScrollTable').click(function(){
		$gridWrapper.show();
		$placeholderTextDiv.hide();
		$contentTableBody.empty();
		var $allrows = $(&quot;
&lt;td class=&quot;content_cell_1&quot;&gt; &lt;/td&gt;
  SPY
&lt;td class=&quot;content_cell_2&quot;&gt; &lt;/td&gt;
  Buy
&lt;td class=&quot;content_cell_3&quot;&gt; &lt;/td&gt;
  12
&lt;td class=&quot;content_cell_4&quot;&gt; &lt;/td&gt;
  12/09/2010
&lt;td class=&quot;content_cell_1&quot;&gt; &lt;/td&gt;
  SPY
&lt;td class=&quot;content_cell_2&quot;&gt; &lt;/td&gt;
  Buy
&lt;td class=&quot;content_cell_3&quot;&gt; &lt;/td&gt;
  12
&lt;td class=&quot;content_cell_4&quot;&gt; &lt;/td&gt;
  12/09/2010
&lt;td class=&quot;content_cell_1&quot;&gt; &lt;/td&gt;
  SPY
&lt;td class=&quot;content_cell_2&quot;&gt; &lt;/td&gt;
  Buy
&lt;td class=&quot;content_cell_3&quot;&gt; &lt;/td&gt;
  12
&lt;td class=&quot;content_cell_4&quot;&gt; &lt;/td&gt;
  12/09/2010
&quot;);
		$contentTableBody.append($allrows);
		$('.header_table_wrapper').addClass('header_table_wrapper_noscroll');
		$('.header_table').addClass('header_table_noscroll');
		$('.content_table').addClass('content_table_noscroll');
		$('.content_div').addClass('content_div_noscroll');

		// set widths of all cells to auto, remove width
		for (var i=len; i--;){
	        var $cell = $(allrows[i]).find('td');
			if ($cell.hasClass('content_cell_1')){
				$cell.removeClass('content_cell_1');
			}
			if ($cell.hasClass('content_cell_2')){
				$cell.removeClass('content_cell_2');
			}
			if ($cell.hasClass('content_cell_3')){
				$cell.removeClass('content_cell_3');
			}
			if ($cell.hasClass('content_cell_4')){
				$cell.removeClass('content_cell_4');
			}
        }

	})
});
</pre></p>
<p><strong>CSS file</strong></p>
<p><pre class="brush: plain;">
body{
	font-size:11px;
}

table{
	text-align:left;
	margin:0;
	table-layout:fixed;
	border-collapse:collapse;
	border-spacing:0;
}

div.placeholder_txt{
	width:300px;
	height:300px;
	float:left;
}

.clr{
	clear:both;
}
div.main{
	margin:0 auto;
	width:500px;
}

div.text_wrapper{
	margin:100px 0 0 80px;
	font-size:14px;
	color:red;
}
/* WIDTH OF THE WRAPPER IS 300 px */
.grid_wrapper{
	width:300px;
	left:0;
	padding:0;
	position:relative;
	top:0;
}

/* WIDTH OF HEADER DIV IS SAME AS THAT OF THE WRAPPER */
.header_div{
	background:url(&quot;ui-bg_glass_75_e6e6e6_1x400.png&quot;) repeat-x scroll 50% 50% #E6E6E6;
	border:1px solid #D3D3D3;
	color:#555555;
	font-weight:normal;
	width:300px;
	border-left:0 none !important;
	border-right:0 none !important;
	border-top:0 none !important;
	margin:0;
	overflow-x:hidden;
	overflow-y:auto;
	padding:0;
	position:relative;
}

.header_table_wrapper{
	float:left;
	padding-right:20px;
}

table.header_table{
	width:282px;
}

table.header_table thead tr th{
	border-right:1px solid #D3D3D3;
	overflow:hidden;
	text-align:center;
	white-space:nowrap;
	height:22px;
	padding:0 2px;
	font-weight:normal;
}

.content_div{
	height:250px;
	width:300px;
	margin:0;
	overflow-y:auto;
	overflow-x:hidden;
	padding:0;
	position:relative;
	border-bottom:1px solid #AAAAAA;
}

.relative_div{
	position:relative;
}

.content_table_row{
	border:1px solid #AAAAAA !important;
    color:#222222;
}

tr.content_table_row td{
	border-right-color:inherit;
	border-right-style:solid;
	border-right-width:1px;
	text-align:center;
	border-bottom-color:inherit;
	border-bottom-style:solid;
	border-bottom-width:1px;
	font-weight:normal;
	height:22px;
	overflow:hidden;
	padding:0 2px;
	white-space:pre;
	*border-left:1px solid #AAAAAA !important;
}

td.content_cell_1, td.content_cell_2, td.content_cell_3{
	width:65px;
}

td.content_cell_4{
	width:67px;
}

div.button_wrapper{
	margin-top:10px;
}

/* SPECIAL STYLES FOR NO SCROLL SCENARIO */

.header_table_wrapper_noscroll{
	padding-right:0 !important;
}

.header_table_noscroll{
	width:300px !important;
}

table.content_table_noscroll{
	width:300px !important;
}

.content_div_noscroll{
	border-bottom:none;
}
</pre></p>
<br />  <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gocomments/ujjaini.wordpress.com/503/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/comments/ujjaini.wordpress.com/503/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godelicious/ujjaini.wordpress.com/503/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/delicious/ujjaini.wordpress.com/503/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gofacebook/ujjaini.wordpress.com/503/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/facebook/ujjaini.wordpress.com/503/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gotwitter/ujjaini.wordpress.com/503/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/twitter/ujjaini.wordpress.com/503/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gostumble/ujjaini.wordpress.com/503/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/stumble/ujjaini.wordpress.com/503/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godigg/ujjaini.wordpress.com/503/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/digg/ujjaini.wordpress.com/503/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/goreddit/ujjaini.wordpress.com/503/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/reddit/ujjaini.wordpress.com/503/" /></a> <img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=ujjaini.wordpress.com&amp;blog=7825904&amp;post=503&amp;subd=ujjaini&amp;ref=&amp;feed=1" width="1" height="1" />]]></content:encoded>
			<wfw:commentRss>http://ujjaini.wordpress.com/2010/12/13/vertical-scrollbar-in-html-tables/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
	
		<media:content url="http://1.gravatar.com/avatar/f47cc3c0824e42caed5f04ab77ee71ff?s=96&#38;d=identicon&#38;r=G" medium="image">
			<media:title type="html">ujjaini</media:title>
		</media:content>
	</item>
		<item>
		<title>Linked Lists using Javascript</title>
		<link>http://ujjaini.wordpress.com/2010/12/01/linekd-lists-using-javascript/</link>
		<comments>http://ujjaini.wordpress.com/2010/12/01/linekd-lists-using-javascript/#comments</comments>
		<pubDate>Wed, 01 Dec 2010 00:06:51 +0000</pubDate>
		<dc:creator>ujjaini</dc:creator>
				<category><![CDATA[data structures]]></category>
		<category><![CDATA[Javascript]]></category>

		<guid isPermaLink="false">http://ujjaini.wordpress.com/?p=534</guid>
		<description><![CDATA[Basic Linked list I have written code for a single linked list. To test the above, I have written this - &#160;<img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=ujjaini.wordpress.com&amp;blog=7825904&amp;post=534&amp;subd=ujjaini&amp;ref=&amp;feed=1" width="1" height="1" />]]></description>
			<content:encoded><![CDATA[<p><strong>Basic Linked list</strong></p>
<p>I have written code for a single linked list.</p>
<p><pre class="brush: plain;">

/**
 * Linked List class
 *  set headItem to null
 */

function LinkedList(){
	this.headItem= null;
}

/**
 * Class for each item of linked list
 * @param {Object} val
 */
function Item(val){
	this.val = val;
	this.next = null;
}

LinkedList.prototype = {

	/**
	 * add an item at the head
	 * @param {Object} item
	 */
	insertAtHead:function(item){
		if (this.headItem == null) {
			this.headItem = item;
			this.headItem.next = null;
		}else{
			var temp = this.headItem;
			this.headItem = item;
			this.headItem.next = temp;
		}
	},

	/**
	 * add an item at the tail
	 * @param {Object} item
	 */
	insertAtTail:function(item){
		if (this.headItem == null){
			this.headItem = item;
			this.headItem.next = null;
		}else{
			var iter = this.headItem;
			while(iter.next != null){
				iter = iter.next;
			}
			iter.next = item;
			item.next = null;
		}
	},

	/**
	 * get number of elements in linked list
	 */
	getLength:function(){
		var iter = this.headItem, i= 0;
		while(iter.next != null){
			iter = iter.next;
			i++;
		}
		return i+1;
	},

	/**
	 * display all elements of linked list
	 */
	showAllElements:function(){
		var arr = [], iter = this.headItem, len = 0;
		while(iter.next != null){
			arr.push(iter.val);
			iter = iter.next;
			len++;
		}
		arr.push(iter.val);
		for(var i=0;i&lt;=len;i++){
			console.log(arr[i]);
		}
	},

	/**
	 * returns last element of linked list
	 */
	findLastElement:function(){
		var i=0, iter = this.headItem;
		while(iter.next != null){
			iter = iter.next;
		}
		return iter;
	},

	/**
	 * remove an item from the head
	 */
	removeFromHead:function(){
		if (this.getLength() == 0)
		   throw new Error('You cannot remove elements from empty list');
		var temp = this.headItem;
		this.headItem = this.headItem.next;
		temp.next = null;
		return temp;
	},

	/**
	 * remove an item from the end
	 */
	removeFromTail:function(){
		if (this.getLength() == 0)
		   throw new Error('You cannot remove elements from empty list');
		var temp, iter = this.headItem;
		while(iter.next != null){
			temp = iter;
			iter = iter.next;
		}
		var last = temp.next;
		temp.next = null;
		return last;
	},

	/**
	 * insert an item n elements from head
	 * @param {Object} n
	 * @param {Object} item
	 */
	insertItemNthPositionFromHead:function(n, item){
		var i = 0, iter = this.headItem, temp;
		while(iter.next != null){
			if (i == n){
				temp = iter.next;
				iter.next = item;
				item.next = temp;
			}
			iter = iter.next;
			i++;
		}

	},

	/**
	 * find nth element from the end of the list
	 * there are 2 pointers, p and q
	 * when p is equal to n, start increasing q
	 * when p is null, q will point to the nth element from the end
	 * @param {Object} n
	 */
	findNthElementFromEnd:function(n){
		var iter = this.headItem, p=0, q = this.headItem;
		while(iter.next != null){
			if (p == n){
				q = q.next;

			}
			iter = iter.next;
			p++;
			if (q != this.headItem){
				q = q.next;
			}
		}
		return q;
	},

	/**
	 * reverses a linked list
	 * returns the first element of the reversed list
	 */
	reverseLinkedList:function(){
		var previous = null, next;
		while(this.headItem != null){
			next = this.headItem.next;
			this.headItem.next = previous;

			previous = this.headItem;
			this.headItem = next;
		}
		return previous;

	},

	/**
	 * show all elements of a reverse linked list
	 */
	showReverseLinkedList:function(){
		var firstItem = this.reverseLinkedList(), i = 1;
		console.log('The value of the first element in reversed list is ' + firstItem.val);
		while(firstItem.next != null){
		    i++;
			firstItem = firstItem.next;
			console.log('The value of the ' + i + ' th element in the reversed list is ' + firstItem.val);
		}
	}
}

</pre></p>
<p>To test the above, I have written this -</p>
<p><pre class="brush: plain;">
&lt;script type='text/javascript'&gt;
			function setup(){
	// add items at end
	var item1 = new Item('tom');
	var item2 = new Item('harry');
	var item3 = new Item('john');
	var item4 = new Item('tori');
	var item5  = new Item('susie');

	var list = new LinkedList();
	list.insertAtHead(item1);
	list.insertAtHead(item2);
	list.insertAtTail(item3);
	list.insertAtTail(item4);

	// length is 4
	console.log('The length of the linked list is ' + list.getLength());

	// the list would look like this
	// harry-tom-john-tori
	list.showAllElements();

	// shows tori
	console.log('The value of the last element of the linked list is ' + list.findLastElement().val);

	// new list - harry-tom-john-susie-tori
	list.insertItemNthPositionFromHead(2, item5);

	// shows 'tom'
	console.log('The value of the 3rd element from end of the linked list is ' + list.findNthElementFromEnd(3).val);

	// reverses list is - tori=susie-john-tom-harry
	list.showReverseLinkedList();

}

window.onload = setup;
</pre></p>
<p>&nbsp;</p>
<br />  <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gocomments/ujjaini.wordpress.com/534/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/comments/ujjaini.wordpress.com/534/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godelicious/ujjaini.wordpress.com/534/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/delicious/ujjaini.wordpress.com/534/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gofacebook/ujjaini.wordpress.com/534/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/facebook/ujjaini.wordpress.com/534/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gotwitter/ujjaini.wordpress.com/534/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/twitter/ujjaini.wordpress.com/534/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gostumble/ujjaini.wordpress.com/534/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/stumble/ujjaini.wordpress.com/534/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godigg/ujjaini.wordpress.com/534/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/digg/ujjaini.wordpress.com/534/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/goreddit/ujjaini.wordpress.com/534/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/reddit/ujjaini.wordpress.com/534/" /></a> <img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=ujjaini.wordpress.com&amp;blog=7825904&amp;post=534&amp;subd=ujjaini&amp;ref=&amp;feed=1" width="1" height="1" />]]></content:encoded>
			<wfw:commentRss>http://ujjaini.wordpress.com/2010/12/01/linekd-lists-using-javascript/feed/</wfw:commentRss>
		<slash:comments>1</slash:comments>
	
		<media:content url="http://1.gravatar.com/avatar/f47cc3c0824e42caed5f04ab77ee71ff?s=96&#38;d=identicon&#38;r=G" medium="image">
			<media:title type="html">ujjaini</media:title>
		</media:content>
	</item>
		<item>
		<title>Removing all rows from jqGrid</title>
		<link>http://ujjaini.wordpress.com/2010/11/23/removing-all-rows-from-jqgrid/</link>
		<comments>http://ujjaini.wordpress.com/2010/11/23/removing-all-rows-from-jqgrid/#comments</comments>
		<pubDate>Tue, 23 Nov 2010 23:17:47 +0000</pubDate>
		<dc:creator>ujjaini</dc:creator>
				<category><![CDATA[Javascript]]></category>
		<category><![CDATA[jqGrid]]></category>

		<guid isPermaLink="false">http://ujjaini.wordpress.com/?p=523</guid>
		<description><![CDATA[Sometimes, we need to make a jqGrid empty (i.e. remove all rows from it). I have written a small piece of code for that.<img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=ujjaini.wordpress.com&amp;blog=7825904&amp;post=523&amp;subd=ujjaini&amp;ref=&amp;feed=1" width="1" height="1" />]]></description>
			<content:encoded><![CDATA[<p>Sometimes, we need to make a jqGrid empty (i.e. remove all rows from it).<br />
 I have written a small piece of code for that. </p>
<p><pre class="brush: plain;">
/* 'grid1' - is the name of the table on which we are creating the jqGrid */

// get IDs of all the rows odf jqGrid 
var rowIds = $('#grid1').jqGrid('getDataIDs');
// iterate through the rows and delete each of them
for(var i=0,len=rowIds.length;i&lt;len;i++){
	var currRow = rowIds[i];
	$('#grid1').jqGrid('delRowData', currRow);
}	


</pre></p>
<br />  <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gocomments/ujjaini.wordpress.com/523/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/comments/ujjaini.wordpress.com/523/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godelicious/ujjaini.wordpress.com/523/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/delicious/ujjaini.wordpress.com/523/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gofacebook/ujjaini.wordpress.com/523/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/facebook/ujjaini.wordpress.com/523/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gotwitter/ujjaini.wordpress.com/523/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/twitter/ujjaini.wordpress.com/523/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gostumble/ujjaini.wordpress.com/523/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/stumble/ujjaini.wordpress.com/523/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godigg/ujjaini.wordpress.com/523/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/digg/ujjaini.wordpress.com/523/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/goreddit/ujjaini.wordpress.com/523/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/reddit/ujjaini.wordpress.com/523/" /></a> <img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=ujjaini.wordpress.com&amp;blog=7825904&amp;post=523&amp;subd=ujjaini&amp;ref=&amp;feed=1" width="1" height="1" />]]></content:encoded>
			<wfw:commentRss>http://ujjaini.wordpress.com/2010/11/23/removing-all-rows-from-jqgrid/feed/</wfw:commentRss>
		<slash:comments>3</slash:comments>
	
		<media:content url="http://1.gravatar.com/avatar/f47cc3c0824e42caed5f04ab77ee71ff?s=96&#38;d=identicon&#38;r=G" medium="image">
			<media:title type="html">ujjaini</media:title>
		</media:content>
	</item>
		<item>
		<title>How to setup MySQLdb for Python on Windows</title>
		<link>http://ujjaini.wordpress.com/2010/08/19/how-to-setup-mysqldb-for-python-on-windows/</link>
		<comments>http://ujjaini.wordpress.com/2010/08/19/how-to-setup-mysqldb-for-python-on-windows/#comments</comments>
		<pubDate>Thu, 19 Aug 2010 22:17:36 +0000</pubDate>
		<dc:creator>ujjaini</dc:creator>
				<category><![CDATA[MySQL]]></category>
		<category><![CDATA[Pyhton]]></category>
		<category><![CDATA[Python]]></category>

		<guid isPermaLink="false">http://ujjaini.wordpress.com/?p=460</guid>
		<description><![CDATA[Versions of Python which are supported by MySQLdb As of today, MySQLdb supports - MySQL versions 3.23-5.1 Python versions 2.3-2.6 For the purposes of this article, I am testing with &#8211; Python 2.6 and MySQL 5.1 Installation Steps If you have not done so already, install Apache 2.2 Install Python 2.6 from http://www.python.org/download/releases/2.6/- (Windows x86 [...]<img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=ujjaini.wordpress.com&amp;blog=7825904&amp;post=460&amp;subd=ujjaini&amp;ref=&amp;feed=1" width="1" height="1" />]]></description>
			<content:encoded><![CDATA[<p><strong>Versions of Python which are supported by MySQLdb</strong></p>
<p>As of today, MySQLdb supports -</p>
<ul>
<li>MySQL versions 3.23-5.1</li>
<li>Python versions 2.3-2.6</li>
</ul>
<p>For the purposes of this article, I am testing with &#8211; <strong>Python 2.6</strong> and <strong>MySQL 5.1</strong></p>
<p><strong>Installation Steps</strong></p>
<ul>
<li>If you have not done so already, install <span style="color:#0000ff;">Apache 2.2</span></li>
<div style='height:5px;'></div>
<li>Install <span style="color:#0000ff;">Python 2.6</span> from <span style="color:#0000ff;">http://www.python.org/download/releases/2.6/<span style="color:#000000;">-<br />
</span></span>(Windows x86 MSI Installer (2.6) )</li>
<div style='height:5px;'></div>
<li>Install <span style="color:#0000ff;">MySQL 5.1</span> from<span style="color:#0000ff;"> http://dev.mysql.com/downloads/mysql/</span><br />
(Windows (x86, 32-bit), MSI Installer)</li>
<div style='height:5px;'></div>
<li>Install <span style="color:#0000ff;">MySQLdb</span><span style="color:#000000;"> from </span><span style="color:#0000ff;">http://www.codegood.com.</span><br />
<span style="color:#0000ff;">MySQL-python-1.2.2.win32-py2.6.exe (1,022.8 KiB)</span><br />
<span style="color:#0000ff;"><span style="color:#000000;"> </span></span></li>
</ul>
<p><strong>Testing whether Python works with Apache server</strong></p>
<p>For this, refer to my blog entry<br />
<a href="http://ujjaini.wordpress.com/2010/08/13/how-to-run-python-script-on-apache-on-windows/" target="_blank">How to configure Apache to run Python on Windows</a></p>
<p><strong>Testing whether MySQLdb is installed -</strong></p>
<p>-  Go to Python Shell (Start -&gt; Programs -&gt; Python 2.6 -&gt; IDLE(Python GUI)<br />
- Type &#8211; <span style="color:blue;">&#8220;import MySQLdb&#8221;</span></p>
<div style="margin-top:5px;border:2px dashed green;padding:5px;">
<span style="color:red;"><strong>SUCCESS CASE</strong></span><br />
If MySQLdb is installed correctly, no message appears
</div>
<div style="margin-top:15px;border:2px dashed green;padding:5px;">
<span style="color:red;"><strong>ERROR CASE 1</strong></span><br />
If you see this -<br />
<pre class="brush: plain;">
  Traceback (most recent call last):
  File &quot;&lt;pyshell#2&gt;&quot;, line 1, in &lt;module&gt;
    import MySQLdb
  ImportError: No module named MySQLdb
</pre></p>
<p><span style="color:blue;"><strong>Remedy</strong></span><br />
<br />
You have to install MySQLdb
</div>
<div style="margin-top:15px;border:2px dashed green;padding:5px;">
<span style="color:red;"><strong>ERROR CASE 2</strong></span><br />
if you see this -<br />
<pre class="brush: plain;">
Traceback (most recent call last):
  File &quot;&lt;pyshell#0&gt;&quot;, line 1, in &lt;module&gt;
    import MySQLdb
  File &quot;C:\Python26\lib\site-packages\MySQLdb\__init__.py&quot;, line 34, in &lt;module&gt;
    from sets import ImmutableSet
  File &quot;C:\Python26\lib\sets.py&quot;, line 85, in &lt;module&gt;
    stacklevel=2)
  File &quot;C:\Python26\lib\warnings.py&quot;, line 29, in _show_warning
    file.write(formatwarning(message, category, filename, lineno, line))
TypeError: idle_formatwarning_subproc() takes exactly 4 arguments (5 given)
</pre></p>
<p><span style="color:blue;"><strong>Remedy</strong></span><br />
MySQLdb is not installed correctly. To fix this -</p>
<ul>
<li> Go to C:\Python26\lib\site-packages\MySQLdb\__init__.py </li>
<li>Comment this line &#8211; &#8216;from sets import ImmutableSet&#8217; </li>
<li> Add the following  line below it &#8211; &#8216;ImmutableSet = frozenset&#8217; </li>
<p><pre class="brush: plain;">
&quot;&quot;&quot;from sets import ImmutableSet&quot;&quot;&quot;
ImmutableSet = frozenset
</pre>
</ul>
</div>
<div style="margin-top:15px;">
<strong>Testing a connection between MySQL and Python </strong></p>
<ul>
<li> I am assuming that on MySQL , there is a database &#8211; &#8216;test&#8217;. If not create it.</li>
<li> Open a notepad, and type the following-</li>
<p><pre class="brush: plain;">
#!C:\Python26\python.exe

print &quot;Content-Type: text/html\n\n&quot;
import MySQLdb


# Open database connection
db = MySQLdb.connect(&quot;localhost&quot;,&quot;username&quot;,&quot;password&quot;,&quot;test&quot; )

# prepare a cursor object using cursor() method
cursor = db.cursor()

# execute SQL query using execute() method.
cursor.execute(&quot;SELECT VERSION()&quot;)

# Fetch a single row using fetchone() method.
data = cursor.fetchone()
print &quot;Database version : %s &quot; % data

# disconnect from server
db.close()
</pre><br />
(replace &#8216;username&#8217; and &#8216;password&#8217; to the actual login username/password values of MySQL)</p>
<li>If everything works fine, you should see the following<br />
     <span style="color:blue;">Database version : 5.1.50-community </span>
</li>
</ul>
</div>
<br />  <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gocomments/ujjaini.wordpress.com/460/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/comments/ujjaini.wordpress.com/460/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godelicious/ujjaini.wordpress.com/460/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/delicious/ujjaini.wordpress.com/460/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gofacebook/ujjaini.wordpress.com/460/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/facebook/ujjaini.wordpress.com/460/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gotwitter/ujjaini.wordpress.com/460/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/twitter/ujjaini.wordpress.com/460/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gostumble/ujjaini.wordpress.com/460/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/stumble/ujjaini.wordpress.com/460/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godigg/ujjaini.wordpress.com/460/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/digg/ujjaini.wordpress.com/460/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/goreddit/ujjaini.wordpress.com/460/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/reddit/ujjaini.wordpress.com/460/" /></a> <img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=ujjaini.wordpress.com&amp;blog=7825904&amp;post=460&amp;subd=ujjaini&amp;ref=&amp;feed=1" width="1" height="1" />]]></content:encoded>
			<wfw:commentRss>http://ujjaini.wordpress.com/2010/08/19/how-to-setup-mysqldb-for-python-on-windows/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
	
		<media:content url="http://1.gravatar.com/avatar/f47cc3c0824e42caed5f04ab77ee71ff?s=96&#38;d=identicon&#38;r=G" medium="image">
			<media:title type="html">ujjaini</media:title>
		</media:content>
	</item>
	</channel>
</rss>
