<?xml version="1.0" encoding="UTF-8"?>
<?xml-stylesheet type="text/xsl" media="screen" href="/~d/styles/rss2full.xsl"?><?xml-stylesheet type="text/css" media="screen" href="http://feeds.feedburner.com/~d/styles/itemcontent.css"?><rss 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:creativeCommons="http://backend.userland.com/creativeCommonsRssModule" version="2.0">

<channel>
	<title>Diabolical or Smart</title>
	
	<link>http://blog.singhanuvrat.com</link>
	<description>Nitwit, Blubber, Oddment, Tweak !!</description>
	<lastBuildDate>Sun, 20 May 2012 08:40:36 +0000</lastBuildDate>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=3.3.2</generator>
		<atom10:link xmlns:atom10="http://www.w3.org/2005/Atom" rel="self" type="application/rss+xml" href="http://feeds.feedburner.com/DiabolicalOrSmart" /><feedburner:info xmlns:feedburner="http://rssnamespace.org/feedburner/ext/1.0" uri="diabolicalorsmart" /><atom10:link xmlns:atom10="http://www.w3.org/2005/Atom" rel="hub" href="http://pubsubhubbub.appspot.com/" /><creativeCommons:license>http://creativecommons.org/licenses/by-nc-sa/3.0/</creativeCommons:license><image><link>http://creativecommons.org/licenses/by-nc-sa/3.0/</link><url>http://creativecommons.org/images/public/somerights20.gif</url><title>Some Rights Reserved</title></image><item>
		<title>Chelsea : There’s Only One Drog At The Bridge</title>
		<link>http://blog.singhanuvrat.com/sports/chelsea-theres-only-one-drog-at-the-bridge</link>
		<comments>http://blog.singhanuvrat.com/sports/chelsea-theres-only-one-drog-at-the-bridge#comments</comments>
		<pubDate>Sun, 20 May 2012 08:40:36 +0000</pubDate>
		<dc:creator>Anuvrat</dc:creator>
				<category><![CDATA[Sports]]></category>
		<category><![CDATA[championsLeague]]></category>
		<category><![CDATA[chelsea]]></category>
		<category><![CDATA[drogba]]></category>
		<category><![CDATA[epl]]></category>
		<category><![CDATA[faCup]]></category>
		<category><![CDATA[football]]></category>
		<category><![CDATA[soccer]]></category>

		<guid isPermaLink="false">http://blog.singhanuvrat.com/?p=2517</guid>
		<description><![CDATA[Didier Drogba There&#8217;s only one Drog at the Bridge, the whole of England actually. No other team has a striker so reliant that you can just will him to score and he will. And you don&#8217;t have to go through all the foreplay of passing the ball around in the midfield. Everything works for him [...]
Related posts:<ol>
<li><a href='http://blog.singhanuvrat.com/sports/epl-chelsea-vs-tottenham-hotspur-march-2012' rel='bookmark' title='EPL: Chelsea vs Tottenham Hotspur &#8211; March 2012'>EPL: Chelsea vs Tottenham Hotspur &#8211; March 2012</a></li>
<li><a href='http://blog.singhanuvrat.com/sports/fa-cup-chelsea-vs-leicester-city-march-2012' rel='bookmark' title='FA Cup: Chelsea vs Leicester City &#8211; March 2012'>FA Cup: Chelsea vs Leicester City &#8211; March 2012</a></li>
<li><a href='http://blog.singhanuvrat.com/sports/ucl-chelsea-vs-napoli-march-2012-reaction' rel='bookmark' title='UCL: Chelsea vs Napoli &#8211; March 2012 &#8211; Reaction'>UCL: Chelsea vs Napoli &#8211; March 2012 &#8211; Reaction</a></li>
</ol>]]></description>
			<content:encoded><![CDATA[<div class="mceTemp mceIEcenter" style="text-align: center;">
<dl id="" class="wp-caption aligncenter" style="width: 510px;">
<dt class="wp-caption-dt"><img title="Didier Drogba" src="http://farm8.staticflickr.com/7097/7232139872_d88f65f92f.jpg" alt="Didier Drogba" width="500" height="333" /></dt>
<dd class="wp-caption-dd">Didier Drogba</dd>
</dl>
</div>
<p style="text-align: justify;">There&#8217;s only one Drog at the Bridge, the whole of England actually. No other team has a striker so reliant that you can just will him to score and he will. And you don&#8217;t have to go through all the foreplay of passing the ball around in the midfield. Everything works for him &#8211; loft it to him directly from the goal kick, cross the ball for him, play a cutting pass through the defenders &#8211; he&#8217;s always there to collect the ball. His strength and precision makes him a defender&#8217;s nightmare. The man is Didier Drogba!</p>
<p style="text-align: justify;">He&#8217;s been the man of big moments for Chelsea these last couple of months. He&#8217;s started every decisive match. He&#8217;s always been there for Chelsea &#8211; playing the hit man looking for goals or being the actor to break the oppositions flow and get a much deserved rest for his teammates. And he&#8217;s scored in both the finals this year.</p>
<p style="text-align: justify;">And this is exactly why I feel a tinge of guilt about being so happy on signing Torres. I was one of the joyful people who thought we had replaced Drogba. I had even wanted Drogba out last summer so that Torres can finally take the center stage. But it is at times like these that prove we had the best striker of the English Premier League all the time. Torres&#8217; goals and pretty play at Liverpool count for nothing against what the legendary Drogba has done at Chelsea. I am not maligning Torres &#8211; I love him and know he&#8217;ll come good for us, it&#8217;s just that I feel guilty of thinking he was eons ahead of Drogba. Well, one thing is for sure &#8211; no one can replace Drogba from the legends of Chelsea. You just cannot find another man in his mold with the same passion and dedication for the club.</p>
<p><iframe src="http://www.youtube.com/embed/Q2Zgxdvwehg" frameborder="0" width="640" height="360"></iframe></p>
<p style="text-align: justify;">With Drogba&#8217;s contract over, the million dollar question is &#8211; Will Drogba sign a new contract at Chelsea? Will Drogba leave? Should Drogba leave? Should Drogba be given the 2 year contract he so desires?</p>
<p style="text-align: justify;">Alas all good things must come to an end. As Harvey Dent said</p>
<blockquote>
<p style="text-align: justify;">You either die a hero or you live long enough to see yourself become the villain.</p>
</blockquote>
<p style="text-align: justify;">Drogba has conquered all at Stamford Bridge &#8211; the premier league titles, the Carling cup, the FA cup and now the Champions League. He has nothing to prove to anyone anymore. He&#8217;ll forever be loved by all the Chelsea fans and respected by the neutrals. And he literally won the Champions League for Chelsea. But his league form had been terrible. He&#8217;s gotten older and has slowed down. He cannot help us in the league anymore. He&#8217;s become a man for the big occasions now. He gets all charged up and energized for one game. You cannot expect him to play this way a whole year. And I do not think being a bit-part bench player would be acceptable for him. He is a legend, he deserves respect. And this is why I feel this is the right time to call it quits on his Chelsea adventure. He can walk out with his head held high on his own terms.</p>
<p style="text-align: justify;">I realize that letting Drogba leave could backfire disastrously. Andrea Pirlo is the best example &#8211; left by Milan he won the scudetto for Juventus. But I think that letting go of Drogba now would be the best thing to do. Roman wants a change in style of play to one that does not suit Drogba. It&#8217;s better for him to leave now as the European Champion than endear a possibly frustrating campaign trying to adapt to a completely new system.</p>
<p style="text-align: justify;">The Chelsea management have got some pretty tough decisions to make this summer. It makes me anxious. I want the suspense of summer to be over. I want to know how this story ends and I want to dream of the beginning of a new season at the Bridge. If only I could close my eyes and drift off into a month long hibernation.</p>
<img src="http://blog.singhanuvrat.com/?ak_action=api_record_view&id=2517&type=feed" alt="" /><p>Related posts:<ol>
<li><a href='http://blog.singhanuvrat.com/sports/epl-chelsea-vs-tottenham-hotspur-march-2012' rel='bookmark' title='EPL: Chelsea vs Tottenham Hotspur &#8211; March 2012'>EPL: Chelsea vs Tottenham Hotspur &#8211; March 2012</a></li>
<li><a href='http://blog.singhanuvrat.com/sports/fa-cup-chelsea-vs-leicester-city-march-2012' rel='bookmark' title='FA Cup: Chelsea vs Leicester City &#8211; March 2012'>FA Cup: Chelsea vs Leicester City &#8211; March 2012</a></li>
<li><a href='http://blog.singhanuvrat.com/sports/ucl-chelsea-vs-napoli-march-2012-reaction' rel='bookmark' title='UCL: Chelsea vs Napoli &#8211; March 2012 &#8211; Reaction'>UCL: Chelsea vs Napoli &#8211; March 2012 &#8211; Reaction</a></li>
</ol></p><div class="feedflare">
<a href="http://feeds.feedburner.com/~ff/DiabolicalOrSmart?a=tw9D4MwtyIw:p8A9VL3vL38:yIl2AUoC8zA"><img src="http://feeds.feedburner.com/~ff/DiabolicalOrSmart?d=yIl2AUoC8zA" border="0"></img></a> <a href="http://feeds.feedburner.com/~ff/DiabolicalOrSmart?a=tw9D4MwtyIw:p8A9VL3vL38:TPCkKD-roEg"><img src="http://feeds.feedburner.com/~ff/DiabolicalOrSmart?i=tw9D4MwtyIw:p8A9VL3vL38:TPCkKD-roEg" border="0"></img></a>
</div><img src="http://feeds.feedburner.com/~r/DiabolicalOrSmart/~4/tw9D4MwtyIw" height="1" width="1"/>]]></content:encoded>
			<wfw:commentRss>http://blog.singhanuvrat.com/sports/chelsea-theres-only-one-drog-at-the-bridge/feed</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Perforce: Can’t Clobber Writable File Error</title>
		<link>http://blog.singhanuvrat.com/tech/perforce-cant-clobber-writable-file-error</link>
		<comments>http://blog.singhanuvrat.com/tech/perforce-cant-clobber-writable-file-error#comments</comments>
		<pubDate>Sat, 12 May 2012 08:57:53 +0000</pubDate>
		<dc:creator>Anuvrat</dc:creator>
				<category><![CDATA[Tech]]></category>
		<category><![CDATA[clobber]]></category>
		<category><![CDATA[error]]></category>
		<category><![CDATA[file]]></category>
		<category><![CDATA[perforce]]></category>
		<category><![CDATA[permissions]]></category>
		<category><![CDATA[sync]]></category>

		<guid isPermaLink="false">http://blog.singhanuvrat.com/?p=2510</guid>
		<description><![CDATA[When getting the latest version of a package from a perforce repository I was getting the following error: Can&#8217;t clobber writable file And of course the file was not being updated. Remember that all the files in perforce are marked as read-only unless opened by the &#8216;p4 edit&#8217; command. I did a &#8216;p4 opened&#8217; to [...]
Related posts:<ol>
<li><a href='http://blog.singhanuvrat.com/tech/whats-in-proc' rel='bookmark' title='What&#8217;s in /proc?'>What&#8217;s in /proc?</a></li>
<li><a href='http://blog.singhanuvrat.com/coding/hive-udf-cannot-run-program-no-such-file-or-directory' rel='bookmark' title='Hive UDF: Cannot Run Program &#8211; No Such File Or Directory'>Hive UDF: Cannot Run Program &#8211; No Such File Or Directory</a></li>
<li><a href='http://blog.singhanuvrat.com/tech/save-file-with-sudo-permissions-in-vim' rel='bookmark' title='Save File With Sudo Permissions In VIM'>Save File With Sudo Permissions In VIM</a></li>
</ol>]]></description>
			<content:encoded><![CDATA[<p style="text-align: justify;">When getting the latest version of a package from a perforce repository I was getting the following error:</p>
<p style="text-align: justify; padding-left: 30px;">Can&#8217;t clobber writable file</p>
<p style="text-align: justify;">And of course the file was not being updated. Remember that all the files in perforce are marked as read-only unless opened by the &#8216;p4 edit&#8217; command. I did a &#8216;p4 opened&#8217; to check if the file had been opened for edit. It was not. Then I checked the permissions and found that the file was marked as writable.</p>
<p style="text-align: justify;">Simply removing the writable field from the permissions of the file did the trick.</p>
<p style="text-align: justify; padding-left: 30px;">chmod -w &lt;filename&gt;</p>
<p style="text-align: justify;">Now when I did a &#8216;p4 sync&#8217; the file got updated. Happy.</p>
<img src="http://blog.singhanuvrat.com/?ak_action=api_record_view&id=2510&type=feed" alt="" /><p>Related posts:<ol>
<li><a href='http://blog.singhanuvrat.com/tech/whats-in-proc' rel='bookmark' title='What&#8217;s in /proc?'>What&#8217;s in /proc?</a></li>
<li><a href='http://blog.singhanuvrat.com/coding/hive-udf-cannot-run-program-no-such-file-or-directory' rel='bookmark' title='Hive UDF: Cannot Run Program &#8211; No Such File Or Directory'>Hive UDF: Cannot Run Program &#8211; No Such File Or Directory</a></li>
<li><a href='http://blog.singhanuvrat.com/tech/save-file-with-sudo-permissions-in-vim' rel='bookmark' title='Save File With Sudo Permissions In VIM'>Save File With Sudo Permissions In VIM</a></li>
</ol></p><div class="feedflare">
<a href="http://feeds.feedburner.com/~ff/DiabolicalOrSmart?a=0tyHnC9e_YI:X3tmFDnb-E8:yIl2AUoC8zA"><img src="http://feeds.feedburner.com/~ff/DiabolicalOrSmart?d=yIl2AUoC8zA" border="0"></img></a> <a href="http://feeds.feedburner.com/~ff/DiabolicalOrSmart?a=0tyHnC9e_YI:X3tmFDnb-E8:TPCkKD-roEg"><img src="http://feeds.feedburner.com/~ff/DiabolicalOrSmart?i=0tyHnC9e_YI:X3tmFDnb-E8:TPCkKD-roEg" border="0"></img></a>
</div><img src="http://feeds.feedburner.com/~r/DiabolicalOrSmart/~4/0tyHnC9e_YI" height="1" width="1"/>]]></content:encoded>
			<wfw:commentRss>http://blog.singhanuvrat.com/tech/perforce-cant-clobber-writable-file-error/feed</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Java: Fix Unchecked Warnings In Java Collections</title>
		<link>http://blog.singhanuvrat.com/tech/java-fix-unchecked-warnings-in-java-collections</link>
		<comments>http://blog.singhanuvrat.com/tech/java-fix-unchecked-warnings-in-java-collections#comments</comments>
		<pubDate>Fri, 04 May 2012 07:20:27 +0000</pubDate>
		<dc:creator>Anuvrat</dc:creator>
				<category><![CDATA[Tech]]></category>
		<category><![CDATA[collections]]></category>
		<category><![CDATA[java]]></category>
		<category><![CDATA[unchecked]]></category>
		<category><![CDATA[warning]]></category>

		<guid isPermaLink="false">http://blog.singhanuvrat.com/?p=2508</guid>
		<description><![CDATA[If you use Collections.EMPTY_LIST, eclipse shows up an unchecked conversion warning. This can be easily avoided by using Collections.&#60;FooBar&#62; emptyList() instead. Related posts: Java ArrayList Is Actually Just An Array ! Java : PropertiesConfiguration Escapes Characters on Save :( Java Code: Pair Class
Related posts:<ol>
<li><a href='http://blog.singhanuvrat.com/coding/java-arraylist-is-actually-just-an-array' rel='bookmark' title='Java ArrayList Is Actually Just An Array !'>Java ArrayList Is Actually Just An Array !</a></li>
<li><a href='http://blog.singhanuvrat.com/coding/java-propertiesconfiguration-escapes-characters-on-save' rel='bookmark' title='Java : PropertiesConfiguration Escapes Characters on Save :('>Java : PropertiesConfiguration Escapes Characters on Save :(</a></li>
<li><a href='http://blog.singhanuvrat.com/coding/java-code-pair-class' rel='bookmark' title='Java Code: Pair Class'>Java Code: Pair Class</a></li>
</ol>]]></description>
			<content:encoded><![CDATA[<p style="text-align: justify;">If you use Collections.EMPTY_LIST, eclipse shows up an unchecked conversion warning. This can be easily avoided by using Collections.&lt;FooBar&gt; emptyList() instead.</p>
<img src="http://blog.singhanuvrat.com/?ak_action=api_record_view&id=2508&type=feed" alt="" /><p>Related posts:<ol>
<li><a href='http://blog.singhanuvrat.com/coding/java-arraylist-is-actually-just-an-array' rel='bookmark' title='Java ArrayList Is Actually Just An Array !'>Java ArrayList Is Actually Just An Array !</a></li>
<li><a href='http://blog.singhanuvrat.com/coding/java-propertiesconfiguration-escapes-characters-on-save' rel='bookmark' title='Java : PropertiesConfiguration Escapes Characters on Save :('>Java : PropertiesConfiguration Escapes Characters on Save :(</a></li>
<li><a href='http://blog.singhanuvrat.com/coding/java-code-pair-class' rel='bookmark' title='Java Code: Pair Class'>Java Code: Pair Class</a></li>
</ol></p><div class="feedflare">
<a href="http://feeds.feedburner.com/~ff/DiabolicalOrSmart?a=bhy12MTEQXI:FmSLqoNwh3s:yIl2AUoC8zA"><img src="http://feeds.feedburner.com/~ff/DiabolicalOrSmart?d=yIl2AUoC8zA" border="0"></img></a> <a href="http://feeds.feedburner.com/~ff/DiabolicalOrSmart?a=bhy12MTEQXI:FmSLqoNwh3s:TPCkKD-roEg"><img src="http://feeds.feedburner.com/~ff/DiabolicalOrSmart?i=bhy12MTEQXI:FmSLqoNwh3s:TPCkKD-roEg" border="0"></img></a>
</div><img src="http://feeds.feedburner.com/~r/DiabolicalOrSmart/~4/bhy12MTEQXI" height="1" width="1"/>]]></content:encoded>
			<wfw:commentRss>http://blog.singhanuvrat.com/tech/java-fix-unchecked-warnings-in-java-collections/feed</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>The Linux OOM Killer</title>
		<link>http://blog.singhanuvrat.com/tech/the-linux-oom-killer</link>
		<comments>http://blog.singhanuvrat.com/tech/the-linux-oom-killer#comments</comments>
		<pubDate>Sun, 15 Apr 2012 07:01:10 +0000</pubDate>
		<dc:creator>Anuvrat</dc:creator>
				<category><![CDATA[Tech]]></category>
		<category><![CDATA[amazon]]></category>
		<category><![CDATA[linux]]></category>
		<category><![CDATA[oom]]></category>
		<category><![CDATA[outOfMemory]]></category>
		<category><![CDATA[sde]]></category>
		<category><![CDATA[tip]]></category>

		<guid isPermaLink="false">http://blog.singhanuvrat.com/?p=2502</guid>
		<description><![CDATA[Most Linux distributions allow processes to request more memory that what is available in the system. The logic behind the approval is that generally the allocated memory is not used up immediately. Also it has been observed that processes over their lifetime do not utilize all of the memory they had initially requested. Thus over-committing [...]
Related posts:<ol>
<li><a href='http://blog.singhanuvrat.com/tech/whats-in-proc' rel='bookmark' title='What&#8217;s in /proc?'>What&#8217;s in /proc?</a></li>
<li><a href='http://blog.singhanuvrat.com/tech/jvm-out-of-memory-permgen' rel='bookmark' title='JVM : Out Of Memory PermGen'>JVM : Out Of Memory PermGen</a></li>
<li><a href='http://blog.singhanuvrat.com/tech/kill-a-process-running-on-a-particular-port-in-windows' rel='bookmark' title='Kill A Process Running On A Particular Port In Windows'>Kill A Process Running On A Particular Port In Windows</a></li>
</ol>]]></description>
			<content:encoded><![CDATA[<p style="text-align: justify;">Most Linux distributions allow processes to request more memory that what is available in the system. The logic behind the approval is that generally the allocated memory is not used up immediately. Also it has been observed that processes over their lifetime do not utilize all of the memory they had initially requested. Thus over-committing allows the system to fully utilize it&#8217;s memory at the risk of out-of-memory (OOM) situations.</p>
<p style="text-align: justify;">The purpose of OOM Killer is to find the best process to kill in case of severe memory shortage. The process is selected on the basis of <em>badness score</em>. The value of <em>badness score</em> is determined by the following properties:</p>
<ul style="text-align: justify;">
<li>original memory size of the process &#8211; more memory a process uses higher is its score</li>
<li>it&#8217;s CPU time</li>
<li>the run time &#8211; the longer a process is alive lower is its score</li>
<li>oom_adj value &#8211; The /proc/&lt;pid&gt;/oom_adj can be set to a value between -17 and +15. Higher the value, more likely is it to be selected as the sacrificial lamb. Setting this value to -17 instructs the OOM Killer to never kill the process.</li>
<li>Half of each child&#8217;s memory size is added to parent&#8217;s score.</li>
<li>If the task has a nice value above zero, the score doubles</li>
<li>Superuser or direct hardware access tasks have their values divided by 4</li>
<li>Depending on oom_adj the value is adjusted as:</li>
<ul>
<li>if oom_adj &gt; 0, score &lt;&lt;= oom_adj</li>
<li>if oom_adj &lt; 0, score &gt;&gt;= -(oom_adj)</li>
</ul>
</ul>
<p style="text-align: justify;">The principle on which the OOM Killer operates is :</p>
<blockquote><p>System should lose the minimum amount of work done, recovers a large amount of memory, doesn&#8217;t kill innocent processes eating tons of memory and kills the minimum number of processes (limit to 1 if possible).</p></blockquote>
<p style="text-align: justify;">The task with the highest badness score is selected and all it&#8217;s children are killed. If the process does not have any child then the process itself will be killed.</p>
<p style="text-align: justify;">Adding more info from <a title="OOM Killer" href="http://linux-mm.org/OOM_Killer" target="_blank">OOM_KILLER</a>.</p>
<p style="text-align: justify;">The function which does the above mentioned <em>badness score</em> computation is called <em>badness()</em>. It gets called by the following chain:</p>
<blockquote>
<p style="text-align: justify;">_alloc_pages -&gt; out_of_memory() -&gt; select_bad_process() -&gt; badness()</p>
</blockquote>
<p style="text-align: justify;">The <em>badness()</em> accumulates points for each process and returns them to <em>select_bad_process()</em>. The scoring of a process starts with the size of it&#8217;s resident memory:</p>
<p style="text-align: justify;"><div id="gist-2390588" class="gist">

        <div class="gist-file">
          <div class="gist-data gist-syntax">
              <div class="highlight"><pre><div class='line' id='LC1'>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<span class="cm">/*</span></div><div class='line' id='LC2'><span class="cm">         * The memory size of the process is the basis for the badness.</span></div><div class='line' id='LC3'><span class="cm">         */</span></div><div class='line' id='LC4'>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<span class="n">points</span> <span class="o">=</span> <span class="n">p</span><span class="o">-&gt;</span><span class="n">mm</span><span class="o">-&gt;</span><span class="n">total_vm</span><span class="p">;</span></div></pre></div>
          </div>

          <div class="gist-meta">
            <a href="https://gist.github.com/raw/2390588/0563d7b86ca6ad5b8471a0c71564d121ad3411da/badness_1.c" style="float:right;">view raw</a>
            <a href="https://gist.github.com/2390588#file_badness_1.c" style="float:right;margin-right:10px;color:#666">badness_1.c</a>
            <a href="https://gist.github.com/2390588">This Gist</a> brought to you by <a href="http://github.com">GitHub</a>.
          </div>
        </div>
</div>
</p>
<p style="text-align: justify;">The memory size of any child is added to the process:</p>
<p style="text-align: justify;"><div id="gist-2390595" class="gist">

        <div class="gist-file">
          <div class="gist-data gist-syntax">
              <div class="highlight"><pre><div class='line' id='LC1'>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<span class="cm">/*</span></div><div class='line' id='LC2'><span class="cm">         * Processes which fork a lot of child processes are likely</span></div><div class='line' id='LC3'><span class="cm">         * a good choice. We add the vmsize of the childs if they</span></div><div class='line' id='LC4'><span class="cm">         * have an own mm. This prevents forking servers to flood the</span></div><div class='line' id='LC5'><span class="cm">         * machine with an endless amount of childs</span></div><div class='line' id='LC6'><span class="cm">         */</span></div><div class='line' id='LC7'>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<span class="p">...</span></div><div class='line' id='LC8'>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<span class="k">if</span> <span class="p">(</span><span class="n">chld</span><span class="o">-&gt;</span><span class="n">mm</span> <span class="o">!=</span> <span class="n">p</span><span class="o">-&gt;</span><span class="n">mm</span> <span class="o">&amp;&amp;</span> <span class="n">chld</span><span class="o">-&gt;</span><span class="n">mm</span><span class="p">)</span></div><div class='line' id='LC9'>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<span class="n">points</span> <span class="o">+=</span> <span class="n">chld</span><span class="o">-&gt;</span><span class="n">mm</span><span class="o">-&gt;</span><span class="n">total_vm</span><span class="p">;</span></div></pre></div>
          </div>

          <div class="gist-meta">
            <a href="https://gist.github.com/raw/2390595/ec8c56f8bc687edfb71cd0612b1690d9ddb82ada/badness_2.c" style="float:right;">view raw</a>
            <a href="https://gist.github.com/2390595#file_badness_2.c" style="float:right;margin-right:10px;color:#666">badness_2.c</a>
            <a href="https://gist.github.com/2390595">This Gist</a> brought to you by <a href="http://github.com">GitHub</a>.
          </div>
        </div>
</div>
</p>
<p style="text-align: justify;">Process with nice value above zero have their score increased and long running processes have theirs decreased:</p>
<p style="text-align: justify;"><div id="gist-2390598" class="gist">

        <div class="gist-file">
          <div class="gist-data gist-syntax">
              <div class="highlight"><pre><div class='line' id='LC1'>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<span class="n">s</span> <span class="o">=</span> <span class="n">int_sqrt</span><span class="p">(</span><span class="n">cpu_time</span><span class="p">);</span></div><div class='line' id='LC2'>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<span class="k">if</span> <span class="p">(</span><span class="n">s</span><span class="p">)</span></div><div class='line' id='LC3'>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<span class="n">points</span> <span class="o">/=</span> <span class="n">s</span><span class="p">;</span></div><div class='line' id='LC4'>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<span class="n">s</span> <span class="o">=</span> <span class="n">int_sqrt</span><span class="p">(</span><span class="n">int_sqrt</span><span class="p">(</span><span class="n">run_time</span><span class="p">));</span></div><div class='line' id='LC5'>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<span class="k">if</span> <span class="p">(</span><span class="n">s</span><span class="p">)</span></div><div class='line' id='LC6'>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<span class="n">points</span> <span class="o">/=</span> <span class="n">s</span><span class="p">;</span></div><div class='line' id='LC7'><br/></div><div class='line' id='LC8'>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<span class="cm">/*</span></div><div class='line' id='LC9'><span class="cm">         * Niced processes are most likely less important, so double</span></div><div class='line' id='LC10'><span class="cm">         * their badness points.</span></div><div class='line' id='LC11'><span class="cm">         */</span></div><div class='line' id='LC12'>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<span class="k">if</span> <span class="p">(</span><span class="n">task_nice</span><span class="p">(</span><span class="n">p</span><span class="p">)</span> <span class="o">&gt;</span> <span class="mi">0</span><span class="p">)</span></div><div class='line' id='LC13'>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<span class="n">points</span> <span class="o">*=</span> <span class="mi">2</span><span class="p">;</span></div></pre></div>
          </div>

          <div class="gist-meta">
            <a href="https://gist.github.com/raw/2390598/3e8dacf89780d734e8154bdbd6816d9aeb79ec8d/badness_3.c" style="float:right;">view raw</a>
            <a href="https://gist.github.com/2390598#file_badness_3.c" style="float:right;margin-right:10px;color:#666">badness_3.c</a>
            <a href="https://gist.github.com/2390598">This Gist</a> brought to you by <a href="http://github.com">GitHub</a>.
          </div>
        </div>
</div>
</p>
<p style="text-align: justify;">Superuser processes and direct hardware access tasks have their scores reduced:</p>
<p style="text-align: justify;"><div id="gist-2390603" class="gist">

        <div class="gist-file">
          <div class="gist-data gist-syntax">
              <div class="highlight"><pre><div class='line' id='LC1'>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<span class="cm">/*</span></div><div class='line' id='LC2'><span class="cm">         * Superuser processes are usually more important, so we make it</span></div><div class='line' id='LC3'><span class="cm">         * less likely that we kill those.</span></div><div class='line' id='LC4'><span class="cm">         */</span></div><div class='line' id='LC5'>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<span class="k">if</span> <span class="p">(</span><span class="n">cap_t</span><span class="p">(</span><span class="n">p</span><span class="o">-&gt;</span><span class="n">cap_effective</span><span class="p">)</span> <span class="o">&amp;</span> <span class="n">CAP_TO_MASK</span><span class="p">(</span><span class="n">CAP_SYS_ADMIN</span><span class="p">)</span> <span class="o">||</span></div><div class='line' id='LC6'>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<span class="n">p</span><span class="o">-&gt;</span><span class="n">uid</span> <span class="o">==</span> <span class="mi">0</span> <span class="o">||</span> <span class="n">p</span><span class="o">-&gt;</span><span class="n">euid</span> <span class="o">==</span> <span class="mi">0</span><span class="p">)</span></div><div class='line' id='LC7'>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<span class="n">points</span> <span class="o">/=</span> <span class="mi">4</span><span class="p">;</span></div><div class='line' id='LC8'><br/></div><div class='line' id='LC9'>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<span class="cm">/*</span></div><div class='line' id='LC10'><span class="cm">         * We don&#39;t want to kill a process with direct hardware access.</span></div><div class='line' id='LC11'><span class="cm">         * Not only could that mess up the hardware, but usually users</span></div><div class='line' id='LC12'><span class="cm">         * tend to only have this flag set on applications they think</span></div><div class='line' id='LC13'><span class="cm">         * of as important.</span></div><div class='line' id='LC14'><span class="cm">         */</span></div><div class='line' id='LC15'>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<span class="k">if</span> <span class="p">(</span><span class="n">cap_t</span><span class="p">(</span><span class="n">p</span><span class="o">-&gt;</span><span class="n">cap_effective</span><span class="p">)</span> <span class="o">&amp;</span> <span class="n">CAP_TO_MASK</span><span class="p">(</span><span class="n">CAP_SYS_RAWIO</span><span class="p">))</span></div><div class='line' id='LC16'>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<span class="n">points</span> <span class="o">/=</span> <span class="mi">4</span><span class="p">;</span></div><div class='line' id='LC17'><br/></div></pre></div>
          </div>

          <div class="gist-meta">
            <a href="https://gist.github.com/raw/2390603/247eb4d8b79ff026aa1f1ab589bc9ecaa9da9cd2/badness_4.c" style="float:right;">view raw</a>
            <a href="https://gist.github.com/2390603#file_badness_4.c" style="float:right;margin-right:10px;color:#666">badness_4.c</a>
            <a href="https://gist.github.com/2390603">This Gist</a> brought to you by <a href="http://github.com">GitHub</a>.
          </div>
        </div>
</div>
</p>
<p style="text-align: justify;">Finally, honour the oom_adj setting:</p>
<p style="text-align: justify;"><div id="gist-2390604" class="gist">

        <div class="gist-file">
          <div class="gist-data gist-syntax">
              <div class="highlight"><pre><div class='line' id='LC1'>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<span class="cm">/*</span></div><div class='line' id='LC2'><span class="cm">         * Adjust the score by oomkilladj.</span></div><div class='line' id='LC3'><span class="cm">         */</span></div><div class='line' id='LC4'>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<span class="k">if</span> <span class="p">(</span><span class="n">p</span><span class="o">-&gt;</span><span class="n">oomkilladj</span><span class="p">)</span> <span class="p">{</span></div><div class='line' id='LC5'>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<span class="k">if</span> <span class="p">(</span><span class="n">p</span><span class="o">-&gt;</span><span class="n">oomkilladj</span> <span class="o">&gt;</span> <span class="mi">0</span><span class="p">)</span></div><div class='line' id='LC6'>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<span class="n">points</span> <span class="o">&lt;&lt;=</span> <span class="n">p</span><span class="o">-&gt;</span><span class="n">oomkilladj</span><span class="p">;</span></div><div class='line' id='LC7'>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<span class="k">else</span></div><div class='line' id='LC8'>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<span class="n">points</span> <span class="o">&gt;&gt;=</span> <span class="o">-</span><span class="p">(</span><span class="n">p</span><span class="o">-&gt;</span><span class="n">oomkilladj</span><span class="p">);</span></div><div class='line' id='LC9'>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<span class="p">}</span></div></pre></div>
          </div>

          <div class="gist-meta">
            <a href="https://gist.github.com/raw/2390604/0de6c5289f5bba6a076689aa4cd1cd6f01569818/badness_5.c" style="float:right;">view raw</a>
            <a href="https://gist.github.com/2390604#file_badness_5.c" style="float:right;margin-right:10px;color:#666">badness_5.c</a>
            <a href="https://gist.github.com/2390604">This Gist</a> brought to you by <a href="http://github.com">GitHub</a>.
          </div>
        </div>
</div>
</p>
<p style="text-align: justify;">Thus the ideal candidate will be:</p>
<blockquote>
<p style="text-align: justify;">One that was recently started, is a non-privileged process which together with its children uses a lot of memory, has been nice&#8217;d and does no I/O. Something like a nohup&#8217;d parallel kernel build (which is not a bad choice since all results are saved to disk and very little work is lost when a <em>make</em> is terminated).</p>
</blockquote>
<p class="alert" style="text-align: right;">From the SDE Tip &#8211; Amazon</p>
<img src="http://blog.singhanuvrat.com/?ak_action=api_record_view&id=2502&type=feed" alt="" /><p>Related posts:<ol>
<li><a href='http://blog.singhanuvrat.com/tech/whats-in-proc' rel='bookmark' title='What&#8217;s in /proc?'>What&#8217;s in /proc?</a></li>
<li><a href='http://blog.singhanuvrat.com/tech/jvm-out-of-memory-permgen' rel='bookmark' title='JVM : Out Of Memory PermGen'>JVM : Out Of Memory PermGen</a></li>
<li><a href='http://blog.singhanuvrat.com/tech/kill-a-process-running-on-a-particular-port-in-windows' rel='bookmark' title='Kill A Process Running On A Particular Port In Windows'>Kill A Process Running On A Particular Port In Windows</a></li>
</ol></p><div class="feedflare">
<a href="http://feeds.feedburner.com/~ff/DiabolicalOrSmart?a=V-aOhk9u6xQ:CpW3s-TZ-UM:yIl2AUoC8zA"><img src="http://feeds.feedburner.com/~ff/DiabolicalOrSmart?d=yIl2AUoC8zA" border="0"></img></a> <a href="http://feeds.feedburner.com/~ff/DiabolicalOrSmart?a=V-aOhk9u6xQ:CpW3s-TZ-UM:TPCkKD-roEg"><img src="http://feeds.feedburner.com/~ff/DiabolicalOrSmart?i=V-aOhk9u6xQ:CpW3s-TZ-UM:TPCkKD-roEg" border="0"></img></a>
</div><img src="http://feeds.feedburner.com/~r/DiabolicalOrSmart/~4/V-aOhk9u6xQ" height="1" width="1"/>]]></content:encoded>
			<wfw:commentRss>http://blog.singhanuvrat.com/tech/the-linux-oom-killer/feed</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Knuth-Morris-Pratt String Search Algorithm</title>
		<link>http://blog.singhanuvrat.com/academic/knuth-morris-pratt-string-search-algorithm</link>
		<comments>http://blog.singhanuvrat.com/academic/knuth-morris-pratt-string-search-algorithm#comments</comments>
		<pubDate>Sat, 14 Apr 2012 05:27:42 +0000</pubDate>
		<dc:creator>Anuvrat</dc:creator>
				<category><![CDATA[Academic]]></category>
		<category><![CDATA[algorithm]]></category>
		<category><![CDATA[code]]></category>
		<category><![CDATA[java]]></category>
		<category><![CDATA[kmp]]></category>
		<category><![CDATA[knuth]]></category>
		<category><![CDATA[morris]]></category>
		<category><![CDATA[pratt]]></category>
		<category><![CDATA[programming]]></category>
		<category><![CDATA[search]]></category>
		<category><![CDATA[string]]></category>

		<guid isPermaLink="false">http://blog.singhanuvrat.com/?p=2493</guid>
		<description><![CDATA[The KMP algorithm searches for the occurrence of a word W in a sentence S while employing the observation that when a mismatch occurs W contains sufficient information to determine the start position of the next search in S. Say W = abcd and S = abcbabcd. Now we compare W[0] with S[0], W[1] with [...]
Related posts:<ol>
<li><a href='http://blog.singhanuvrat.com/miscel/in-search-of-a-book-recommendation-engine' rel='bookmark' title='In Search Of A Book Recommendation Engine'>In Search Of A Book Recommendation Engine</a></li>
<li><a href='http://blog.singhanuvrat.com/problems/project-euler-verifying-triangle-words' rel='bookmark' title='Project Euler : Verifying Triangle Words'>Project Euler : Verifying Triangle Words</a></li>
<li><a href='http://blog.singhanuvrat.com/problems/fast-factorial-computation' rel='bookmark' title='Project Euler : Fast Factorial Computation'>Project Euler : Fast Factorial Computation</a></li>
</ol>]]></description>
			<content:encoded><![CDATA[<p style="text-align: justify;">The KMP algorithm searches for the occurrence of a word <em>W</em> in a sentence <em>S</em> while employing the observation that when a mismatch occurs <em>W</em> contains sufficient information to determine the start position of the next search in <em>S</em>.</p>
<p style="text-align: justify;">Say <em>W = abc</em>d and <em>S = abcbabcd</em>. Now we compare <em>W[0]</em> with <em>S[0]</em>, <em>W[1]</em> with <em>S[1]</em>, <em>W[2]</em> with <em>S[2]</em> and they all match. But <em>W[3]</em> does not match <em>S[3]</em>. The brute force algorithm would have started the next search by comparing <em>W[0]</em> with <em>S[1]</em>. But a simple observation tells us that it would be fruitless as there is no <em>W[0]</em> till <em>S[3]</em>. We would have done better by starting the next search from <em>S[4]</em>. And this is exactly what the KMP tries to achieve.</p>
<p style="text-align: justify;">KMP requires a pre-processing of the word <em>W</em>. We create a <em>Partial Match Table</em> by iterating over all the letters of <em>W</em> in such a way that in case of a mismatch we can quickly figure out the next start position by looking at the table. The wiki article on KMP describes with an example how to create the table:</p>
<p style="text-align: center;"><a title="KMP - Partial Match Table - Wiki Article" href="http://en.wikipedia.org/w/index.php?title=Knuth%E2%80%93Morris%E2%80%93Pratt_algorithm#.22Partial_match.22_table_.28also_known_as_.22failure_function.22.29" target="_blank">KMP &#8211; Partial Match Table</a></p>
<p style="text-align: justify;">The partial match table can be created in <em>O(n)</em> time using <em>O(n)</em> space, where <em>n</em> is the length of the word <em>W</em>. Once we have the table we can iterate over each element of <em>S</em> consulting the table every time a mismatch occurs. You may want to read up the algorithm with examples from</p>
<p style="text-align: center;"><a title="KMP - Algorithm with Examples - Wiki Article" href="http://en.wikipedia.org/w/index.php?title=Knuth%E2%80%93Morris%E2%80%93Pratt_algorithm#KMP_algorithm" target="_blank">KMP &#8211; Algorithm With Examples &#8211; Wikipedia</a></p>
<p style="text-align: justify;">The search happens in <em>O(k)</em> where <em>k</em> is the length of the sentence <em>S</em>. Thus the algorithm runs in <em>O(n + k)</em>.</p>
<p style="text-align: justify;">Below is my java implementation of the same:</p>
<p style="text-align: center;"><div id="gist-2382245" class="gist">

        <div class="gist-file">
          <div class="gist-data gist-syntax">
              <div class="highlight"><pre><div class='line' id='LC1'><span class="cm">/**</span></div><div class='line' id='LC2'><span class="cm"> * Perform the Knuth-Morris-Pratt string search. The algorithm first pre-processes the word to create a Partial Match</span></div><div class='line' id='LC3'><span class="cm"> * Table. The table is creatd in O(n) where n is the length of the word. After the pre-processing, the actual search can</span></div><div class='line' id='LC4'><span class="cm"> * be performed in O(k) where k is the size of the sentence.</span></div><div class='line' id='LC5'><span class="cm"> */</span></div><div class='line' id='LC6'><span class="kd">public</span> <span class="kd">class</span> <span class="nc">KMPStringSearch</span> <span class="o">{</span></div><div class='line' id='LC7'>	<span class="cm">/**</span></div><div class='line' id='LC8'><span class="cm">	 * Searches for all occurances of the word in the sentence. Runs in O(n+k) where n is the word length and k is the</span></div><div class='line' id='LC9'><span class="cm">	 * sentence length.</span></div><div class='line' id='LC10'><span class="cm">	 * </span></div><div class='line' id='LC11'><span class="cm">	 * @param word The word that is being searched</span></div><div class='line' id='LC12'><span class="cm">	 * @param sentence The collections of word over which the search happens.</span></div><div class='line' id='LC13'><span class="cm">	 * @return The list of starting indices of the matched word in the sentence. Empty list in case of no match.</span></div><div class='line' id='LC14'><span class="cm">	 */</span></div><div class='line' id='LC15'>	<span class="kd">public</span> <span class="n">List</span><span class="o">&lt;</span><span class="n">Integer</span><span class="o">&gt;</span> <span class="n">searchString</span><span class="o">(</span><span class="kd">final</span> <span class="n">String</span> <span class="n">word</span><span class="o">,</span> <span class="kd">final</span> <span class="n">String</span> <span class="n">sentence</span><span class="o">)</span> <span class="o">{</span></div><div class='line' id='LC16'>		<span class="kd">final</span> <span class="n">List</span><span class="o">&lt;</span><span class="n">Integer</span><span class="o">&gt;</span> <span class="n">matchedIndices</span> <span class="o">=</span> <span class="k">new</span> <span class="n">ArrayList</span><span class="o">&lt;&gt;();</span></div><div class='line' id='LC17'><br/></div><div class='line' id='LC18'>		<span class="kd">final</span> <span class="kt">int</span> <span class="n">sentenceLength</span> <span class="o">=</span> <span class="n">sentence</span><span class="o">.</span><span class="na">length</span><span class="o">();</span></div><div class='line' id='LC19'>		<span class="kd">final</span> <span class="kt">int</span> <span class="n">wordLength</span> <span class="o">=</span> <span class="n">word</span><span class="o">.</span><span class="na">length</span><span class="o">();</span></div><div class='line' id='LC20'>		<span class="kt">int</span> <span class="n">beginMatch</span> <span class="o">=</span> <span class="mi">0</span><span class="o">;</span> <span class="c1">// the starting position in sentence from which the match started</span></div><div class='line' id='LC21'>		<span class="kt">int</span> <span class="n">idxWord</span> <span class="o">=</span> <span class="mi">0</span><span class="o">;</span> <span class="c1">// the index of the character of the word that is being compared to a character in string</span></div><div class='line' id='LC22'>		<span class="kd">final</span> <span class="n">List</span><span class="o">&lt;</span><span class="n">Integer</span><span class="o">&gt;</span> <span class="n">partialTable</span> <span class="o">=</span> <span class="n">createPartialMatchTable</span><span class="o">(</span><span class="n">word</span><span class="o">);</span></div><div class='line' id='LC23'>		<span class="k">while</span> <span class="o">(</span><span class="n">beginMatch</span> <span class="o">+</span> <span class="n">idxWord</span> <span class="o">&lt;</span> <span class="n">sentenceLength</span><span class="o">)</span></div><div class='line' id='LC24'>			<span class="k">if</span> <span class="o">(</span><span class="n">word</span><span class="o">.</span><span class="na">charAt</span><span class="o">(</span><span class="n">idxWord</span><span class="o">)</span> <span class="o">==</span> <span class="n">sentence</span><span class="o">.</span><span class="na">charAt</span><span class="o">(</span><span class="n">beginMatch</span> <span class="o">+</span> <span class="n">idxWord</span><span class="o">))</span> <span class="o">{</span></div><div class='line' id='LC25'>				<span class="c1">// the characters have matched</span></div><div class='line' id='LC26'>				<span class="k">if</span> <span class="o">(</span><span class="n">idxWord</span> <span class="o">==</span> <span class="n">wordLength</span> <span class="o">-</span> <span class="mi">1</span><span class="o">)</span> <span class="o">{</span></div><div class='line' id='LC27'>					<span class="c1">// the word is complete. we have a match.</span></div><div class='line' id='LC28'>					<span class="n">matchedIndices</span><span class="o">.</span><span class="na">add</span><span class="o">(</span><span class="n">beginMatch</span><span class="o">);</span></div><div class='line' id='LC29'>					<span class="c1">// restart the search</span></div><div class='line' id='LC30'>					<span class="n">beginMatch</span> <span class="o">=</span> <span class="n">beginMatch</span> <span class="o">+</span> <span class="n">idxWord</span> <span class="o">-</span> <span class="n">partialTable</span><span class="o">.</span><span class="na">get</span><span class="o">(</span><span class="n">idxWord</span><span class="o">);</span></div><div class='line' id='LC31'>					<span class="k">if</span> <span class="o">(</span><span class="n">partialTable</span><span class="o">.</span><span class="na">get</span><span class="o">(</span><span class="n">idxWord</span><span class="o">)</span> <span class="o">&gt;</span> <span class="o">-</span><span class="mi">1</span><span class="o">)</span> <span class="n">idxWord</span> <span class="o">=</span> <span class="n">partialTable</span><span class="o">.</span><span class="na">get</span><span class="o">(</span><span class="n">idxWord</span><span class="o">);</span></div><div class='line' id='LC32'>					<span class="k">else</span> <span class="n">idxWord</span> <span class="o">=</span> <span class="mi">0</span><span class="o">;</span></div><div class='line' id='LC33'>				<span class="o">}</span> <span class="k">else</span> <span class="n">idxWord</span><span class="o">++;</span></div><div class='line' id='LC34'>			<span class="o">}</span> <span class="k">else</span> <span class="o">{</span></div><div class='line' id='LC35'>				<span class="c1">// mismatch. restart the search.</span></div><div class='line' id='LC36'>				<span class="n">beginMatch</span> <span class="o">=</span> <span class="n">beginMatch</span> <span class="o">+</span> <span class="n">idxWord</span> <span class="o">-</span> <span class="n">partialTable</span><span class="o">.</span><span class="na">get</span><span class="o">(</span><span class="n">idxWord</span><span class="o">);</span></div><div class='line' id='LC37'>				<span class="k">if</span> <span class="o">(</span><span class="n">partialTable</span><span class="o">.</span><span class="na">get</span><span class="o">(</span><span class="n">idxWord</span><span class="o">)</span> <span class="o">&gt;</span> <span class="o">-</span><span class="mi">1</span><span class="o">)</span> <span class="n">idxWord</span> <span class="o">=</span> <span class="n">partialTable</span><span class="o">.</span><span class="na">get</span><span class="o">(</span><span class="n">idxWord</span><span class="o">);</span></div><div class='line' id='LC38'>				<span class="k">else</span> <span class="n">idxWord</span> <span class="o">=</span> <span class="mi">0</span><span class="o">;</span></div><div class='line' id='LC39'>			<span class="o">}</span></div><div class='line' id='LC40'><br/></div><div class='line' id='LC41'>		<span class="k">return</span> <span class="n">Collections</span><span class="o">.</span><span class="na">unmodifiableList</span><span class="o">(</span><span class="n">matchedIndices</span><span class="o">);</span></div><div class='line' id='LC42'>	<span class="o">}</span></div><div class='line' id='LC43'><br/></div><div class='line' id='LC44'>	<span class="cm">/**</span></div><div class='line' id='LC45'><span class="cm">	 * Creates the Partial Match Table for the word. Runs in O(n) where n is the length of the word.</span></div><div class='line' id='LC46'><span class="cm">	 * </span></div><div class='line' id='LC47'><span class="cm">	 * @param word The word whose Partial Match Table is required.</span></div><div class='line' id='LC48'><span class="cm">	 * @return The table as a list of integers.</span></div><div class='line' id='LC49'><span class="cm">	 */</span></div><div class='line' id='LC50'>	<span class="kd">public</span> <span class="n">List</span><span class="o">&lt;</span><span class="n">Integer</span><span class="o">&gt;</span> <span class="n">createPartialMatchTable</span><span class="o">(</span><span class="kd">final</span> <span class="n">String</span> <span class="n">word</span><span class="o">)</span> <span class="o">{</span></div><div class='line' id='LC51'>		<span class="k">if</span> <span class="o">(</span><span class="n">StringUtils</span><span class="o">.</span><span class="na">isBlank</span><span class="o">(</span><span class="n">word</span><span class="o">))</span> <span class="k">return</span> <span class="n">Collections</span><span class="o">.</span><span class="na">EMPTY_LIST</span><span class="o">;</span></div><div class='line' id='LC52'><br/></div><div class='line' id='LC53'>		<span class="kd">final</span> <span class="kt">int</span> <span class="n">length</span> <span class="o">=</span> <span class="n">word</span><span class="o">.</span><span class="na">length</span><span class="o">();</span></div><div class='line' id='LC54'>		<span class="kd">final</span> <span class="n">List</span><span class="o">&lt;</span><span class="n">Integer</span><span class="o">&gt;</span> <span class="n">partialTable</span> <span class="o">=</span> <span class="k">new</span> <span class="n">ArrayList</span><span class="o">&lt;&gt;(</span><span class="n">length</span> <span class="o">+</span> <span class="mi">1</span><span class="o">);</span></div><div class='line' id='LC55'>		<span class="n">partialTable</span><span class="o">.</span><span class="na">add</span><span class="o">(-</span><span class="mi">1</span><span class="o">);</span></div><div class='line' id='LC56'>		<span class="n">partialTable</span><span class="o">.</span><span class="na">add</span><span class="o">(</span><span class="mi">0</span><span class="o">);</span></div><div class='line' id='LC57'><br/></div><div class='line' id='LC58'>		<span class="kd">final</span> <span class="kt">char</span> <span class="n">firstChar</span> <span class="o">=</span> <span class="n">word</span><span class="o">.</span><span class="na">charAt</span><span class="o">(</span><span class="mi">0</span><span class="o">);</span></div><div class='line' id='LC59'>		<span class="k">for</span> <span class="o">(</span><span class="kt">int</span> <span class="n">idx</span> <span class="o">=</span> <span class="mi">1</span><span class="o">;</span> <span class="n">idx</span> <span class="o">&lt;</span> <span class="n">word</span><span class="o">.</span><span class="na">length</span><span class="o">();</span> <span class="n">idx</span><span class="o">++)</span> <span class="o">{</span></div><div class='line' id='LC60'>			<span class="kd">final</span> <span class="kt">int</span> <span class="n">prevVal</span> <span class="o">=</span> <span class="n">partialTable</span><span class="o">.</span><span class="na">get</span><span class="o">(</span><span class="n">idx</span><span class="o">);</span></div><div class='line' id='LC61'>			<span class="k">if</span> <span class="o">(</span><span class="n">prevVal</span> <span class="o">==</span> <span class="mi">0</span><span class="o">)</span> <span class="o">{</span></div><div class='line' id='LC62'>				<span class="k">if</span> <span class="o">(</span><span class="n">word</span><span class="o">.</span><span class="na">charAt</span><span class="o">(</span><span class="n">idx</span><span class="o">)</span> <span class="o">==</span> <span class="n">firstChar</span><span class="o">)</span> <span class="n">partialTable</span><span class="o">.</span><span class="na">add</span><span class="o">(</span><span class="mi">1</span><span class="o">);</span></div><div class='line' id='LC63'>				<span class="k">else</span> <span class="n">partialTable</span><span class="o">.</span><span class="na">add</span><span class="o">(</span><span class="mi">0</span><span class="o">);</span></div><div class='line' id='LC64'>			<span class="o">}</span> <span class="k">else</span> <span class="k">if</span> <span class="o">(</span><span class="n">word</span><span class="o">.</span><span class="na">charAt</span><span class="o">(</span><span class="n">idx</span><span class="o">)</span> <span class="o">==</span> <span class="n">word</span><span class="o">.</span><span class="na">charAt</span><span class="o">(</span><span class="n">prevVal</span><span class="o">))</span> <span class="n">partialTable</span><span class="o">.</span><span class="na">add</span><span class="o">(</span><span class="n">prevVal</span> <span class="o">+</span> <span class="mi">1</span><span class="o">);</span></div><div class='line' id='LC65'>			<span class="k">else</span> <span class="n">partialTable</span><span class="o">.</span><span class="na">add</span><span class="o">(</span><span class="mi">0</span><span class="o">);</span></div><div class='line' id='LC66'>		<span class="o">}</span></div><div class='line' id='LC67'><br/></div><div class='line' id='LC68'>		<span class="k">return</span> <span class="n">Collections</span><span class="o">.</span><span class="na">unmodifiableList</span><span class="o">(</span><span class="n">partialTable</span><span class="o">);</span></div><div class='line' id='LC69'>	<span class="o">}</span></div><div class='line' id='LC70'><span class="o">}</span></div><div class='line' id='LC71'><br/></div></pre></div>
          </div>

          <div class="gist-meta">
            <a href="https://gist.github.com/raw/2382245/d2f58b93ec2583b688e57aff543b8252b31fdc5d/KMPStringSearch.java" style="float:right;">view raw</a>
            <a href="https://gist.github.com/2382245#file_kmp_string_search.java" style="float:right;margin-right:10px;color:#666">KMPStringSearch.java</a>
            <a href="https://gist.github.com/2382245">This Gist</a> brought to you by <a href="http://github.com">GitHub</a>.
          </div>
        </div>
</div>
</p>
<img src="http://blog.singhanuvrat.com/?ak_action=api_record_view&id=2493&type=feed" alt="" /><p>Related posts:<ol>
<li><a href='http://blog.singhanuvrat.com/miscel/in-search-of-a-book-recommendation-engine' rel='bookmark' title='In Search Of A Book Recommendation Engine'>In Search Of A Book Recommendation Engine</a></li>
<li><a href='http://blog.singhanuvrat.com/problems/project-euler-verifying-triangle-words' rel='bookmark' title='Project Euler : Verifying Triangle Words'>Project Euler : Verifying Triangle Words</a></li>
<li><a href='http://blog.singhanuvrat.com/problems/fast-factorial-computation' rel='bookmark' title='Project Euler : Fast Factorial Computation'>Project Euler : Fast Factorial Computation</a></li>
</ol></p><div class="feedflare">
<a href="http://feeds.feedburner.com/~ff/DiabolicalOrSmart?a=etSWd8xXWWs:YAtNlijU7ew:yIl2AUoC8zA"><img src="http://feeds.feedburner.com/~ff/DiabolicalOrSmart?d=yIl2AUoC8zA" border="0"></img></a> <a href="http://feeds.feedburner.com/~ff/DiabolicalOrSmart?a=etSWd8xXWWs:YAtNlijU7ew:TPCkKD-roEg"><img src="http://feeds.feedburner.com/~ff/DiabolicalOrSmart?i=etSWd8xXWWs:YAtNlijU7ew:TPCkKD-roEg" border="0"></img></a>
</div><img src="http://feeds.feedburner.com/~r/DiabolicalOrSmart/~4/etSWd8xXWWs" height="1" width="1"/>]]></content:encoded>
			<wfw:commentRss>http://blog.singhanuvrat.com/academic/knuth-morris-pratt-string-search-algorithm/feed</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Chelsea: Do I Want Di Matteo To Stay?</title>
		<link>http://blog.singhanuvrat.com/sports/chelsea-do-i-want-di-matteo-to-stay</link>
		<comments>http://blog.singhanuvrat.com/sports/chelsea-do-i-want-di-matteo-to-stay#comments</comments>
		<pubDate>Thu, 05 Apr 2012 18:22:40 +0000</pubDate>
		<dc:creator>Anuvrat</dc:creator>
				<category><![CDATA[Sports]]></category>
		<category><![CDATA[avb]]></category>
		<category><![CDATA[chelsea]]></category>
		<category><![CDATA[coach]]></category>
		<category><![CDATA[diMatteo]]></category>
		<category><![CDATA[manager]]></category>
		<category><![CDATA[rdm]]></category>
		<category><![CDATA[villasBoas]]></category>

		<guid isPermaLink="false">http://blog.singhanuvrat.com/?p=2483</guid>
		<description><![CDATA[Honest to god answer &#8211; No. But do I believe Chelsea can find a better manager with no Champions League &#8211; Probably not. Don&#8217;t get me wrong. Di Matteo has done a fantastic job since taking over from Villas Boas. This Chelsea team had been written off by one and all. Napoli players knew that [...]
Related posts:<ol>
<li><a href='http://blog.singhanuvrat.com/sports/epl-chelsea-vs-tottenham-hotspur-march-2012' rel='bookmark' title='EPL: Chelsea vs Tottenham Hotspur &#8211; March 2012'>EPL: Chelsea vs Tottenham Hotspur &#8211; March 2012</a></li>
<li><a href='http://blog.singhanuvrat.com/sports/fa-cup-chelsea-vs-leicester-city-march-2012-reaction' rel='bookmark' title='FA Cup: Chelsea vs Leicester City &#8211; March 2012 &#8211; Reaction'>FA Cup: Chelsea vs Leicester City &#8211; March 2012 &#8211; Reaction</a></li>
<li><a href='http://blog.singhanuvrat.com/sports/rumour-jose-to-chelsea' rel='bookmark' title='Rumour: Jose To Chelsea?'>Rumour: Jose To Chelsea?</a></li>
</ol>]]></description>
			<content:encoded><![CDATA[<p style="text-align: justify;">Honest to god answer &#8211; No. But do I believe Chelsea can find a better manager with no Champions League &#8211; Probably not.</p>
<p style="text-align: justify;">Don&#8217;t get me wrong. Di Matteo has done a fantastic job since taking over from Villas Boas. This Chelsea team had been written off by one and all. Napoli players knew that they were into the next round even before visiting the Stamford Bridge. It&#8217;s a testament to the our interim Italian manager that he brought together a divided dressing room to produce a brilliant display in front of the home crowd. Chelsea fans will be hard pressed to find a more emotional and charged atmosphere than the second leg victory against Napoli.</p>
<p style="text-align: center;"><a href="http://www.flickr.com/photos/anuvrat/7048463227/" title="Chelsea flag by Anuvrat, on Flickr"><img src="http://farm8.staticflickr.com/7249/7048463227_9e299f9c22.jpg" width="500" height="311" alt="Chelsea flag"></a></p>
<p style="text-align: justify;">Amazing as the start has been to Matteo&#8217;s managerial stint at Chelsea, the spark is still missing. One notable difference between Villas Boas and Matteo&#8217;s side is the change in formation from 4-3-3 to 4-5-1. The biggest loser from this change is Sturridge and the biggest gainer being Kalou. Let&#8217;s not get into that though.</p>
<p style="text-align: justify;">Villas Boas tried to create a Chelsea team that attacks with flair. This required a high line of defense and lot of pressing. Chelsea got off to a great start in the Premier League. It was not soon enough when the opposition team started to realize that the Chelsea players were not suited to the high line tactics. Villas Boas reluctance to change his style eventually cost him his job.</p>
<p style="text-align: justify;">Di Matteo has decided to pack his mid field and play with a lone striker. Luckily for him Torres has begun finding his feet and Matteo can make the simple decision of playing Torres ahead of Drogba &#8211; which must be pleasing Roman as well. But when you play with 5 in the middle you are expected to retain possession for majority of the game. Stats paint a completely different picture. Only against Stoke at home did Chelsea have like 70% possession. Other games we have been chasing mostly with around 47% possession. Villas Boas side almost always managed a 60% possession even with just 3 midfielders! This could mean only one thing &#8211; Di Matteo has set up his side to play defensively. Chelsea don&#8217;t care about possession play any more, they just want to sit tight and attack on the break. This also explains why Matteo prefers Meirless and Kalou over the tired, slow legs of Lampard and Malouda.</p>
<p style="text-align: justify;">Now I don&#8217;t have much problem with a counter attacking setup. The German national team played the whole World Cup 2010 with that philosophy and no one can complain that the German games were boring. They were high energy exciting games! Napoli, that caught the eye of Europe this season, have been setup to play counter attacking game and even they are an exciting sight to watch. Chelsea on the other hand fail to convince. They are too slow &#8211; even when counter attacking. Most of the times the Chelsea midfielders run out of ideas after reaching the final third and instead of playing a defense-splitting pass to release the striker they just play the ball back to their safest player.</p>
<p style="text-align: justify;">Di Matteo has been effective but not interesting or exciting. Chelsea have gone back to being boring and this is not what Roman desires &#8211; nor do I. One could argue that Matteo is doing the best with what he has and if given a chance to create a new team during the summers then he could turn around Chelsea fortunes. But the argument isn&#8217;t as convincing as one might want to believe.</p>
<p style="text-align: justify;">The biggest problem that Chelsea will have to deal with this summer is attracting exciting players. They either need the Champions League or a charismatic manager. Champions league qualification looks more and more unlikely as the days pass by. So to finally bring about the transition that we&#8217;ve been talking about for a year not we would need a coach with lots of klout &#8211; someone players will want to play for &#8211; a man with reputation.But then without the lure of Champions League would a manager be willing to take up the high-profile high-risk job of Roman&#8217;s empire?</p>
<p style="text-align: justify;">It&#8217;ll be unfair to Di Matteo after his inspiring work in these few weeks. But being realistic and without meaning any disrespect to him, I do not believe that he&#8217;ll remain as our manager the next season. The only reason I could perhaps want him to stay will be his love for the club. In fact, getting Zola as the manager could perhaps be the best solution. He&#8217;s a legend at Stamford Bridge. He could be to Chelsea what Pep has been to Barcelona. But after the spectacular failure of the young Villas Boas do I really believe Roman will go for another not-so-experienced coach again &#8211; naah.There are quite a few big names being talked about.</p>
<p style="text-align: justify;">Patience is the key. I&#8217;m already looking forwards to the next season with a hope that nothing can be worse than the year that has just passed. Just when you think Chelsea can get out of the miserable form they pull you back in!</p>
<img src="http://blog.singhanuvrat.com/?ak_action=api_record_view&id=2483&type=feed" alt="" /><p>Related posts:<ol>
<li><a href='http://blog.singhanuvrat.com/sports/epl-chelsea-vs-tottenham-hotspur-march-2012' rel='bookmark' title='EPL: Chelsea vs Tottenham Hotspur &#8211; March 2012'>EPL: Chelsea vs Tottenham Hotspur &#8211; March 2012</a></li>
<li><a href='http://blog.singhanuvrat.com/sports/fa-cup-chelsea-vs-leicester-city-march-2012-reaction' rel='bookmark' title='FA Cup: Chelsea vs Leicester City &#8211; March 2012 &#8211; Reaction'>FA Cup: Chelsea vs Leicester City &#8211; March 2012 &#8211; Reaction</a></li>
<li><a href='http://blog.singhanuvrat.com/sports/rumour-jose-to-chelsea' rel='bookmark' title='Rumour: Jose To Chelsea?'>Rumour: Jose To Chelsea?</a></li>
</ol></p><div class="feedflare">
<a href="http://feeds.feedburner.com/~ff/DiabolicalOrSmart?a=5b9RQ139SaI:ILmUBZfAI1E:yIl2AUoC8zA"><img src="http://feeds.feedburner.com/~ff/DiabolicalOrSmart?d=yIl2AUoC8zA" border="0"></img></a> <a href="http://feeds.feedburner.com/~ff/DiabolicalOrSmart?a=5b9RQ139SaI:ILmUBZfAI1E:TPCkKD-roEg"><img src="http://feeds.feedburner.com/~ff/DiabolicalOrSmart?i=5b9RQ139SaI:ILmUBZfAI1E:TPCkKD-roEg" border="0"></img></a>
</div><img src="http://feeds.feedburner.com/~r/DiabolicalOrSmart/~4/5b9RQ139SaI" height="1" width="1"/>]]></content:encoded>
			<wfw:commentRss>http://blog.singhanuvrat.com/sports/chelsea-do-i-want-di-matteo-to-stay/feed</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Your ClassNotFound Error Is Probably Not Telling You Everything</title>
		<link>http://blog.singhanuvrat.com/coding/your-classnotfound-error-is-probably-not-telling-you-everything</link>
		<comments>http://blog.singhanuvrat.com/coding/your-classnotfound-error-is-probably-not-telling-you-everything#comments</comments>
		<pubDate>Tue, 03 Apr 2012 20:40:36 +0000</pubDate>
		<dc:creator>Anuvrat</dc:creator>
				<category><![CDATA[Coding]]></category>
		<category><![CDATA[amazon]]></category>
		<category><![CDATA[classNotFoundException]]></category>
		<category><![CDATA[coding]]></category>
		<category><![CDATA[exception]]></category>
		<category><![CDATA[java]]></category>
		<category><![CDATA[noClassDefFoundError]]></category>
		<category><![CDATA[programming]]></category>
		<category><![CDATA[sdeTip]]></category>

		<guid isPermaLink="false">http://blog.singhanuvrat.com/?p=2479</guid>
		<description><![CDATA[Quicktip If a class fails to load due to an exception during class initialization, the actual problem is only logged the first time you attempt to load the class.  After the first time, the classloader recognizes that it’s already tried to load the class and just throws a ClassNotFoundException or NoClassDefFoundError. Symptom You will see [...]
Related posts:<ol>
<li><a href='http://blog.singhanuvrat.com/tech/adding-startup-and-shutdown-scripts-in-ubuntu' rel='bookmark' title='Adding Startup And Shutdown Scripts in Ubuntu'>Adding Startup And Shutdown Scripts in Ubuntu</a></li>
<li><a href='http://blog.singhanuvrat.com/problems/project-euler-digits-of-sum-of-11-22-3-3' rel='bookmark' title='Project Euler : Digits Of Sum of 1^1 + 2^2 + 3 ^ 3 &#8230;'>Project Euler : Digits Of Sum of 1^1 + 2^2 + 3 ^ 3 &#8230;</a></li>
<li><a href='http://blog.singhanuvrat.com/problems/adding-100-50-digit-numbers' rel='bookmark' title='Project Euler : Adding 100 50-Digit Numbers'>Project Euler : Adding 100 50-Digit Numbers</a></li>
</ol>]]></description>
			<content:encoded><![CDATA[<p style="text-align: justify;"><strong>Quicktip</strong><br />
If a class fails to load due to an exception during class initialization, the actual problem is only logged the first time you attempt to load the class.  After the first time, the classloader recognizes that it’s already tried to load the class and just throws a ClassNotFoundException or NoClassDefFoundError.</p>
<p style="text-align: justify;"><strong>Symptom</strong><br />
You will see logs for the ClassNotFoundException or NoClassDefFoundError (usually many such logs), but you see that the class is in the classpath.  You won’t see any root cause on any stack trace but the first (and that one is typically not a CNFE or NCDFE).</p>
<p><strong>Finding the root cause</strong><br />
If you get a CNFE or NCDFE and you see the class in the classpath, search back your logs for ${missing classname}.&lt;clinit&gt; in a stack trace to figure out what prevented the class from being loaded.  Remember that the log may have rolled off.</p>
<p><strong>Possible root causes for CNFE/NCDFE</strong></p>
<ul>
<li>Desired class is not in classpath (this is the boring case)</li>
<li>Initialization of desired class throws a RuntimeException or an Error</li>
<ul>
<li>Static variable is initialized via a function which threw an uncaught Throwable</li>
<ul>
<li>E.g. public static final String SOME_CONST = SomeClass.getString(“SOME_KEY”); where SomeClass.getString(String key) can throw an Exception.</li>
</ul>
<li>Static block (loose code in {} in the class definition) threw an uncaught Throwable</li>
<ul>
<li>E.g. public class Foo { { doSomeStaticInitialization(); } …</li>
</ul>
<li>variable or method signature includes type which could not be initialized (see this same list of root causes)</li>
<ul>
<li>E.g. public class Foo { SomeClassWithErrorInInitializer attr1; …</li>
</ul>
</ul>
</ul>
<p style="text-align: right;" class="alert">From The SDE Tip &#8211; Amazon</p>
<img src="http://blog.singhanuvrat.com/?ak_action=api_record_view&id=2479&type=feed" alt="" /><p>Related posts:<ol>
<li><a href='http://blog.singhanuvrat.com/tech/adding-startup-and-shutdown-scripts-in-ubuntu' rel='bookmark' title='Adding Startup And Shutdown Scripts in Ubuntu'>Adding Startup And Shutdown Scripts in Ubuntu</a></li>
<li><a href='http://blog.singhanuvrat.com/problems/project-euler-digits-of-sum-of-11-22-3-3' rel='bookmark' title='Project Euler : Digits Of Sum of 1^1 + 2^2 + 3 ^ 3 &#8230;'>Project Euler : Digits Of Sum of 1^1 + 2^2 + 3 ^ 3 &#8230;</a></li>
<li><a href='http://blog.singhanuvrat.com/problems/adding-100-50-digit-numbers' rel='bookmark' title='Project Euler : Adding 100 50-Digit Numbers'>Project Euler : Adding 100 50-Digit Numbers</a></li>
</ol></p><div class="feedflare">
<a href="http://feeds.feedburner.com/~ff/DiabolicalOrSmart?a=U0_Lv2Vh6eo:Y6N7zGdWPm0:yIl2AUoC8zA"><img src="http://feeds.feedburner.com/~ff/DiabolicalOrSmart?d=yIl2AUoC8zA" border="0"></img></a> <a href="http://feeds.feedburner.com/~ff/DiabolicalOrSmart?a=U0_Lv2Vh6eo:Y6N7zGdWPm0:TPCkKD-roEg"><img src="http://feeds.feedburner.com/~ff/DiabolicalOrSmart?i=U0_Lv2Vh6eo:Y6N7zGdWPm0:TPCkKD-roEg" border="0"></img></a>
</div><img src="http://feeds.feedburner.com/~r/DiabolicalOrSmart/~4/U0_Lv2Vh6eo" height="1" width="1"/>]]></content:encoded>
			<wfw:commentRss>http://blog.singhanuvrat.com/coding/your-classnotfound-error-is-probably-not-telling-you-everything/feed</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Chelsea: Torres and Sturridge Neighbors In Dressing Room!</title>
		<link>http://blog.singhanuvrat.com/sports/chelsea-torres-and-sturridge-neighbors-in-dressing-room</link>
		<comments>http://blog.singhanuvrat.com/sports/chelsea-torres-and-sturridge-neighbors-in-dressing-room#comments</comments>
		<pubDate>Sat, 24 Mar 2012 11:34:57 +0000</pubDate>
		<dc:creator>Anuvrat</dc:creator>
				<category><![CDATA[Sports]]></category>
		<category><![CDATA[chelsea]]></category>
		<category><![CDATA[dressingRoom]]></category>
		<category><![CDATA[pic]]></category>
		<category><![CDATA[sturridge]]></category>
		<category><![CDATA[torres]]></category>

		<guid isPermaLink="false">http://blog.singhanuvrat.com/?p=2466</guid>
		<description><![CDATA[In the Chelsea dressing room, players are allowed to choose their neighbors. Earlier they were seated by their jersey numbers. Now I don&#8217;t recall when this change happened but I remember it was because Terry wanted to sit beside someone else. But that is a completely different matter. Well, now the above arrangement in the [...]
Related posts:<ol>
<li><a href='http://blog.singhanuvrat.com/sports/chelsea-in-torres-we-trust' rel='bookmark' title='Chelsea: In Torres We Trust'>Chelsea: In Torres We Trust</a></li>
<li><a href='http://blog.singhanuvrat.com/sports/opportunity-for-the-golden-boy' rel='bookmark' title='Opportunity For The Golden Boy?'>Opportunity For The Golden Boy?</a></li>
<li><a href='http://blog.singhanuvrat.com/sports/torres-benched-again' rel='bookmark' title='Torres Benched Again !'>Torres Benched Again !</a></li>
</ol>]]></description>
			<content:encoded><![CDATA[<div class="wp-caption aligncenter" style="width: 730px"><img class="    " title="Chelsea Dressing Room" src="https://p.twimg.com/Aov3LsCCQAAvMDP.jpg:large" alt="Chelsea Dressing Room" width="720" height="540" /><p class="wp-caption-text">Chelsea Dressing Room</p></div>
<p style="text-align: justify;">In the Chelsea dressing room, players are allowed to choose their neighbors. Earlier they were seated by their jersey numbers. Now I don&#8217;t recall when this change happened but I remember it was because Terry wanted to sit beside someone else. But that is a completely different matter.</p>
<p style="text-align: justify;">Well, now the above arrangement in the Chelsea dressing room surprises me. It&#8217;s kind of ironic that Torres and Sturridge sit beside each other, what with Sturridge completely blanking out Torres in the games. Neighborly love hasn&#8217;t yet rubbed on eh?</p>
<p style="text-align: justify;">Source of pic: <a title="@chelseafc twitter status" href="https://twitter.com/#!/chelseafc/status/183511990004760577" target="_blank">@chelseafc</a></p>
<img src="http://blog.singhanuvrat.com/?ak_action=api_record_view&id=2466&type=feed" alt="" /><p>Related posts:<ol>
<li><a href='http://blog.singhanuvrat.com/sports/chelsea-in-torres-we-trust' rel='bookmark' title='Chelsea: In Torres We Trust'>Chelsea: In Torres We Trust</a></li>
<li><a href='http://blog.singhanuvrat.com/sports/opportunity-for-the-golden-boy' rel='bookmark' title='Opportunity For The Golden Boy?'>Opportunity For The Golden Boy?</a></li>
<li><a href='http://blog.singhanuvrat.com/sports/torres-benched-again' rel='bookmark' title='Torres Benched Again !'>Torres Benched Again !</a></li>
</ol></p><div class="feedflare">
<a href="http://feeds.feedburner.com/~ff/DiabolicalOrSmart?a=diWhGViSvG8:uQ699E2omO0:yIl2AUoC8zA"><img src="http://feeds.feedburner.com/~ff/DiabolicalOrSmart?d=yIl2AUoC8zA" border="0"></img></a> <a href="http://feeds.feedburner.com/~ff/DiabolicalOrSmart?a=diWhGViSvG8:uQ699E2omO0:TPCkKD-roEg"><img src="http://feeds.feedburner.com/~ff/DiabolicalOrSmart?i=diWhGViSvG8:uQ699E2omO0:TPCkKD-roEg" border="0"></img></a>
</div><img src="http://feeds.feedburner.com/~r/DiabolicalOrSmart/~4/diWhGViSvG8" height="1" width="1"/>]]></content:encoded>
			<wfw:commentRss>http://blog.singhanuvrat.com/sports/chelsea-torres-and-sturridge-neighbors-in-dressing-room/feed</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>EPL: Chelsea vs Tottenham Hotspur – March 2012</title>
		<link>http://blog.singhanuvrat.com/sports/epl-chelsea-vs-tottenham-hotspur-march-2012</link>
		<comments>http://blog.singhanuvrat.com/sports/epl-chelsea-vs-tottenham-hotspur-march-2012#comments</comments>
		<pubDate>Sat, 24 Mar 2012 05:00:41 +0000</pubDate>
		<dc:creator>Anuvrat</dc:creator>
				<category><![CDATA[Sports]]></category>
		<category><![CDATA[bpl]]></category>
		<category><![CDATA[chelsea]]></category>
		<category><![CDATA[epl]]></category>
		<category><![CDATA[football]]></category>
		<category><![CDATA[season2011]]></category>
		<category><![CDATA[tottenham]]></category>
		<category><![CDATA[video]]></category>

		<guid isPermaLink="false">http://blog.singhanuvrat.com/?p=2461</guid>
		<description><![CDATA[No one needs to be reminded about how massive a game this is for both the clubs. A month ago Spurs were flying high in their third place, comfortably ahead of Arsenal. But all that England manager talk seems to have gotten to them and now they are fourth with just 5 more better than [...]
Related posts:<ol>
<li><a href='http://blog.singhanuvrat.com/sports/epl-manchester-city-vs-chelsea-march-2012' rel='bookmark' title='EPL: Manchester City vs Chelsea &#8211; March 2012'>EPL: Manchester City vs Chelsea &#8211; March 2012</a></li>
<li><a href='http://blog.singhanuvrat.com/sports/fa-cup-chelsea-vs-leicester-city-march-2012-reaction' rel='bookmark' title='FA Cup: Chelsea vs Leicester City &#8211; March 2012 &#8211; Reaction'>FA Cup: Chelsea vs Leicester City &#8211; March 2012 &#8211; Reaction</a></li>
<li><a href='http://blog.singhanuvrat.com/sports/fa-cup-chelsea-vs-leicester-city-march-2012' rel='bookmark' title='FA Cup: Chelsea vs Leicester City &#8211; March 2012'>FA Cup: Chelsea vs Leicester City &#8211; March 2012</a></li>
</ol>]]></description>
			<content:encoded><![CDATA[<p><iframe src="http://www.youtube.com/embed/-_eutq_oiGA" frameborder="0" width="853" height="480"></iframe></p>
<p style="text-align: justify;">No one needs to be reminded about how massive a game this is for both the clubs. A month ago Spurs were flying high in their third place, comfortably ahead of Arsenal. But all that England manager talk seems to have gotten to them and now they are fourth with just 5 more better than Chelsea. If Chelsea were to win today this fight for the final Champions League birth will go right to the end!</p>
<p style="text-align: justify;">Last weeks defeat at the hands of Manchester City coupled with Spurs somehow drawing their match leaves Chelsea with a must-win scenario. 5 points towards the end of the season is too much to make up and a win is absolutely must if we want to qualify for the Champions League. The FA Cup and the Champions League games coming up don&#8217;t make life any easier as Di Matteo must take care of player energy levels and rotate the squad. Arsenal and Tottenham do not have this problem &#8211; and I don&#8217;t envy them for this luxury.</p>
<p style="text-align: justify;">I will be watching the game nervously, hoping for a Chelsea victory. Let&#8217;s pile more pressure on Spurs. We know they can crack under pressure and yield us that qualifying spot.</p>
<img src="http://blog.singhanuvrat.com/?ak_action=api_record_view&id=2461&type=feed" alt="" /><p>Related posts:<ol>
<li><a href='http://blog.singhanuvrat.com/sports/epl-manchester-city-vs-chelsea-march-2012' rel='bookmark' title='EPL: Manchester City vs Chelsea &#8211; March 2012'>EPL: Manchester City vs Chelsea &#8211; March 2012</a></li>
<li><a href='http://blog.singhanuvrat.com/sports/fa-cup-chelsea-vs-leicester-city-march-2012-reaction' rel='bookmark' title='FA Cup: Chelsea vs Leicester City &#8211; March 2012 &#8211; Reaction'>FA Cup: Chelsea vs Leicester City &#8211; March 2012 &#8211; Reaction</a></li>
<li><a href='http://blog.singhanuvrat.com/sports/fa-cup-chelsea-vs-leicester-city-march-2012' rel='bookmark' title='FA Cup: Chelsea vs Leicester City &#8211; March 2012'>FA Cup: Chelsea vs Leicester City &#8211; March 2012</a></li>
</ol></p><div class="feedflare">
<a href="http://feeds.feedburner.com/~ff/DiabolicalOrSmart?a=TQKKfoOnfqA:d6M0BVrbWP4:yIl2AUoC8zA"><img src="http://feeds.feedburner.com/~ff/DiabolicalOrSmart?d=yIl2AUoC8zA" border="0"></img></a> <a href="http://feeds.feedburner.com/~ff/DiabolicalOrSmart?a=TQKKfoOnfqA:d6M0BVrbWP4:TPCkKD-roEg"><img src="http://feeds.feedburner.com/~ff/DiabolicalOrSmart?i=TQKKfoOnfqA:d6M0BVrbWP4:TPCkKD-roEg" border="0"></img></a>
</div><img src="http://feeds.feedburner.com/~r/DiabolicalOrSmart/~4/TQKKfoOnfqA" height="1" width="1"/>]]></content:encoded>
			<wfw:commentRss>http://blog.singhanuvrat.com/sports/epl-chelsea-vs-tottenham-hotspur-march-2012/feed</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>EPL: Manchester City vs Chelsea – March 2012</title>
		<link>http://blog.singhanuvrat.com/sports/epl-manchester-city-vs-chelsea-march-2012</link>
		<comments>http://blog.singhanuvrat.com/sports/epl-manchester-city-vs-chelsea-march-2012#comments</comments>
		<pubDate>Mon, 19 Mar 2012 03:10:53 +0000</pubDate>
		<dc:creator>Anuvrat</dc:creator>
				<category><![CDATA[Sports]]></category>
		<category><![CDATA[bpl]]></category>
		<category><![CDATA[chelsea]]></category>
		<category><![CDATA[epl]]></category>
		<category><![CDATA[manchesterCity]]></category>
		<category><![CDATA[season2011]]></category>
		<category><![CDATA[video]]></category>

		<guid isPermaLink="false">http://blog.singhanuvrat.com/?p=2454</guid>
		<description><![CDATA[We have yet another blockbuster coming our way. We travel to the Etihad stadium to face the wounded Manchester City who we defeated 2-1 at home earlier in December. Remember that game when the high flying blue side of Manchester visited a frail Chelsea? That was a sweet victory. We were the first team in [...]
Related posts:<ol>
<li><a href='http://blog.singhanuvrat.com/sports/epl-chelsea-vs-tottenham-hotspur-march-2012' rel='bookmark' title='EPL: Chelsea vs Tottenham Hotspur &#8211; March 2012'>EPL: Chelsea vs Tottenham Hotspur &#8211; March 2012</a></li>
<li><a href='http://blog.singhanuvrat.com/sports/fa-cup-chelsea-vs-leicester-city-march-2012-reaction' rel='bookmark' title='FA Cup: Chelsea vs Leicester City &#8211; March 2012 &#8211; Reaction'>FA Cup: Chelsea vs Leicester City &#8211; March 2012 &#8211; Reaction</a></li>
<li><a href='http://blog.singhanuvrat.com/sports/fa-cup-chelsea-vs-leicester-city-march-2012' rel='bookmark' title='FA Cup: Chelsea vs Leicester City &#8211; March 2012'>FA Cup: Chelsea vs Leicester City &#8211; March 2012</a></li>
</ol>]]></description>
			<content:encoded><![CDATA[<p><iframe src="http://www.youtube.com/embed/Fkin8IC-lB0" frameborder="0" width="640" height="360"></iframe></p>
<p style="text-align: justify;">We have yet another blockbuster coming our way. We travel to the Etihad stadium to face the wounded Manchester City who we defeated 2-1 at home earlier in December. Remember that game when the high flying blue side of Manchester visited a frail Chelsea? That was a sweet victory. We were the first team in this season to defeat Manchester City! Now it&#8217;s time to inflict their first home defeat in the premier league. Are we ready? Hell yea &#8211; more than we have ever been this whole season.</p>
<p style="text-align: justify;">We have strung together a streak of 4 wins scoring 12 and allowing only 3 in the process. Torres is finding his feet once again and the <em>Old Guard</em> are back to their dominating best. Manchester City on the other hand have just crashed out of the European competition &#8211; that&#8217;s twice in two months actually &#8211; and were also defeated by Swansea City. They are also under tremendous pressure with Manchester United having taken a 4 point lead yesterday. After having spent so much in the summer &#8211; a British record &#8211; a trophy-less season will be a disaster for Mancini.</p>
<p style="text-align: justify;" class="alert">Quick Fact: Last time a club smashed the British summer spending record they went on to win the Premier League two consecutive seasons. That was Chelsea of course.</p>
<p style="text-align: justify;">The biggest headache for RDM will be his team selection. Chelsea has mostly played in the 4-3-3 formation. But with Torres and Drogba both showing good form there is a possibility to pair them up at the front. RDM has tried that in the Napoli game towards the end and one wouldn&#8217;t call that a disaster.  Also Mata has been playing centrally just behind the strikers the last two games. Has RDM been preparing his team for the coming fixture? Below is the team I would like to see walk out on Wednesday.</p>
<p><a><img class="aligncenter" src="http://this11.com/boards/abCjCEhakR.jpg" alt="football formations" border="0" /></a></p>
<p style="text-align: justify;">C&#8217;mon. Admit it. Every Chelsea fan wants to see the pairing of Drogba and Torres flourish. Add the cunning Mata behind them and you&#8217;ve got yourself an entertainment. The only problem with having Mata in the center is that when Chelsea attack through the flanks he becomes useless. Ivanovich has been something like a revelation. The way he&#8217;s attacking the right flank and sending across those crosses is amazing. We do need the hard working Ramires in the team. His energy keeps our otherwise static midfield on their toes. Lampard over Meirless is a no brainer. And the tidy Essien should sit in front of the defense. When Essien&#8217;s in the mood, and given the Bison that he is nicknamed, he keeps the ball well and helps breakdown opposition attacks.</p>
<p style="text-align: justify;">For me Mata behind the strikers is the key. But he&#8217;ll have to deal with the physical presence of Yaya Toure. I&#8217;m hoping for another great game of football and keeping my fingers crossed for a Chelsea victory.</p>
<img src="http://blog.singhanuvrat.com/?ak_action=api_record_view&id=2454&type=feed" alt="" /><p>Related posts:<ol>
<li><a href='http://blog.singhanuvrat.com/sports/epl-chelsea-vs-tottenham-hotspur-march-2012' rel='bookmark' title='EPL: Chelsea vs Tottenham Hotspur &#8211; March 2012'>EPL: Chelsea vs Tottenham Hotspur &#8211; March 2012</a></li>
<li><a href='http://blog.singhanuvrat.com/sports/fa-cup-chelsea-vs-leicester-city-march-2012-reaction' rel='bookmark' title='FA Cup: Chelsea vs Leicester City &#8211; March 2012 &#8211; Reaction'>FA Cup: Chelsea vs Leicester City &#8211; March 2012 &#8211; Reaction</a></li>
<li><a href='http://blog.singhanuvrat.com/sports/fa-cup-chelsea-vs-leicester-city-march-2012' rel='bookmark' title='FA Cup: Chelsea vs Leicester City &#8211; March 2012'>FA Cup: Chelsea vs Leicester City &#8211; March 2012</a></li>
</ol></p><div class="feedflare">
<a href="http://feeds.feedburner.com/~ff/DiabolicalOrSmart?a=zTuuIHtMni4:VI3iwZBhSmI:yIl2AUoC8zA"><img src="http://feeds.feedburner.com/~ff/DiabolicalOrSmart?d=yIl2AUoC8zA" border="0"></img></a> <a href="http://feeds.feedburner.com/~ff/DiabolicalOrSmart?a=zTuuIHtMni4:VI3iwZBhSmI:TPCkKD-roEg"><img src="http://feeds.feedburner.com/~ff/DiabolicalOrSmart?i=zTuuIHtMni4:VI3iwZBhSmI:TPCkKD-roEg" border="0"></img></a>
</div><img src="http://feeds.feedburner.com/~r/DiabolicalOrSmart/~4/zTuuIHtMni4" height="1" width="1"/>]]></content:encoded>
			<wfw:commentRss>http://blog.singhanuvrat.com/sports/epl-manchester-city-vs-chelsea-march-2012/feed</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
	</channel>
</rss>

