Wallowing in bed lazily on a Monday afternoon, I started watching a documentary on the Civil War by Ken Burns. While the first episode was in entirety riveting, the most poignant section was towards the end, where, to a rendition of Ashokan Farewell in the background, an actor recited portions of a letter that Major Sullivan Ballou had written to his wife Sarah a week before the First Battle of Bull Run, in which (as he had predicted / feared in his letter) he lay down his life for the cause of the Union.

Major Ballou writes eloquently about his love for his wife and their children but points out frequently that service to his nation is far more important to him than the happiness he can ever seek in their company.

Sarah, my love for you is deathless, it seems to bind me to you with mighty cables that nothing but Omnipotence could break; and yet my love of Country comes over me like a strong wind and bears me irresistibly on with all these chains to the battlefield.

It is Memorial Day in the United States, and I salute servicemen all across the globe for laying their lives down so we could continue to live and for engaging in wars no one likes to wage so we could all live in peace.

 

The greatest footballer the world never recognized as such.

Il Capitano, Paolo Maldini, the greatest footballer ever

Il Capitano, Paolo Maldini, the greatest footballer ever

 

Absolutely funny video of a monkey playing pranks on a couple of tigers. The monkey reminds me of thalaivar – “yer-la (air-la) parandhu parandhu adikkudhu”

 

One of the debates over the past few months has been about the use and the ban of torture – or enhanced interrogation techniques – against terror suspects. America’s newfound morality amazes me as a dabbler in history. A sound clip in the Wikipedia entry on the bombings of Hiroshima and Nagasaki is of then President Truman announcing the the annihilation of the former. The voice says:

“The world will note that the first atomic bomb was dropped on Hiroshima, a military base. We won the race of discovery against the Germans.We have used it in order to shorten the agony of war, in order to save the lives of thousands and thousands of young Americans. We shall continue to use it until we completely destroy Japan’s power to make war.”

The estimate of the number of people who lost their lives because of this barbaric act is pegged at over 200000, a major portion of which must be civilians. When Barack Obama says that the ban on torture is necessary to restore America’s moral standing in the world, one wonders which period the President is talking about. Surely not 1945?

P.S.: According to Wikipedia, “Truman has been consistently ranked by scholars as one of the greatest U.S. Presidents.”

 

Manmohan Singh, Rahul Gandhi and Mamata Banerjee will be the names bandied about in the media as the big victors of this election. No denying that. But in an understated way, the Chief Minister of Tamil Nadu, M. Karunanidhi, is one of the biggest winners. Under pressure for being non-committal on the issue of Sri Lankan Tamils, and having had to endure a split in the grand coalition that he cobbled together in the previous election, MK and the DMK were expected to fare poorly. In contrast, the ADMK was supposed to be in the ascendancy, with some “political pundits” even predicting that Jayalalithaa would play a crucial role in Government formation. Bollocks!

Winning 18 seats of their own, when their entire combine was expected to pick up only 15, the DMK has sprung a surprise and MK will ensure that Tamil Nadu gets more than its fair share of plum Cabinet posts. That is price for remaining one of the Congress’ most dependable allies. Come rain or shine, the DMK does manage to win seats. And its impressive win ratio of over 80% (18 wins from 22) is possibly the best showing across the country by any party that contested in more than ten seats.

Longevity is its own reward, but when coupled with success, it is even more delectable. At (a couple of weeks short of) 86, MK surely must be given the title, “the Grand Old Man of Indian Politics” for never ceasing to amaze.

P.S.: Apologists for the ADMK’s defeat drubbing will tell you that the DMK won because of “money power”. Which is bullshit of the first order. If that is what it takes to win an election, so be it, and it is not as if Amma is not endowed with either the wisdom or the deep pockets to win at the ballot box. And Vijayakanth stealing votes from the ADMK is against a stupid argument. You lost because you lost. Being intelligent as to the causes of an event after it happens does not change its outcome.

And folks like Vijayakanth and Chiranjeevi, you are IRRELEVANT. You are no MGR or NTR. While you can keep chipping away, that is the most you can do. Keep making movies, or just retire.

 

The best comic ever

The best comic ever

The only trouble in sharing a really good joke is having to explain it.

 

Consider this. You have a list* of maps. You want to replicate the list a specified number of times. For example, if the list has two maps, and you want to create from this list another list that contains six maps. The constraint is that you have to write your own method, and you must not use Java’s object cloning feature.

The first approach is simple. You take each map in the list and add it to the list a specified number of times (n-1 times, if n is multiplier). If this is methodized, the code would look something like this.

firstcut

A first-cut, defective solution

Basically, we add every map from the input list into a temporary list, and then add back to the original list each map “n” (or, in this case, “size”) number of times. And all is well.

Well? Think again. The above method will fail… miserably. It will, of course, return a list of maps that is n times bigger. But its utility ends there. If you work with the list, you will find that it behaves strangely. Modifying some element in the list will also modify some other element. Why does this happen?

In our ingenious first-cut method, we have add the same map multiple times to the list. What happens internally is that the list contains multiple references to the same map (or set of maps). So any change to one map in the resultant list will also modify all its replicas, since each map reference points to the same map. In essence, we have performed a shallow copy.

The correct approach (and I do not claim that this is the best) is to modify the map-copy portion of the above method (the second for-loop) as follows. Iterate through the map entries and copy each entry, i.e. key-value pair, to a temporary map, and when done, add this map to the list. This way, you are not left with references to a single map. Each map in the list is its own object.

second-cut

A better, more correct solution

 

Update

The purpose of the above was specifically to illustrate the concept of object references. The point is, you cannot copy objects in Java the way you copy simple data types. The more straightforward solution to the above (as Thejo points out) is to use the constructor of the HashMap (or another map implementation) class. Under the hood, however, the constructor does the same thing as we have done — it iterates through the map entries and copies each key-value pair of the passed map object to a new map object.

Here is how the method will look when refactored.

third-cut

An easier, more straight-forward approach

P.S.: Looking back, all this sounds very intuitive. Yet, intuition is not the first faculty that one can command when frantically debugging code on a Sunday evening. 

* I have used list and map instead of List and Map. This is just for explanatory purposes. If you are a purist, please accept my sincerest apologies.

 

Arsene Wenger had promised a magnificent performance from his side ahead of the second leg Champions League semifinal tie at home against Manchester United. Instead the Gunners received a master class in counter-attacking football from the Red Devils, especially Cristiano Ronaldo.

Video highlights will follow.

Of the three goals United scored tonight, my favorite is the third where Park and Rooney combined brilliantly to set up Ronaldo to complete a move that he had started with a deft back heel. It reminded me of a very similar goal that Rooney and Ronaldo scored a couple of seasons ago against Bolton. It remains one of the best goals of the end-to-end quick counter-attack variety that I’ve seen.

The quality of this video is poor. I couldn’t find a better one.

 

El clásico, the Real Madrid – Barcelona derby turned out to be a total humiliation for Real Madrid today, as the hosts were blanked out 6 – 2 by a rampaging Barcelona side that moved ever closer to regaining the Primera Liga. To be honest, I think I’ve used the word rampaging incorrectly, because it didn’t seem like the Blaugranas needed to produce an inspired performance to beat Real, who were poor through and through. So while one must not deny Barca the plaudits, one should also not hold back criticism of a spineless Real side, whose obvious shortcomings were exposed by their Catalan rivals, just as Liverpool had a few weeks ago. Real Madrid conceded six goals, their worst defensive performance at home in the history of the derby, but they could well have conceded 16 – yes, they were that bad.

The result puts Barcelona seven points ahead of Real. With just four games left in the Liga, Barca have well and truly wrapped up the league. Given the substantial goal advantage they possess (+72 for Barca against +38 for Real), a win and two draws will guarantee glory for Guardiola’s men. And so they will turn their attention to Wednesday night’s Champions League semifinal second leg at Stamford Bridge.

While I like Barcelona better than Chelsea (who I don’t like), I would consider the home side favorites to progress. Chelsea, having worked their socks off to bring home a creditable 0-0 draw away at the Nou Camp, will offer more of the same but will be a bit more adventurous and try to exploit Barcelona’s defensive fragility – an aspect of their game that Guardiola must work on. Barcelona are without their overrated first choice central defensive pairing (Puyol and Marquez), and Drogba might relish taking on young Pique.

I thought Chelsea would rest many of their big names and field a less potent line-up today. But I was surprised by Hiddink’s decision to play Chelsea’s first team against Fulham. Barca could not have afforded the same luxury as defeat would have meant that Real would be breathing down their necks.

Talking of resting players, Arsenal sent out a virtual B-team against Pompey, and still ran out 3-1 winners. To be fair, United rested Cristiano Ronaldo, Edwin van der Sar and their entire starting midfield from midweek, but that is about as much tinkering that Sir Alex Ferguson could afford.

I predict that the 2009 Champions League final would be a repeat of 2008′s, with Chelsea challenging United in Rome for the crown. Chelsea to win at home against Barcelona, and United to pick up an away win at the Emirates.

© 2011 VKpedia Suffusion theme by Sayontan Sinha