whihathac's Den

code is poetry

Format XML in C#

Found an interesting link - http://www.shrinkrays.net/code-snippets/csharp/format-xml-in-csharp.aspx

This is to format XML in C#. I have found it quite useful to view and analyze the XML returned from the Web Services.

/// <summary> 
/// Formats the provided XML so it's indented and humanly-readable. 
/// </summary> 
/// <param name="inputXml">The input XML to format.</param> 
/// <returns></returns> 
public static string FormatXml(string inputXml) 
    XmlDocument document = new XmlDocument(); 
    document.Load(new StringReader(inputXml)); 
    StringBuilder builder = new StringBuilder(); 
    using (XmlTextWriter writer = new XmlTextWriter(new StringWriter(builder))) 
        writer.Formatting = Formatting.Indented; 
    return builder.ToString(); 


IPL 3 – Mathematics for Semis

I and Sandy (Sandeep Kumar) got to the inside of the mathematics behind the top 4 slots for IPL 3 Semis after considering all possible outcomes (2*2*2) of the remaing 3 matches and the most likely impact on the Net Run Rate. This does brings out interesting facts.

Following is the current standings (as on 4/17)–>


Matches Points NRR
Mumbai Indians (MI) 13 20 1.251
Royal Challengers Bangalore (RCB) 14 14 0.219
Delhi Daredevils (DD) 13 14 0.066
Deccan Chargers (DC) 13 14 -0.363
Chennai Super Kings (CSK) 13 12 0.27
Kolkata Knight Riders (KKR) 13 12 -0.456
Rajasthan Royals (RR) 14 12 -0.514
Kings XI Punjab (KXIP) 13 8 -0.49

On Following are the analysis for each teams:

1. Mumbai Indians: They have already qualified for Semis and will pick up the 1st slot. The only unanswered question is whom do they play for Semis. They will see RCB if CSK wins against KXIP else they’ll see the losing team of DC and DD and with a very slight chance of seeing KKR.

2. Royal Challengers Bangalore: They are surely in Semis. The position now depends on CSK vs KXIP. If CSK win, RCB will take the 4th berth and play MI in Semis else they remain on 2nd berth and avoid MI in Semis.

3. Delhi Daredevils: If they win against DC, they take the 2nd berth. They can still qualify for the Semifinals provided CSK loses against KXIP. KKR shouldn’t pose problem since their runrate is quite high and they should try to maintain the run-rate while losing to DC.

4. Deccan Chargers: Same case as DD. If they win against DD, they take the 2nd berth. They can still qualify for the Semifinals provided CSK loses against KXIP but they should control the net run rate (while losing to DD) so that they don’t fall behind KKR and lose the semi-finals spot to them.

5. Chennai Super Kings: Couldn’t get more simple than this. CSK needs to win against KXIP to be in Semis. If they win, they’ll take up the 3rd Spot.

6. Kolkata Knight Riders: Chances are quite low, but still statistically possible. They do still need to beat MI (quite convincingly) and then hope that the winner of DC vs DD wins with a huge margin. Though looking at the present net run rate KKR should hope that DD wins against DC.

7. Rajasthan Royals: Well its THE-END for the team. No chances to play in Semis this year. :(

8. Kings XI Punjab: KXIP wont play the Semis, but they can still stop CSK from qualifying if they win against them.

To Reference follow the below table to check who’ll be the Top –4 teams and which are the teams playing Semis 1 and Semis 2.

KXIP vs CSK DD vs DC MI vs KKR Points table (top 4) Semi Final 1 Semi Final 2


Bhavik and Sandeep.

P.S.: Thanks to Ranjit Salvi (die hard fan of KKR) : this analysis was also done in a bid to prove that chances of KKR qualifying for Semis are even less than 1/8 (considering net run rate is a major factor). ;)

For Swayams query - Swayam Khialani :  bangalore can still (statistically) get knocked out if kolkata beat mumbai by a huge huge huge margin and if chennai beat kings 11... then it would be MI, DD/DC, Chennai, Kolkata in semis... btw, by how much does kolkata need to beat mumbai to stand a possible chance???

Our joint answer:

Considering your scenario: MI(1st spot), DD/DC Winner (2nd spot), Chennai (3rd spot) - Fixed!!

NRRs: CSK (considering a win) > 0.270; DD < 0.066 (if they lose), DC < -0.363 (if they lose); RCB = 0.219; KKR (current) -0.456

For KKR to win in this scenario, they have to beat the NRR of RCB to claim the 4th spot... The first 2 would be taken on the basis of points while the 3rd spot CSK would enjoy a NRR of > 0.270. So, KKR would require to make their NRR surpass 0.219 (of RCB). We have 2 cases.

Present NRR equation for KKR: (2009/255.3) - (2059/247.3) = -0.456

Case 1: KKR bats first and scores x runs (in 20 overs or gets all out before), Mumbai is restricted to y runs(in 20 overs or gets all out before)

New NRR value for KKR = ((2009+x)/275.3) - ((2059+y)/267.3) which needs to be > 0.219

Solving the inequality, (x-y) should be roughly > 160 runs (Whoa!!)

Case 2: MI bats first and scores x runs(in 20 overs or gets all out before); KKR scores (x+1) in y overs

New NRR value for KKR = ((2010+x)/(255.3+y)) - ((2059+y)/267.3) which needs to be > 0.219

This inequality is not solvable for positive values of x and y. This implies KKR cannot achieve the reqd. NRR.

Conclusion: KKR will need to bat first !!! Hope Ganguly realises this maths before he walks in for the toss!!! ;)

Watch MIX 10 Sessions online


You Couldn’t Make It to MIX10 - but You Can Watch Online

While it isn’t the same as attending MIX10, we’ve made it possible for you to watch the keynotes and sessions (posted within 24 hours after they happen) and interact with the MIX Online community. Visit the MIX10 site now to see what you’re missing. Learn about the next generation of Windows Phone 7 Series, Internet Explorer 9 and the future of Web Design and User Experience.


Upgrading to BlogEngine.NET 1.6 from Previous versions

Hi All,

I use BlogEngine.NET , the best opensource .NET blogging platform. And on Friday morning I had been busy for about 20 mins upgrading to 1.6 version. The upgrade was pretty smooth but with one glitch. I found an issue while following the usual steps learnt over my previous upgrade experiences, Well then, there is a step missing (its missing even on the BlogEngine.NET Upgrade Page).

There has been some changes done to the App_Data\DataStore folder with some addition of some config files. I was eventually able to find this issue when BenAmada replied to me on the BlogEngine.NET forums. Well this fixes all the issues with the installation and I am currently checking out the new features of the upgrade!

For an excellent upgrade instruction guide head over to David Wynne’ Blog. I wish I had seen it earlier :)


Important Reminder Regarding Expiration of the Windows 7 RC

Source: The Windows Blog - http://windowsteamblog.com/blogs/windows7/archive/2010/02/01/

On February 15th, people still running the Windows 7 Release Candidate (RC) will receive a notification reminding them that starting March 1st, 2010, their PC will begin experiencing bi-hourly shutdowns. These shutdowns will continue through June 1st, 2010.

On June 1st, 2010, a non-genuine experience is triggered where your wallpaper is removed and “This copy of Windows is not genuine” will be displayed in the lower right corner above the taskbar. This means your PC will no longer be able to obtain optional updates or downloads that require genuine Windows validation.

To avoid any data loss, I suggest making plans to move to a released version of Windows 7 before the automatic shutdowns start. During these shutdowns, your work will not be saved.”

In short – Please upgrade to RTM version before Feb 15 to avoid nagging.



Got this nice forward. Thought of sharing this to you all ---

Hope you will enjoy the  very useful hand book. All the  forty  points are worth remembering while we all welcome the  New Year 2010.
Thank you 2009 for having made all of us sail through without any great trouble. Wish you a great new year 2010.       
                 "TIMELY & VERY HANDY 2 FOLLOW"


1. Drink plenty of water.

2. Eat breakfast like a king, lunch like a prince and dinner like a beggar.

3. Eat more foods that grow on trees and plants and eat less food that is manufactured in plants.

4. Live with the 3 E's -- Energy, Enthusiasm, and Empathy.

5. Make time to practice meditation, yoga, and prayer.

6. Play more games.

7. Read more books than you did in 2009.

8. Sit in silence for at least 10 minutes each day.

9. Sleep for 7 hours.

10. Take a 10-30 minutes walk every day. And while you walk, smile.


11. Don't compare your life to others'. You have no idea what their journey is all about.

12. Don't have negative thoughts or things you cannot control. Instead invest your energy in the positive present moment.

13. Don't overdo. Keep your limits.

14. Don't take yourself so seriously. No one else does.

15. Don't waste your precious energy on gossip.

16. Dream more while you are awake.

17. Envy is a waste of time. You already have all you need.

18. Forget issues of the past. Don't remind your partner with his/her mistakes of the past. That will ruin your present happiness.

19. Life is too short to waste time hating anyone. Don't hate others.

20. Make peace with your past so it won't spoil the present.

21. No one is in charge of your happiness except you.

22. Realize that life is a school and you are here to learn. Problems are simply part of the curriculum that appear and fade away like algebra class but the lessons you learn will last a lifetime.

23. Smile and laugh more.

24. You don't have to win every argument. Agree to disagree.


25. Call your family often.

26. Each day give something good to others.

27. Forgive everyone for everything.

28. Spend time with people over the age of 70 & under the age of 6.

29. Try to make at least three people smile each day.

30. What other people think of you is none of your business.

31. Your job won't take care of you when you are sick. Your friends will. Stay in touch.


32. Do the right thing!

33. Get rid of anything that isn't useful, beautiful or joyful.

34. GOD heals everything.

35. However good or bad a situation is, it will change.

36. No matter how you feel, get up, dress up and show up.

37. The best is yet to come.

38. When you awake alive in the morning, thank GOD for it.

39. Your Inner most self is always happy. So, be happy.

Last but not the least:

40. Please Forward this to everyone you care about

3 Idiots (2009 – Hindi)

Cast: Aamir Khan, Sharman Joshi, Madhavan, Kareena, Boman Irani.
Directed by : Rajkumar Hirani
Length: 2 hours 50 mins (approximately)

Loosely based on novel ‘5 Point Someone’ by Chetan Bhagat, '3-Idiots' is a feel good movie which is hilarious, filled with emotions and comes with a clear message for the current education system. Set in the background of an Engineering college, the movie focuses on the real ground issues prevalent in current system as theoretical knowledge and practical knowledge, exam stress, career rat race, student suicides, peer and parents pressure.

The film starts with Farhan (Madhavan) who has boarded a plane and a frantic call from his college friend “Silencer” who tells them that Rancho (Aamir) has been found. He manages to get the plane do an emergency landing by enacting a cardiac arrest and is on route to pick up Raju (Sharman). Soon they find that he is in Shimla and they start the journey to meet him. Then movie goes into a flashback.

Shot in IIM-Bangalore, the 3 students Farhan, Raju and Rancho enter the Imperial College of Engineering (ICE), the premier college of Engineering in India of which Viru Sahastrabudhhe aka ‘Virus’ (Boman Irani) is the dean of. College starts with Ragging of the newcomers where seniors are trying to force undo their pants. Rancho takes the charge and pulls of the plug on the senior with his plain simple knowledge of science. Following these are very comic sequences in college involving Rancho and various professors and the dean himself.

The movie rides on the emotional drama unfolding at various check points where Rancho emerges as the savior. Rancho is the best friend who makes his friends realize their dreams, the unknown stranger who ignites a break-up and then falls in love with Pia (Kareena) who is actually Viru’s daugher, the scientist who comes up with innovations that come from applying theory to practice. The ultimate timings of the dialogs and the jokes will engross you so much that you wouldn’t want the movie to stop.

Rancho emerges as the Student of the Year while he graduate and mysteriously disappears. And movie then comes back to the present. And from here to “All Iz Well” is the happy ending of the movie.

There is so much to write in the review. But wouldn’t want to spoil the fun for the movie-goers. :).

Positives: Movie is a laughter riot. Based on a strong script Aamir, Sharman and Madhavan delivers the positive message that Hirani wishes to tell as he has done with the MunnaBhai series. You can relate Rancho with Munnabhai, and will fall in love with the fun-loving, patient and extremely soft hearted character. The Music is notably good. Boman is also an respectable and adorable in his role.

Negatives: Kareena was in a short 20 min cameo role. (I’d rather consider it as a positive, but for the junta).

Verdict: 5/5. After all the movie is inspired from “5 point someone” ;). The movie is a total paisa-wasool and is right for this festive season. I am really lucky to see the 2 awesome movies – Avatar and 3 Idiots back to back, a good start to the end of this year. I am ready to watch any of the movie again. Any goers ?

Original Post: http://blog.bhavikvora.com/post/2009/12/24/3-Idiots-(2009-e28093-Hindi).aspx

Avatar 3D - (2009 – English)

Original Post: http://blog.bhavikvora.com/post/2009/12/23/Avatar-3D-(2009-e28093-English).aspx

James Cameron, writer and director of Blockbusters like Terminator 1 and 2, Titanic, Aliens presents to you Avatar – a Sci-fiction movie set at backdrop of an alien land – Pandora and their inhabitants Na’vi (that understand and talk in English – Now I know why it is an universal language :p). It’s 2154AD, and Humans are deployed to a moon Pandora to Polyphemus for exploiting ‘Unobtanium’ (see the unusual name :)), a precious metal which sells for $20mn/kg back on Earth. And there are Scientists who are trying to understand Na’vi by creating hybrid Avatars. Jake Sully (Sam Worthington) is a former Marine who is paralyzed below waist, is chosen for the ‘Avatar Program’ when his twin brother who was a scientist there is killed. And he takes his brother's place because he is compatible with his brother’s avatar.

The story unfolds into Jake’s Avatar getting lost into the jungle and is attacked by many dangerous predators. This attracts the attention of a female Na’vi named Neytiri (Zoe Saldaña) who initially thought of killing Jake, saves her when some floating seeds are attracted to him and she sees it as a spirityal sign from Eywa (mother goddess, they worship). Neytiri then takes her to the Na’vi Hometree, where the clan lives. Amidst much confrontation, Neytiri’s father, the leader of the tribe allows Jake being part of them.

Moving forward the story, underneath Na’vi hometree is enormous deposits of the precious metal. Colonel Miles Quaritch, head of military operations convinces Parker Selfridge, head of operations for the company to attack the clan and get hold of the situation. Earlier Miles had commanded Jack to obtain the trust of the Na’vi clan and convince them to migrate elsewhere. But, Jack falls in love with Neytiri and the events take an different turn. Not divulging much of the story, I recommend you to find it out yourself.

The movie has so much visually enthralling experiences. The whole Avatar experience is fun. The knowing of how the Na’vis live, survive, hunt and believe in soul. The way they say sorry to the animals after they are hunt. The cinematography, the sceneries, the funda’s of being a Na’vi, Choosing a ‘Toruk’, a winged creature which they use to hunt, the network of memories stored in sacred trees and the healing power of the Tree of Soul. The imagination just takes a elite level with 3D effects.

Positives: Everything. Every minute of 2hour 45 mins was spent well. 3D was a great plus.
Negatives: None that i can think of now.
Ratings: 5/5 (My First movie with 5/5 ratings!). Its a complete paisa-wasool. Go for it! Its the movie of the year :)

Ps. Please post your feedback on the movie/my review. Let me know where can I improve on. :) Thanks for your support.


VSTF Source Control : Move Multiple Files

If you have worked with the Team Explorer in Visual Studio (VSTF) you know there is a functionality missing of moving multiple files/folders. But you can use TF.exe which has a move command and supports Wildcard.

Syntax: tf.exe move <items> <destination>

Usage: tf.exe move $/TeamProject1/Source/WebApp1/* $/TeamProject1/Source/WebApp2/

Note: You’ll need to run this command from Visual Studio Command Prompt.

Hope it helps save time, as it did for me :)