<?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>Amit's Codebase</title>
	<atom:link href="http://amitcodes.wordpress.com/feed/" rel="self" type="application/rss+xml" />
	<link>http://amitcodes.wordpress.com</link>
	<description>All my codes</description>
	<lastBuildDate>Thu, 05 Jan 2012 07:59:13 +0000</lastBuildDate>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.com/</generator>
<cloud domain='amitcodes.wordpress.com' port='80' path='/?rsscloud=notify' registerProcedure='' protocol='http-post' />
<image>
		<url>http://1.gravatar.com/blavatar/510e1f3c7ec63f3d12e0029c3ec614da?s=96&#038;d=http%3A%2F%2Fs2.wp.com%2Fi%2Fbuttonw-com.png</url>
		<title>Amit's Codebase</title>
		<link>http://amitcodes.wordpress.com</link>
	</image>
	<atom:link rel="search" type="application/opensearchdescription+xml" href="http://amitcodes.wordpress.com/osd.xml" title="Amit&#039;s Codebase" />
	<atom:link rel='hub' href='http://amitcodes.wordpress.com/?pushpress=hub'/>
		<item>
		<title>Given two sorted arrays, develop logic to merge them into a third sorted array. Ideally, with O(n) complexity.</title>
		<link>http://amitcodes.wordpress.com/2011/05/10/given-two-sorted-arrays-develop-logic-to-merge-them-into-a-third-sorted-array-ideally-with-on-complexity/</link>
		<comments>http://amitcodes.wordpress.com/2011/05/10/given-two-sorted-arrays-develop-logic-to-merge-them-into-a-third-sorted-array-ideally-with-on-complexity/#comments</comments>
		<pubDate>Tue, 10 May 2011 03:37:33 +0000</pubDate>
		<dc:creator>amitcodes</dc:creator>
				<category><![CDATA[Programming Problems]]></category>
		<category><![CDATA[interview question]]></category>
		<category><![CDATA[merge sort]]></category>
		<category><![CDATA[sort arrays]]></category>
		<category><![CDATA[sorted arrays]]></category>

		<guid isPermaLink="false">http://amitcodes.wordpress.com/?p=139</guid>
		<description><![CDATA[There are two ways to attack this problem. The first-cut solution, which comes almost instantaneously to our minds, is The complexity for this solution will be O(nlogn). Not so impressive, given the fact that we already have two re-sorted arrays. The second approach uses the following logic: Since the two given arrays are iterated over [...]<img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=amitcodes.wordpress.com&amp;blog=4944087&amp;post=139&amp;subd=amitcodes&amp;ref=&amp;feed=1" width="1" height="1" />]]></description>
			<content:encoded><![CDATA[<p>There are two ways to attack this problem.</p>
<p>The first-cut solution, which comes almost instantaneously to our minds, is</p>
<p><pre class="brush: plain; gutter: false;">
    1. append the two arrays [ O(n) ]
    2. sort the resulting array [ O(nlogn) ]
</pre></p>
<p>The complexity for this solution will be O(nlogn). Not so impressive, given the fact that we already have two re-sorted arrays.</p>
<p>The second approach uses the following logic:</p>
<p><pre class="brush: plain; gutter: false;">
1. First array is denoted by a1. a1[i] denotes an element in a1[i]
   Second array is denoted by a2. a2[j] denotes an element in a2[j]
2. create a new array with length = len(a1) + len(a2). Let us call this array m. An element in m is denoted by m[k].
3. if (a1[i] &lt; a2[j]):
        m[k]=a1[i]
        m[++k]=a2[j]
        i++
   else if (a1[i] &gt; a2[j]):
        m[k]=a2[j]
        m[++k]=a1[i]
        j++
   else :
        m[k]=a1[i]
        m[++k]=a2[j]
        i++
        j++
4. if (i==len(a1)):
        append elements j to len(a2)-1 of a2 to m
   else if (j==len(a2)):
        append elements i to len(a1)-1 of a1 to m
   else :
        goto step 3
</pre></p>
<p>Since the two given arrays are iterated over only once in this solution, the complexity is O(n). Where n is the length of the resulting merged array.</p>
<br />  <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gocomments/amitcodes.wordpress.com/139/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/comments/amitcodes.wordpress.com/139/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godelicious/amitcodes.wordpress.com/139/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/delicious/amitcodes.wordpress.com/139/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gofacebook/amitcodes.wordpress.com/139/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/facebook/amitcodes.wordpress.com/139/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gotwitter/amitcodes.wordpress.com/139/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/twitter/amitcodes.wordpress.com/139/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gostumble/amitcodes.wordpress.com/139/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/stumble/amitcodes.wordpress.com/139/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godigg/amitcodes.wordpress.com/139/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/digg/amitcodes.wordpress.com/139/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/goreddit/amitcodes.wordpress.com/139/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/reddit/amitcodes.wordpress.com/139/" /></a> <img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=amitcodes.wordpress.com&amp;blog=4944087&amp;post=139&amp;subd=amitcodes&amp;ref=&amp;feed=1" width="1" height="1" />]]></content:encoded>
			<wfw:commentRss>http://amitcodes.wordpress.com/2011/05/10/given-two-sorted-arrays-develop-logic-to-merge-them-into-a-third-sorted-array-ideally-with-on-complexity/feed/</wfw:commentRss>
		<slash:comments>1</slash:comments>
	
		<media:content url="http://0.gravatar.com/avatar/c53ec4f8cae62ce7905180cb3071368a?s=96&#38;d=identicon&#38;r=G" medium="image">
			<media:title type="html">amitcodes</media:title>
		</media:content>
	</item>
		<item>
		<title>Efficiency.</title>
		<link>http://amitcodes.wordpress.com/2011/03/24/efficiency/</link>
		<comments>http://amitcodes.wordpress.com/2011/03/24/efficiency/#comments</comments>
		<pubDate>Thu, 24 Mar 2011 07:20:13 +0000</pubDate>
		<dc:creator>amitcodes</dc:creator>
				<category><![CDATA[Java]]></category>

		<guid isPermaLink="false">http://amitcodes.wordpress.com/?p=135</guid>
		<description><![CDATA[I was writing code for Base64 encoder today. I was able to. And then it occurred to me &#8211; &#8220;How about writing a function which can theoritically encode file of any arbitrary size.&#8221; So I proceeded, to read bytes, encode them, write them to a file. And then came in the second challenge &#8211; breaking the BIG [...]<img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=amitcodes.wordpress.com&amp;blog=4944087&amp;post=135&amp;subd=amitcodes&amp;ref=&amp;feed=1" width="1" height="1" />]]></description>
			<content:encoded><![CDATA[<p>I was writing code for Base64 encoder today. I was able to.<br />
And then it occurred to me &#8211; &#8220;How about writing a function which can theoritically encode file of any arbitrary size.&#8221;</p>
<p>So I proceeded, to read bytes, encode them, write them to a file.<br />
And then came in the second challenge &#8211; breaking the BIG base64 string into fixed-width lines (doesn&#8217;t sound challenging ? Try it!)<br />
I was successful after burning out some brain cells.</p>
<p>But the joy of flexibility did not last long &#8230; read on to know why &#8230;</p>
<ul>
<li>Target : encode 80 MB binary file.</li>
<li>My code takes 4.3 seconds (average)</li>
<li>GNU base64 took only 2.5 seconds</li>
<li> <img src='http://s0.wp.com/wp-includes/images/smilies/icon_sad.gif' alt=':-(' class='wp-smiley' /> </li>
</ul>
<p>A lag of 1.8 seconds, not as efficient as &#8216;The Gurus&#8217; &#8230;</p>
<p><span style="text-decoration:underline;"><strong>Note:</strong></span><strong> </strong>The programming language I used was Java. Say &#8230; how about trying out the same in Python ?? <img src='http://s0.wp.com/wp-includes/images/smilies/icon_smile.gif' alt=':)' class='wp-smiley' /> </p>
<br />  <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gocomments/amitcodes.wordpress.com/135/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/comments/amitcodes.wordpress.com/135/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godelicious/amitcodes.wordpress.com/135/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/delicious/amitcodes.wordpress.com/135/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gofacebook/amitcodes.wordpress.com/135/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/facebook/amitcodes.wordpress.com/135/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gotwitter/amitcodes.wordpress.com/135/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/twitter/amitcodes.wordpress.com/135/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gostumble/amitcodes.wordpress.com/135/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/stumble/amitcodes.wordpress.com/135/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godigg/amitcodes.wordpress.com/135/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/digg/amitcodes.wordpress.com/135/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/goreddit/amitcodes.wordpress.com/135/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/reddit/amitcodes.wordpress.com/135/" /></a> <img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=amitcodes.wordpress.com&amp;blog=4944087&amp;post=135&amp;subd=amitcodes&amp;ref=&amp;feed=1" width="1" height="1" />]]></content:encoded>
			<wfw:commentRss>http://amitcodes.wordpress.com/2011/03/24/efficiency/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
	
		<media:content url="http://0.gravatar.com/avatar/c53ec4f8cae62ce7905180cb3071368a?s=96&#38;d=identicon&#38;r=G" medium="image">
			<media:title type="html">amitcodes</media:title>
		</media:content>
	</item>
		<item>
		<title>Designing Filters</title>
		<link>http://amitcodes.wordpress.com/2011/02/08/designing-filters/</link>
		<comments>http://amitcodes.wordpress.com/2011/02/08/designing-filters/#comments</comments>
		<pubDate>Tue, 08 Feb 2011 08:48:47 +0000</pubDate>
		<dc:creator>amitcodes</dc:creator>
				<category><![CDATA[Java]]></category>
		<category><![CDATA[Programming Problems]]></category>
		<category><![CDATA[filter design]]></category>
		<category><![CDATA[filters]]></category>
		<category><![CDATA[implementing filters]]></category>
		<category><![CDATA[java filters]]></category>
		<category><![CDATA[spring filters]]></category>

		<guid isPermaLink="false">http://amitcodes.wordpress.com/?p=128</guid>
		<description><![CDATA[The other day me and my friends were discussing ways to implement filters. The things we focussed on were : Pluggable &#8211; The design should enable developers to add or remove filters as plug-ins Sequence &#8211; The order in which filters are applied should be configurable Testing &#8211; If adding a new filter, the developer [...]<img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=amitcodes.wordpress.com&amp;blog=4944087&amp;post=128&amp;subd=amitcodes&amp;ref=&amp;feed=1" width="1" height="1" />]]></description>
			<content:encoded><![CDATA[<p>The other day me and my friends were discussing ways to implement filters. The things we focussed on were :</p>
<ul>
<li>Pluggable &#8211; The design should enable developers to add or remove filters as plug-ins</li>
<li>Sequence &#8211; The order in which filters are applied should be configurable</li>
<li>Testing &#8211; If adding a new filter, the developer should only be able to write a test case for the new filter and be done with it</li>
</ul>
<p>Finally we agreed upon what is described best by the following UML ( disclaimer: we are not UML Gods, but use uml just to convey the idea):</p>
<ul>
<li><a href="http://amitcodes.files.wordpress.com/2011/02/filters.png"><img class="aligncenter size-full wp-image-129" style="border:1px solid black;margin:5px;" title="Filters" src="http://amitcodes.files.wordpress.com/2011/02/filters.png" alt="filters uml" width="908" height="432" /></a>There should be an interface which exposes the filtering function, for example, the <tt>Filter</tt> interface above exposes the <tt>doFilter()</tt> function. This function takes a sequence of results as input.</li>
<li>There may be <tt>n</tt> implementations of the <tt>Filter</tt> interface, each providing &#8211; ideally &#8211; a unique filtering functionality.</li>
<li>The class which performs filtering (in this case the <tt>FilterEnforcer</tt> class)
<ul>
<li>should be aware of the <tt>Filter</tt> interface and not of any implementations of the same.</li>
<li>The member variable <tt>filters</tt> is an <tt>Array</tt> or <tt>List</tt> of filters, thereby determining the sequence in which the filters will be applied.</li>
<li>The function which applies the these filters to the result-set will simply iterate over the filters and invoke the <tt>doFilter()</tt> function of each filter.</li>
</ul>
</li>
</ul>
<p>This design is already a widely used one &#8211; and if I am not wrong &#8211; I have seen this being implemented somewhere in Tomcat and Spring-Framework codebase.</p>
<br />  <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gocomments/amitcodes.wordpress.com/128/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/comments/amitcodes.wordpress.com/128/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godelicious/amitcodes.wordpress.com/128/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/delicious/amitcodes.wordpress.com/128/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gofacebook/amitcodes.wordpress.com/128/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/facebook/amitcodes.wordpress.com/128/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gotwitter/amitcodes.wordpress.com/128/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/twitter/amitcodes.wordpress.com/128/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gostumble/amitcodes.wordpress.com/128/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/stumble/amitcodes.wordpress.com/128/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godigg/amitcodes.wordpress.com/128/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/digg/amitcodes.wordpress.com/128/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/goreddit/amitcodes.wordpress.com/128/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/reddit/amitcodes.wordpress.com/128/" /></a> <img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=amitcodes.wordpress.com&amp;blog=4944087&amp;post=128&amp;subd=amitcodes&amp;ref=&amp;feed=1" width="1" height="1" />]]></content:encoded>
			<wfw:commentRss>http://amitcodes.wordpress.com/2011/02/08/designing-filters/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
	
		<media:content url="http://0.gravatar.com/avatar/c53ec4f8cae62ce7905180cb3071368a?s=96&#38;d=identicon&#38;r=G" medium="image">
			<media:title type="html">amitcodes</media:title>
		</media:content>

		<media:content url="http://amitcodes.files.wordpress.com/2011/02/filters.png" medium="image">
			<media:title type="html">Filters</media:title>
		</media:content>
	</item>
		<item>
		<title>MEMCACHED telnet syntax reference</title>
		<link>http://amitcodes.wordpress.com/2011/01/18/122/</link>
		<comments>http://amitcodes.wordpress.com/2011/01/18/122/#comments</comments>
		<pubDate>Tue, 18 Jan 2011 11:30:53 +0000</pubDate>
		<dc:creator>amitcodes</dc:creator>
				<category><![CDATA[How To]]></category>
		<category><![CDATA[Linux]]></category>
		<category><![CDATA[memcached]]></category>
		<category><![CDATA[memcached add]]></category>
		<category><![CDATA[telnet]]></category>

		<guid isPermaLink="false">http://amitcodes.wordpress.com/?p=122</guid>
		<description><![CDATA[Quick and Handy MEMCACHED telnet syntax reference: http://blog.elijaa.org/index.php?post/2010/05/21/Memcached-telnet-command-summary<img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=amitcodes.wordpress.com&amp;blog=4944087&amp;post=122&amp;subd=amitcodes&amp;ref=&amp;feed=1" width="1" height="1" />]]></description>
			<content:encoded><![CDATA[<p>Quick and Handy MEMCACHED telnet syntax reference:</p>
<p><a href="http://blog.elijaa.org/index.php?post/2010/05/21/Memcached-telnet-command-summary">http://blog.elijaa.org/index.php?post/2010/05/21/Memcached-telnet-command-summary</a></p>
<br />  <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gocomments/amitcodes.wordpress.com/122/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/comments/amitcodes.wordpress.com/122/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godelicious/amitcodes.wordpress.com/122/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/delicious/amitcodes.wordpress.com/122/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gofacebook/amitcodes.wordpress.com/122/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/facebook/amitcodes.wordpress.com/122/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gotwitter/amitcodes.wordpress.com/122/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/twitter/amitcodes.wordpress.com/122/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gostumble/amitcodes.wordpress.com/122/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/stumble/amitcodes.wordpress.com/122/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godigg/amitcodes.wordpress.com/122/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/digg/amitcodes.wordpress.com/122/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/goreddit/amitcodes.wordpress.com/122/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/reddit/amitcodes.wordpress.com/122/" /></a> <img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=amitcodes.wordpress.com&amp;blog=4944087&amp;post=122&amp;subd=amitcodes&amp;ref=&amp;feed=1" width="1" height="1" />]]></content:encoded>
			<wfw:commentRss>http://amitcodes.wordpress.com/2011/01/18/122/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
	
		<media:content url="http://0.gravatar.com/avatar/c53ec4f8cae62ce7905180cb3071368a?s=96&#38;d=identicon&#38;r=G" medium="image">
			<media:title type="html">amitcodes</media:title>
		</media:content>
	</item>
		<item>
		<title>UBUNTU: Reset Compiz from command line</title>
		<link>http://amitcodes.wordpress.com/2010/07/23/ubuntu-reset-compiz-from-command-line/</link>
		<comments>http://amitcodes.wordpress.com/2010/07/23/ubuntu-reset-compiz-from-command-line/#comments</comments>
		<pubDate>Fri, 23 Jul 2010 14:45:31 +0000</pubDate>
		<dc:creator>amitcodes</dc:creator>
				<category><![CDATA[How To]]></category>
		<category><![CDATA[Linux]]></category>
		<category><![CDATA[compiz fuckup]]></category>
		<category><![CDATA[reset compiz]]></category>
		<category><![CDATA[reset compiz on commandline]]></category>
		<category><![CDATA[ubuntu]]></category>

		<guid isPermaLink="false">http://amitcodes.wordpress.com/?p=107</guid>
		<description><![CDATA[I assume that you completly fucked-up gnome while fingering compiz (exactly like I did) . Open a terminal (ctrl+alt+F1 if you are all-fucked) and type away the following : $ gconftool-2 --recursive-unset /apps/compiz $ sudo /etc/init.d/gdm restart Works like magic !<img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=amitcodes.wordpress.com&amp;blog=4944087&amp;post=107&amp;subd=amitcodes&amp;ref=&amp;feed=1" width="1" height="1" />]]></description>
			<content:encoded><![CDATA[<pre><strong>I assume that you completly fucked-up gnome while fingering compiz (exactly like I did) .
Open a terminal (ctrl+alt+F1 if you are all-fucked) and type away the following :</strong><span style="color:#008000;">
</span>
<span style="color:#008000;"><strong>$ gconftool-2 --recursive-unset /apps/compiz
$ sudo /etc/init.d/gdm restart
<span style="color:#000000;">
Works like magic !</span>

<a rel="attachment wp-att-110" href="http://amitcodes.wordpress.com/2010/07/23/ubuntu-reset-compiz-from-command-line/compiz-reset/"><img class="aligncenter size-full wp-image-110" title="compiz-reset" src="http://amitcodes.files.wordpress.com/2010/07/compiz-reset.png" alt="" width="674" height="369" /></a>
</strong></span></pre>
<br />  <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gocomments/amitcodes.wordpress.com/107/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/comments/amitcodes.wordpress.com/107/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godelicious/amitcodes.wordpress.com/107/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/delicious/amitcodes.wordpress.com/107/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gofacebook/amitcodes.wordpress.com/107/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/facebook/amitcodes.wordpress.com/107/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gotwitter/amitcodes.wordpress.com/107/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/twitter/amitcodes.wordpress.com/107/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gostumble/amitcodes.wordpress.com/107/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/stumble/amitcodes.wordpress.com/107/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godigg/amitcodes.wordpress.com/107/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/digg/amitcodes.wordpress.com/107/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/goreddit/amitcodes.wordpress.com/107/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/reddit/amitcodes.wordpress.com/107/" /></a> <img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=amitcodes.wordpress.com&amp;blog=4944087&amp;post=107&amp;subd=amitcodes&amp;ref=&amp;feed=1" width="1" height="1" />]]></content:encoded>
			<wfw:commentRss>http://amitcodes.wordpress.com/2010/07/23/ubuntu-reset-compiz-from-command-line/feed/</wfw:commentRss>
		<slash:comments>1</slash:comments>
	
		<media:content url="http://0.gravatar.com/avatar/c53ec4f8cae62ce7905180cb3071368a?s=96&#38;d=identicon&#38;r=G" medium="image">
			<media:title type="html">amitcodes</media:title>
		</media:content>

		<media:content url="http://amitcodes.files.wordpress.com/2010/07/compiz-reset.png" medium="image">
			<media:title type="html">compiz-reset</media:title>
		</media:content>
	</item>
		<item>
		<title>Ssh without password</title>
		<link>http://amitcodes.wordpress.com/2009/06/22/ssh-without-password/</link>
		<comments>http://amitcodes.wordpress.com/2009/06/22/ssh-without-password/#comments</comments>
		<pubDate>Mon, 22 Jun 2009 06:56:39 +0000</pubDate>
		<dc:creator>amitcodes</dc:creator>
				<category><![CDATA[How To]]></category>
		<category><![CDATA[Linux]]></category>

		<guid isPermaLink="false">http://amitcodes.wordpress.com/?p=104</guid>
		<description><![CDATA[Run the following command on the client -&#62; ssh-keygen -t dsa File id_dsa and id_dsa.pub will be created inside $HOME/.ssh Copy the id_dsa.pub to the server&#8217;s .ssh directory -&#62; ssh-copy-id -i ~/.ssh/id_dsa.pub user@server You can try ssh to the server from the client and no password will be needed -&#62; ssh user@server Source:  http://linuxwave.blogspot.com/2007/07/ssh-without-password.html<img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=amitcodes.wordpress.com&amp;blog=4944087&amp;post=104&amp;subd=amitcodes&amp;ref=&amp;feed=1" width="1" height="1" />]]></description>
			<content:encoded><![CDATA[<ol>
<li>Run the following command on the <span style="font-style:italic;">client</span>
<ul>
<li><span style="color:#ff0000;"><span style="color:#000000;">-&gt;</span> ssh-keygen -t dsa</span></li>
</ul>
</li>
<li>File id_dsa and id_dsa.pub will be created inside $HOME/.ssh</li>
<li>Copy the id_dsa.pub to the server&#8217;s .ssh directory
<ul>
<li>-&gt; <span style="color:#ff0000;">ssh-copy-id -i ~/.ssh/id_dsa.pub user@server</span></li>
</ul>
</li>
<li>You can try ssh to the <span style="font-style:italic;">server</span> from the <span style="font-style:italic;">client</span> and  no password will be needed
<ul>
<li>-&gt; <span style="color:#ff0000;">ssh user@server</span></li>
</ul>
</li>
</ol>
<p>Source:  http://linuxwave.blogspot.com/2007/07/ssh-without-password.html</p>
<br />  <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gocomments/amitcodes.wordpress.com/104/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/comments/amitcodes.wordpress.com/104/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godelicious/amitcodes.wordpress.com/104/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/delicious/amitcodes.wordpress.com/104/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gofacebook/amitcodes.wordpress.com/104/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/facebook/amitcodes.wordpress.com/104/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gotwitter/amitcodes.wordpress.com/104/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/twitter/amitcodes.wordpress.com/104/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gostumble/amitcodes.wordpress.com/104/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/stumble/amitcodes.wordpress.com/104/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godigg/amitcodes.wordpress.com/104/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/digg/amitcodes.wordpress.com/104/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/goreddit/amitcodes.wordpress.com/104/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/reddit/amitcodes.wordpress.com/104/" /></a> <img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=amitcodes.wordpress.com&amp;blog=4944087&amp;post=104&amp;subd=amitcodes&amp;ref=&amp;feed=1" width="1" height="1" />]]></content:encoded>
			<wfw:commentRss>http://amitcodes.wordpress.com/2009/06/22/ssh-without-password/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
	
		<media:content url="http://0.gravatar.com/avatar/c53ec4f8cae62ce7905180cb3071368a?s=96&#38;d=identicon&#38;r=G" medium="image">
			<media:title type="html">amitcodes</media:title>
		</media:content>
	</item>
		<item>
		<title>Why do we write any servlet initialization code in init() and not in servlet&#8217;s constructor ?</title>
		<link>http://amitcodes.wordpress.com/2009/06/16/why-do-we-write-any-servlet-initialization-code-in-init-and-not-in-servlets-constructor/</link>
		<comments>http://amitcodes.wordpress.com/2009/06/16/why-do-we-write-any-servlet-initialization-code-in-init-and-not-in-servlets-constructor/#comments</comments>
		<pubDate>Tue, 16 Jun 2009 11:53:16 +0000</pubDate>
		<dc:creator>amitcodes</dc:creator>
				<category><![CDATA[Java]]></category>
		<category><![CDATA[java servlet init]]></category>

		<guid isPermaLink="false">http://amitcodes.wordpress.com/?p=98</guid>
		<description><![CDATA[I was asked this question and I found this here when I googled for the same: The init() method is typically used to perform servlet initialization&#8211;creating or loading objects that are used by the servlet in the handling of its requests. Why not use a constructor instead? Well, in JDK 1.0 (for which servlets were [...]<img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=amitcodes.wordpress.com&amp;blog=4944087&amp;post=98&amp;subd=amitcodes&amp;ref=&amp;feed=1" width="1" height="1" />]]></description>
			<content:encoded><![CDATA[<p style="text-align:justify;">I was asked this question and I found this <a title="Java Servlet Programming eBook" href="http://mvs.org.ua/Docs/oreilly/javaenterprise/servlet/ch03_03.htm" target="_blank">here</a> when I googled for the same:</p>
<blockquote>
<p style="text-align:justify;">The init() method is typically used to perform servlet initialization&#8211;creating or loading objects that are used by the servlet in the handling of its requests. Why not use a constructor instead? Well, in JDK 1.0 (for which servlets were originally written), constructors for dynamically loaded Java classes (such as servlets) couldn&#8217;t accept arguments. So, in order to provide a new servlet any information about itself and its environment, a server had to call a servlet&#8217;s init() method and pass along an object that implements the ServletConfig interface. Also, Java doesn&#8217;t allow interfaces to declare constructors. This means that the javax.servlet.Servlet interface cannot declare a constructor that accepts a ServletConfig parameter. It has to declare another method, like init(). It&#8217;s still possible, of course, for you to define constructors for your servlets, but in the constructor you don&#8217;t have access to the ServletConfig object or the ability to throw a ServletException.</p>
</blockquote>
<p style="text-align:justify;">I started digging deep into java code where Servlet classes are loaded and found the code in <a title="StandardWrapper source" href="http://www.docjar.com/html/api/org/apache/catalina/core/StandardWrapper.java.html" target="_blank">org.apache.catalina.core.StandardWrapper.loadServlet()</a>.<br />
It goes like this:</p>
<ul>
<li> A servlet class is loaded</li>
<li> An instance of the the servlet class is created using default (zero argument) constructor of the class by reflection</li>
<li> The method init(ServletConfig config) is called on this instance which passes all context related configuration to the servlet</li>
<li> The method init(ServletConfig config) then calls method init()</li>
<li> The servlet is now loaded and the instance created !</li>
</ul>
<p style="text-align:justify;">
So if you put in any servlet initialization code in servlet&#8217;s default constructor, it should not use ServletConfig and ServletContext objects. This will throw NullpointerException, since ServerConfig information is not initialized the Servlet till this point. However, if you want to perform any initialization which does not refer to ServletContext / ServletConfig, you can safely do so in the default constructor.</p>
<p><em>Note:</em> Any constructor other than the default constructor is useless as it is never called by the servlet-container.</p>
<br />  <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gocomments/amitcodes.wordpress.com/98/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/comments/amitcodes.wordpress.com/98/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godelicious/amitcodes.wordpress.com/98/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/delicious/amitcodes.wordpress.com/98/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gofacebook/amitcodes.wordpress.com/98/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/facebook/amitcodes.wordpress.com/98/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gotwitter/amitcodes.wordpress.com/98/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/twitter/amitcodes.wordpress.com/98/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gostumble/amitcodes.wordpress.com/98/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/stumble/amitcodes.wordpress.com/98/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godigg/amitcodes.wordpress.com/98/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/digg/amitcodes.wordpress.com/98/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/goreddit/amitcodes.wordpress.com/98/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/reddit/amitcodes.wordpress.com/98/" /></a> <img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=amitcodes.wordpress.com&amp;blog=4944087&amp;post=98&amp;subd=amitcodes&amp;ref=&amp;feed=1" width="1" height="1" />]]></content:encoded>
			<wfw:commentRss>http://amitcodes.wordpress.com/2009/06/16/why-do-we-write-any-servlet-initialization-code-in-init-and-not-in-servlets-constructor/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
	
		<media:content url="http://0.gravatar.com/avatar/c53ec4f8cae62ce7905180cb3071368a?s=96&#38;d=identicon&#38;r=G" medium="image">
			<media:title type="html">amitcodes</media:title>
		</media:content>
	</item>
		<item>
		<title>Write a function to remove the duplicate items in-place</title>
		<link>http://amitcodes.wordpress.com/2009/06/05/93/</link>
		<comments>http://amitcodes.wordpress.com/2009/06/05/93/#comments</comments>
		<pubDate>Fri, 05 Jun 2009 10:04:47 +0000</pubDate>
		<dc:creator>amitcodes</dc:creator>
				<category><![CDATA[Programming Problems]]></category>
		<category><![CDATA[inplace duplicate removal]]></category>

		<guid isPermaLink="false">http://amitcodes.wordpress.com/?p=93</guid>
		<description><![CDATA[Write a function to remove the duplicate items in-place (return the new size of the array) Solution: Sort the array, complexity of this step depends on algo used. loop over array till index &#60; len(array)-1 check if current element == next element if true, delete next element, else increment index Complexity: Complexity = complexity(sort()) + [...]<img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=amitcodes.wordpress.com&amp;blog=4944087&amp;post=93&amp;subd=amitcodes&amp;ref=&amp;feed=1" width="1" height="1" />]]></description>
			<content:encoded><![CDATA[<p><strong>Write a function to remove the duplicate items in-place (return the new size of the array)</strong></p>
<p><strong>Solution:</strong></p>
<ol>
<li>Sort the array, complexity of this step depends on algo used.</li>
<li>loop over array till index &lt; len(array)-1</li>
<li>check if current element == next element</li>
<li>if true, delete next element, else increment index</li>
</ol>
<p><strong>Complexity:</strong><br />
Complexity = complexity(sort()) + Complexity(remove_duplicates())<br />
           = O(N) + Complexity(remove_duplicates())<br />
Hence depending on whether you use Bubble Sort or Merge Sort (?) the<br />
overall complexity is going to be O(N^2) or O(NlogN)</p>
<p><strong>Python Code:</strong></p>
<pre>
<pre class="brush: python;">
#!/usr/bin/python

# Simple bubble sort for demo, O(N^2)
# You can use a better sorting algo
def sort( arr ):
    L=len(arr)-1
    for i in range(L,0,-1):
        for j in range (0,i):
           if arr[j] &gt; arr[j+1]:
                t = arr[j]
                arr[j] = arr[j+1]
                arr[j+1] = t
    return arr
        
# Complexity O(N)
def remove_duplicates( arr ):
    length = len(arr)
    i=0;

    while i &lt; (length-1):
        
        # check if two consequtive 
        # elements are equal ...
        if arr[i] == arr[i+1] :
            #delete next element
            arr.pop(i+1)
            #get new size of array
            length = len(arr)
        else:
            # else move on to next
            # element
            i = i + 1
    return arr

# Execute
a = [1,3,6,1,5,5,0,9,6,8,9,7]
arr = remove_duplicates(sort(a))
print arr
</pre>
</pre>
<br />  <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gocomments/amitcodes.wordpress.com/93/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/comments/amitcodes.wordpress.com/93/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godelicious/amitcodes.wordpress.com/93/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/delicious/amitcodes.wordpress.com/93/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gofacebook/amitcodes.wordpress.com/93/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/facebook/amitcodes.wordpress.com/93/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gotwitter/amitcodes.wordpress.com/93/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/twitter/amitcodes.wordpress.com/93/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gostumble/amitcodes.wordpress.com/93/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/stumble/amitcodes.wordpress.com/93/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godigg/amitcodes.wordpress.com/93/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/digg/amitcodes.wordpress.com/93/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/goreddit/amitcodes.wordpress.com/93/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/reddit/amitcodes.wordpress.com/93/" /></a> <img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=amitcodes.wordpress.com&amp;blog=4944087&amp;post=93&amp;subd=amitcodes&amp;ref=&amp;feed=1" width="1" height="1" />]]></content:encoded>
			<wfw:commentRss>http://amitcodes.wordpress.com/2009/06/05/93/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
	
		<media:content url="http://0.gravatar.com/avatar/c53ec4f8cae62ce7905180cb3071368a?s=96&#38;d=identicon&#38;r=G" medium="image">
			<media:title type="html">amitcodes</media:title>
		</media:content>
	</item>
		<item>
		<title>How to multiply a number by 7 most efficiently</title>
		<link>http://amitcodes.wordpress.com/2009/06/05/how-to-multiply-a-number-by-7-most-efficiently/</link>
		<comments>http://amitcodes.wordpress.com/2009/06/05/how-to-multiply-a-number-by-7-most-efficiently/#comments</comments>
		<pubDate>Fri, 05 Jun 2009 08:13:40 +0000</pubDate>
		<dc:creator>amitcodes</dc:creator>
				<category><![CDATA[Programming Problems]]></category>
		<category><![CDATA[efficient division]]></category>
		<category><![CDATA[efficient multiplication]]></category>

		<guid isPermaLink="false">http://amitcodes.wordpress.com/?p=86</guid>
		<description><![CDATA[This is an easy one. For machines it is always simpler to do bit-shifting than multiply. What is bit-shifting one place to left, physically ? Bit shifting one place right means multiplication by 2. Example: 0010 &#60;&#60; 1 = 0100, ( 2 * 2 = 4 ) 0100 &#60;&#60; 1 = 1000, ( 4 * [...]<img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=amitcodes.wordpress.com&amp;blog=4944087&amp;post=86&amp;subd=amitcodes&amp;ref=&amp;feed=1" width="1" height="1" />]]></description>
			<content:encoded><![CDATA[<p>This is an easy one.<br />
For machines it is always simpler to do bit-shifting than multiply.</p>
<p><strong>What is bit-shifting one place to left, physically ?</strong><br />
Bit shifting one place right means multiplication by 2.<br />
Example:</p>
<pre>0010 &lt;&lt; 1 = 0100, ( 2 * 2 = 4 )
0100 &lt;&lt; 1 = 1000, ( 4 * 2 = 8 )
0011 &lt;&lt; 1 = 0110, ( 3 * 2 = 6 )</pre>
<p>Similarly, bit-shifting one place right means diuvision by 2.</p>
<p>Now what if you shit each bit 2 places ? It is simply bitshiting each bit by 1, 2 times &#8211; right ? Which is nothing but multiplying by 2 twice!<br />
Hence, bit-shifting a number 2 places left multiplies it by 4.</p>
<p><strong>That&#8217;s ok, but how is it related to multiplication by 7 ?</strong><br />
Elementary Watson!<br />
For any given number N,</p>
<pre>N*7 = N*( 1 + 2 + 4)
    = N + N*2 + N*4
    = N + N&lt;&lt;1 + N&lt;&lt;2</pre>
<p>Where &lt;&lt; is the bitwise left shift operator.</p>
<p>Here is example python code:</p>
<pre><pre class="brush: python;">
&gt;&gt;&gt; def multiply_by_seven( n ):
...     return (n&lt;&lt;1) + (n&lt;&lt;2) +n;
... 
&gt;&gt;&gt; multiply_by_seven(2)
14
&gt;&gt;&gt; multiply_by_seven(3)
21
&gt;&gt;&gt; multiply_by_seven(7)
49
&gt;&gt;&gt; 
</pre></pre>
<p>Similarly you can break multiplication by any number into powers of 2 and perform an efficient multiplication.</p>
<p><strong>NOTE:</strong> Akshay just walked past me and said &#8220;Well, just multiply by 8 and subtract 1&#8243; <img src='http://s1.wp.com/wp-includes/images/smilies/icon_wink.gif' alt=';-)' class='wp-smiley' /> </p>
<br />  <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gocomments/amitcodes.wordpress.com/86/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/comments/amitcodes.wordpress.com/86/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godelicious/amitcodes.wordpress.com/86/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/delicious/amitcodes.wordpress.com/86/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gofacebook/amitcodes.wordpress.com/86/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/facebook/amitcodes.wordpress.com/86/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gotwitter/amitcodes.wordpress.com/86/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/twitter/amitcodes.wordpress.com/86/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gostumble/amitcodes.wordpress.com/86/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/stumble/amitcodes.wordpress.com/86/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godigg/amitcodes.wordpress.com/86/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/digg/amitcodes.wordpress.com/86/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/goreddit/amitcodes.wordpress.com/86/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/reddit/amitcodes.wordpress.com/86/" /></a> <img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=amitcodes.wordpress.com&amp;blog=4944087&amp;post=86&amp;subd=amitcodes&amp;ref=&amp;feed=1" width="1" height="1" />]]></content:encoded>
			<wfw:commentRss>http://amitcodes.wordpress.com/2009/06/05/how-to-multiply-a-number-by-7-most-efficiently/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
	
		<media:content url="http://0.gravatar.com/avatar/c53ec4f8cae62ce7905180cb3071368a?s=96&#38;d=identicon&#38;r=G" medium="image">
			<media:title type="html">amitcodes</media:title>
		</media:content>
	</item>
		<item>
		<title>How do you efficiently right-shift an array with the least memory usage?</title>
		<link>http://amitcodes.wordpress.com/2009/06/04/how-do-you-efficiently-right-shift-an-array-with-the-least-memory-usage/</link>
		<comments>http://amitcodes.wordpress.com/2009/06/04/how-do-you-efficiently-right-shift-an-array-with-the-least-memory-usage/#comments</comments>
		<pubDate>Thu, 04 Jun 2009 16:42:35 +0000</pubDate>
		<dc:creator>amitcodes</dc:creator>
				<category><![CDATA[Programming Problems]]></category>
		<category><![CDATA[array memory shift]]></category>
		<category><![CDATA[circular array]]></category>
		<category><![CDATA[shift array efficiently]]></category>

		<guid isPermaLink="false">http://amitcodes.wordpress.com/?p=80</guid>
		<description><![CDATA[How do you efficiently right-shift an array with the least memory usage? For example, the original array could be 2 3 4 5 6. after right-shift two positions, it should be 5 6 2 3 4. The function prototype is shift_right (int[] arret, int shiftCount). OR Algorithm to right-shift an array M places, where M [...]<img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=amitcodes.wordpress.com&amp;blog=4944087&amp;post=80&amp;subd=amitcodes&amp;ref=&amp;feed=1" width="1" height="1" />]]></description>
			<content:encoded><![CDATA[<p><strong>How do you efficiently right-shift an array with the least memory usage?<br />
For example, the original array could be 2 3 4 5 6. after right-shift two positions, it should be 5 6 2 3 4. The function prototype is shift_right (int[] arret, int shiftCount).<br />
</strong>OR<br />
<strong>Algorithm to right-shift an array M places, where M &lt; length(array)</strong></p>
<p><span style="text-decoration:underline;"><strong>Solution 1:</strong></span></p>
<p>Here is the exact solution as given in &#8220;Programming Pearls, 2nd Edition&#8221; :<br />
<em>&#8220;Swap all the numbers M times&#8221;</em><br />
For example: Say you have an array[1,2,3,4] and you have to shift<br />
it right 2 places. The</p>
<pre>---   Start    ---
[1,2,3,4]
--- First Pass ---
[1,2,3,4]
 ^ ^
[2,1,3,4]
   ^ ^
[2,3,1,4]
     ^ ^
[2,3,4,1]

--- Second Pass ---
[2,3,4,1]
 ^ ^
[3,2,4,1]
   ^ ^
[3,4,2,1]
     ^ ^
[3,4,1,2]

---   Result   ---
[3,4,1,2]</pre>
<p><strong>Complexity:</strong><br />
Not good! Take the worstcase. Say you have an array of length `n` and you have to shift all elements `n-1` places.<br />
The complexity becomes `O(N*(N-1)) ≈ O(N^2)` as `n -&gt; ∞`.<br />
In average case it will be O(mN), where `m` is the number of places to shift.</p>
<p><strong>Solution 2:</strong><br />
Yet another solution.<br />
Step 1: reverse the array by swapping all the elements (single pass, O(N))<br />
Step 2: reverse all the elements from 0 to `M-1`<br />
Step 3: reverse all the elements from `M` to `L-1` (where L is the length of the array)</p>
<pre>Array       : [1,2,3,4,5], M=3
First pass  : [5,4,3,2,1] (all elements swapped reversing the array)

Second pass : [3,4,5,2,1] (reverse array from 0 to 3-1=2)
               ^ ^ ^
Third Pass  : [3,4,5,1,2] (reverse elements 3 to 5)
                     ^ ^
Result      : [4,5,1,2,3]</pre>
<p>As simple as that  !!</p>
<p><strong>Java Code: </strong>[ source: <a href="http://forums.sun.com/thread.jspa?messageID=9563614#9563614" target="_blank">sun java fourums</a> ]</p>
<pre><pre class="brush: java;">
int[] reverse(int[] a, int i, int j) { // reverse elements i, i+1 ... j-1
   for (; --j &gt; i; i++) {
      int t= a[i]; a[i]= a[j]; a[j]= t;
   }
   return a; // convenience.
}

int[] shiftRight(int[] a, int i) {
   return reverse(reverse(reverse(a, 0, a.length), 0, i), i, a.length);
}

</pre></pre>
</pre>
</pre>
<p><strong>Complexity:</strong> O(N)<br />
Basically you traverse over the array twice, hence the complexity turns out to be O(2N) ≈ O(N)` as `n -&gt; ∞`.</p>
<br />  <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gocomments/amitcodes.wordpress.com/80/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/comments/amitcodes.wordpress.com/80/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godelicious/amitcodes.wordpress.com/80/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/delicious/amitcodes.wordpress.com/80/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gofacebook/amitcodes.wordpress.com/80/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/facebook/amitcodes.wordpress.com/80/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gotwitter/amitcodes.wordpress.com/80/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/twitter/amitcodes.wordpress.com/80/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gostumble/amitcodes.wordpress.com/80/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/stumble/amitcodes.wordpress.com/80/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godigg/amitcodes.wordpress.com/80/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/digg/amitcodes.wordpress.com/80/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/goreddit/amitcodes.wordpress.com/80/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/reddit/amitcodes.wordpress.com/80/" /></a> <img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=amitcodes.wordpress.com&amp;blog=4944087&amp;post=80&amp;subd=amitcodes&amp;ref=&amp;feed=1" width="1" height="1" />]]></content:encoded>
			<wfw:commentRss>http://amitcodes.wordpress.com/2009/06/04/how-do-you-efficiently-right-shift-an-array-with-the-least-memory-usage/feed/</wfw:commentRss>
		<slash:comments>1</slash:comments>
	
		<media:content url="http://0.gravatar.com/avatar/c53ec4f8cae62ce7905180cb3071368a?s=96&#38;d=identicon&#38;r=G" medium="image">
			<media:title type="html">amitcodes</media:title>
		</media:content>
	</item>
		<item>
		<title>Given an unsorted array of integers, find all integer pairs in array which add up to 200.</title>
		<link>http://amitcodes.wordpress.com/2009/06/02/given-an-unsorted-array-of-integers-find-all-integer-pairs-in-array-which-add-up-to-200/</link>
		<comments>http://amitcodes.wordpress.com/2009/06/02/given-an-unsorted-array-of-integers-find-all-integer-pairs-in-array-which-add-up-to-200/#comments</comments>
		<pubDate>Tue, 02 Jun 2009 12:58:34 +0000</pubDate>
		<dc:creator>amitcodes</dc:creator>
				<category><![CDATA[Programming Problems]]></category>

		<guid isPermaLink="false">http://amitcodes.wordpress.com/?p=44</guid>
		<description><![CDATA[Problem : Given an unsorted array of integers, find all integer pairs in array which add up to 200. Solution: First of all sort the array so that the largest number is on top There should be two pointers &#8211; initialize both by letting one point to the head of array and another to the [...]<img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=amitcodes.wordpress.com&amp;blog=4944087&amp;post=44&amp;subd=amitcodes&amp;ref=&amp;feed=1" width="1" height="1" />]]></description>
			<content:encoded><![CDATA[<p><strong>Problem :</strong> Given an unsorted array of integers, find all integer pairs in array which add up to 200.</p>
<p><strong>Solution:<br />
</strong></p>
<ul>
<li>First of all sort the array so that the largest number is on top</li>
<li>There should be two pointers &#8211; initialize both by letting one<br />
point to the head of array and another to the tail.</li>
<li>add head and tail</li>
<li>if (head + tail ) &gt; 200, then increment head</li>
<li>if (head+tail ) &lt; 200, then decrement tail</li>
<li>if (head + tail ) == 200, then decrement tail, increment head</li>
<li>break if head and tail meet</li>
</ul>
<p>The fundamental is you have the greatest number in the lot in `head`. Now you start adding increments to it (starting from the smallest increment). If the result is smaller than the target number, you need to increase the increment and vice-versa.</p>
<p><strong>Complexity: </strong></p>
<ul>
<li>The complexity method findNumbers is O(N) [single pass]</li>
<li>The complexity of method bubble Sort is O(N^2)</li>
</ul>
<p>Since assymptotically O(N^2) dominates O(N), the complexity of this solution is O(N^2) <strong>[ BAD! BAD!! BAD!!! ]</strong><br />
One good trick is to implement quikSort instead of bubbleSort. In that case the complexity becomes :<br />
O(N) + O(NlogN) = O(NlogN)</p>
<p>I implemented bubble sort just for demonstration purposes. The optimized way is to sort it with quick sort.</p>
<p><strong>My Tip: </strong>If you still don&#8217;t understand the fundamentals of this solution, use this text as a hint and try to do it on a piece of paper. It&#8217;s hard to explain but easier to realize <img src='http://s0.wp.com/wp-includes/images/smilies/icon_smile.gif' alt=':)' class='wp-smiley' /> </p>
<p><pre class="brush: java;">
package org.simplesoft.programmingproblems;

/**
 * @author Amit Kumar Sharma
 */
public class Arrays {

    /**
     * Method to find all numbers in a sorted array
     * of integers which add up to number `N`.
     * For example &quot;find all numbers in an array
     * of integers which add up to 200&quot;
     * @param arr: Sorted array of integers
     * @param n: number to which add up to
     */
    public static void findNumbers(int[] arr, int n) {
        // array is assumed to be sorted in descending order
        int head = 0;
        int tail = arr.length - 1;

        int num1, num2;

        while (tail != head - 1) {

            num1 = arr[head];
            num2 = arr[tail];

            if (num1 + num2 &gt; n) {
                head++;
            } else if (num1 + num2 &lt; n) {
                tail--;
            } else if (num1 + num2 == n) {
                System.out.println(num1 + &quot; + &quot; + num2 + &quot; = &quot; + n);
                head++;
                tail--;
            }
        }

    }

    /*
     * Bubble sort of complexity O(n^2)
     * If you push in quick sort here - the complexity of
     * the overall problem becomes O(NlogN)
     */
    public static void bubbleSort(int[] arr) {

        for (int i = (arr.length - 1); i &gt; 1; i--) {

            for (int j = 0; j &lt; i; j++) {

                if (arr[j] &lt; arr[j + 1]) {

                    // swap
                    int tmp = arr[j];
                    arr[j] = arr[j + 1];
                    arr[j + 1] = tmp;
                }
            }
        }
    }

    /**
     * Utility method to print integer arrays
     */
    public static void echoArray(int[] arr) {
        for (int i : arr) {
            System.out.print(i + &quot;, &quot;);
        }
        System.out.println();
    }

    public static void main(String[] args) {
        int[] arr = {
                       1,  8,  9,
                      23, 32, 16,
                      44, 83, 92,
                      62, 51, 12,
                      48, 50, 10,
                      22, 38, 15
                    };

        echoArray(arr);

        bubbleSort(arr);
        findNumbers(arr, 60);

    }
}

</pre></p>
<br />  <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gocomments/amitcodes.wordpress.com/44/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/comments/amitcodes.wordpress.com/44/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godelicious/amitcodes.wordpress.com/44/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/delicious/amitcodes.wordpress.com/44/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gofacebook/amitcodes.wordpress.com/44/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/facebook/amitcodes.wordpress.com/44/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gotwitter/amitcodes.wordpress.com/44/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/twitter/amitcodes.wordpress.com/44/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gostumble/amitcodes.wordpress.com/44/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/stumble/amitcodes.wordpress.com/44/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godigg/amitcodes.wordpress.com/44/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/digg/amitcodes.wordpress.com/44/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/goreddit/amitcodes.wordpress.com/44/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/reddit/amitcodes.wordpress.com/44/" /></a> <img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=amitcodes.wordpress.com&amp;blog=4944087&amp;post=44&amp;subd=amitcodes&amp;ref=&amp;feed=1" width="1" height="1" />]]></content:encoded>
			<wfw:commentRss>http://amitcodes.wordpress.com/2009/06/02/given-an-unsorted-array-of-integers-find-all-integer-pairs-in-array-which-add-up-to-200/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
	
		<media:content url="http://0.gravatar.com/avatar/c53ec4f8cae62ce7905180cb3071368a?s=96&#38;d=identicon&#38;r=G" medium="image">
			<media:title type="html">amitcodes</media:title>
		</media:content>
	</item>
		<item>
		<title>WSDLException: faultCode=OTHER_ERROR: Can&#8217;t find prefix</title>
		<link>http://amitcodes.wordpress.com/2009/04/08/wsdlexception-faultcodeother_error-cant-find-prefix/</link>
		<comments>http://amitcodes.wordpress.com/2009/04/08/wsdlexception-faultcodeother_error-cant-find-prefix/#comments</comments>
		<pubDate>Wed, 08 Apr 2009 11:58:52 +0000</pubDate>
		<dc:creator>amitcodes</dc:creator>
				<category><![CDATA[Java]]></category>

		<guid isPermaLink="false">http://amitcodes.wordpress.com/?p=38</guid>
		<description><![CDATA[damn! damn!! damn!!! I was developing a webservice using Apache-CXF (2.1.1) and Spring (2.5.5) using wsdl-first-approach. All went well, wsdl validation passed, code compiled, war created, webservice hosted on apache-tomcat 6. And then as I tried to access the wsdl url, I got this error : Apr 8, 2009 4:37:15 AM org.apache.catalina.core.StandardWrapperValve invoke ---- 8&#60; [...]<img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=amitcodes.wordpress.com&amp;blog=4944087&amp;post=38&amp;subd=amitcodes&amp;ref=&amp;feed=1" width="1" height="1" />]]></description>
			<content:encoded><![CDATA[<p>damn! damn!! damn!!!</p>
<p>I was developing a webservice using Apache-CXF (2.1.1) and Spring (2.5.5) using wsdl-first-approach.</p>
<p>All went well, wsdl validation passed, code compiled, war created, webservice hosted on apache-tomcat 6. And then as I tried to access the wsdl url, I got this error :</p>
<pre>Apr 8, 2009 4:37:15 AM org.apache.catalina.core.StandardWrapperValve invoke
---- 8&lt; ------------------------------------------------------
SEVERE: Servlet.service() for servlet CXFServlet threw exception
javax.wsdl.WSDLException: WSDLException: faultCode=OTHER_ERROR: Can't find prefix for 'http://prediction.simplesoft.org/2009/xsd'. Namespace prefixes must be set on the Definition object using the addNamespace(...) method.
    at com.ibm.wsdl.util.xml.DOMUtils.getPrefix(Unknown Source)
    at com.ibm.wsdl.util.xml.DOMUtils.getQualifiedValue(Unknown Source)
    at com.ibm.wsdl.util.xml.DOMUtils.printQualifiedAttribute(Unknown Source)
    at com.ibm.wsdl.xml.WSDLWriterImpl.printParts(Unknown Source)
    at com.ibm.wsdl.xml.WSDLWriterImpl.printMessages(Unknown Source)
    at com.ibm.wsdl.xml.WSDLWriterImpl.printDefinition(Unknown Source)
    at com.ibm.wsdl.xml.WSDLWriterImpl.writeWSDL(Unknown Source)
    at com.ibm.wsdl.xml.WSDLWriterImpl.getDocument(Unknown Source)
    at org.apache.cxf.transport.http.WSDLQueryHandler.writeResponse(WSDLQueryHandler.java:168)
    at org.apache.cxf.transport.servlet.ServletController.invoke(ServletController.java:147)
    at org.apache.cxf.transport.servlet.AbstractCXFServlet.invoke(AbstractCXFServlet.java:174)
    at org.apache.cxf.transport.servlet.AbstractCXFServlet.doGet(AbstractCXFServlet.java:156)
    at javax.servlet.http.HttpServlet.service(HttpServlet.java:617)
    at javax.servlet.http.HttpServlet.service(HttpServlet.java:717)
    at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:290)
    at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:206)
    at org.springframework.orm.hibernate3.support.OpenSessionInViewFilter.doFilterInternal(OpenSessionInViewFilter.java:198)
    at org.springframework.web.filter.OncePerRequestFilter.doFilter(OncePerRequestFilter.java:76)
    at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:235)
    at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:206)
    at org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:233)
    at org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:191)
    at org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:128)
    at org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:102)
    at org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:109)
    at org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:286)
    at org.apache.coyote.http11.Http11Processor.process(Http11Processor.java:845)
    at org.apache.coyote.http11.Http11Protocol$Http11ConnectionHandler.process(Http11Protocol.java:583)
    at org.apache.tomcat.util.net.JIoEndpoint$Worker.run(JIoEndpoint.java:447)
    at java.lang.Thread.run(Thread.java:619)
---- 8&lt; ------------------------------------------------------</pre>
<p>I searched and searched through google and internet, found nothing that could fix this issue.<br />
I finally found the silly bug : pretty improbable, but true:<br />
The targetNamespace annotations for my endpoint (interface) and implementation class were different. This can not be, so I simply made them same and it all worked like cake-walk! <img src='http://s0.wp.com/wp-includes/images/smilies/icon_smile.gif' alt=':)' class='wp-smiley' /> </p>
<p>I am pasting the erred source below for all to see ( Don&#8217;t laugh <img src='http://s2.wp.com/wp-includes/images/smilies/icon_razz.gif' alt=':P' class='wp-smiley' />  )</p>
<p><strong>The Endpoint &gt;&gt;</strong></p>
<p><pre class="brush: java;">
/**
 * This class was generated by Apache CXF 2.1.1
 * Fri Apr 03 17:22:14 IST 2009
 * Generated source version: 2.1.1
 *
 */

@WebService(targetNamespace = &quot;http://prediction.simplesoft.org/ws&quot;, name = &quot;PredictionPortType&quot;)
@XmlSeeAlso({org.simplesoft.prediction._2009.xsd.ObjectFactory.class})
@SOAPBinding(parameterStyle = SOAPBinding.ParameterStyle.BARE)
public interface PredictionPortType {

// And the rest of class definition ...
// ...
// ...
</pre></p>
<p><strong>The Implementation &gt;&gt;</strong></p>
<p><pre class="brush: java;">
@WebService(serviceName = &quot;PredictionService&quot;, portName = &quot;PredictionPort&quot;,
targetNamespace = &quot;http://prediction.simplesoft.org/2009/xsd&quot;, /*namespace is wrong, i.e, different from endpoint*/
endpointInterface = &quot;org.simplesoft.prediction.ws.PredictionPortType&quot;)
public class PredictionServiceImpl implements PredictionPortType {

// And the rest of class definition ...
// ...
// ...
</pre></p>
<br />  <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gocomments/amitcodes.wordpress.com/38/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/comments/amitcodes.wordpress.com/38/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godelicious/amitcodes.wordpress.com/38/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/delicious/amitcodes.wordpress.com/38/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gofacebook/amitcodes.wordpress.com/38/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/facebook/amitcodes.wordpress.com/38/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gotwitter/amitcodes.wordpress.com/38/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/twitter/amitcodes.wordpress.com/38/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gostumble/amitcodes.wordpress.com/38/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/stumble/amitcodes.wordpress.com/38/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godigg/amitcodes.wordpress.com/38/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/digg/amitcodes.wordpress.com/38/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/goreddit/amitcodes.wordpress.com/38/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/reddit/amitcodes.wordpress.com/38/" /></a> <img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=amitcodes.wordpress.com&amp;blog=4944087&amp;post=38&amp;subd=amitcodes&amp;ref=&amp;feed=1" width="1" height="1" />]]></content:encoded>
			<wfw:commentRss>http://amitcodes.wordpress.com/2009/04/08/wsdlexception-faultcodeother_error-cant-find-prefix/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
	
		<media:content url="http://0.gravatar.com/avatar/c53ec4f8cae62ce7905180cb3071368a?s=96&#38;d=identicon&#38;r=G" medium="image">
			<media:title type="html">amitcodes</media:title>
		</media:content>
	</item>
		<item>
		<title>sendmail jumpstart</title>
		<link>http://amitcodes.wordpress.com/2008/10/02/sendmail-jumpstart/</link>
		<comments>http://amitcodes.wordpress.com/2008/10/02/sendmail-jumpstart/#comments</comments>
		<pubDate>Thu, 02 Oct 2008 21:17:03 +0000</pubDate>
		<dc:creator>amitcodes</dc:creator>
				<category><![CDATA[How To]]></category>
		<category><![CDATA[sendmail linux email command-line]]></category>

		<guid isPermaLink="false">http://amitcodes.wordpress.com/?p=21</guid>
		<description><![CDATA[This little tutorial tells you how to send email using a server on which sendmail is installed. STEP 1: telnet to mail server telnet mail.example.net 25 STEP 2: Type the text starting with &#8216;#&#8216; [without # ofcourse ] when you see the following and press Enter 220 local ESMTP Sendmail 8.13.5/8.13.5; Wed, 15 Mar 2006 [...]<img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=amitcodes.wordpress.com&amp;blog=4944087&amp;post=21&amp;subd=amitcodes&amp;ref=&amp;feed=1" width="1" height="1" />]]></description>
			<content:encoded><![CDATA[<p>This little tutorial tells you how to send email using a server on which sendmail is installed.<br />
<strong><br />
STEP 1:</strong> telnet to mail server</p>
<pre>telnet mail.example.net 25</pre>
<p><strong>STEP 2:</strong> Type the text starting with &#8216;<strong>#</strong>&#8216; [without # ofcourse ] when you see the following and press Enter</p>
<pre style="padding-left:30px;">220 local ESMTP Sendmail 8.13.5/8.13.5; Wed, 15 Mar 2006 01:51:21 -0800 (PST)
<strong>#HELO host.example.com</strong>
250 mail.example.net Hello host.example.com [192.0.2.1], pleased to meet you
<strong>#MAIL FROM:&lt;user@example.com&gt;</strong>
250 2.1.0 &lt;user@example.com&gt;... Sender ok
<strong>#RCPT TO:&lt;postmaster@example.net&gt;</strong>
250 2.1.5 &lt;postmaster@example.net&gt;... Recipient ok
<strong>#DATA</strong>
354 Enter mail, end with "." on a line by itself
<strong>#This is a test message</strong>
<strong>#.</strong>
250 2.0.0 k2FApLlB020139 Message accepted for delivery
<strong>#QUIT</strong>
221 2.0.0 mail.example.net closing connection</pre>
<p><strong>Step 3: </strong>Check status<br />
Sendmail uses the mail facility of syslog for logging. The mail log is usually written to /var/log/maillog. You can test the status by tailing the log file.</p>
<p>Simple <img src='http://s0.wp.com/wp-includes/images/smilies/icon_smile.gif' alt=':)' class='wp-smiley' /> </p>
<br />  <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gocomments/amitcodes.wordpress.com/21/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/comments/amitcodes.wordpress.com/21/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godelicious/amitcodes.wordpress.com/21/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/delicious/amitcodes.wordpress.com/21/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gofacebook/amitcodes.wordpress.com/21/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/facebook/amitcodes.wordpress.com/21/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gotwitter/amitcodes.wordpress.com/21/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/twitter/amitcodes.wordpress.com/21/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gostumble/amitcodes.wordpress.com/21/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/stumble/amitcodes.wordpress.com/21/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godigg/amitcodes.wordpress.com/21/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/digg/amitcodes.wordpress.com/21/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/goreddit/amitcodes.wordpress.com/21/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/reddit/amitcodes.wordpress.com/21/" /></a> <img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=amitcodes.wordpress.com&amp;blog=4944087&amp;post=21&amp;subd=amitcodes&amp;ref=&amp;feed=1" width="1" height="1" />]]></content:encoded>
			<wfw:commentRss>http://amitcodes.wordpress.com/2008/10/02/sendmail-jumpstart/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
	
		<media:content url="http://0.gravatar.com/avatar/c53ec4f8cae62ce7905180cb3071368a?s=96&#38;d=identicon&#38;r=G" medium="image">
			<media:title type="html">amitcodes</media:title>
		</media:content>
	</item>
		<item>
		<title>Hello world!</title>
		<link>http://amitcodes.wordpress.com/2008/09/22/hello-world/</link>
		<comments>http://amitcodes.wordpress.com/2008/09/22/hello-world/#comments</comments>
		<pubDate>Mon, 22 Sep 2008 21:20:42 +0000</pubDate>
		<dc:creator>amitcodes</dc:creator>
				<category><![CDATA[Uncategorized]]></category>

		<guid isPermaLink="false"></guid>
		<description><![CDATA[<img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=amitcodes.wordpress.com&amp;blog=4944087&amp;post=1&amp;subd=amitcodes&amp;ref=&amp;feed=1" width="1" height="1" />]]></description>
			<content:encoded><![CDATA[<p><pre class="brush: java;">

public class Hello {
    public static void main ( String[] args ) {
        System.out.println(&quot;Hello World :)&quot;);
    }
}

</pre></p>
<br />  <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gocomments/amitcodes.wordpress.com/1/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/comments/amitcodes.wordpress.com/1/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godelicious/amitcodes.wordpress.com/1/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/delicious/amitcodes.wordpress.com/1/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gofacebook/amitcodes.wordpress.com/1/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/facebook/amitcodes.wordpress.com/1/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gotwitter/amitcodes.wordpress.com/1/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/twitter/amitcodes.wordpress.com/1/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gostumble/amitcodes.wordpress.com/1/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/stumble/amitcodes.wordpress.com/1/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godigg/amitcodes.wordpress.com/1/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/digg/amitcodes.wordpress.com/1/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/goreddit/amitcodes.wordpress.com/1/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/reddit/amitcodes.wordpress.com/1/" /></a> <img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=amitcodes.wordpress.com&amp;blog=4944087&amp;post=1&amp;subd=amitcodes&amp;ref=&amp;feed=1" width="1" height="1" />]]></content:encoded>
			<wfw:commentRss>http://amitcodes.wordpress.com/2008/09/22/hello-world/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
	
		<media:content url="http://0.gravatar.com/avatar/c53ec4f8cae62ce7905180cb3071368a?s=96&#38;d=identicon&#38;r=G" medium="image">
			<media:title type="html">amitcodes</media:title>
		</media:content>
	</item>
		<item>
		<title>Are static methods safe to be invoked by multiple threads simultaneously ?</title>
		<link>http://amitcodes.wordpress.com/2008/08/10/18/</link>
		<comments>http://amitcodes.wordpress.com/2008/08/10/18/#comments</comments>
		<pubDate>Sun, 10 Aug 2008 15:01:00 +0000</pubDate>
		<dc:creator>amitcodes</dc:creator>
				<category><![CDATA[Programming Problems]]></category>

		<guid isPermaLink="false">http://amitcodes.wordpress.com/2008/08/10/18/</guid>
		<description><![CDATA[Are static methods safe to be invoked by multiple threads simultaneously ? Ok. So it goes like this. Picture this : the instruction sequence for a method is stored in memory the calling method stores data (arguments) at a particular memory location instruction counter starts executing instructions for the given method on parameter data and [...]<img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=amitcodes.wordpress.com&amp;blog=4944087&amp;post=18&amp;subd=amitcodes&amp;ref=&amp;feed=1" width="1" height="1" />]]></description>
			<content:encoded><![CDATA[<p><span style="font-size:130%;"><strong>Are static methods safe to be invoked by multiple threads simultaneously ?</strong></span><br />
Ok. So it goes like this. Picture this :</p>
<ul>
<li>the instruction sequence for a method is stored in memory</li>
<li>the calling method stores data (arguments) at a particular memory location</li>
<li>instruction counter starts executing instructions for the given method on parameter data and storing results</li>
<li>when end of method instructions is reached,  result is returned and the parameter data is cleared.</li>
</ul>
<p>Now of in this process, the called method does not store the resulting value at a memory location  which will not be cleared after the instruction sequence is completed then this method can be accessed  by multiple threads at the same time without any problem.  This can be so because each thread comes with it&#8217;s own data and these instructions are executed on  the given data.   This can be be true for both &#8211; instance methods as well as static methods.   <strong></strong></p>
<p><strong>Can Data Access Objects be Singleton ? If so, when ?</strong><br />
DAOs can be singleton <span style="text-decoration:underline;"><em><strong>provided</strong></em></span> none of the methods store state in any way.  All the methods of the DAOs should just :</p>
<ul>
<li>take data</li>
<li>execute set of instructions</li>
<li>return the result</li>
</ul>
<p>If so happens &#8211; even the following scenario will not result in a dicey result :</p>
<ul>
<li>Thread A calls method X to insert a record in database and at the same time</li>
<li>Thread B also calls method X for the same operation.</li>
<li>What happens in such a case is &#8211; two different database connections try to insert data into database. Which is same as calling the same method on two different instances of the  given DAO class.</li>
<li>In fact &#8211; it&#8217;s safer to use singleton DAOs in case of server applications  where 1000 users trying to query database may result in 1000 DAO objects  which is not a very elegant design!</li>
</ul>
<br /><img alt="" border="0" src="http://feeds.wordpress.com/1.0/categories/amitcodes.wordpress.com/18/" /> <img alt="" border="0" src="http://feeds.wordpress.com/1.0/tags/amitcodes.wordpress.com/18/" /> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gocomments/amitcodes.wordpress.com/18/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/comments/amitcodes.wordpress.com/18/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godelicious/amitcodes.wordpress.com/18/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/delicious/amitcodes.wordpress.com/18/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gofacebook/amitcodes.wordpress.com/18/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/facebook/amitcodes.wordpress.com/18/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gotwitter/amitcodes.wordpress.com/18/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/twitter/amitcodes.wordpress.com/18/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gostumble/amitcodes.wordpress.com/18/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/stumble/amitcodes.wordpress.com/18/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godigg/amitcodes.wordpress.com/18/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/digg/amitcodes.wordpress.com/18/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/goreddit/amitcodes.wordpress.com/18/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/reddit/amitcodes.wordpress.com/18/" /></a> <img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=amitcodes.wordpress.com&amp;blog=4944087&amp;post=18&amp;subd=amitcodes&amp;ref=&amp;feed=1" width="1" height="1" />]]></content:encoded>
			<wfw:commentRss>http://amitcodes.wordpress.com/2008/08/10/18/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
	
		<media:content url="http://0.gravatar.com/avatar/c53ec4f8cae62ce7905180cb3071368a?s=96&#38;d=identicon&#38;r=G" medium="image">
			<media:title type="html">amitcodes</media:title>
		</media:content>
	</item>
		<item>
		<title>Are static methods safe to be invoked by multiple threads simultaneously ?</title>
		<link>http://amitcodes.wordpress.com/2008/08/10/17/</link>
		<comments>http://amitcodes.wordpress.com/2008/08/10/17/#comments</comments>
		<pubDate>Sun, 10 Aug 2008 15:01:00 +0000</pubDate>
		<dc:creator>amitcodes</dc:creator>
				<category><![CDATA[Programming Problems]]></category>

		<guid isPermaLink="false">http://amitcodes.wordpress.com/2008/08/10/17/</guid>
		<description><![CDATA[Are static methods safe to be invoked by multiple threads simultaneously ? Ok. So it goes like this. Picture this : the instruction sequence for a method is stored in memory the calling method stores data (arguments) at a particular memory location instruction counter starts executing instructions for the given method on parameter data and [...]<img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=amitcodes.wordpress.com&amp;blog=4944087&amp;post=17&amp;subd=amitcodes&amp;ref=&amp;feed=1" width="1" height="1" />]]></description>
			<content:encoded><![CDATA[<p><span style="font-size:130%;"><strong>Are static methods safe to be invoked by multiple threads simultaneously ?</strong></span></p>
<p>Ok. So it goes like this. Picture this :</p>
<ul>
<li>the instruction sequence for a method is stored in memory</li>
<li>the calling method stores data (arguments) at a particular memory location</li>
<li>instruction counter starts executing instructions for the given method on parameter data<br />
and storing results</li>
<li>when end of method instructions is reached,<br />
result is returned and the parameter data is cleared.</li>
</ul>
<p>Now of in this process, the called method does not store the resulting value at a memory location<br />
which will not be cleared after the instruction sequence is completed then this method can be accessed<br />
by multiple threads at the same time without any problem.</p>
<p>This can be so because each thread comes with it&#8217;s own data and these ins6tructions are executed on<br />
the given data.</p>
<p>This can be be true for both &#8211; instance methods as well as static methods.</p>
<p><strong>Can Data Access Objects be Singleton ? If so, when ?</strong></p>
<p>DAOs can be singleton <span style="text-decoration:underline;"><em><strong>provided</strong></em></span> none of the methods store state in any way.<br />
All the methods of the DAOs should just :</p>
<ul>
<li>take data</li>
<li>execute set of instructions</li>
<li>return the result</li>
</ul>
<p>If so happens &#8211; even the following scenario will not result in a dicey result :<br />
Thread A calls method X to insert a record in database and at the same time<br />
Thread B also calls method X for the same operation.<br />
What happens in such a case is &#8211; two different database connections try to<br />
insert data into database.<br />
Which is same as calling the same method on two different instances of the<br />
given DAO class.</p>
<p>In fact &#8211; it&#8217;s safer to use singleton DAOs in case of server applications<br />
where 1000 users trying to query database may result in 1000 DAO objects<br />
which is not a very elegant design!</p>
<br /><img alt="" border="0" src="http://feeds.wordpress.com/1.0/categories/amitcodes.wordpress.com/17/" /> <img alt="" border="0" src="http://feeds.wordpress.com/1.0/tags/amitcodes.wordpress.com/17/" /> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gocomments/amitcodes.wordpress.com/17/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/comments/amitcodes.wordpress.com/17/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godelicious/amitcodes.wordpress.com/17/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/delicious/amitcodes.wordpress.com/17/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gofacebook/amitcodes.wordpress.com/17/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/facebook/amitcodes.wordpress.com/17/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gotwitter/amitcodes.wordpress.com/17/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/twitter/amitcodes.wordpress.com/17/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gostumble/amitcodes.wordpress.com/17/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/stumble/amitcodes.wordpress.com/17/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godigg/amitcodes.wordpress.com/17/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/digg/amitcodes.wordpress.com/17/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/goreddit/amitcodes.wordpress.com/17/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/reddit/amitcodes.wordpress.com/17/" /></a> <img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=amitcodes.wordpress.com&amp;blog=4944087&amp;post=17&amp;subd=amitcodes&amp;ref=&amp;feed=1" width="1" height="1" />]]></content:encoded>
			<wfw:commentRss>http://amitcodes.wordpress.com/2008/08/10/17/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
	
		<media:content url="http://0.gravatar.com/avatar/c53ec4f8cae62ce7905180cb3071368a?s=96&#38;d=identicon&#38;r=G" medium="image">
			<media:title type="html">amitcodes</media:title>
		</media:content>
	</item>
		<item>
		<title>MySQL, Hibernate and Broken Pipe Exception</title>
		<link>http://amitcodes.wordpress.com/2008/07/26/16/</link>
		<comments>http://amitcodes.wordpress.com/2008/07/26/16/#comments</comments>
		<pubDate>Sat, 26 Jul 2008 21:30:00 +0000</pubDate>
		<dc:creator>amitcodes</dc:creator>
				<category><![CDATA[Java]]></category>
		<category><![CDATA[MySQL]]></category>

		<guid isPermaLink="false">http://amitcodes.wordpress.com/2008/07/26/16/</guid>
		<description><![CDATA[I was using Hibernate with Apache Tomcat and MySQL with apache-commons-dbcp for a web application I was developping recently and I used to get this annoying `java.net.SocketException: Broken pipe` after about 8 hours of usage. I tried the following quick fixes: sessions were closed (which acually were) ensuring that the mysql connection url had autoreconnect=true [...]<img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=amitcodes.wordpress.com&amp;blog=4944087&amp;post=16&amp;subd=amitcodes&amp;ref=&amp;feed=1" width="1" height="1" />]]></description>
			<content:encoded><![CDATA[<p>I was using Hibernate with Apache Tomcat and MySQL with apache-commons-dbcp for a web application I was developping recently and I used to get this annoying `<span style="font-family:courier new;">java.net.SocketException: Broken pipe</span>` after about 8 hours of usage. I tried the following quick fixes:</p>
<ul>
<li> sessions were closed (which acually were)</li>
<li>ensuring that the mysql connection url had <span style="font-family:courier new;">autoreconnect=true</span> attribute</li>
</ul>
<p>But none of it fixed the issue. Finally after searching for a while on internet i found out the cause and here it is.</p>
<p><span style="font-weight:bold;">Cause:</span> MySQL server has a default timeout period after which it terminates the idle connections. This period is 8 hours by default. Now here&#8217;s what happens. The dbcp creates a set of connections to database when the servlet container / application server starts up. If the connections are not used for the tinmeout period, the MySQL server assumes these to be dead connections and terminates them. The dbcp, however, is unaware of the fact that the connections have been terminated. So when a connection is demended from the connection-pool, these dead connections are returned and when a call is made on these dead connections &#8211; *BOOM* &#8211; you the java.net.SocketException: Broken pipe exception. Ok &#8211; so what&#8217;s the fix ??</p>
<p><span style="font-weight:bold;">Fix:</span> If only the connection pool could check if the the connection it is about to return is live or not, the porblem is fixed. This can be done in apache-common-dbcp (I know this one coz I used it, please look into documentation of the connection-pool you are using). Here&#8217;s how you do it: You add the following properties to dbcp configuration.</p>
<ul>
<li> validationQuery=&#8221;SELECT 1&#8243;</li>
<li> testOnBorrow=&#8221;true&#8221;</li>
</ul>
<p>And that does the trick.</p>
<p><span style="font-weight:bold;">How it works:</span></p>
<ul>
<li>Before returning the connection from pool to the application, dbcp runs the &#8220;<span style="font-family:courier new;">SELECT 1 </span>&#8221; query on the connection to see it it is still live. That&#8217;s the job of <span style="font-family:courier new;">validationQuery</span>.</li>
<li>As for <span style="font-family:courier new;">testOnBorrow</span>, you tell dbcp to perform the check before returning the connection to application.</li>
</ul>
<p>For more details refer to the apache-common-dbcp configuration manual <a href="http://commons.apache.org/dbcp/configuration.html">here</a>. <span style="font-style:italic;">The apache-commons-dbcp config:</span></p>
<p><pre class="brush: xml;">
&lt;Resource   name=&quot;jdbc/cooldatabase&quot;
			description=&quot;Strandls.com license database&quot;
			auth=&quot;Container&quot;
			type=&quot;javax.sql.DataSource&quot;
			factory=&quot;org.apache.tomcat.dbcp.dbcp.BasicDataSourceFactory&quot;
			driverClassName=&quot;com.mysql.jdbc.Driver&quot;
			url=&quot;jdbc:mysql://localhost:3306/cooldatabase?autoReconnect=true&quot;
			username=&quot;cooluser&quot;
			password=&quot;coolpassword&quot;
			initialSize=&quot;0&quot;
			maxActive=&quot;20&quot;
			maxIdle=&quot;10&quot;
			minIdle=&quot;0&quot;
			maxWait=&quot;-1&quot;
			validationQuery=&quot;SELECT 1&quot;
			testOnBorrow=&quot;true&quot;
			poolPreparedStatements=&quot;true&quot;
			removeAbandoned=&quot;true&quot;
			removeAbandonedTimeout=&quot;60&quot;
			logAbandoned=&quot;true&quot;/&gt;
</pre></p>
<p><span style="font-style:italic;">The complete stacktrace:</span></p>
<pre>
<pre>[ERROR] 12:27 (JDBCExceptionReporter.java:logExceptions:78)Communications link failure due to underlying exception:

** BEGIN NESTED EXCEPTION **

java.net.SocketExceptionMESSAGE: Broken pipe

STACKTRACE:
java.net.SocketException: Broken pipeat
java.net.SocketOutputStream.socketWrite0(Native Method)
at java.net.SocketOutputStream.socketWrite(SocketOutputStream.java:92)
at java.net.SocketOutputStream.write(SocketOutputStream.java:136)
at java.io.BufferedOutputStream.flushBuffer(BufferedOutputStream.java:65)
at java.io.BufferedOutputStream.flush(BufferedOutputStream.java:123)
at com.mysql.jdbc.MysqlIO.send(MysqlIO.java:2689)
at com.mysql.jdbc.MysqlIO.send(MysqlIO.java:2618)
at com.mysql.jdbc.MysqlIO.sendCommand(MysqlIO.java:1551).....</pre>
</pre>
<br /><img alt="" border="0" src="http://feeds.wordpress.com/1.0/categories/amitcodes.wordpress.com/16/" /> <img alt="" border="0" src="http://feeds.wordpress.com/1.0/tags/amitcodes.wordpress.com/16/" /> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gocomments/amitcodes.wordpress.com/16/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/comments/amitcodes.wordpress.com/16/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godelicious/amitcodes.wordpress.com/16/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/delicious/amitcodes.wordpress.com/16/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gofacebook/amitcodes.wordpress.com/16/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/facebook/amitcodes.wordpress.com/16/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gotwitter/amitcodes.wordpress.com/16/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/twitter/amitcodes.wordpress.com/16/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gostumble/amitcodes.wordpress.com/16/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/stumble/amitcodes.wordpress.com/16/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godigg/amitcodes.wordpress.com/16/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/digg/amitcodes.wordpress.com/16/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/goreddit/amitcodes.wordpress.com/16/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/reddit/amitcodes.wordpress.com/16/" /></a> <img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=amitcodes.wordpress.com&amp;blog=4944087&amp;post=16&amp;subd=amitcodes&amp;ref=&amp;feed=1" width="1" height="1" />]]></content:encoded>
			<wfw:commentRss>http://amitcodes.wordpress.com/2008/07/26/16/feed/</wfw:commentRss>
		<slash:comments>5</slash:comments>
	
		<media:content url="http://0.gravatar.com/avatar/c53ec4f8cae62ce7905180cb3071368a?s=96&#38;d=identicon&#38;r=G" medium="image">
			<media:title type="html">amitcodes</media:title>
		</media:content>
	</item>
		<item>
		<title>RDP On Linux</title>
		<link>http://amitcodes.wordpress.com/2008/04/11/15/</link>
		<comments>http://amitcodes.wordpress.com/2008/04/11/15/#comments</comments>
		<pubDate>Fri, 11 Apr 2008 07:33:00 +0000</pubDate>
		<dc:creator>amitcodes</dc:creator>
				<category><![CDATA[How To]]></category>
		<category><![CDATA[Linux]]></category>
		<category><![CDATA[debian]]></category>
		<category><![CDATA[rdp]]></category>
		<category><![CDATA[ubuntu]]></category>

		<guid isPermaLink="false">http://amitcodes.wordpress.com/2008/04/11/15/</guid>
		<description><![CDATA[RDP On Linux Ok &#8211; I may sound a little out-of-date but today i discovered the power of (remote desktop protocol) on debian based linux distro. So there&#8217;s this cool command line utility called `rdesktop` using which you can connect to any windows machine using Rmote Desktop Connection. I tried it and it worked smoothly [...]<img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=amitcodes.wordpress.com&amp;blog=4944087&amp;post=15&amp;subd=amitcodes&amp;ref=&amp;feed=1" width="1" height="1" />]]></description>
			<content:encoded><![CDATA[<div style="text-align:center;"><span style="font-size:180%;">RDP On Linux</span></div>
<p>Ok &#8211; I may sound a little out-of-date but today i discovered the power of (remote desktop protocol) on debian based linux distro.</p>
<p>So there&#8217;s this cool command line utility called `rdesktop` using which you can connect to any windows machine using Rmote Desktop Connection.</p>
<p>I tried it and it worked smoothly with Windows 2003 Server R2 with SP2, Windows XP SP2. The reaction time for a keyboard / mouse click response was pretty low. Enuff said &#8211; now lets get down to basics of using the same.</p>
<p><span style="font-weight:bold;">STEP 1:</span> Install rdesktop<br />
<span style="font-family:courier new;">$ sudo apt-get install rdesktop</span></p>
<p><span style="font-weight:bold;">STEP 2:</span> Connect to windows machine issuing the command<br />
<span style="font-family:courier new;">$ rdesktop -f foobox.mynetwork.com</span><br />
The `-f` option opens rdp connection in full-screen mode.  You can look out for more options by issuing the <span style="font-family:courier new;">`rdesktop &#8211;help`</span> command.</p>
<p><span style="font-weight:bold;">STEP 3:</span> To quit the session simply logout of the windows session.</p>
<p>I am posting a screenshot (rdesktop in non-fullscreen mode) for the world to see <img src='http://s0.wp.com/wp-includes/images/smilies/icon_smile.gif' alt=':)' class='wp-smiley' /><br />
<a href="http://bp2.blogger.com/_1UkdJjocoYU/R_8aO8LyW7I/AAAAAAAAAGM/KqDWkfFvqZ0/s1600-h/rdesktop-logon.png"><img style="display:block;text-align:center;cursor:pointer;margin:0 auto 10px;" src="http://bp2.blogger.com/_1UkdJjocoYU/R_8aO8LyW7I/AAAAAAAAAGM/KqDWkfFvqZ0/s320/rdesktop-logon.png" border="0" alt="" /></a><br />
<a href="http://bp0.blogger.com/_1UkdJjocoYU/R_8atcLyW8I/AAAAAAAAAGU/VNO1Toj31fA/s1600-h/rdesktop-sample.png"><img style="display:block;text-align:center;cursor:pointer;margin:0 auto 10px;" src="http://bp0.blogger.com/_1UkdJjocoYU/R_8atcLyW8I/AAAAAAAAAGU/VNO1Toj31fA/s320/rdesktop-sample.png" border="0" alt="" /></a></p>
<br /><img alt="" border="0" src="http://feeds.wordpress.com/1.0/categories/amitcodes.wordpress.com/15/" /> <img alt="" border="0" src="http://feeds.wordpress.com/1.0/tags/amitcodes.wordpress.com/15/" /> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gocomments/amitcodes.wordpress.com/15/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/comments/amitcodes.wordpress.com/15/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godelicious/amitcodes.wordpress.com/15/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/delicious/amitcodes.wordpress.com/15/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gofacebook/amitcodes.wordpress.com/15/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/facebook/amitcodes.wordpress.com/15/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gotwitter/amitcodes.wordpress.com/15/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/twitter/amitcodes.wordpress.com/15/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gostumble/amitcodes.wordpress.com/15/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/stumble/amitcodes.wordpress.com/15/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godigg/amitcodes.wordpress.com/15/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/digg/amitcodes.wordpress.com/15/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/goreddit/amitcodes.wordpress.com/15/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/reddit/amitcodes.wordpress.com/15/" /></a> <img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=amitcodes.wordpress.com&amp;blog=4944087&amp;post=15&amp;subd=amitcodes&amp;ref=&amp;feed=1" width="1" height="1" />]]></content:encoded>
			<wfw:commentRss>http://amitcodes.wordpress.com/2008/04/11/15/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
	
		<media:content url="http://0.gravatar.com/avatar/c53ec4f8cae62ce7905180cb3071368a?s=96&#38;d=identicon&#38;r=G" medium="image">
			<media:title type="html">amitcodes</media:title>
		</media:content>

		<media:content url="http://bp2.blogger.com/_1UkdJjocoYU/R_8aO8LyW7I/AAAAAAAAAGM/KqDWkfFvqZ0/s320/rdesktop-logon.png" medium="image" />

		<media:content url="http://bp0.blogger.com/_1UkdJjocoYU/R_8atcLyW8I/AAAAAAAAAGU/VNO1Toj31fA/s320/rdesktop-sample.png" medium="image" />
	</item>
		<item>
		<title>Stream Redirection Trips and Tricks</title>
		<link>http://amitcodes.wordpress.com/2007/12/05/14/</link>
		<comments>http://amitcodes.wordpress.com/2007/12/05/14/#comments</comments>
		<pubDate>Wed, 05 Dec 2007 11:34:00 +0000</pubDate>
		<dc:creator>amitcodes</dc:creator>
				<category><![CDATA[How To]]></category>
		<category><![CDATA[Linux]]></category>
		<category><![CDATA[redirection]]></category>

		<guid isPermaLink="false">http://amitcodes.wordpress.com/2007/12/05/14/</guid>
		<description><![CDATA[Stream Redirection Trips and Tricks Applies to : Linux shell scripting Picture this : You execute a command on console and you want to `append` the stderr and stdout to the same file. How do you do it ? Solution : $ {command} &#62;&#62; {logfile} 2&#62;&#38;1 Example : $ ls -xy &#62;&#62; silly.log 2&#62;&#38;1 Picture [...]<img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=amitcodes.wordpress.com&amp;blog=4944087&amp;post=14&amp;subd=amitcodes&amp;ref=&amp;feed=1" width="1" height="1" />]]></description>
			<content:encoded><![CDATA[<div style="text-align:center;"><span style="font-weight:bold;font-size:130%;">Stream Redirection Trips and Tricks</span></div>
<p><span style="font-weight:bold;"><br />
Applies to : </span>Linux shell scripting</p>
<p><span style="font-weight:bold;">Picture this : </span><br />
You execute a command on console and you want to <span style="font-weight:bold;font-style:italic;">`append`</span> the stderr and stdout to the same file.<br />
How do you do it ?</p>
<p><span style="font-weight:bold;">Solution : </span><br />
$ {command} &gt;&gt; {logfile} 2&gt;&amp;1<br />
<span style="font-weight:bold;">Example :</span><br />
$ ls -xy &gt;&gt; silly.log 2&gt;&amp;1</p>
<p><span style="font-weight:bold;">Picture This :</span><br />
Yet another interesting trick i learned was to create empty files in linux console. What the next command does is that it creates ampty file `silly.txt` if it does not exist, otherwise truncates the file if it already exists.</p>
<p><span style="font-weight:bold;">Solution :</span><br />
$ : &gt; {filename}<br />
<span style="font-weight:bold;">Example : </span><br />
$ : &gt; silly.txt</p>
<p><span style="font-weight:bold;">Picture This :</span> to simply redirect ( and *NOT* append ) stderr and stdout of a command to a log file, simply use the following :</p>
<p><span style="font-weight:bold;">Solution :</span><br />
$ {command} &amp;&gt; {logfile}</p>
<p><span style="font-weight:bold;">Example: </span><br />
$ ls -xy  &amp;&gt; silly.log</p>
<p>(this happens coz bash simply puts in the default values : 2 for stderr and 1 for stdout in the redirection above. `&amp;&gt;` is a simple shorthand for `2&gt;&amp;1`)</p>
<br /><img alt="" border="0" src="http://feeds.wordpress.com/1.0/categories/amitcodes.wordpress.com/14/" /> <img alt="" border="0" src="http://feeds.wordpress.com/1.0/tags/amitcodes.wordpress.com/14/" /> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gocomments/amitcodes.wordpress.com/14/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/comments/amitcodes.wordpress.com/14/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godelicious/amitcodes.wordpress.com/14/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/delicious/amitcodes.wordpress.com/14/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gofacebook/amitcodes.wordpress.com/14/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/facebook/amitcodes.wordpress.com/14/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gotwitter/amitcodes.wordpress.com/14/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/twitter/amitcodes.wordpress.com/14/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gostumble/amitcodes.wordpress.com/14/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/stumble/amitcodes.wordpress.com/14/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godigg/amitcodes.wordpress.com/14/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/digg/amitcodes.wordpress.com/14/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/goreddit/amitcodes.wordpress.com/14/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/reddit/amitcodes.wordpress.com/14/" /></a> <img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=amitcodes.wordpress.com&amp;blog=4944087&amp;post=14&amp;subd=amitcodes&amp;ref=&amp;feed=1" width="1" height="1" />]]></content:encoded>
			<wfw:commentRss>http://amitcodes.wordpress.com/2007/12/05/14/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
	
		<media:content url="http://0.gravatar.com/avatar/c53ec4f8cae62ce7905180cb3071368a?s=96&#38;d=identicon&#38;r=G" medium="image">
			<media:title type="html">amitcodes</media:title>
		</media:content>
	</item>
		<item>
		<title>Change Firefox Default Search Engine</title>
		<link>http://amitcodes.wordpress.com/2007/09/17/13/</link>
		<comments>http://amitcodes.wordpress.com/2007/09/17/13/#comments</comments>
		<pubDate>Mon, 17 Sep 2007 16:41:00 +0000</pubDate>
		<dc:creator>amitcodes</dc:creator>
				<category><![CDATA[How To]]></category>
		<category><![CDATA[default search engine]]></category>
		<category><![CDATA[firefox]]></category>
		<category><![CDATA[search]]></category>

		<guid isPermaLink="false">http://amitcodes.wordpress.com/2007/09/17/13/</guid>
		<description><![CDATA[Change Firefox Default Search Engine Ok &#8211; so some screwy toolbar screwed up your default search engine in Mozilla Firefox and when you perform a search using address bar &#8211; you go to some screwy search engine instead of google! Well, here is the solution : STEP 1: In the address bar type "about:config" (without [...]<img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=amitcodes.wordpress.com&amp;blog=4944087&amp;post=13&amp;subd=amitcodes&amp;ref=&amp;feed=1" width="1" height="1" />]]></description>
			<content:encoded><![CDATA[<div style="text-align:center;"><span style="font-size:180%;">Change Firefox Default Search Engine</span></p>
<div style="text-align:left;">Ok &#8211; so some screwy toolbar screwed up your default search engine in Mozilla Firefox and when you perform a search using address bar &#8211; you go to some screwy search engine instead of google!</p>
<p>Well, here is the solution :<br />
<code><br />
STEP 1:  In the address bar type "about:config" (without the quotes)<br />
STEP 2:  search for key "keyword.url" and double click to edit it<br />
STEP 3: change the value to "http://www.google.com/search?btnI=I%27m+Feeling+Lucky&amp;q="<br />
STEP 4: Click OK<br />
</code><br />
That&#8217;s all &#8211; you are done <img src='http://s0.wp.com/wp-includes/images/smilies/icon_smile.gif' alt=':)' class='wp-smiley' /> </div>
</div>
<br /><img alt="" border="0" src="http://feeds.wordpress.com/1.0/categories/amitcodes.wordpress.com/13/" /> <img alt="" border="0" src="http://feeds.wordpress.com/1.0/tags/amitcodes.wordpress.com/13/" /> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gocomments/amitcodes.wordpress.com/13/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/comments/amitcodes.wordpress.com/13/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godelicious/amitcodes.wordpress.com/13/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/delicious/amitcodes.wordpress.com/13/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gofacebook/amitcodes.wordpress.com/13/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/facebook/amitcodes.wordpress.com/13/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gotwitter/amitcodes.wordpress.com/13/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/twitter/amitcodes.wordpress.com/13/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gostumble/amitcodes.wordpress.com/13/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/stumble/amitcodes.wordpress.com/13/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godigg/amitcodes.wordpress.com/13/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/digg/amitcodes.wordpress.com/13/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/goreddit/amitcodes.wordpress.com/13/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/reddit/amitcodes.wordpress.com/13/" /></a> <img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=amitcodes.wordpress.com&amp;blog=4944087&amp;post=13&amp;subd=amitcodes&amp;ref=&amp;feed=1" width="1" height="1" />]]></content:encoded>
			<wfw:commentRss>http://amitcodes.wordpress.com/2007/09/17/13/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
	
		<media:content url="http://0.gravatar.com/avatar/c53ec4f8cae62ce7905180cb3071368a?s=96&#38;d=identicon&#38;r=G" medium="image">
			<media:title type="html">amitcodes</media:title>
		</media:content>
	</item>
		<item>
		<title>Ubuntu : Slow Application Startups</title>
		<link>http://amitcodes.wordpress.com/2007/09/13/12/</link>
		<comments>http://amitcodes.wordpress.com/2007/09/13/12/#comments</comments>
		<pubDate>Thu, 13 Sep 2007 10:42:00 +0000</pubDate>
		<dc:creator>amitcodes</dc:creator>
				<category><![CDATA[How To]]></category>
		<category><![CDATA[Linux]]></category>
		<category><![CDATA[slow startup]]></category>
		<category><![CDATA[ubuntu]]></category>
		<category><![CDATA[X11]]></category>

		<guid isPermaLink="false">http://amitcodes.wordpress.com/2007/09/13/12/</guid>
		<description><![CDATA[Ubuntu : Slow Application Startups Symptoms : Applications take too much time to start up &#8211; like gnome-terminal takes 15-20 seconds to start up. Fix : STEP 1 : edit /etc/hosts file STEP 2 : make sure the following two are the first 2 lines : ## &#8212; start &#8211; 127.0.0.1 localhost 127.0.1.1 {your-host-name} ## [...]<img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=amitcodes.wordpress.com&amp;blog=4944087&amp;post=12&amp;subd=amitcodes&amp;ref=&amp;feed=1" width="1" height="1" />]]></description>
			<content:encoded><![CDATA[<div style="text-align:center;"><span style="font-size:130%;"><span style="font-family:courier new;font-weight:bold;">Ubuntu : Slow Application Startups</span></span></div>
<p><span style="font-family:courier new;"><span style="font-weight:bold;">Symptoms :</span> Applications take too much time to start up &#8211; like gnome-terminal takes 15-20 seconds to start up. </span></p>
<p><span style="font-family:courier new;"><span style="font-weight:bold;">Fix : </span><br />
<code><br />
STEP 1 : edit /etc/hosts file</code></span></p>
<p>STEP 2 : make sure the following two are the first 2 lines :</p>
<p>## &#8212; start &#8211;<br />
127.0.0.1  localhost<br />
127.0.1.1  {your-host-name}<br />
## &#8212; end &#8211;</p>
<p>STEP 3 : restart network service</p>
<p>/etc/init.d/networking restart</p>
<p><span style="font-weight:bold;">Reason :</span> This way the window manager can quickly connect to the X server (without having to timeout a non-existent connection) and things are cool. (thanks <span class="normal"><a href="http://ubuntuforums.org/member.php?u=195110">lavazza</a> </span>)</p>
<p>This solution was found <a href="http://ubuntuforums.org/showthread.php?t=296625">here</a></p>
<br /><img alt="" border="0" src="http://feeds.wordpress.com/1.0/categories/amitcodes.wordpress.com/12/" /> <img alt="" border="0" src="http://feeds.wordpress.com/1.0/tags/amitcodes.wordpress.com/12/" /> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gocomments/amitcodes.wordpress.com/12/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/comments/amitcodes.wordpress.com/12/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godelicious/amitcodes.wordpress.com/12/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/delicious/amitcodes.wordpress.com/12/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gofacebook/amitcodes.wordpress.com/12/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/facebook/amitcodes.wordpress.com/12/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gotwitter/amitcodes.wordpress.com/12/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/twitter/amitcodes.wordpress.com/12/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gostumble/amitcodes.wordpress.com/12/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/stumble/amitcodes.wordpress.com/12/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godigg/amitcodes.wordpress.com/12/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/digg/amitcodes.wordpress.com/12/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/goreddit/amitcodes.wordpress.com/12/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/reddit/amitcodes.wordpress.com/12/" /></a> <img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=amitcodes.wordpress.com&amp;blog=4944087&amp;post=12&amp;subd=amitcodes&amp;ref=&amp;feed=1" width="1" height="1" />]]></content:encoded>
			<wfw:commentRss>http://amitcodes.wordpress.com/2007/09/13/12/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
	
		<media:content url="http://0.gravatar.com/avatar/c53ec4f8cae62ce7905180cb3071368a?s=96&#38;d=identicon&#38;r=G" medium="image">
			<media:title type="html">amitcodes</media:title>
		</media:content>
	</item>
		<item>
		<title>Bat Script To Add Files In Classpath For Java</title>
		<link>http://amitcodes.wordpress.com/2007/04/13/11/</link>
		<comments>http://amitcodes.wordpress.com/2007/04/13/11/#comments</comments>
		<pubDate>Fri, 13 Apr 2007 16:47:00 +0000</pubDate>
		<dc:creator>amitcodes</dc:creator>
				<category><![CDATA[Java]]></category>

		<guid isPermaLink="false">http://amitcodes.wordpress.com/2007/04/13/11/</guid>
		<description><![CDATA[Bat Script To Add Files In Classpath For Java Can you believe it? what takes just couple of lines in Linux, requires serious effort in dos! Seriously! Windiwows Sucks!! Anyways. Here is a script to add all files inside the lib directory to a variable %CLASSPATH% &#8212;&#8212;&#8212;&#8212; BEGIN SCRIPT &#8212;&#8212;&#8212;&#8212;- @ECHO OFF SET CLASSPATH=. FOR [...]<img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=amitcodes.wordpress.com&amp;blog=4944087&amp;post=11&amp;subd=amitcodes&amp;ref=&amp;feed=1" width="1" height="1" />]]></description>
			<content:encoded><![CDATA[<div style="text-align:center;"><span style="font-weight:bold;">Bat Script To Add Files In Classpath For Java</p>
<p></span></p>
<div style="text-align:left;">Can you believe it? what takes just couple of lines in Linux, requires serious effort in dos!<br />
Seriously! Windiwows Sucks!!<br />
Anyways. Here is a script to add all files inside the lib directory to a variable <span style="font-weight:bold;color:#ff6600;">%CLASSPATH%</span></div>
<div style="text-align:left;">&#8212;&#8212;&#8212;&#8212; BEGIN SCRIPT &#8212;&#8212;&#8212;&#8212;-</div>
<div style="text-align:left;"><span><span style="font-size:85%;"><span style="color:#3333ff;font-weight:bold;font-family:courier new;">@ECHO</span><span style="font-family:courier new;"> OFF<br />
</span><span style="font-weight:bold;color:#3333ff;font-family:courier new;">SET </span><span style="font-family:courier new;">CLASSPATH</span><span style="font-weight:bold;color:#cc66cc;font-family:courier new;"><span style="color:#ff0000;">=</span><span style="color:#000000;">.</span></span></p>
<p><span style="font-weight:bold;color:#3333ff;font-family:courier new;">FOR </span><span style="font-family:courier new;">/R lib </span><span style="font-weight:bold;color:#ff6600;font-family:courier new;">%%f</span><span style="font-family:courier new;"> in (</span><span style="color:#ff0000;font-family:courier new;">*</span><span style="font-family:courier new;">.jar) </span><span style="font-weight:bold;color:#3333ff;font-family:courier new;">do</span><span style="font-family:courier new;"> (<br />
</span><span style="font-family:courier new;"><span style="font-weight:bold;color:#3333ff;"> SET </span>jarfile<span style="font-weight:bold;color:#ff0000;">=</span></span><span style="font-weight:bold;color:#ff6600;font-family:courier new;">%%f<br />
</span><span style="font-family:courier new;"> <span style="font-weight:bold;color:#3333ff;"> CALL </span><span style="color:#3366ff;">:addToClasspath</span> <span style="font-weight:bold;color:#ff6600;">%jarfile%</span></span><span style="font-family:courier new;"><br />
)</span><span style="font-family:courier new;"><span style="font-weight:bold;color:#3333ff;"><br />
GOTO </span>done</span><br />
<span style="font-weight:bold;color:#ff0000;font-family:courier new;"><br />
:addToClasspath</span><span style="font-family:courier new;"><span style="font-weight:bold;color:#3333ff;"><br />
</span><span style="color:#000000;"><span style="font-weight:bold;color:#006600;">REM </span><span style="color:#006600;">&#8211; Make path dos compatible by knocking out spaces &#8211;</span><br />
<span style="font-weight:bold;color:#3333ff;">FOR </span><span style="font-weight:bold;color:#ff6600;">%%X</span><span style="color:#ff6600;"> </span><span style="font-weight:bold;color:#3333ff;">IN </span>(<span style="font-weight:bold;color:#ff6600;">%jarfile%</span>) <span style="font-weight:bold;color:#3333ff;">DO </span>(<br />
<span style="font-weight:bold;color:#3333ff;"> SET </span>jarFixPath<span style="font-weight:bold;color:#ff0000;">=</span><span style="font-weight:bold;color:#ff6600;">%%~sX</span><br />
)</span></span></p>
<p></span><span style="font-weight:bold;color:#006600;">REM </span><span style="color:#006600;">&#8211; Append to classpath &#8211;</span><span style="font-weight:bold;color:#3333ff;"><br />
SET </span>CLASSPATH<span style="font-weight:bold;color:#ff0000;">=</span><span style="font-weight:bold;color:#ff6600;">%CLASSPATH%</span>;<span style="font-weight:bold;color:#ff6600;">%~sXjarfile%</span></span><span style="font-family:courier new;"><span style="font-weight:bold;color:#3333ff;"><br />
GOTO </span>:EOF</span><br />
<span style="font-family:courier new;"><br />
<span style="font-weight:bold;color:#ff0000;">:done</span></span><span style="font-family:courier new;"><span style="font-weight:bold;color:#3333ff;"><br />
ECHO</span> <span style="font-weight:bold;color:#ff6600;">%CLASSPATH%</span></span><br />
<span style="font-weight:bold;"><br />
</span>&#8212;&#8212;&#8212;&#8212;&#8211; END SCRIPT &#8212;&#8212;&#8212;&#8212;&#8212;</div>
</div>
<br /><img alt="" border="0" src="http://feeds.wordpress.com/1.0/categories/amitcodes.wordpress.com/11/" /> <img alt="" border="0" src="http://feeds.wordpress.com/1.0/tags/amitcodes.wordpress.com/11/" /> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gocomments/amitcodes.wordpress.com/11/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/comments/amitcodes.wordpress.com/11/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godelicious/amitcodes.wordpress.com/11/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/delicious/amitcodes.wordpress.com/11/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gofacebook/amitcodes.wordpress.com/11/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/facebook/amitcodes.wordpress.com/11/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gotwitter/amitcodes.wordpress.com/11/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/twitter/amitcodes.wordpress.com/11/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gostumble/amitcodes.wordpress.com/11/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/stumble/amitcodes.wordpress.com/11/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godigg/amitcodes.wordpress.com/11/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/digg/amitcodes.wordpress.com/11/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/goreddit/amitcodes.wordpress.com/11/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/reddit/amitcodes.wordpress.com/11/" /></a> <img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=amitcodes.wordpress.com&amp;blog=4944087&amp;post=11&amp;subd=amitcodes&amp;ref=&amp;feed=1" width="1" height="1" />]]></content:encoded>
			<wfw:commentRss>http://amitcodes.wordpress.com/2007/04/13/11/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
	
		<media:content url="http://0.gravatar.com/avatar/c53ec4f8cae62ce7905180cb3071368a?s=96&#38;d=identicon&#38;r=G" medium="image">
			<media:title type="html">amitcodes</media:title>
		</media:content>
	</item>
		<item>
		<title>Delete All Empty Folders On Linux</title>
		<link>http://amitcodes.wordpress.com/2007/04/12/10/</link>
		<comments>http://amitcodes.wordpress.com/2007/04/12/10/#comments</comments>
		<pubDate>Thu, 12 Apr 2007 09:07:00 +0000</pubDate>
		<dc:creator>amitcodes</dc:creator>
				<category><![CDATA[How To]]></category>
		<category><![CDATA[Linux]]></category>

		<guid isPermaLink="false">http://amitcodes.wordpress.com/2007/04/12/10/</guid>
		<description><![CDATA[Delete All Empty Folders find -depth -type d -empty -exec rmdir {} \;<img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=amitcodes.wordpress.com&amp;blog=4944087&amp;post=10&amp;subd=amitcodes&amp;ref=&amp;feed=1" width="1" height="1" />]]></description>
			<content:encoded><![CDATA[<div style="text-align:center;"><span style="font-weight:bold;">Delete All Empty Folders</span></div>
<p><code><br />
<span style="font-family:courier new;color:#3333ff;">find -depth -type d -empty -exec rmdir {} \;</span></code></p>
<br /><img alt="" border="0" src="http://feeds.wordpress.com/1.0/categories/amitcodes.wordpress.com/10/" /> <img alt="" border="0" src="http://feeds.wordpress.com/1.0/tags/amitcodes.wordpress.com/10/" /> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gocomments/amitcodes.wordpress.com/10/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/comments/amitcodes.wordpress.com/10/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godelicious/amitcodes.wordpress.com/10/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/delicious/amitcodes.wordpress.com/10/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gofacebook/amitcodes.wordpress.com/10/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/facebook/amitcodes.wordpress.com/10/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gotwitter/amitcodes.wordpress.com/10/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/twitter/amitcodes.wordpress.com/10/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gostumble/amitcodes.wordpress.com/10/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/stumble/amitcodes.wordpress.com/10/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godigg/amitcodes.wordpress.com/10/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/digg/amitcodes.wordpress.com/10/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/goreddit/amitcodes.wordpress.com/10/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/reddit/amitcodes.wordpress.com/10/" /></a> <img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=amitcodes.wordpress.com&amp;blog=4944087&amp;post=10&amp;subd=amitcodes&amp;ref=&amp;feed=1" width="1" height="1" />]]></content:encoded>
			<wfw:commentRss>http://amitcodes.wordpress.com/2007/04/12/10/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
	
		<media:content url="http://0.gravatar.com/avatar/c53ec4f8cae62ce7905180cb3071368a?s=96&#38;d=identicon&#38;r=G" medium="image">
			<media:title type="html">amitcodes</media:title>
		</media:content>
	</item>
		<item>
		<title>METHOD TO CALCULATE SHA-1 DIGEST OF A STRING</title>
		<link>http://amitcodes.wordpress.com/2006/09/07/9/</link>
		<comments>http://amitcodes.wordpress.com/2006/09/07/9/#comments</comments>
		<pubDate>Thu, 07 Sep 2006 21:21:00 +0000</pubDate>
		<dc:creator>amitcodes</dc:creator>
				<category><![CDATA[Java]]></category>

		<guid isPermaLink="false">http://amitcodes.wordpress.com/2006/09/07/9/</guid>
		<description><![CDATA[METHOD TO CALCULATE SHA-1 DIGEST OF A STRING ---------START OF CODE---------- import java.io.UnsupportedEncodingException; import java.security.MessageDigest; import java.security.NoSuchAlgorithmException; /** * method to compute a SHA-1 message digest */ public class SHAHashCalculator { String calcSHA1Hash( String data ) throws UnsupportedEncodingException, NoSuchAlgorithmException { byte[] theTextToDigestAsBytes = data.getBytes( &#8220;8859_1&#8243; /* encoding */ ); MessageDigest md = MessageDigest.getInstance( &#8220;SHA&#8221; ); [...]<img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=amitcodes.wordpress.com&amp;blog=4944087&amp;post=9&amp;subd=amitcodes&amp;ref=&amp;feed=1" width="1" height="1" />]]></description>
			<content:encoded><![CDATA[<div style="text-align:center;"><span style="font-weight:bold;">METHOD TO CALCULATE SHA-1 DIGEST OF A STRING</span></div>
<p><code><br />
---------START OF CODE----------<br />
import java.io.UnsupportedEncodingException;<br />
import java.security.MessageDigest;<br />
import java.security.NoSuchAlgorithmException;</code></p>
<p>/**<br />
* method to compute a SHA-1 message digest<br />
*/<br />
public class SHAHashCalculator {</p>
<p>String calcSHA1Hash( String data )<br />
throws UnsupportedEncodingException, NoSuchAlgorithmException {</p>
<p>byte[] theTextToDigestAsBytes = data.getBytes( &#8220;8859_1&#8243; /* encoding */ );<br />
MessageDigest md = MessageDigest.getInstance( &#8220;SHA&#8221; );<br />
md.update( theTextToDigestAsBytes );<br />
byte[] digest = md.digest();</p>
<p>// should be 20 bytes, 160 bits long<br />
//System.out.println( digest.length );</p>
<p>// dump out the hash<br />
String shaHash = &#8220;&#8221;;<br />
for ( byte b : digest ) {<br />
shaHash = shaHash + Integer.toHexString( b &amp; 0xff ) ;<br />
}<br />
return shaHash;<br />
}<br />
}<br />
&#8212;&#8212;&#8212;END OF CODE&#8212;&#8212;&#8212;-</p>
<p>** Inspired from code by Roedy Green as seen on <a href="http://mindprod.com/jgloss/sha1.html">http://mindprod.com/jgloss/sha1.html </a>**</p>
<br /><img alt="" border="0" src="http://feeds.wordpress.com/1.0/categories/amitcodes.wordpress.com/9/" /> <img alt="" border="0" src="http://feeds.wordpress.com/1.0/tags/amitcodes.wordpress.com/9/" /> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gocomments/amitcodes.wordpress.com/9/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/comments/amitcodes.wordpress.com/9/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godelicious/amitcodes.wordpress.com/9/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/delicious/amitcodes.wordpress.com/9/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gofacebook/amitcodes.wordpress.com/9/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/facebook/amitcodes.wordpress.com/9/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gotwitter/amitcodes.wordpress.com/9/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/twitter/amitcodes.wordpress.com/9/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gostumble/amitcodes.wordpress.com/9/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/stumble/amitcodes.wordpress.com/9/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godigg/amitcodes.wordpress.com/9/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/digg/amitcodes.wordpress.com/9/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/goreddit/amitcodes.wordpress.com/9/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/reddit/amitcodes.wordpress.com/9/" /></a> <img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=amitcodes.wordpress.com&amp;blog=4944087&amp;post=9&amp;subd=amitcodes&amp;ref=&amp;feed=1" width="1" height="1" />]]></content:encoded>
			<wfw:commentRss>http://amitcodes.wordpress.com/2006/09/07/9/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
	
		<media:content url="http://0.gravatar.com/avatar/c53ec4f8cae62ce7905180cb3071368a?s=96&#38;d=identicon&#38;r=G" medium="image">
			<media:title type="html">amitcodes</media:title>
		</media:content>
	</item>
		<item>
		<title>How to change MySQL root password</title>
		<link>http://amitcodes.wordpress.com/2006/08/21/8/</link>
		<comments>http://amitcodes.wordpress.com/2006/08/21/8/#comments</comments>
		<pubDate>Mon, 21 Aug 2006 17:33:00 +0000</pubDate>
		<dc:creator>amitcodes</dc:creator>
				<category><![CDATA[How To]]></category>
		<category><![CDATA[MySQL]]></category>

		<guid isPermaLink="false">http://amitcodes.wordpress.com/2006/08/21/8/</guid>
		<description><![CDATA[Method to change MySQL root password root@u-1:/home/u-1# mysql -u root mysqlReading table information for completion of table and column namesYou can turn off this feature to get a quicker startup with -A Welcome to the MySQL monitor. Commands end with ; or g.Your MySQL connection id is 1 to server version: 3.23.47 Type 'help;' or [...]<img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=amitcodes.wordpress.com&amp;blog=4944087&amp;post=8&amp;subd=amitcodes&amp;ref=&amp;feed=1" width="1" height="1" />]]></description>
			<content:encoded><![CDATA[<div style="text-align:center;"><span style="font-family:arial;font-weight:bold;">Method to change MySQL root password</span></div>
<pre>root@u-1:/home/u-1# <strong>mysql -u root mysql</strong>Reading table information for completion of table and column namesYou can turn off this feature to get a quicker startup with -A

Welcome to the MySQL monitor.  Commands end with ; or g.Your MySQL connection id is 1 to server version: 3.23.47

Type 'help;' or 'h' for help. Type 'c' to clear the buffer.

mysql&gt; <strong>SET PASSWORD FOR root@localhost=PASSWORD('rubberchicken');</strong>Query OK, 0 rows affected (0.06 sec)

mysql&gt;</pre>
<br /><img alt="" border="0" src="http://feeds.wordpress.com/1.0/categories/amitcodes.wordpress.com/8/" /> <img alt="" border="0" src="http://feeds.wordpress.com/1.0/tags/amitcodes.wordpress.com/8/" /> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gocomments/amitcodes.wordpress.com/8/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/comments/amitcodes.wordpress.com/8/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godelicious/amitcodes.wordpress.com/8/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/delicious/amitcodes.wordpress.com/8/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gofacebook/amitcodes.wordpress.com/8/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/facebook/amitcodes.wordpress.com/8/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gotwitter/amitcodes.wordpress.com/8/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/twitter/amitcodes.wordpress.com/8/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gostumble/amitcodes.wordpress.com/8/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/stumble/amitcodes.wordpress.com/8/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godigg/amitcodes.wordpress.com/8/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/digg/amitcodes.wordpress.com/8/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/goreddit/amitcodes.wordpress.com/8/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/reddit/amitcodes.wordpress.com/8/" /></a> <img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=amitcodes.wordpress.com&amp;blog=4944087&amp;post=8&amp;subd=amitcodes&amp;ref=&amp;feed=1" width="1" height="1" />]]></content:encoded>
			<wfw:commentRss>http://amitcodes.wordpress.com/2006/08/21/8/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
	
		<media:content url="http://0.gravatar.com/avatar/c53ec4f8cae62ce7905180cb3071368a?s=96&#38;d=identicon&#38;r=G" medium="image">
			<media:title type="html">amitcodes</media:title>
		</media:content>
	</item>
		<item>
		<title>Convert WINDOWS format file (\r\n) to LINUX format file (\n)</title>
		<link>http://amitcodes.wordpress.com/2006/08/21/7/</link>
		<comments>http://amitcodes.wordpress.com/2006/08/21/7/#comments</comments>
		<pubDate>Mon, 21 Aug 2006 11:58:00 +0000</pubDate>
		<dc:creator>amitcodes</dc:creator>
				<category><![CDATA[How To]]></category>
		<category><![CDATA[Linux]]></category>

		<guid isPermaLink="false">http://amitcodes.wordpress.com/2006/08/21/7/</guid>
		<description><![CDATA[Convert WINDOWS format file (\r\n) to LINUX format file (\n) In cas you are stuck with a file created / modified in Windows and now you have to use it on Linux, here is the simplest way to do that. Open the file in vi / vim / gvim try the following command: To covert [...]<img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=amitcodes.wordpress.com&amp;blog=4944087&amp;post=7&amp;subd=amitcodes&amp;ref=&amp;feed=1" width="1" height="1" />]]></description>
			<content:encoded><![CDATA[<div style="text-align:center;"><span style="font-weight:bold;">Convert WINDOWS format file (\r\n) to LINUX format file (\n)</span></div>
<p>In cas you are stuck with a file created / modified in Windows and now you have to use it on Linux, here is the simplest way to do that.<br />
Open the file in <span style="font-weight:bold;font-style:italic;">vi / vim / gvim</span> try the following command:<br />
To covert to unix file format:<br />
<tt><span style="font-weight:bold;font-size:100%;">:set ff=unix </span></tt></p>
<p><tt></tt> To convert to windows format:<br />
<tt> :set ff=dos </tt></p>
<p><tt>Original source: <a href="http://www.vim.org/tips/tip.php?tip_id=26">http://www.vim.org/tips/tip.php?tip_id=26</a><br />
</tt></p>
<br /><img alt="" border="0" src="http://feeds.wordpress.com/1.0/categories/amitcodes.wordpress.com/7/" /> <img alt="" border="0" src="http://feeds.wordpress.com/1.0/tags/amitcodes.wordpress.com/7/" /> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gocomments/amitcodes.wordpress.com/7/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/comments/amitcodes.wordpress.com/7/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godelicious/amitcodes.wordpress.com/7/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/delicious/amitcodes.wordpress.com/7/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gofacebook/amitcodes.wordpress.com/7/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/facebook/amitcodes.wordpress.com/7/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gotwitter/amitcodes.wordpress.com/7/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/twitter/amitcodes.wordpress.com/7/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gostumble/amitcodes.wordpress.com/7/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/stumble/amitcodes.wordpress.com/7/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godigg/amitcodes.wordpress.com/7/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/digg/amitcodes.wordpress.com/7/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/goreddit/amitcodes.wordpress.com/7/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/reddit/amitcodes.wordpress.com/7/" /></a> <img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=amitcodes.wordpress.com&amp;blog=4944087&amp;post=7&amp;subd=amitcodes&amp;ref=&amp;feed=1" width="1" height="1" />]]></content:encoded>
			<wfw:commentRss>http://amitcodes.wordpress.com/2006/08/21/7/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
	
		<media:content url="http://0.gravatar.com/avatar/c53ec4f8cae62ce7905180cb3071368a?s=96&#38;d=identicon&#38;r=G" medium="image">
			<media:title type="html">amitcodes</media:title>
		</media:content>
	</item>
		<item>
		<title>Pepping up Cygwin</title>
		<link>http://amitcodes.wordpress.com/2006/08/18/6/</link>
		<comments>http://amitcodes.wordpress.com/2006/08/18/6/#comments</comments>
		<pubDate>Fri, 18 Aug 2006 20:17:00 +0000</pubDate>
		<dc:creator>amitcodes</dc:creator>
				<category><![CDATA[How To]]></category>

		<guid isPermaLink="false">http://amitcodes.wordpress.com/2006/08/18/6/</guid>
		<description><![CDATA[Pepping up Cygwin In case you cygwin console doesnot show file colors, pressing delet key prints &#8216;~&#8217; and the .bashrc file doesnot do what it should, please read ahead&#8230; In this little article we shall see how to i) Enable colour support on cygwin console ii) Enable ~/.bashrc so that you can customize the console [...]<img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=amitcodes.wordpress.com&amp;blog=4944087&amp;post=6&amp;subd=amitcodes&amp;ref=&amp;feed=1" width="1" height="1" />]]></description>
			<content:encoded><![CDATA[<div style="text-align:center;"><span style="font-weight:bold;font-size:130%;">Pepping up Cygwin </span></div>
<p>In case you cygwin console doesnot show<br />
file colors, pressing delet key prints &#8216;~&#8217;<br />
and the .bashrc file doesnot do what it<br />
should, please read ahead&#8230;</p>
<p>In this little article we shall see how to<br />
i) Enable colour support on cygwin console<br />
ii) Enable ~/.bashrc so that you can customize<br />
the console envoirnment.<br />
iii) Fix the Delete key</p>
<p>Copy files in /etc/skel to user home<br />
<span style="font-family:courier new;font-weight:bold;color:#666666;">$ cp /etc/skel/. ~</span></p>
<p>Edit ~/.bashrc and copy the following lines<br />
<span style="font-family:courier new;font-weight:bold;color:#666666;"> alias ls=&#8217;ls &#8211;color=tty&#8217;</span><br />
<span style="font-family:courier new;font-weight:bold;color:#666666;"> alias rm=&#8217;rm -i&#8217;</span></p>
<p>Yes that&#8217;s all to enable color, bashrc and<br />
delete key on cygwin <img src='http://s0.wp.com/wp-includes/images/smilies/icon_smile.gif' alt=':)' class='wp-smiley' /> </p>
<br /><img alt="" border="0" src="http://feeds.wordpress.com/1.0/categories/amitcodes.wordpress.com/6/" /> <img alt="" border="0" src="http://feeds.wordpress.com/1.0/tags/amitcodes.wordpress.com/6/" /> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gocomments/amitcodes.wordpress.com/6/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/comments/amitcodes.wordpress.com/6/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godelicious/amitcodes.wordpress.com/6/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/delicious/amitcodes.wordpress.com/6/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gofacebook/amitcodes.wordpress.com/6/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/facebook/amitcodes.wordpress.com/6/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gotwitter/amitcodes.wordpress.com/6/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/twitter/amitcodes.wordpress.com/6/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gostumble/amitcodes.wordpress.com/6/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/stumble/amitcodes.wordpress.com/6/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godigg/amitcodes.wordpress.com/6/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/digg/amitcodes.wordpress.com/6/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/goreddit/amitcodes.wordpress.com/6/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/reddit/amitcodes.wordpress.com/6/" /></a> <img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=amitcodes.wordpress.com&amp;blog=4944087&amp;post=6&amp;subd=amitcodes&amp;ref=&amp;feed=1" width="1" height="1" />]]></content:encoded>
			<wfw:commentRss>http://amitcodes.wordpress.com/2006/08/18/6/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
	
		<media:content url="http://0.gravatar.com/avatar/c53ec4f8cae62ce7905180cb3071368a?s=96&#38;d=identicon&#38;r=G" medium="image">
			<media:title type="html">amitcodes</media:title>
		</media:content>
	</item>
		<item>
		<title>Get rid of .SVN directories</title>
		<link>http://amitcodes.wordpress.com/2006/08/18/5/</link>
		<comments>http://amitcodes.wordpress.com/2006/08/18/5/#comments</comments>
		<pubDate>Fri, 18 Aug 2006 20:05:00 +0000</pubDate>
		<dc:creator>amitcodes</dc:creator>
				<category><![CDATA[How To]]></category>

		<guid isPermaLink="false">http://amitcodes.wordpress.com/2006/08/18/5/</guid>
		<description><![CDATA[a) Simplest way out: This is the simplest of all, simply use the svn export command. Suppose you want to check out a copy of tree src/ from SVN without those annoying .svn folders, simple issue the following command: $ svn export Example: $ svn co http://svn_server/rep/phantom/src ~/Export This will fetch you a neat copy [...]<img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=amitcodes.wordpress.com&amp;blog=4944087&amp;post=5&amp;subd=amitcodes&amp;ref=&amp;feed=1" width="1" height="1" />]]></description>
			<content:encoded><![CDATA[<p><span style="font-weight:bold;font-style:italic;">a) Simplest way out:</span><br />
This is the simplest of all, simply use the<br />
svn export command. Suppose you want to check<br />
out a copy of tree src/ from SVN without those<br />
annoying .svn folders, simple issue the<br />
following command:<br />
<span style="font-weight:bold;font-family:courier new;"> $ svn export </span></p>
<p>Example:<br />
<span style="color:#666666;font-weight:bold;font-family:courier new;">$ svn co http://svn_server/rep/phantom/src ~/Export</span></p>
<p>This will fetch you a neat copy of the src/ tree<br />
without .svn folder.</p>
<p><span style="font-weight:bold;font-style:italic;">b) Shell way out:</span><br />
Suppose in a series of unfortunate events you are<br />
left with a copy of a SVN branch which has<br />
recursive .svn folder <img src='http://s0.wp.com/wp-includes/images/smilies/icon_sad.gif' alt=':(' class='wp-smiley' /><br />
Here is a simple shell script to clean it up for<br />
you:</p>
<div style="text-align:center;">
<div style="text-align:left;"><span style="font-weight:bold;color:#666666;font-family:courier new;"> $ find </span><span style="font-weight:bold;color:#666666;font-family:courier new;">-type d -name .svn -exec rm -rfv {} \;</span></div>
</div>
<p>What this does is simply<br />
a) find all directories [type -d]<br />
b) whose name is .svn   [-name .svn]<br />
c) and execute rm -rf   [-exec rm -rf]<br />
d) on each result found [{} \;]</p>
<br /><img alt="" border="0" src="http://feeds.wordpress.com/1.0/categories/amitcodes.wordpress.com/5/" /> <img alt="" border="0" src="http://feeds.wordpress.com/1.0/tags/amitcodes.wordpress.com/5/" /> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gocomments/amitcodes.wordpress.com/5/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/comments/amitcodes.wordpress.com/5/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godelicious/amitcodes.wordpress.com/5/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/delicious/amitcodes.wordpress.com/5/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gofacebook/amitcodes.wordpress.com/5/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/facebook/amitcodes.wordpress.com/5/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gotwitter/amitcodes.wordpress.com/5/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/twitter/amitcodes.wordpress.com/5/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gostumble/amitcodes.wordpress.com/5/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/stumble/amitcodes.wordpress.com/5/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godigg/amitcodes.wordpress.com/5/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/digg/amitcodes.wordpress.com/5/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/goreddit/amitcodes.wordpress.com/5/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/reddit/amitcodes.wordpress.com/5/" /></a> <img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=amitcodes.wordpress.com&amp;blog=4944087&amp;post=5&amp;subd=amitcodes&amp;ref=&amp;feed=1" width="1" height="1" />]]></content:encoded>
			<wfw:commentRss>http://amitcodes.wordpress.com/2006/08/18/5/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
	
		<media:content url="http://0.gravatar.com/avatar/c53ec4f8cae62ce7905180cb3071368a?s=96&#38;d=identicon&#38;r=G" medium="image">
			<media:title type="html">amitcodes</media:title>
		</media:content>
	</item>
	</channel>
</rss>
