<?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>Public MindNitin&#8217;s Blog</title>
	<atom:link href="http://publicmind.in/blog/category/nitins-blog/feed/" rel="self" type="application/rss+xml" />
	<link>http://publicmind.in/blog</link>
	<description>Simple and Sophisticated</description>
	<lastBuildDate>Thu, 13 May 2010 23:32:50 +0000</lastBuildDate>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=3.0</generator>
		<item>
		<title>PHP: Encoding a URL before accessing it</title>
		<link>http://publicmind.in/blog/url-encoding/</link>
		<comments>http://publicmind.in/blog/url-encoding/#comments</comments>
		<pubDate>Sat, 08 May 2010 16:56:34 +0000</pubDate>
		<dc:creator>Nitin</dc:creator>
				<category><![CDATA[Nitin's Blog]]></category>
		<category><![CDATA[encoding]]></category>
		<category><![CDATA[facebook]]></category>
		<category><![CDATA[php]]></category>
		<category><![CDATA[URL]]></category>

		<guid isPermaLink="false">http://publicmind.in/blog/?p=605</guid>
		<description><![CDATA[I discussed a little about URL encoding in my recent post Facebook: Bug with URL encoding, although it seems like the bug still exists. In this post I will discuss &#8220;how to encode a given URL before accessing it using CURL or fsockopen&#8221;. The problem with URLs is that they might contain certain disallowed characters [...]]]></description>
			<content:encoded><![CDATA[<p>I discussed a little about URL encoding in my recent post <a title="Facebook: Bug with URL encoding" href="http://publicmind.in/blog/facebook-bug-with-url-encoding/">Facebook: Bug with URL encoding</a>, although it seems like the bug still exists. In this post I will discuss &#8220;how to encode a given URL before accessing it using CURL or fsockopen&#8221;. The problem with URLs is that they might contain certain disallowed characters like spaces, according to RFC 3986. Our aim is to convert these invalid characters to their <a href="http://en.wikipedia.org/wiki/Percent-encoding" target="_blank">percentage encoded values</a> in a given URL , so that we can access the URL using our regular HTTP request methods. For example the URL [http://example.com/space space] should be converted to [http://example.com/space%20space] before we can access it using CURL. However, the URL [http://example.com/percents%25percent] is perfectly valid as it doesn&#8217;t contains any of the disallowed characters.<br />
<span id="more-605"></span><br />
The given URL can only contain characters which are allowed by RFC 3986 which includes alpha-numeric characters along with reserved characters and delimiters  (<strong>:</strong> | <strong>/</strong> | <strong>?</strong> | <strong>#</strong> | <strong>[</strong> | <strong>]</strong> | <strong>@ </strong>| <strong>!</strong> | <strong>$</strong> | <strong>&amp;</strong> | <strong>&#8216; </strong>| <strong>(</strong> | <strong>)</strong> | <strong>*</strong> | <strong>+</strong> | <strong>,</strong> | <strong>;</strong> | <strong>=</strong> | <strong>%</strong>).  The following piece of code changes the disallowed characters in the URL to their corresponding percentage encoded values. The characters and delimiters which are allowed are left untouched.</p>
<div class="codecolorer-container php default" style="overflow:auto;white-space:nowrap;border:1px solid #9F9F9F;width:435px;height:700px;"><table cellspacing="0" cellpadding="0"><tbody><tr><td style="padding:5px;text-align:center;color:#888888;background-color:#EEEEEE;border-right: 1px solid #9F9F9F;font: normal 12px/1.4em Monaco, Lucida Console, monospace;"><div>1<br />2<br />3<br />4<br />5<br />6<br />7<br />8<br />9<br />10<br />11<br />12<br />13<br />14<br />15<br />16<br />17<br />18<br />19<br />20<br />21<br />22<br />23<br />24<br />25<br />26<br />27<br />28<br />29<br />30<br />31<br />32<br />33<br />34<br />35<br /></div></td><td><div class="php codecolorer" style="padding:5px;font:normal 12px/1.4em Monaco, Lucida Console, monospace;white-space:nowrap"><span style="color: #009933; font-style: italic;">/**<br />
* @param $url<br />
* &nbsp; &nbsp; The URL to encode<br />
*<br />
* @return<br />
* &nbsp; &nbsp; A string containing the encoded URL with disallowed<br />
* &nbsp; &nbsp; characters converted to their percentage encodings.<br />
*/</span><br />
<span style="color: #000000; font-weight: bold;">function</span> encode_url<span style="color: #009900;">&#40;</span><span style="color: #000088;">$url</span><span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span><br />
<span style="color: #000088;">$reserved</span> <span style="color: #339933;">=</span> <a href="http://www.php.net/array"><span style="color: #990000;">array</span></a><span style="color: #009900;">&#40;</span><br />
<span style="color: #0000ff;">&quot;:&quot;</span> <span style="color: #339933;">=&amp;</span>gt<span style="color: #339933;">;</span> <span style="color: #0000ff;">'!%3A!ui'</span><span style="color: #339933;">,</span><br />
<span style="color: #0000ff;">&quot;/&quot;</span> <span style="color: #339933;">=&amp;</span>gt<span style="color: #339933;">;</span> <span style="color: #0000ff;">'!%2F!ui'</span><span style="color: #339933;">,</span><br />
<span style="color: #0000ff;">&quot;?&quot;</span> <span style="color: #339933;">=&amp;</span>gt<span style="color: #339933;">;</span> <span style="color: #0000ff;">'!%3F!ui'</span><span style="color: #339933;">,</span><br />
<span style="color: #0000ff;">&quot;#&quot;</span> <span style="color: #339933;">=&amp;</span>gt<span style="color: #339933;">;</span> <span style="color: #0000ff;">'!%23!ui'</span><span style="color: #339933;">,</span><br />
<span style="color: #0000ff;">&quot;[&quot;</span> <span style="color: #339933;">=&amp;</span>gt<span style="color: #339933;">;</span> <span style="color: #0000ff;">'!%5B!ui'</span><span style="color: #339933;">,</span><br />
<span style="color: #0000ff;">&quot;]&quot;</span> <span style="color: #339933;">=&amp;</span>gt<span style="color: #339933;">;</span> <span style="color: #0000ff;">'!%5D!ui'</span><span style="color: #339933;">,</span><br />
<span style="color: #0000ff;">&quot;@&quot;</span> <span style="color: #339933;">=&amp;</span>gt<span style="color: #339933;">;</span> <span style="color: #0000ff;">'!%40!ui'</span><span style="color: #339933;">,</span><br />
<span style="color: #0000ff;">&quot;!&quot;</span> <span style="color: #339933;">=&amp;</span>gt<span style="color: #339933;">;</span> <span style="color: #0000ff;">'!%21!ui'</span><span style="color: #339933;">,</span><br />
<span style="color: #0000ff;">&quot;$&quot;</span> <span style="color: #339933;">=&amp;</span>gt<span style="color: #339933;">;</span> <span style="color: #0000ff;">'!%24!ui'</span><span style="color: #339933;">,</span><br />
<span style="color: #0000ff;">&quot;&amp;amp;&quot;</span> <span style="color: #339933;">=&amp;</span>gt<span style="color: #339933;">;</span> <span style="color: #0000ff;">'!%26!ui'</span><span style="color: #339933;">,</span><br />
<span style="color: #0000ff;">&quot;'&quot;</span> <span style="color: #339933;">=&amp;</span>gt<span style="color: #339933;">;</span> <span style="color: #0000ff;">'!%27!ui'</span><span style="color: #339933;">,</span><br />
<span style="color: #0000ff;">&quot;(&quot;</span> <span style="color: #339933;">=&amp;</span>gt<span style="color: #339933;">;</span> <span style="color: #0000ff;">'!%28!ui'</span><span style="color: #339933;">,</span><br />
<span style="color: #0000ff;">&quot;)&quot;</span> <span style="color: #339933;">=&amp;</span>gt<span style="color: #339933;">;</span> <span style="color: #0000ff;">'!%29!ui'</span><span style="color: #339933;">,</span><br />
<span style="color: #0000ff;">&quot;*&quot;</span> <span style="color: #339933;">=&amp;</span>gt<span style="color: #339933;">;</span> <span style="color: #0000ff;">'!%2A!ui'</span><span style="color: #339933;">,</span><br />
<span style="color: #0000ff;">&quot;+&quot;</span> <span style="color: #339933;">=&amp;</span>gt<span style="color: #339933;">;</span> <span style="color: #0000ff;">'!%2B!ui'</span><span style="color: #339933;">,</span><br />
<span style="color: #0000ff;">&quot;,&quot;</span> <span style="color: #339933;">=&amp;</span>gt<span style="color: #339933;">;</span> <span style="color: #0000ff;">'!%2C!ui'</span><span style="color: #339933;">,</span><br />
<span style="color: #0000ff;">&quot;;&quot;</span> <span style="color: #339933;">=&amp;</span>gt<span style="color: #339933;">;</span> <span style="color: #0000ff;">'!%3B!ui'</span><span style="color: #339933;">,</span><br />
<span style="color: #0000ff;">&quot;=&quot;</span> <span style="color: #339933;">=&amp;</span>gt<span style="color: #339933;">;</span> <span style="color: #0000ff;">'!%3D!ui'</span><span style="color: #339933;">,</span><br />
<span style="color: #0000ff;">&quot;%&quot;</span> <span style="color: #339933;">=&amp;</span>gt<span style="color: #339933;">;</span> <span style="color: #0000ff;">'!%25!ui'</span><span style="color: #339933;">,</span><br />
<span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span><br />
<br />
<span style="color: #000088;">$url</span> <span style="color: #339933;">=</span> <a href="http://www.php.net/rawurlencode"><span style="color: #990000;">rawurlencode</span></a><span style="color: #009900;">&#40;</span><span style="color: #000088;">$url</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span><br />
<span style="color: #000088;">$url</span> <span style="color: #339933;">=</span> <a href="http://www.php.net/preg_replace"><span style="color: #990000;">preg_replace</span></a><span style="color: #009900;">&#40;</span><a href="http://www.php.net/array_values"><span style="color: #990000;">array_values</span></a><span style="color: #009900;">&#40;</span><span style="color: #000088;">$reserved</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">,</span> <a href="http://www.php.net/array_keys"><span style="color: #990000;">array_keys</span></a><span style="color: #009900;">&#40;</span><span style="color: #000088;">$reserved</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">,</span> <span style="color: #000088;">$url</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span><br />
<span style="color: #b1b100;">return</span> <span style="color: #000088;">$url</span><span style="color: #339933;">;</span><br />
<span style="color: #009900;">&#125;</span></div></td></tr></tbody></table></div>
<p>One thing to notice here is that the &#8216;%&#8217; character must be the last in the <em>$reserved</em> array. This makes sure that the already encoded values are not lost or encoded again.</p>
<p><strong>Note</strong>: This might not be the best solution but well, it works. If you are using something better, let me know in the comments.</p>
]]></content:encoded>
			<wfw:commentRss>http://publicmind.in/blog/url-encoding/feed/</wfw:commentRss>
		<slash:comments>7</slash:comments>
		</item>
		<item>
		<title>Firefox extensions to improve history tools</title>
		<link>http://publicmind.in/blog/firefox-extensions-to-improve-history-tools/</link>
		<comments>http://publicmind.in/blog/firefox-extensions-to-improve-history-tools/#comments</comments>
		<pubDate>Sun, 02 May 2010 21:05:20 +0000</pubDate>
		<dc:creator>Nitin</dc:creator>
				<category><![CDATA[Nitin's Blog]]></category>
		<category><![CDATA[addons]]></category>
		<category><![CDATA[extensions]]></category>
		<category><![CDATA[firefox]]></category>
		<category><![CDATA[history]]></category>

		<guid isPermaLink="false">http://publicmind.in/blog/?p=593</guid>
		<description><![CDATA[We visit and revisit web pages. You will find that more than 60% of your web visits are actually revisits of some sort. But web browsers support for such revisitations is limited to bookmarks, history list, URL auto-completion and back button. Here are a few history tools which can greatly improve your experience during web [...]]]></description>
			<content:encoded><![CDATA[<p>We visit and revisit web pages. You will find that more than 60% of your web visits are actually revisits of some sort. But web browsers support for such revisitations is limited to bookmarks, history list, URL auto-completion and <strong>back</strong> button. Here are a few history tools which can greatly improve your experience during web browsing.</p>
<ul>
<li><strong><a href="https://addons.mozilla.org/en-US/firefox/addon/1859" target="_blank"> Tab History</a></strong>: It is the simplest yet very useful extension. Usually when we open a link in a new tab, the back button history for the new tab is empty. This extensions adds the session history from the parent tab to this new tab, so that you are not lost with the question &#8220;where do i come from?&#8221;.</li>
<li><strong><a href="https://addons.mozilla.org/en-US/firefox/addon/5890" target="_blank">Tree Style Tab:</a> </strong>This extension arranges your tabs in a tree structure, like a folder tree of Windows explorer. So whenever you open a new tab from a link, this tab is added as &#8216;child&#8217; node in the tab tree of the parent node.
<div id="attachment_595" class="wp-caption aligncenter" style="width: 210px"><img class="size-full wp-image-595  " title="Tree style tab" src="http://publicmind.in/blog/wp-content/uploads/2010/05/1192921260.png" alt="Tree style tab" width="200" height="134" /><p class="wp-caption-text">Tree style tab</p></div>
<p>You can conveniently arrange these tabs in the tree using the simple drap and drop feature. You can go through  an extensive list of features on the official site. One thing I would like to mention is that if you close a tab, its children are orphaned. As the father is gone, no way children would know about their grandparents <img src='http://publicmind.in/blog/wp-includes/images/smilies/icon_wink.gif' alt=';)' class='wp-smiley' /> .</li>
</ul>
<p><span id="more-593"></span></p>
<ul>
<li><strong><a href="https://addons.mozilla.org/en-US/firefox/addon/13316" target="_blank">History Tree:</a> </strong>History tree visualizes your history as a tree of tabs with thumbnails of web pages which makes it pretty easier for you to recognize what you are looking for. It is a very easy to use extension and provides four different visualizations for your history. It also shows the part of the history which is lost by back and forward buttons due to their LIFO implementation. For example, if you visit &lt;A&gt;, &lt;B&gt;, &lt;C&gt;, &lt;D&gt;, &lt;BACK to D&gt;, &lt;BACK to C&gt; , E. This sequence will loose &lt;C&gt; and &lt;D&gt; from the back button&#8217;s history but History tree will not. <img src='http://publicmind.in/blog/wp-includes/images/smilies/icon_smile.gif' alt=':)' class='wp-smiley' />
<p><div id="attachment_599" class="wp-caption aligncenter" style="width: 310px"><img class="size-medium wp-image-599" title="History Tree" src="http://publicmind.in/blog/wp-content/uploads/2010/05/IntroTV-300x187.png" alt="History Tree" width="300" height="187" /><p class="wp-caption-text">History Tree</p></div></li>
<li><strong><a href="/en-US/firefox/images/t/35086/1248779093" target="_blank">Infoaxe:</a> </strong>Infoaxe belongs to a family of history tools which provide a lot of cool features but ask you to register on their website so your history can be uploaded and processed on their servers. With Infoaxe, you can browse through all of your history in your browser or online. It also supports IE, so it doesn&#8217;t matter if you were browsing a page on which computer or browser, it will all be recorded by Infoaxe and made available to you &#8220;exactly when you need it&#8221;. It supports full text search on the web pages you browse and not just titles or keywords like your history list, which makes it pretty impressive.<br />
It provides a Google widget which adds result for your queries on Google search results page (SERP) with results from your local history. Read more about it here: http://infoaxe.wordpress.com/2008/12/23/the-infoaxe-vs-google-challenge-be-lazy-while-searching/</p>
<p><div id="attachment_597" class="wp-caption aligncenter" style="width: 514px"><img class="size-full wp-image-597   " title="infoaxe-lazy1" src="http://publicmind.in/blog/wp-content/uploads/2010/05/infoaxe-lazy1.jpg" alt="Infoaxe Google widget" width="504" height="315" /><p class="wp-caption-text">Infoaxe Google Widget</p></div></li>
<li><strong><a href="https://addons.mozilla.org/en-US/firefox/addon/5847" target="_blank">Hooeey</a></strong>: Hooeey is quite similar to Infoaxe in the way that it is also an online web browser history management tool. But it gives you full control over what part of your history is uploaded to their servers. I also like the analytics they provide about my browsing behavior.</li>
</ul>
<p>There are several more to explore like <a href="https://addons.mozilla.org/en-US/firefox/addon/5045">Thumbstribs</a> which provide a filmstrip from your browsing history or <a href="http://www.webmynd.com/html/index.html" target="_blank">Webmynd</a> which provides integration with Twitter, Wikipedia, Youtube and provides top results from these websites whenever you search with Google. But I leave them up to you to find out and report.</p>
]]></content:encoded>
			<wfw:commentRss>http://publicmind.in/blog/firefox-extensions-to-improve-history-tools/feed/</wfw:commentRss>
		<slash:comments>1</slash:comments>
		</item>
		<item>
		<title>&#8220;Hey Chef&#8221;, South Park</title>
		<link>http://publicmind.in/blog/hey-chef-south-park/</link>
		<comments>http://publicmind.in/blog/hey-chef-south-park/#comments</comments>
		<pubDate>Sun, 25 Apr 2010 17:42:45 +0000</pubDate>
		<dc:creator>Nitin</dc:creator>
				<category><![CDATA[Nitin's Blog]]></category>
		<category><![CDATA[chef]]></category>
		<category><![CDATA[fun]]></category>
		<category><![CDATA[south park]]></category>

		<guid isPermaLink="false">http://publicmind.in/blog/?p=578</guid>
		<description><![CDATA[Some of the &#8220;quotes&#8221; I like from South Park, by Chef. Disclaimer: The following contains coarse language and due to its content it should not be viewed by anyone. Episode 401 Chef: Well look at you cute little crackers with your money and your fancy clothes and your cell phones. It&#8217;s almost like you were&#8230; [...]]]></description>
			<content:encoded><![CDATA[<p><!-- Digg Digg Disabled -->Some of the &#8220;quotes&#8221; I like from South Park, by Chef.<br />
<strong>Disclaimer</strong>: The following contains coarse language and due to its content it should not be viewed by anyone.<div id="attachment_585" class="wp-caption alignright" style="width: 160px"><a href="http://publicmind.in/blog/wp-content/uploads/2010/04/chef.jpg"><img src="http://publicmind.in/blog/wp-content/uploads/2010/04/chef-150x150.jpg" alt="" title="Chef with Boys" width="150" height="150" class="size-thumbnail wp-image-585" /></a><p class="wp-caption-text">Chef with Boys</p></div></p>
<h3>Episode 401</h3>
<p><strong>Chef</strong>: Well look at you cute little crackers with your money and your fancy clothes and your cell phones. It&#8217;s almost like you were&#8230; Oh my God! Children, what have I told you about drugs<br />
<strong>Stan, Kyle, Cartman, and Kenny</strong>: There&#8217;s a time and a place for everything and it&#8217;s called college.<br />
<span id="more-578"></span></p>
<h3>Episode 405</h3>
<p><strong>Stan</strong>: Chef, what&#8217;s a prostitute?<strong><br />
Chef sings</strong>: But a prostitute is someone who would love you,<br />
No matter who you are, or what you look like.<br />
Yes, it&#8217;s true, children.<br />
That&#8217;s not why you pay a prostitute,<br />
No, you don&#8217;t pay her to stay;<br />
you pay her to leave afterwards<br />
That&#8217;s why I pay&#8217;s a lot for prostitutes!<br />
Ladies and Gentlemen, Mr. James Taylor<br />
<strong>James Taylor</strong>: A prostitute is like any other woman,<br />
They all trade something for sex and they do it well.<strong><br />
Chef</strong>: And that&#8217;s why I say-<br />
<strong>Chef and James Taylor</strong>: Prostitutes! Prostitutes!</p>
<h3>Episode 204</h3>
<p><strong>Chef</strong>: Hello there, children!<br />
<strong>Boys</strong>: Hey, Chef!<br />
<strong>Kyle</strong>: How&#8217;s it going?<br />
<strong>Chef</strong>: Bad<br />
<strong>Kyle</strong>: Why bad?<strong><br />
Chef</strong>: Children, I heard about what happened at school today! Now none of you tooked that nasty marijuana, did you?<strong><br />
Stan</strong>: No, dude! We never even saw it!<strong><br />
Chef</strong>: Okay, because I just want to tell you that drugs are bad.<br />
<strong>Stan</strong>: We know, we know, that&#8217;s what everybody says!<br />
<strong>Chef</strong>: Right. But do you know WHY they&#8217;re bad?<strong><br />
Kyle</strong>: Because they&#8217;re an addictive solution to a greater problem, causing disease of both body and mind, the consequences far outweighing their supposed benefits.<strong><br />
Chef</strong>: And do you have ANY idea what that means?<strong><br />
Kyle</strong>: No.<br />
<strong>Cartman</strong>: I know! Drugs are bad, because if you do drugs, you&#8217;re a hippie; and hippies suck!</p>
<p>P.S.: It was damn hard to write this post, given that my mouse has gone crazy with clicks.</p>
]]></content:encoded>
			<wfw:commentRss>http://publicmind.in/blog/hey-chef-south-park/feed/</wfw:commentRss>
		<slash:comments>1</slash:comments>
		</item>
		<item>
		<title>Facebook: Bug with URL encoding</title>
		<link>http://publicmind.in/blog/facebook-bug-with-url-encoding/</link>
		<comments>http://publicmind.in/blog/facebook-bug-with-url-encoding/#comments</comments>
		<pubDate>Fri, 12 Mar 2010 05:33:48 +0000</pubDate>
		<dc:creator>Nitin</dc:creator>
				<category><![CDATA[Drupal]]></category>
		<category><![CDATA[Nitin's Blog]]></category>
		<category><![CDATA[bug]]></category>
		<category><![CDATA[encoding]]></category>
		<category><![CDATA[facebook]]></category>
		<category><![CDATA[fbsl]]></category>

		<guid isPermaLink="false">http://publicmind.in/blog/?p=548</guid>
		<description><![CDATA[Today, while I was working on the URL encoding for the recently released Facebook-style Links module, I realized a bug with Link Attachments feature on Facebook. Before I explain, let us reproduce it: Try to attach the following link on Facebook: http://google.com/search?q=blenders%26pride. This URL actually queries Google for &#8216;blenders&#038;pride&#8217;. Facebook converts/encodes the above URL to [...]]]></description>
			<content:encoded><![CDATA[<p>Today, while I was working on the URL encoding for the recently released <a href="http://publicmind.in/blog/drupal-facebook-link">Facebook-style Links</a> module, I realized a bug with Link Attachments feature on Facebook. Before I explain, let us reproduce it:</p>
<p>Try to attach the following link on Facebook: <a href="http://google.com/search?q=blenders%26pride">http://google.com/search?q=blenders%26pride</a>. This URL actually queries Google for &#8216;blenders&#038;pride&#8217;. Facebook converts/encodes the above URL to <a href="http://google.com/search?q=blenders&#038;pride">http://google.com/search?q=blenders&#038;pride </a> which is not the same as above and queries Google for just &#8216;blenders&#8217;.</p>
<p>So, why Facebook does this? Probably Facebook tries to encode the URL to remove the characters which are not allowed by RFC 3986 and replaces them with their percent encoding. But there are certain characters which should not be encoded, such as &#8216;/&#8217;, &#8216;?&#8217;, &#8216;#&#8217;, &#8216;@&#8217; which are the reserved characters and used as delimiters in the URL. So, it decodes these characters and converts their encoding to the original character which gives rise to the problem. Let us see an example:<br />
<span id="more-548"></span><br />
&#8216;<a href="http://google.com/search?q= %2B">http://google.com/search?q= %2B</a>&#8216; is first encoded to replace unwanted character with their percent encoding, turns into &#8216;http%3A%2F%2Fgoogle.com%2Fsearch%3Fq%3D%20%2B&#8217;. (Note: I assume that already encoded characters are not encoded again in order to reproduce the bug, i.e.%2B does not gets converted to %252B). Then, the reserved characters (/,:,?,=,@,+) must be decoded again, therefore it gets converted to &#8216;<a href="http://google.com/search?q=%20+">http://google.com/search?q=%20+</a>&#8216; which as we see is not the same. It ideally should have been &#8216;http://google.com/search?q=%20%2B&#8217;.</p>
<p>I have already reported it in the bugs on Facebook. I will like to hear your views on URL encoding. Do you consider this as bug? Why does such URLs are not properly formatted at source making lives of developers difficult? Why does URLs with spaces and other disallowed characters exists?</p>
<p>Enjoy.</p>
<p><strong>Related Resources:</strong></p>
<ul>
<li><a href="http://en.wikipedia.org/wiki/Percent-encoding">http://en.wikipedia.org/wiki/Percent-encoding</a></li>
</ul>
]]></content:encoded>
			<wfw:commentRss>http://publicmind.in/blog/facebook-bug-with-url-encoding/feed/</wfw:commentRss>
		<slash:comments>1</slash:comments>
		</item>
		<item>
		<title>Dumping a remote SVN repository without admin access</title>
		<link>http://publicmind.in/blog/dumping-a-remote-svn-repository-without-admin-access/</link>
		<comments>http://publicmind.in/blog/dumping-a-remote-svn-repository-without-admin-access/#comments</comments>
		<pubDate>Fri, 29 Jan 2010 20:49:47 +0000</pubDate>
		<dc:creator>Nitin</dc:creator>
				<category><![CDATA[Nitin's Blog]]></category>
		<category><![CDATA[cvsdude]]></category>
		<category><![CDATA[script]]></category>
		<category><![CDATA[svn]]></category>
		<category><![CDATA[tutorial]]></category>

		<guid isPermaLink="false">http://publicmind.in/blog/?p=415</guid>
		<description><![CDATA[When you need to dump a SVN repository, all you have to do is 1svnadmin dump REPOS_PATH But wait, then you need to have access to the server on which your SVN repository is hosted. Often, that is not the case and you have to contact the company which hosts your repository to do it [...]]]></description>
			<content:encoded><![CDATA[<p>When you need to dump a SVN repository, all you have to do is</p>
<div class="codecolorer-container text default" style="overflow:auto;white-space:nowrap;border:1px solid #9F9F9F;width:435px;"><table cellspacing="0" cellpadding="0"><tbody><tr><td style="padding:5px;text-align:center;color:#888888;background-color:#EEEEEE;border-right: 1px solid #9F9F9F;font: normal 12px/1.4em Monaco, Lucida Console, monospace;"><div>1<br /></div></td><td><div class="text codecolorer" style="padding:5px;font:normal 12px/1.4em Monaco, Lucida Console, monospace;white-space:nowrap">svnadmin dump REPOS_PATH</div></td></tr></tbody></table></div>
<p>But wait, then you need to have access to the server on which your SVN repository is hosted. Often, that is not the case and you have to contact the company which hosts your repository to do it for you. I have a repository hosted at <a href="http://cvsdude.com">CVSdude</a> and I needed to dump it. As I am on the Developer Edition plan, I do not enjoy the privileges to backup my repositories from my admin panel. I could have mailed the guys at cvsdude, who according to me are quite supportive and quick to respond, but that would have taken longer than what I am going to describe next.</p>
<p>SVN provides a unique utility, <strong>svnsync</strong> which is a Subversion remote repository mirroring tool. Put simply, it allows you to replay the revisions of one repository into another one. Now, we can create an empty repository on our local system, synchronize it with the remote repository and then dump the local repository. Follow the following 4 step process to have a dump of your repository:<br />
<span id="more-415"></span></p>
<ol>
<li><strong>Create a local repository</strong>
<div class="codecolorer-container text default" style="overflow:auto;white-space:nowrap;border:1px solid #9F9F9F;width:435px;"><table cellspacing="0" cellpadding="0"><tbody><tr><td style="padding:5px;text-align:center;color:#888888;background-color:#EEEEEE;border-right: 1px solid #9F9F9F;font: normal 12px/1.4em Monaco, Lucida Console, monospace;"><div>1<br /></div></td><td><div class="text codecolorer" style="padding:5px;font:normal 12px/1.4em Monaco, Lucida Console, monospace;white-space:nowrap">svnadmin create c:/repos</div></td></tr></tbody></table></div>
<p>It will create an empty repository on your local system.</li>
<li><strong>Add “pre-revprop-change” hook to your local repository</strong><br />
You need to add an empty file into the hooks folder of your repository. This file should be named <strong>pre-revprop-change.cmd</strong> on Windows and <strong>pre-revprop-change</strong> on Linux systems.<br />
For Linux users:</p>
<div class="codecolorer-container text default" style="overflow:auto;white-space:nowrap;border:1px solid #9F9F9F;width:435px;"><table cellspacing="0" cellpadding="0"><tbody><tr><td style="padding:5px;text-align:center;color:#888888;background-color:#EEEEEE;border-right: 1px solid #9F9F9F;font: normal 12px/1.4em Monaco, Lucida Console, monospace;"><div>1<br />2<br /></div></td><td><div class="text codecolorer" style="padding:5px;font:normal 12px/1.4em Monaco, Lucida Console, monospace;white-space:nowrap">echo ‘#!/bin/sh’ &gt; repos/hooks/pre-revprop-change<br />
chmod +x repos/hooks/pre-revprop-change</div></td></tr></tbody></table></div>
<p>This allows <strong><em>svnsync</em></strong> to make revision changes to your local repository. Note that your remote repository is never modified during this process, in fact we just need read access to the remote repository.</li>
<li><strong>Synchronize your local repository with the remote repository</strong>
<div class="codecolorer-container text default" style="overflow:auto;white-space:nowrap;border:1px solid #9F9F9F;width:435px;"><table cellspacing="0" cellpadding="0"><tbody><tr><td style="padding:5px;text-align:center;color:#888888;background-color:#EEEEEE;border-right: 1px solid #9F9F9F;font: normal 12px/1.4em Monaco, Lucida Console, monospace;"><div>1<br />2<br /></div></td><td><div class="text codecolorer" style="padding:5px;font:normal 12px/1.4em Monaco, Lucida Console, monospace;white-space:nowrap">svnsync init file:///c:/repos https://test.cvsdude.com/fbl<br />
svnsync sync file:///c:/repos</div></td></tr></tbody></table></div>
</li>
<li><strong>Dump your local repository</strong>
<div class="codecolorer-container text default" style="overflow:auto;white-space:nowrap;border:1px solid #9F9F9F;width:435px;"><table cellspacing="0" cellpadding="0"><tbody><tr><td style="padding:5px;text-align:center;color:#888888;background-color:#EEEEEE;border-right: 1px solid #9F9F9F;font: normal 12px/1.4em Monaco, Lucida Console, monospace;"><div>1<br /></div></td><td><div class="text codecolorer" style="padding:5px;font:normal 12px/1.4em Monaco, Lucida Console, monospace;white-space:nowrap">svnadmin dump file:///c:/repos &gt; repos.dmp</div></td></tr></tbody></table></div>
</li>
</ol>
<p>That would be all, you can now have a cup of coffee. <img src='http://publicmind.in/blog/wp-includes/images/smilies/icon_smile.gif' alt=':)' class='wp-smiley' /> </p>
]]></content:encoded>
			<wfw:commentRss>http://publicmind.in/blog/dumping-a-remote-svn-repository-without-admin-access/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>GoogleSharing: Remain Anonymous from Google</title>
		<link>http://publicmind.in/blog/googlesharing-anonymizer/</link>
		<comments>http://publicmind.in/blog/googlesharing-anonymizer/#comments</comments>
		<pubDate>Sun, 24 Jan 2010 17:25:22 +0000</pubDate>
		<dc:creator>Nitin</dc:creator>
				<category><![CDATA[Nitin's Blog]]></category>
		<category><![CDATA[extension]]></category>
		<category><![CDATA[firefox]]></category>
		<category><![CDATA[google]]></category>
		<category><![CDATA[http]]></category>

		<guid isPermaLink="false">http://publicmind.in/blog/?p=404</guid>
		<description><![CDATA[Who knows more about the citizens in their own country, Kim Jong-Il or Google? Google tracks everything, your searches, web movement which arises from your search, what places you went last summer (or are planning to go, thanks to Google maps). Google not only knows about you but also understands you much better than your [...]]]></description>
			<content:encoded><![CDATA[<p>Who knows more about the citizens in their own country, Kim Jong-Il or Google?</p>
<p>Google tracks everything, your searches, web movement which arises from your search, what places you went last summer (or are planning to go, thanks to Google maps). Google not only knows about you but also understands you much better than your own girlfriend. If that freaks you out, I&#8217;d say you are in your right mind. But now you can avoid it to a certain extent by using GoogleSharing.</p>
<p>GoogleSharing is an extension for Firefox, which will anonymize your requests to Google products which do not require you to log in but where your activities can be tracked by Google. Google keep tracks of you through cookies. If you attempt to strip off your cookies from your HTTP request, Google might tag you as spam bot and will force you to type in a CAPTCHA for your every request.<br />
<span id="more-404"></span><br />
GoogleSharing strips off your personal information (IP, OS, browser agent, etc) from your requests to Google products (which do not require you to log-in) and your request is sent to Google Sharing Proxy Server which adds any required information to your requests and forward them to Google. All your requests made to other websites or google products which require log in, are left &#8220;completely untouched, unredirected, and unaffected&#8221; and they go directly to their destination.</p>
<div class="wp-caption aligncenter" style="width: 202px"><img title="GoogleSharing" src="http://www.googlesharing.net/images/diagram2.png" alt="GoogleSharing" width="192" height="268" /><p class="wp-caption-text">How GoogleSharing works. Source:googlesharing.net</p></div>
<p>Any of your log-in information is never sent to Google Sharing servers, it is stripped off by the firefox addon that you will install. So you never have to compromise with security and you can still enjoy the services like Gmail, Reader, other non-Google websites without any proxy in between. Wherever required GoogleSharing will dive in between you and Google to protect you from Google.</p>
<p>GoogleSharing logs none of your requests on their servers and even better, they provide you with the source code they run on their servers so that if you have proper resources you can set up your own &#8220;Google Sharing Proxy Server&#8221; which will have nothing to do with GoogleSharing. You can find more about it on their official website.</p>
<p>Link to official website: <a href="http://www.googlesharing.net">GoogleSharing</a><br />
Link to Mozilla Firefox addon site: <a href="https://addons.mozilla.org/en-US/firefox/addon/60333/">GoogleSharing</a></p>
<p>Let me know through your comments what you think about this firefox addon.</p>
<p>Here is funny video on Google invading your privacy:</p>
<p><object classid="clsid:d27cdb6e-ae6d-11cf-96b8-444553540000" width="425" height="344" codebase="http://download.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=6,0,40,0"><param name="allowFullScreen" value="true" /><param name="allowScriptAccess" value="always" /><param name="src" value="http://www.youtube.com/v/hrontojPWEE&amp;color1=0xb1b1b1&amp;color2=0xcfcfcf&amp;hl=en_US&amp;feature=player_embedded&amp;fs=1" /><param name="allowfullscreen" value="true" /><embed type="application/x-shockwave-flash" width="425" height="344" src="http://www.youtube.com/v/hrontojPWEE&amp;color1=0xb1b1b1&amp;color2=0xcfcfcf&amp;hl=en_US&amp;feature=player_embedded&amp;fs=1" allowscriptaccess="always" allowfullscreen="true"></embed></object></p>
]]></content:encoded>
			<wfw:commentRss>http://publicmind.in/blog/googlesharing-anonymizer/feed/</wfw:commentRss>
		<slash:comments>1</slash:comments>
		</item>
		<item>
		<title>Withdraw PayPal Money Directly to A Bank Account in India</title>
		<link>http://publicmind.in/blog/paypal-withdraw-to-bank-in-india/</link>
		<comments>http://publicmind.in/blog/paypal-withdraw-to-bank-in-india/#comments</comments>
		<pubDate>Wed, 16 Sep 2009 14:05:45 +0000</pubDate>
		<dc:creator>Nitin</dc:creator>
				<category><![CDATA[Nitin's Blog]]></category>
		<category><![CDATA[Drupal]]></category>
		<category><![CDATA[paypal]]></category>

		<guid isPermaLink="false">http://publicmind.in/blog/?p=239</guid>
		<description><![CDATA[PayPal is used by a lot of online merchants to accept payments for the products they sell online. PayPal can also be used to accept donations for your technical open source projects or charity organization. Recently, I opened an account with PayPal to accept payments from my clients who reside outside India. Before I started, [...]]]></description>
			<content:encoded><![CDATA[<p>PayPal is used by a lot of online merchants to accept payments for the products they sell online. PayPal can also be used to accept donations for your technical open source projects or charity organization.</p>
<p>Recently, I opened an account with PayPal to accept payments from my clients who reside outside India. Before I started, I searched for reviews on PayPal which seemed quite horrible. You can read a lot of them <a rel="nofollow" href="http://www.aboutpaypal.com/">here</a>. But then I needed the payments and had no other option (without spending a huge transaction amount), so gave it a try and I am happy that my experience with them till now is excellent.</p>
<p>So, here is a step by step procedure to Withdraw funds to your bank account in India.<span id="more-239"></span></p>
<ol>
<li>Login to your PayPal Account.</li>
<div id="attachment_240" class="wp-caption aligncenter" style="width: 448px"><img class="size-full wp-image-240 " title="paypal_home" src="http://publicmind.in/blog/wp-content/uploads/2009/09/paypal_home.jpg" alt="paypal account homepage" width="438" height="115" /><p class="wp-caption-text">Your PayPal account homepage</p></div>
<li>Click on &#8216;withdraw&#8217; to Proceed to the withdraw funds page.</li>
<div id="attachment_245" class="wp-caption aligncenter" style="width: 552px"><img class="size-full wp-image-245 " title="paypal_withdraw" src="http://publicmind.in/blog/wp-content/uploads/2009/09/paypal_withdraw.jpg" alt="withdraw funds page" width="542" height="134" /><p class="wp-caption-text">withdraw funds page</p></div>
<p><strong>Note:</strong> As you might have noticed in the brackets &#8217;5-7 business days&#8217; but all my transaction till now have arrived within 2 days. I guess it is the upper limit depending upon the different banks.</p>
<li>Click on &#8216;withdraw funds to your bank account&#8217; to move to this page.</li>
<div id="attachment_243" class="wp-caption aligncenter" style="width: 536px"><img class="size-full wp-image-243   " title="paypal_with" src="http://publicmind.in/blog/wp-content/uploads/2009/09/paypal_with.jpg" alt="withdraw to your bank account" width="526" height="230" /><p class="wp-caption-text">withdraw to your bank account</p></div>
<li>If you already attached a bank account, select it from the drop-down menu, fill in the amount you want to transfer and click &#8216;continue&#8217;. Otherwise, click on &#8216;add bank account&#8217; to attach your bank account with paypal. You will be presented with the following page.</li>
<div id="attachment_244" class="wp-caption aligncenter" style="width: 531px"><img class="size-full wp-image-244  " title="paypal_add" src="http://publicmind.in/blog/wp-content/uploads/2009/09/paypal_add1.jpg" alt="attach an Indian bank account to your paypal account" width="521" height="296" /><p class="wp-caption-text">attach an indian bank account to your paypal account</p></div>
<li> Fill in all the details correctly. PayPal allows you to transfer money to anyone having the same surname as you, but I would advise you to drop them an email before you do that. Their response time is great as well. Please check beforehand that your bank is NEFT enabled to prevent any return penalty.</li>
<li>Go to step 3 to withdraw funds to the newly added bank account.</li>
<p>That&#8217;s all!!</ol>
<p>One more thing, if you are concerned about the exchange rate, rest assured PayPal will show them to you before you confirm the transaction. I don&#8217;t know what will happen in future, but for now I am completely satisfied with PayPal.</p>
]]></content:encoded>
			<wfw:commentRss>http://publicmind.in/blog/paypal-withdraw-to-bank-in-india/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>MYSQL: MINUS (Set Difference) Operator</title>
		<link>http://publicmind.in/blog/mysql-minus-set-difference-operator/</link>
		<comments>http://publicmind.in/blog/mysql-minus-set-difference-operator/#comments</comments>
		<pubDate>Thu, 16 Jul 2009 22:26:02 +0000</pubDate>
		<dc:creator>Nitin</dc:creator>
				<category><![CDATA[Nitin's Blog]]></category>
		<category><![CDATA[Intern]]></category>
		<category><![CDATA[mysql]]></category>

		<guid isPermaLink="false">http://publicmind.in/blog/?p=192</guid>
		<description><![CDATA[Often we need MINUS operator as defined by the SQL definitions i.e you have two sets P and Q and you want P-Q which gives all the elements in P that are not in Q. But unfortunately, MYSQL does not have any operator for such an operation (yeah, I had the same reaction when I [...]]]></description>
			<content:encoded><![CDATA[<p>Often we need MINUS operator as defined by the SQL definitions i.e you have two sets P and Q and you want P-Q which gives all the elements in P that are not in Q. But unfortunately, MYSQL does not have any operator for such an operation (yeah, I had the same reaction when I heard this!!).</p>
<p>So here is a way how you can implement it in MYSQL. For simplicity let us consider we have two tables <strong>P and Q</strong> (we can also have views, joins, etc instead of the tables here) which have atleast one column in common (say <strong>id</strong>, which usually will be the primary key) and we want to evaluate <strong>P &#8211; Q</strong> which removes all those rows from P whose <strong>id</strong> is present in Q.</p>
<p>Here is the SQL statement for it. The statement is quite self explanatory, but if you still have doubt then leave a comment.</p>
<div class="codecolorer-container java default" style="overflow:auto;white-space:nowrap;border:1px solid #9F9F9F;width:435px;"><table cellspacing="0" cellpadding="0"><tbody><tr><td style="padding:5px;text-align:center;color:#888888;background-color:#EEEEEE;border-right: 1px solid #9F9F9F;font: normal 12px/1.4em Monaco, Lucida Console, monospace;"><div>1<br /></div></td><td><div class="java codecolorer" style="padding:5px;font:normal 12px/1.4em Monaco, Lucida Console, monospace;white-space:nowrap">Select <span style="color: #339933;">*</span> from P left join Q on P.<span style="color: #006633;">id</span> <span style="color: #339933;">=</span> Q.<span style="color: #006633;">id</span> where Q.<span style="color: #006633;">id</span> is <span style="color: #000066; font-weight: bold;">NULL</span><span style="color: #339933;">;</span></div></td></tr></tbody></table></div>
<p>Thats is what I could think of. If you are using some better and efficient method, then please leave a comment.</p>
]]></content:encoded>
			<wfw:commentRss>http://publicmind.in/blog/mysql-minus-set-difference-operator/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>MYSQL: Get the Auto-Increment Values after Insert Statement</title>
		<link>http://publicmind.in/blog/mysql-auto-increment-values/</link>
		<comments>http://publicmind.in/blog/mysql-auto-increment-values/#comments</comments>
		<pubDate>Wed, 15 Jul 2009 12:24:32 +0000</pubDate>
		<dc:creator>Nitin</dc:creator>
				<category><![CDATA[Nitin's Blog]]></category>
		<category><![CDATA[Intern]]></category>
		<category><![CDATA[java]]></category>
		<category><![CDATA[mysql]]></category>
		<category><![CDATA[php]]></category>

		<guid isPermaLink="false">http://publicmind.in/blog/?p=218</guid>
		<description><![CDATA[Until sometime back, I was unaware of how I could get the value of an auto-incremented field after an Insert Statement. But recently I needed it for two of my projects simultaneously, so I explored the possibilities. As one of my project is in Java and other is in PHP, we will go through both [...]]]></description>
			<content:encoded><![CDATA[<p>Until sometime back, I was unaware of how I could get the value of an auto-incremented field after an Insert Statement. But recently I needed it for two of my projects simultaneously, so I explored the possibilities. As one of my project is in Java and other is in PHP, we will go through both of them. </p>
<p>So, here is the problem. In general, the PRIMARY KEY field is the AUTO_INCREMENT field. Now wen you insert a row, a new key is generated and you can&#8217;t get it through usual way as this row can be accessed only using the primary key.</p>
<p>So here is how it can be done:<br />
<span id="more-218"></span><br />
<strong>In JAVA: </strong></p>
<div class="codecolorer-container java default" style="overflow:auto;white-space:nowrap;border:1px solid #9F9F9F;width:435px;"><table cellspacing="0" cellpadding="0"><tbody><tr><td style="padding:5px;text-align:center;color:#888888;background-color:#EEEEEE;border-right: 1px solid #9F9F9F;font: normal 12px/1.4em Monaco, Lucida Console, monospace;"><div>1<br />2<br />3<br />4<br />5<br />6<br />7<br />8<br />9<br />10<br />11<br />12<br />13<br />14<br /></div></td><td><div class="java codecolorer" style="padding:5px;font:normal 12px/1.4em Monaco, Lucida Console, monospace;white-space:nowrap"><span style="color: #666666; font-style: italic;">/*Insert a row into the desired table that generates <br />
an auto increment field*/</span><br />
<br />
stmt.<span style="color: #006633;">executeUpdate</span><span style="color: #009900;">&#40;</span><span style="color: #0000ff;">&quot;Insert into tableName (col1, col2) values (val1, val2)&quot;</span>, <a href="http://www.google.com/search?hl=en&amp;q=allinurl%3Astatement+java.sun.com&amp;btnI=I%27m%20Feeling%20Lucky"><span style="color: #003399;">Statement</span></a>.<span style="color: #006633;">RETURN_GENERATED_KEYS</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span><br />
<br />
<a href="http://www.google.com/search?hl=en&amp;q=allinurl%3Aresultset+java.sun.com&amp;btnI=I%27m%20Feeling%20Lucky"><span style="color: #003399;">ResultSet</span></a> rs <span style="color: #339933;">=</span> stmt.<span style="color: #006633;">getGeneratedKeys</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span><br />
<br />
<span style="color: #000066; font-weight: bold;">int</span> autoIncValue <span style="color: #339933;">=</span> <span style="color: #339933;">-</span><span style="color: #cc66cc;">1</span><span style="color: #339933;">;</span><br />
<br />
<span style="color: #000000; font-weight: bold;">if</span><span style="color: #009900;">&#40;</span>rs.<span style="color: #006633;">next</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#41;</span> <br />
<span style="color: #009900;">&#123;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp;autoIncValue <span style="color: #339933;">=</span> rs.<span style="color: #006633;">getInt</span><span style="color: #009900;">&#40;</span><span style="color: #cc66cc;">1</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp;<span style="color: #666666; font-style: italic;">/*You can get more generated keys if they are generated in your code*/</span><br />
<span style="color: #009900;">&#125;</span></div></td></tr></tbody></table></div>
<p><strong>In PHP</strong>:</p>
<p>The mysql_insert_id() function in PHP returns the AUTO_INCREMENT ID generated from the previous INSERT operation.</p>
<div class="codecolorer-container php default" style="overflow:auto;white-space:nowrap;border:1px solid #9F9F9F;width:435px;"><table cellspacing="0" cellpadding="0"><tbody><tr><td style="padding:5px;text-align:center;color:#888888;background-color:#EEEEEE;border-right: 1px solid #9F9F9F;font: normal 12px/1.4em Monaco, Lucida Console, monospace;"><div>1<br />2<br />3<br />4<br />5<br />6<br />7<br />8<br />9<br />10<br />11<br />12<br />13<br />14<br />15<br />16<br /></div></td><td><div class="php codecolorer" style="padding:5px;font:normal 12px/1.4em Monaco, Lucida Console, monospace;white-space:nowrap"><span style="color: #000000; font-weight: bold;">&lt;?php</span><br />
<span style="color: #000088;">$con</span> <span style="color: #339933;">=</span> <a href="http://www.php.net/mysql_connect"><span style="color: #990000;">mysql_connect</span></a><span style="color: #009900;">&#40;</span><span style="color: #0000ff;">&quot;hostname&quot;</span><span style="color: #339933;">,</span> <span style="color: #0000ff;">&quot;username&quot;</span><span style="color: #339933;">,</span> <span style="color: #0000ff;">&quot;password&quot;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span><br />
<span style="color: #b1b100;">if</span> <span style="color: #009900;">&#40;</span><span style="color: #339933;">!</span><span style="color: #000088;">$con</span><span style="color: #009900;">&#41;</span><br />
&nbsp; <span style="color: #009900;">&#123;</span><br />
&nbsp; <a href="http://www.php.net/die"><span style="color: #990000;">die</span></a><span style="color: #009900;">&#40;</span><span style="color: #0000ff;">'Error while connecting: '</span> <span style="color: #339933;">.</span> <a href="http://www.php.net/mysql_error"><span style="color: #990000;">mysql_error</span></a><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span><br />
&nbsp; <span style="color: #009900;">&#125;</span><br />
<br />
<span style="color: #000088;">$db_selected</span> <span style="color: #339933;">=</span> <a href="http://www.php.net/mysql_select_db"><span style="color: #990000;">mysql_select_db</span></a><span style="color: #009900;">&#40;</span>database_name<span style="color: #339933;">,</span><span style="color: #000088;">$con</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span><br />
<br />
<span style="color: #000088;">$sql</span> <span style="color: #339933;">=</span> <span style="color: #0000ff;">&quot;INSERT INTO tablename VALUES (val1,val2)&quot;</span><span style="color: #339933;">;</span><br />
<span style="color: #000088;">$result</span> <span style="color: #339933;">=</span> <a href="http://www.php.net/mysql_query"><span style="color: #990000;">mysql_query</span></a><span style="color: #009900;">&#40;</span><span style="color: #000088;">$sql</span><span style="color: #339933;">,</span><span style="color: #000088;">$con</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span><br />
<br />
<span style="color: #b1b100;">echo</span> <span style="color: #0000ff;">&quot;ID of last inserted record is: &quot;</span> <span style="color: #339933;">.</span> <a href="http://www.php.net/mysql_insert_id"><span style="color: #990000;">mysql_insert_id</span></a><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span><br />
<br />
<a href="http://www.php.net/mysql_close"><span style="color: #990000;">mysql_close</span></a><span style="color: #009900;">&#40;</span><span style="color: #000088;">$con</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span><br />
<span style="color: #000000; font-weight: bold;">?&gt;</span></div></td></tr></tbody></table></div>
<p>Note: Be sure to call mysql_insert_id() immediately after a query to get the correct value. The function returns 0 if the previous query does not generate an AUTO_INCREMENT value, or FALSE if no MySQL connection was established. </p>
<p>Enjoy!!</p>
]]></content:encoded>
			<wfw:commentRss>http://publicmind.in/blog/mysql-auto-increment-values/feed/</wfw:commentRss>
		<slash:comments>1</slash:comments>
		</item>
		<item>
		<title>Sorting a 2-Dimensional Array in Java</title>
		<link>http://publicmind.in/blog/sorting-2d-array-java/</link>
		<comments>http://publicmind.in/blog/sorting-2d-array-java/#comments</comments>
		<pubDate>Sun, 05 Jul 2009 21:47:28 +0000</pubDate>
		<dc:creator>Nitin</dc:creator>
				<category><![CDATA[Nitin's Blog]]></category>
		<category><![CDATA[code]]></category>
		<category><![CDATA[Intern]]></category>
		<category><![CDATA[java]]></category>

		<guid isPermaLink="false">http://publicmind.in/blog/?p=199</guid>
		<description><![CDATA[Recently while working for my project, I came across this situation when I had a 2-D array and I needed to sort it twice on 2 of its columns. Consider the following 2D array: 1234String&#91;&#93;&#91;&#93; testString = new String&#91;&#93;&#91;&#93; &#123; &#160; &#160; &#123;&#34;1&#34;, &#34;2&#34;, &#34;6&#34;&#125;, &#160; &#160; &#123;&#34;4&#34;, &#34;5&#34;, &#34;3&#34;&#125; &#160; &#125;; Sorting the above [...]]]></description>
			<content:encoded><![CDATA[<p><!-- Digg Digg Disabled -->Recently while working for my project, I came across this situation when I had a 2-D array and I needed to sort it twice on 2 of its columns. Consider the following 2D array:</p>
<div class="codecolorer-container java default" style="overflow:auto;white-space:nowrap;border:1px solid #9F9F9F;width:435px;"><table cellspacing="0" cellpadding="0"><tbody><tr><td style="padding:5px;text-align:center;color:#888888;background-color:#EEEEEE;border-right: 1px solid #9F9F9F;font: normal 12px/1.4em Monaco, Lucida Console, monospace;"><div>1<br />2<br />3<br />4<br /></div></td><td><div class="java codecolorer" style="padding:5px;font:normal 12px/1.4em Monaco, Lucida Console, monospace;white-space:nowrap"><a href="http://www.google.com/search?hl=en&amp;q=allinurl%3Astring+java.sun.com&amp;btnI=I%27m%20Feeling%20Lucky"><span style="color: #003399;">String</span></a><span style="color: #009900;">&#91;</span><span style="color: #009900;">&#93;</span><span style="color: #009900;">&#91;</span><span style="color: #009900;">&#93;</span> testString <span style="color: #339933;">=</span> <span style="color: #000000; font-weight: bold;">new</span> <a href="http://www.google.com/search?hl=en&amp;q=allinurl%3Astring+java.sun.com&amp;btnI=I%27m%20Feeling%20Lucky"><span style="color: #003399;">String</span></a><span style="color: #009900;">&#91;</span><span style="color: #009900;">&#93;</span><span style="color: #009900;">&#91;</span><span style="color: #009900;">&#93;</span> <span style="color: #009900;">&#123;</span><br />
&nbsp; &nbsp; <span style="color: #009900;">&#123;</span><span style="color: #0000ff;">&quot;1&quot;</span>, <span style="color: #0000ff;">&quot;2&quot;</span>, <span style="color: #0000ff;">&quot;6&quot;</span><span style="color: #009900;">&#125;</span>,<br />
&nbsp; &nbsp; <span style="color: #009900;">&#123;</span><span style="color: #0000ff;">&quot;4&quot;</span>, <span style="color: #0000ff;">&quot;5&quot;</span>, <span style="color: #0000ff;">&quot;3&quot;</span><span style="color: #009900;">&#125;</span><br />
&nbsp; <span style="color: #009900;">&#125;</span><span style="color: #339933;">;</span></div></td></tr></tbody></table></div>
<p>Sorting the above 2D array on zero column will give</p>
<div class="codecolorer-container java default" style="overflow:auto;white-space:nowrap;border:1px solid #9F9F9F;width:435px;"><table cellspacing="0" cellpadding="0"><tbody><tr><td style="padding:5px;text-align:center;color:#888888;background-color:#EEEEEE;border-right: 1px solid #9F9F9F;font: normal 12px/1.4em Monaco, Lucida Console, monospace;"><div>1<br />2<br />3<br />4<br /></div></td><td><div class="java codecolorer" style="padding:5px;font:normal 12px/1.4em Monaco, Lucida Console, monospace;white-space:nowrap"><span style="color: #009900;">&#123;</span><br />
&nbsp; &nbsp; <span style="color: #009900;">&#123;</span><span style="color: #0000ff;">&quot;1&quot;</span>, <span style="color: #0000ff;">&quot;2&quot;</span>, <span style="color: #0000ff;">&quot;6&quot;</span><span style="color: #009900;">&#125;</span>,<br />
&nbsp; &nbsp; <span style="color: #009900;">&#123;</span><span style="color: #0000ff;">&quot;4&quot;</span>, <span style="color: #0000ff;">&quot;5&quot;</span>, <span style="color: #0000ff;">&quot;3&quot;</span><span style="color: #009900;">&#125;</span><br />
<span style="color: #009900;">&#125;</span></div></td></tr></tbody></table></div>
<p>whereas sorting it on second column will give</p>
<div class="codecolorer-container java default" style="overflow:auto;white-space:nowrap;border:1px solid #9F9F9F;width:435px;"><table cellspacing="0" cellpadding="0"><tbody><tr><td style="padding:5px;text-align:center;color:#888888;background-color:#EEEEEE;border-right: 1px solid #9F9F9F;font: normal 12px/1.4em Monaco, Lucida Console, monospace;"><div>1<br />2<br />3<br />4<br /></div></td><td><div class="java codecolorer" style="padding:5px;font:normal 12px/1.4em Monaco, Lucida Console, monospace;white-space:nowrap"><span style="color: #009900;">&#123;</span><br />
&nbsp; &nbsp; <span style="color: #009900;">&#123;</span><span style="color: #0000ff;">&quot;4&quot;</span>, <span style="color: #0000ff;">&quot;5&quot;</span>, <span style="color: #0000ff;">&quot;3&quot;</span><span style="color: #009900;">&#125;</span>,<br />
&nbsp; &nbsp; <span style="color: #009900;">&#123;</span><span style="color: #0000ff;">&quot;1&quot;</span>, <span style="color: #0000ff;">&quot;2&quot;</span>, <span style="color: #0000ff;">&quot;6&quot;</span><span style="color: #009900;">&#125;</span><br />
<span style="color: #009900;">&#125;</span></div></td></tr></tbody></table></div>
<p>I did not want to do the most common as well as tedious thing, i.e. write my own sorting function like this:</p>
<div class="codecolorer-container java default" style="overflow:auto;white-space:nowrap;border:1px solid #9F9F9F;width:435px;"><table cellspacing="0" cellpadding="0"><tbody><tr><td style="padding:5px;text-align:center;color:#888888;background-color:#EEEEEE;border-right: 1px solid #9F9F9F;font: normal 12px/1.4em Monaco, Lucida Console, monospace;"><div>1<br />2<br />3<br /></div></td><td><div class="java codecolorer" style="padding:5px;font:normal 12px/1.4em Monaco, Lucida Console, monospace;white-space:nowrap"><span style="color: #000000; font-weight: bold;">public</span> <span style="color: #000066; font-weight: bold;">void</span> myOwnSort<span style="color: #009900;">&#40;</span><a href="http://www.google.com/search?hl=en&amp;q=allinurl%3Astring+java.sun.com&amp;btnI=I%27m%20Feeling%20Lucky"><span style="color: #003399;">String</span></a> <span style="color: #009900;">&#91;</span><span style="color: #009900;">&#93;</span><span style="color: #009900;">&#91;</span><span style="color: #009900;">&#93;</span> exampleArray<span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span><br />
&nbsp; &nbsp; <span style="color: #666666; font-style: italic;">//code for sorting the array according to my wish.</span><br />
<span style="color: #009900;">&#125;</span></div></td></tr></tbody></table></div>
<p>I wanted to avoid this for 2 resons:</p>
<ol>
<li>I would have to write the code for it ( lazy me!!).</li>
<li>Secondly, I can possibly never match the efficiency provided by the sorting functions of java.util.Arrays</li>
</ol>
<p><span id="more-199"></span><br />
So, my main aim was to look for a solution that would help me sort my 2-D array using the internal JAVA sorters.</p>
<p>I started digging into the JAVA docs (I must admit, I was a naive in JAVA at this point), and came across the <a href="http://java.sun.com/j2se/1.4.2/docs/api/java/util/Comparator.html">Comparator</a> Interface, using which we can tell the JAVA sorting function (<a href="http://java.sun.com/j2se/1.4.2/docs/api/java/util/Arrays.html#sort(java.lang.Object[], java.util.Comparator)">Arrays.sort</a>) on how to compare two elements of a 2D array. One must understand that a 2D array is essentially a 1D array with its each element as another 1D array.</p>
<div class="codecolorer-container java default" style="overflow:auto;white-space:nowrap;border:1px solid #9F9F9F;width:435px;"><table cellspacing="0" cellpadding="0"><tbody><tr><td style="padding:5px;text-align:center;color:#888888;background-color:#EEEEEE;border-right: 1px solid #9F9F9F;font: normal 12px/1.4em Monaco, Lucida Console, monospace;"><div>1<br />2<br />3<br />4<br /></div></td><td><div class="java codecolorer" style="padding:5px;font:normal 12px/1.4em Monaco, Lucida Console, monospace;white-space:nowrap"><a href="http://www.google.com/search?hl=en&amp;q=allinurl%3Astring+java.sun.com&amp;btnI=I%27m%20Feeling%20Lucky"><span style="color: #003399;">String</span></a><span style="color: #009900;">&#91;</span><span style="color: #009900;">&#93;</span><span style="color: #009900;">&#91;</span><span style="color: #009900;">&#93;</span> testString <span style="color: #339933;">=</span> <span style="color: #000000; font-weight: bold;">new</span> <a href="http://www.google.com/search?hl=en&amp;q=allinurl%3Astring+java.sun.com&amp;btnI=I%27m%20Feeling%20Lucky"><span style="color: #003399;">String</span></a><span style="color: #009900;">&#91;</span><span style="color: #009900;">&#93;</span><span style="color: #009900;">&#91;</span><span style="color: #009900;">&#93;</span> <span style="color: #009900;">&#123;</span><br />
&nbsp; &nbsp; <span style="color: #009900;">&#123;</span><span style="color: #0000ff;">&quot;1&quot;</span>, <span style="color: #0000ff;">&quot;2&quot;</span>, <span style="color: #0000ff;">&quot;6&quot;</span><span style="color: #009900;">&#125;</span>,<br />
&nbsp; &nbsp; <span style="color: #009900;">&#123;</span><span style="color: #0000ff;">&quot;4&quot;</span>, <span style="color: #0000ff;">&quot;5&quot;</span>, <span style="color: #0000ff;">&quot;3&quot;</span><span style="color: #009900;">&#125;</span><br />
&nbsp; <span style="color: #009900;">&#125;</span><span style="color: #339933;">;</span></div></td></tr></tbody></table></div>
<p>Above, there are two arrays containing 3 strings each. We must now compare these two arrays to determine their order in the resultant 2D array. We can compare these two 1-D arrays in any way we like, we can compare them on the first column, third column or on the average length of the strings (just anything!!). Let us implement Comparator interface to define such a compare function:</p>
<div class="codecolorer-container java default" style="overflow:auto;white-space:nowrap;border:1px solid #9F9F9F;width:435px;"><table cellspacing="0" cellpadding="0"><tbody><tr><td style="padding:5px;text-align:center;color:#888888;background-color:#EEEEEE;border-right: 1px solid #9F9F9F;font: normal 12px/1.4em Monaco, Lucida Console, monospace;"><div>1<br />2<br />3<br />4<br />5<br />6<br />7<br />8<br />9<br />10<br />11<br />12<br />13<br />14<br />15<br />16<br />17<br />18<br />19<br /></div></td><td><div class="java codecolorer" style="padding:5px;font:normal 12px/1.4em Monaco, Lucida Console, monospace;white-space:nowrap"><span style="color: #000000; font-weight: bold;">class</span> 2DcolumnComparator <span style="color: #000000; font-weight: bold;">implements</span> <a href="http://www.google.com/search?hl=en&amp;q=allinurl%3Acomparator+java.sun.com&amp;btnI=I%27m%20Feeling%20Lucky"><span style="color: #003399;">Comparator</span></a> <span style="color: #009900;">&#123;</span><br />
&nbsp; &nbsp; <span style="color: #000000; font-weight: bold;">private</span> <span style="color: #000066; font-weight: bold;">int</span> columnToSortOn<span style="color: #339933;">;</span><br />
&nbsp; &nbsp; <br />
&nbsp; &nbsp; <span style="color: #666666; font-style: italic;">//contructor to set the column to sort on.</span><br />
&nbsp; &nbsp; 2DcolumnComparator<span style="color: #009900;">&#40;</span><span style="color: #000066; font-weight: bold;">int</span> columnToSortOn<span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span><br />
&nbsp; &nbsp; &nbsp; <span style="color: #000000; font-weight: bold;">this</span>.<span style="color: #006633;">columnToSortOn</span> <span style="color: #339933;">=</span> columnToSortOn<span style="color: #339933;">;</span><br />
&nbsp; &nbsp; <span style="color: #009900;">&#125;</span><br />
<br />
&nbsp; &nbsp; <span style="color: #666666; font-style: italic;">// Implement the abstract method which tells</span><br />
&nbsp; &nbsp; <span style="color: #666666; font-style: italic;">// how to order the two elements in the array.</span><br />
&nbsp; &nbsp; <span style="color: #000000; font-weight: bold;">public</span> <span style="color: #000066; font-weight: bold;">int</span> compare<span style="color: #009900;">&#40;</span><a href="http://www.google.com/search?hl=en&amp;q=allinurl%3Aobject+java.sun.com&amp;btnI=I%27m%20Feeling%20Lucky"><span style="color: #003399;">Object</span></a> o1, <a href="http://www.google.com/search?hl=en&amp;q=allinurl%3Aobject+java.sun.com&amp;btnI=I%27m%20Feeling%20Lucky"><span style="color: #003399;">Object</span></a> o2<span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span><br />
&nbsp; &nbsp; <span style="color: #666666; font-style: italic;">// cast the object args back to string arrays</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; <a href="http://www.google.com/search?hl=en&amp;q=allinurl%3Astring+java.sun.com&amp;btnI=I%27m%20Feeling%20Lucky"><span style="color: #003399;">String</span></a><span style="color: #009900;">&#91;</span><span style="color: #009900;">&#93;</span> row1 <span style="color: #339933;">=</span> <span style="color: #009900;">&#40;</span><a href="http://www.google.com/search?hl=en&amp;q=allinurl%3Astring+java.sun.com&amp;btnI=I%27m%20Feeling%20Lucky"><span style="color: #003399;">String</span></a><span style="color: #009900;">&#91;</span><span style="color: #009900;">&#93;</span><span style="color: #009900;">&#41;</span>o1<span style="color: #339933;">;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; <a href="http://www.google.com/search?hl=en&amp;q=allinurl%3Astring+java.sun.com&amp;btnI=I%27m%20Feeling%20Lucky"><span style="color: #003399;">String</span></a><span style="color: #009900;">&#91;</span><span style="color: #009900;">&#93;</span> row2 <span style="color: #339933;">=</span> <span style="color: #009900;">&#40;</span><a href="http://www.google.com/search?hl=en&amp;q=allinurl%3Astring+java.sun.com&amp;btnI=I%27m%20Feeling%20Lucky"><span style="color: #003399;">String</span></a><span style="color: #009900;">&#91;</span><span style="color: #009900;">&#93;</span><span style="color: #009900;">&#41;</span>o2<span style="color: #339933;">;</span><br />
<br />
&nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #666666; font-style: italic;">// compare the desired column values</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #000000; font-weight: bold;">return</span> row1<span style="color: #009900;">&#91;</span>columnToSortOn<span style="color: #009900;">&#93;</span>.<span style="color: #006633;">compareTo</span><span style="color: #009900;">&#40;</span>row2<span style="color: #009900;">&#91;</span>columnToSortOn<span style="color: #009900;">&#93;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span><br />
&nbsp; &nbsp; <span style="color: #009900;">&#125;</span><br />
<span style="color: #009900;">&#125;</span></div></td></tr></tbody></table></div>
<p>Above, we create a class 2DcolumnComparator which implements comparator interface and compare 1D array elements on the column passed to the constructor. Now, we can pass an instance of this class to the Arrays.sort function, and the 2D array will sorted on the desired column.</p>
<div class="codecolorer-container java default" style="overflow:auto;white-space:nowrap;border:1px solid #9F9F9F;width:435px;"><table cellspacing="0" cellpadding="0"><tbody><tr><td style="padding:5px;text-align:center;color:#888888;background-color:#EEEEEE;border-right: 1px solid #9F9F9F;font: normal 12px/1.4em Monaco, Lucida Console, monospace;"><div>1<br />2<br />3<br />4<br />5<br />6<br />7<br />8<br />9<br /></div></td><td><div class="java codecolorer" style="padding:5px;font:normal 12px/1.4em Monaco, Lucida Console, monospace;white-space:nowrap"><span style="color: #000000; font-weight: bold;">public</span> <span style="color: #000000; font-weight: bold;">class</span> Analysis <span style="color: #009900;">&#123;</span><br />
<br />
&nbsp; <span style="color: #000000; font-weight: bold;">public</span> <span style="color: #000000; font-weight: bold;">static</span> <span style="color: #000066; font-weight: bold;">void</span> main<span style="color: #009900;">&#40;</span><a href="http://www.google.com/search?hl=en&amp;q=allinurl%3Astring+java.sun.com&amp;btnI=I%27m%20Feeling%20Lucky"><span style="color: #003399;">String</span></a> args<span style="color: #009900;">&#91;</span><span style="color: #009900;">&#93;</span><span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span><br />
&nbsp; &nbsp; <a href="http://www.google.com/search?hl=en&amp;q=allinurl%3Astring+java.sun.com&amp;btnI=I%27m%20Feeling%20Lucky"><span style="color: #003399;">String</span></a><span style="color: #009900;">&#91;</span><span style="color: #009900;">&#93;</span><span style="color: #009900;">&#91;</span><span style="color: #009900;">&#93;</span> childrenArray <span style="color: #339933;">=</span> <span style="color: #000000; font-weight: bold;">new</span> <a href="http://www.google.com/search?hl=en&amp;q=allinurl%3Astring+java.sun.com&amp;btnI=I%27m%20Feeling%20Lucky"><span style="color: #003399;">String</span></a><span style="color: #009900;">&#91;</span>MAXLIMIT<span style="color: #009900;">&#93;</span><span style="color: #009900;">&#91;</span><span style="color: #cc66cc;">10</span><span style="color: #009900;">&#93;</span><span style="color: #339933;">;</span><br />
<br />
&nbsp; &nbsp; <span style="color: #666666; font-style: italic;">//Populate the Array and sort</span><br />
&nbsp; &nbsp; <a href="http://www.google.com/search?hl=en&amp;q=allinurl%3Aarrays+java.sun.com&amp;btnI=I%27m%20Feeling%20Lucky"><span style="color: #003399;">Arrays</span></a>.<span style="color: #006633;">sort</span><span style="color: #009900;">&#40;</span>childrenArray,<span style="color: #000000; font-weight: bold;">new</span> 2DcolumnComparator<span style="color: #009900;">&#40;</span><span style="color: #cc66cc;">5</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span><br />
<span style="color: #009900;">&#125;</span><br />
<span style="color: #009900;">&#125;</span></div></td></tr></tbody></table></div>
<p>Here, we instantiate the 2DcolumnComaparator class and pass the column to sort on as parameter to its constructor. Above, the 2D array will be sorted on its fifth column (starting from zero). You can, of course, change the <strong>compare</strong> function to order elements according to your wish.</p>
<p>That is all I needed to sort a 2-D Array. Happy Sorting!!! <img src='http://publicmind.in/blog/wp-includes/images/smilies/icon_smile.gif' alt=':-)' class='wp-smiley' /> </p>
<p><strong>Useful Resources:</strong><br />
<a href="http://java.sun.com/j2se/1.4.2/docs/api/java/util/Comparator.html">http://java.sun.com/j2se/1.4.2/docs/api/java/util/Comparator.html</a><br />
<a href="http://java.sun.com/j2se/1.4.2/docs/api/java/util/Arrays.html#sort(java.lang.Object[], java.util.Comparator)">http://java.sun.com/j2se/1.4.2/docs/api/java/util/Arrays.html#sort(java.lang.Object[], java.util.Comparator)</a></p>
<p><strong>Recommended Reading:</strong><br />
<a href="http://publicmind.in/blog/books/corejava1" target="_blank">Core Java(TM), Volume I&#8211;Fundamentals (8th Edition)</a><br />
<a href="http://publicmind.in/blog/books/corejava2" target="_blank">Core Java(TM), Volume 2&#8211;Fundamentals (8th Edition)</a>
</p>
<p>Update: If you need to sort a 2D array of objects of any class which implements Comparable, you can look at the <a href="http://publicmind.in/blog/sorting-2d-array-java/#comment-640">comment</a> by Lars. Article last updated on 25 Feb 2010.</p>
]]></content:encoded>
			<wfw:commentRss>http://publicmind.in/blog/sorting-2d-array-java/feed/</wfw:commentRss>
		<slash:comments>14</slash:comments>
		</item>
	</channel>
</rss>
