Wednesday, October 5, 2011

Steve Jobs: Icon


Steve Jobs, Though I never owned any Apple products but I am a big fan of Steve Jobs. Like many, I liked his passion for the perfection and details. A man full of contradictions who made a remarkable impact on the world in many ways. May his soul rest in peace.


Wednesday, September 21, 2011

Create proportionate size layout in android


Tip: To create a proportionate size layout on the screen, create a container view group object with the layout_width and layout_height attributes set to fill_parent; assign the children height or width to 0 (zero); then assign relative weight values to each child, depending on what proportion of the screen each should have.

This is the tip from android developers website, I don’t know about you, but it took me five or six time to understand what it means. An example is better than thousand words.

As you can see, I have a ListView and two buttons, I want list view to take 60% of width and 20% each for the buttons.

Layout definition in xml, Take a look at these attributes, android:layout_width android:layout_weight


Saturday, September 3, 2011

How to inject context in Android with and without RoboGuice?


If you want have cleaner separation in your Android app, you definitely need to move your logic to classes other than Activity, like you do in any GUI patterns. When you try to do that, first obstacle you would face is lack of access to Context class. Context lets you access resources and controls in the Activity. You can achieve this with or with out a Dependency Injection tool.

One of the simplest and easiest way is to pass the Context around, Take a look at line# 7, I am passing application context not Activity’s context to avoid memory leaks. Only pass Activity’s context when its necessary and keep your eyes open for smelly code. This is not the greatest approach, but it will get you going fast. Be aware, you are opening up yourself  to lot of repetitive code and potential memory leaks.

Another approach is, lets not pass the Context around, use Service Locator anti-pattern to resolve the Context. Little bit less code and we can’t pass around Activity’s context. But we made testing our code harder then before. Now you have to have another constructor to inject Context or have to mock the MyApplication class to provide testable Context.

Notice we are not passing context to the utility class, we are just creating an instance of the utility class. MyUtility class gets the application Context using some bare bone service locator,

Here MyApplication extends from Application and holds a static reference to itself. Don’t forget to set the Application name as MyApplication in manifest.xml file as described here.

Now lets see a cleaner approach using Robo Guice,

Install and wire up Robo Guice as suggested here, Lets take a look at our Application class, We are extending our application from RoboApplication. This is going to act as our IoC container.

Now we need a module to configure our injections. This module holds the injection map. Think this map as a way Robo Guice decides how to create classes for a particular type. See we haven't configured any mapping for Context, Robo Guice has built in mapping to resolve Context and Application.

Now lets take a look at out utility class, it has nothing interesting except the @Inject attribute, it tells Robo Guice to use this constructor to create MyUtility and resolve all the parameters.

Lets take look at the final piece of the puzzle, Activity class, Take a look at how cleaner it is, No cluttered onCreate method no nasty castings of controls. It is much more readable and less code. Robo Guice finds all the members with @Inject attribute and injects necessary types.

Friday, September 2, 2011

Convert flat file to xml using PowerShell


If you have a flat file and want to convert it to some other format like xml or CSV, this may help you. You need PowerShell to do this. All Windows 7 machines come with PowerShell installed, so for most people that shouldn't be a problem

We need some input to proceed, It can be a file or hard coded string or even clipboard. @" and "@helps you handle multiple lines without escaping it.

Now we have the input, lets go through line by line and spit out the output we want, `n is new line character for PowerShell. ` tells PowerShell that statement continues to next line. –f takes the format string and replaces {0} with input parameters.

If you are comfortable with one liners, you can do this, Move formatting string to separate statement, and use % for foreach.You get a nice readable online PowerShell script.

Wednesday, August 17, 2011

It’s harder to read code than to write it


Netscape 6.0 is finally going into its first public beta. There never was a version 5.0. The last major release, version 4.0, was released almost three years ago. Three years is an awfully long time in the Internet world. During this time, Netscape sat by, helplessly, as their market share plummeted.

It's a bit smarmy of me to criticize them for waiting so long between releases. They didn't do it on purpose, now, did they? Well, yes. They did. They did it by making the single worst strategic mistake that any software company can make:

They decided to rewrite the code from scratch.

It’s harder to read code than to write it.

This is why code reuse is so hard. This is why everybody on your team has a different function they like to use for splitting strings into arrays of strings. They write their own function because it's easier and more fun than figuring out how the old function works.

[Things You Should Never Do, Part I - Joel on Software]

Saturday, August 13, 2011

Postel's law


Be conservative in what you send; be liberal in what you accept. - Postel's law

“code that sends commands or data to other machines (or to other programs on the same machine) should conform completely to the specifications, but code that receives input should accept non-conformant input as long as the meaning is clear.” –Wiki via The Absolute Minimum Every Software Developer Absolutely, Positively Must Know About Unicode and Character Sets (No Excuses!)

Wednesday, July 27, 2011

Learning Optimism with the 24x3 Rule


Here's a practical tool for the skeptic or cynic in all of us: the 24x3 rule. The next time you hear an idea for the first time, or meet someone new, try to wait 24 seconds before saying or thinking something negative. This reinforces a foundational skill of good optimists and good leadership. That basic skill is listening. As you gain the ability to listen and pause for a brief 24 seconds before letting the critic in you bubble to the verbal surface, move to the next level and try to do it for 24 minutes. At 24 minutes, you are able to give more considered thought to the idea and think more carefully of the many reasons why it might actually work, why it might be better than what is out there, and why it might just topple conventional wisdom.

And yes, you should also work towards the ability to wait 24 hours — one single day — before pondering or verbalizing the cons against something
Learning Optimism with the 24x3 Rule

Wednesday, June 29, 2011

Navigation bar in Visual Studio


There are several ways you can navigate the code in Visual Studio.

  • Ctrl and Ctrl Shift to navigate back and forth of places you clicked.
  • Bookmarks, you can tag some specific locations and cycle through those book marks using Ctrl K Ctrl N and Ctrl K Ctrl P
  • Ctrl , Navigate to dialog lets you search members across class, project and solution.
  • Ctrl F lets you do simple search on current document and Ctrl Shift F lets you search in Current Project or in entire solution.
  • Navigation bar on top of the text editor lets you navigate the classes in the current document and members in current class.

One of the top features of Visual Studio is, its keyboard bindings. Most of the things you do with your mouse can be done via keyboard. I have been looking  for keyboard shortcut to do this. I posted a question in Stack Overflow hoping to find some answers. Few people suggested Macros in Visual Studio. But its doesnt help. Macro Recorder doesn't recognize mouse clicks and key strokes. Today I started looking again. I googled this link that gave me the answer I have been looking for. Ctrl F2 changes the focus to Navigation bar. Ctrl F2 Tab changes the focus members dropdown list. There are two things I don't like with this approach.

  1. It uses wired key combination Ctrl F2 at lease for me
  2. Ctrl F2 TAB resets the members dropdown list selection. Using Shift TAB fixed this automatic resetting.

Still its too many awkward key strokes. So I wrote a small AutoHotKey script to do this with Ctrl Shift G

Friday, June 17, 2011

Inversion of Control


In old school programming, your program controls the flow. In IoC programming, this process is inverted. Framework controls the flow.

Instead of your program running the system, the system runs your program - Wiki

There are some intersting reads about IoC,

  1. Inversion of control -Wiki
  2. InversionOfControl – Martin Fowler
  3. What is Inversion of Control? – Stack Overflow

மனைவி அமைவதெல்லாம்…





Friday, June 3, 2011

Welcome to USA


Are you coming to USA to work? Welcome to the land of the liberty. Every country comes with its own, unique culture. There were things I learned in hard way and things people taught me before I got burnt. Your experience is not going to be same as mine, but you may find these tips useful.


  1. Keep your I-94 card safe and don't forget to return this on airport when you leave. This is your arrival and departure card.
  2. Always carry some form of identification, You never know when you may need it. You can get a temporary ID card from local Department of Motor and Vehicles. If this doesn't work for you for some reason, keeps a copy of your legal documents.
  3. SSN: This is an unique number given to you by government. So keep it safe and private. Applying SSN after couple of weeks of your arrival believes to be faster way of getting it. Speculated reason for this is, For SSN department, it may take couple of weeks to get your details from INS which is a department of the US government responsible for immigration.

Know thy land

I am a Tamil and from a small village in north central part of Tamil Nadu. When I moved from my village to big cities, there are several strange things. One of them is, how city people tell you directions. It will be some thing along these lines. go left, take right then go straight, take a “U” turn etc… . Where in my village, people would give you “directions”. I am sure most of them don't know what “Cardinal direction” means. But they use it every day.

  1. For directions people will use “Cardinal direction”. Often you will hear words like these, East, South, North, Mid West, South West.
  2. Its a very big country. Approximately three times bigger than India.
  3. There are several regions in this country,
    1. East coast, big cities like New York, New Jersey, Washington D.C. located in this coast. This is where Europeans first arrived and started settlements.
    2. West Coast, Cost of silicon valley. Cities like California, Seattle are located here. Generally pleasant weather than east coast.
    3. Midwest, known for its friendliness and cold winters. Chicago is one of the big cities in this region.
    4. South, generally means south east region. Big cities in these region, Florida, New Orleans.
  4. Distance is measured in miles here, Almost all the units are different here. See Units sections.
  5. Up usually means north. Down means south.
  6. Remember your zip code. This will be useful for lot of online shopping.


When I moved from my village to big cities in India, one of the miserable thing of city life was its strangeness. Unlike in villages, people are rarely friendly. I didn't know the name of the person who was sitting across few cubical from me for few years. First thing I noticed when I entered to US was its friendliness.

  1. People are mostly friendly and humorous.
  2. People don't care and wont judge if you grammar is poor or bad. They understand its not your first language. So don't be shy.
  3. If you are coming from a different country and you look lot different than local people, friendly smile wouldn't hurt. One strange thing with Indians though, they wouldn't smile at other Indians, I have heard many theories for this, but didn't quite understand any.
  4. Its very common to see people wishing “Have a good/nice day”, “Have a good one”, “Take it easy”.
  5. Thank you is big part of life here. They would say thank for any things others do for them, You can see this from shops, work place, movie theaters even government offices.
  6. People are very good forming queue. Indians, control the urge of line jumping.


Weather changes are noticeable here. If you don't pay attention to weather, there are good chances to get into some trouble. Tornados, thunder storm, hurricane, snow storms are big weather factors here. So start paying attention. It may seem complicated, but you will get used to it.


When British left India, Indians kept most of the British system. Americans changed lot of British system. One thing they didn't change is English units. Wiki quotes, US is the only industrialized nation which doesn't use metric system.

  1. Distance is measured in miles. 1 mile is 1.6 kilo meter. I round it to 1.5 times for sake of simplicity. So when people say 100 miles, its more than 150 kilo meters.
  2. Weather is measured in Fahrenheit not Celsius. Though its not accurate, I use this formula for quick and dirty conversion. 
    1. Fahrenheit = (2 x C) + 30
    2. Celsius = (F-30) / 2
  3. Weight is measure in pound, 1 lb is 0.45 kg. 2.2 lb is 1 kg
    1. kg = (lb/2) + (lb/2)/10  i.e. 100lb = 50 + 5 kg
    2. lb = (kg*2) + (kg*2)/10  i.e. 100kg = 200 + 20 lb
  4. Computer memory, MB is meg and GB is gig


America drives in “right” side of the road.

  1. Pedestrians get the highest priority. So always wait for them to clear the road.
  2. Rules are very simple and easy to follow. So take some effort to understand the rules. Take a look at this video series. Teaches you most of the thing about traffic rules in US. Though its of state of California, most of it is true for rest of the country.
  3. Many states allow residents to drive cars for some time with your foreign driving license. Check your DMV website to know law in your state.
  4. Many cities operate buses, you could get monthly passes for bus/train.


  1. For emergency, call 911. You will get help immediately.
  2. Incoming phone calls cost you money. Go figure.
  3. Tele communication is fairly expensive in US compare to India, where you could get 1 year of service for ~10 INR. Telecom is mostly dominated by four companies, AT&T, Verizon, Sprint and T-Mobile. You could get prepaid phones also.
  4. I recommend getting Google Voice. It can help you save money in some ways.
  5. Remember this number 1-800-Bing. You can call this number to find out any business’s phone number. Just say they city and state and business name, it will give you phone numbers, directions etc…
  6. For International calling, you can try these services,
    1. Vonage
      1. You need high-speed internet connection.
      2. $25+ monthly charge. Its worth if you talk more than 2000 minutes per month.
      3. You can get a adapter that you can carry it anywhere or buy Vonage mobile for smart phones.
      4. Free call within US.
      5. - No SMS.
      6. - There are times, you may not get connected because high volume calls.
    2. Google Voice
      1. Free calls to US and Canada.
      2. Free SMS to US numbers.
      3. You can use with/without internet.
      4. 6 cents/minute to call India.
      5. Visual Voice Mail.
      6. - You need a US phone number to get a Google Voice number
    3. Skype
      1. You can get Skype Online number for free incoming calls. Kind of land line number.
      2. With out any subscription, ~10¢ to call India
      3. - You need internet connection.
    4. If you don't want to rely on internet, you may want to check out these plans,
      1. Reliance global call.
      2. You will find lot of cheap plans, but may face low call quality and hidden fees like connections fee, rounding fee etc…

Know your currency

  1. You wouldn't have any problem recognizing bills but coins are tricky.
  2. Generally they come in four shapes.
    1. Penny = 1 cent. Copper color is the unique identifier.  
    2. Nickel = 5 cents. Bigger than penny and dime.
    3. Dime = 10 cents. Smallest coin. Tricky to read.   
    4. Quarter = 25 cents. Mostly used coin in vending machines, washing machine etc…. Bigger than previously mentioned coins. In banks you can get roll of quarters for free.  
  3. 25 bucks means 25 dollars.
  4. Nearly all the businesses accept credit card but government offices don't. So don't need to carry large amount of cash with you.
  5. Men carry wallet and women carry purse.
  6. If you plan to stay here longer, you need credit score. This score decides your credibility. Banks and other financial institutions decide your loan, interest rate for car, house etc.. There are so many way to get this score up. Easiest ways are writing checks, paying bills on time and try to get a prepaid credit card.


  1. In many fast food restaurants, you have to go to the counter and place the order. When you do that they will ask you this, Is this order for here or to go? This means that you want to eat here or take the food and leave?
  2. Some pizza places may ask you this when you call them to place order, is this order Carry out or Delivery? This means that Are you going to come and pick this up or do you want them to deliver it?
  3. Tissue papers are called napkins.
  4. If you don't want ice in your drinks, say “no ice”. They don't understand “without ice
  5. If you are a vegetarian, you have to say “no meat” when you order.
  6. Please leave some tip. Most people work in restaurant are collage students. They could use some money.

Cooking and Food.

Its amazing how food is distributed and available in this century. Virtually you can get any thing in your Indian/regional store here.

  1. Remember it took you so many months to walk. So be patient if you are cooking for first time.
  2. Be adventures. US is a melting pot. This is big cosmopolitan country. You can get all kind food here. Try different cuisine. You never know what you like. I would recommend start with Mexican and Italian cuisine.
  3. Check out these cooking web sites.
    1. Show Me the Curry Very good site for beginners. Full of ~10 minutes videos. You can find lot of Indian recipe as well as few other cuisine recipes.Highly recommended.
    2. South Indian/Tamil cuisine
      5. தாளிக்கும் ஓசை 
      6. தூயாவின்ட சமையல் கட்டு

Strangeness I have noticed

  1. Bi-cycles are called bikes. Front breaks in left side and back breaks in right side.
  2. You insert keys into locks, ridge side facing upwards.
  3. Electric switches, move up to turn on and down to turn off.
  4. Water faucet, turn left for hot water and turn right for cold water.
  5. Electricity used in this country is 120 volt unlike 240 volt in rest of the world.
  6. Electric sockets take only flat pins not round pins.
  7. There are lot of English words spelled different here.
  8. So many different time zones in this country.
  9. In India, every state has its own language, here every state has its own law.


  1. American political party system
  2. National parks
  3. Library
  4. Domination of phone companies
  5. How to buy car?
  6. Entertainment

Some interesting blogs about USA

  1. அமேரிக்கா – I

Tuesday, May 24, 2011



If you are just getting started with Asp.Net MVC, you may find these links helpful.

  1. If you want to learn in traditional way, concept by concept,
    1. From here you can get almost all the concepts from getting started to deployment.
    2. If you like videos, go to It contains videos for various concepts, talks from people like Scott Hanselman, Phil Haack and Rob Conery.
    3. Chanel 9 has videos of Mvc Conference
  2. If you already know Asp.Net and you want to learn by seeing code, take a look at Music Store application. Each part will teach you concepts by showing code and real example. You can find video for this starter kit here.
  3. If you like learning from books, some books for you,
    1. Professional ASP.NET MVC 3
    2. Professional ASP.NET MVC 2 (Wrox Programmer to Programmer)

Sunday, May 22, 2011

ஒரு படம், ஆயிரம் வார்த்தைகள்



தி.மு.க வின் மேல் ஏனிந்த கடுப்பு?


தமிழக தேர்தல் முடிவுகள் வெளியாகி இரண்டு வாரங்கள் ஆகப்போகின்றன. தி.மு.க அனுதபிகளிடமிருந்தும், அ.தி.மு.க எதிர்பாளர்களிடமிருந்தும்  சில கேள்விகள் வந்து கொண்டே இருகின்றன.

  1. எலிக்கு பயந்து வீட்டை கொளுத்திய கதையாய், கருணாநிதிக்கு பதிலாய் ஹிட்லர மாதிரி ஆட்சிபுரிந்த ஜெயலிதாவை கொண்டுவந்துவிட்டீர்கள். தொடங்கும்பொதே மோடியுடன் தொடங்குகிறார், இன்னும் என்னவெல்லாம் நடக்கப்போகிறதோ?
  2. தி.மு.க காங்கிரசுடன் கூட்டணி வைத்ததால்தானே தி.மு.க வை தோற்கடித்தீர்கள், இன்னும் சில் காலங்களில்[வாரங்களில்?] பச்சோந்தி காங்கிரசு அ.தி.மு.க வுடன் போய் சேர்ந்து விடும் அப்போது என்ன செய்வீர்கள்?
  3. கொள்கைகள் ஏதுமின்றி, விசிலடிச்சான் குஞ்சுகளை வைத்து தமிழகத்தை ஆண்டுவிடலாம் என்று இருக்கும் அரைவேக்காட்டு விஜயகாந்தை எதிர்கட்சி தலைவராக்கி விட்டீர்கள், அவர் தமிழக சட்டசபைக்கு பதிலாக ஆந்திர சட்ட சபை போகாமல் இருந்தால் சரி.
  4. ஒரு குடும்பத்தை ஆட்சியில் இருந்து தூக்கி, மற்றொன்றை வைத்து விட்டீர்கள். என்ன மாற்றத்தை கொண்டுவந்தீர்கள்?

இந்த கேள்விகளுக்கான எனது பதிலகள்,

எலிக்கு பயந்து வீட்டை கொளுத்திய கதையாய், கருணாநிதிக்கு பதிலாய் ஹிட்லர மாதிரி ஆட்சிபுரிந்த ஜெயலிதாவை கொண்டுவந்துவிட்டீர்கள். தொடங்கும்பொதே மோடியுடன் தொடங்குகிறார், இன்னும் என்னவெல்லாம் நடக்கப்போகிறதோ?

இந்திய – பாகிஸ்தான் - வங்காள போரின்போது, இந்திராகாந்தியை பெட்டை நாய் என்றும், சூனியகாரி என்றும் அழைத்து சர்சைகளில் மாட்டிய கிசிங்கர் [Henry Kissinger] இரான் – இராக்கிய போரின்போது சொல்லிய ஒரு மேற்கோள்,

It's a shame they both can't lose

இருவரையும் தோற்கடிக்க முடிந்திருந்தால் கண்டிப்பாக அதை நான் ஆதரித்திருந்திருப்பேன். ஜெயலலிதா ஒன்றும் கருணாநிதிக்கு குறைந்தவரல்ல என்பதை நானும் ஒத்துகொள்கிறேன். கட்சிக்குள்ளே சன நாயகம் பார்காத, ஜெயலலிதா தமிழகத்தில் நல்லாட்சி புரிவார் என்று மூட நமிக்கை எல்லாம் இல்லை. கருணாநிதியும் தி.மு.கவும் அ.தி.மு.க வை விட த்ரம் தாழ்ந்து போனதால் தான் அ.தி.மு.க வை ஆதரிக்க வேண்டிய நிலைக்கு ஆளானோம்.

ஜெயலலிதாவிற்கு பயந்து மறுபடியும் தி.மு.க வை ஆட்சிக்கு கொண்டுவந்திருந்தால், கருணாநிதிக்கு என்ன விதமான பாடத்தை கற்று கொடுத்திருப்போம். என்ன வேண்டுமானாலும் செய்யலாம், மக்க்ள் கண்டு கொள்ள மாட்டர்கள் என்று கருணாநிதி மட்டுமல்ல அத்தனை அரசியல் கட்சிகளும் முடிவு செய்திருப்பார்கள். வினை விதைத்தால் வினை அறுத்தே ஆக வேண்டும் என்பதை எப்போது இவர்கள் உணர்வார்கள்? அரசியல்வாதிகள் மட்டுமல்ல நாம் ஒவ்வொருவரும் உணர வேண்டிய பாடம் இது,

ஜெயலலிதாவிற்கு கிடைத்த வெற்றி அவரின் மேல் உள்ள நல்ல எண்ணத்தால் கிடைத்தது இல்லை. கருணாநிதியின் மேல் உள்ள கடுப்பால் கிடைத்தது. கருணாநிதி செய்ததையே ஜெயலலிதாவும் செய்தால், நாளை அவருக்கும் இதே நிலைதான். கோயில்களில் ஆடு, கோழி வெட்டக்கூடாது, என்று பார்பன ஆதிக்கத்தை காட்ட முயன்றதன் விளைவை அவர் மறந்திருக்க மாட்டார் என்று நம்புவோம்.

தி.மு.க காங்கிரசுடன் கூட்டணி வைத்ததால்தானே தி.மு.க வை தோற்கடித்தீர்கள், இன்னும் சில் காலங்களில் பச்சோந்தி காங்கிரசு அ.தி.மு.க வுடன் போய் சேர்ந்து விடும் அப்போது என்ன செய்வீர்கள்?

நாளை காங்கிரசு அ.தி.மு.க வுடன் போய் சேர்ந்தால், அ.தி.மு.க வுக்கும் இதே நிலைதான். தமிழர்களின் நலனை விட நேரு குடும்பத்தின் நலனே பெரிது என்றிருக்கும் காங்கிரசின் நிலை மாறாத வரை, தமிழகத்தில் காங்கிரசிற்கும் அதன் கூட்டணி கட்சிகளுக்கும் இடமில்லை.

கொள்கைகள் ஏதுமின்றி, விசிலடிச்சான் குஞ்சுகளை வைத்து தமிழகத்தை ஆண்டுவிடலாம் என்று இருக்கும் அரைவேக்காட்டு விஜயகாந்தை எதிர்கட்சி தலைவராக்கி விட்டீர்கள், அவர் தமிழக சட்டசபைக்கு பதிலாக ஆந்திர சட்ட சபை போகாமல் இருந்தால் சரி.

அகத்தை விட புறத்திற்கு முக்கியத்துவம் கொடுக்கிற மனப்பான்மை நம்மிடம் உள்ளவரை, வாயசைத்து காலத்தை ஓட்டும் நடிகர்கள்தான் மேலே இருப்பார்கள்.

ஒரு குடும்பத்தை ஆட்சியில் இருந்து தூக்கி, மற்றொன்றை வைத்து விட்டீர்கள். என்ன மாற்றத்தை கொண்டுவந்தீர்கள்?

ஜெயலலிதாவும் கருணாநிதியும் இந்த பாடத்தை மறக்கமாட்டர்கள் என்று நம்புவோமாக.

Monday, May 16, 2011

Microsoft Certification Explained


Wonderful video explains the different levels in Microsoft certification and process to achieve them and their benefits.

Thursday, April 28, 2011

Enhanced Scrollbar in Productivity Power Tools


Visual Studio is one of the best IDE out there, though extensions were part of Visual Studio before, Visual Studio 2010 rocks with lot of cool extensionsProductivity Power Tool is one of my favorite with ton of features. You can find more info in the extension page. Though I have been using 2010 for a while, I haven't noticed Enhanced Scrollbar feature till today. It operates one three mode,

  1. Scrollbar mode
    • Scroll bar with some tiny color rectangles, each rectangle gives you info about cursor location, search term matching locations, break point and bookmark locations etc…. By clicking the tiny square you can navigate code faster.
  2. Map mode
    • Scrollbar mode plus instant preview. By hovering over the cursor, it displays the code in a preview window.


  3. Full Mode
    • Map mode plus zoomed put page as scrollbar. Gives overview of the whole page with instant preview,


It also comes with tons of options and you can switch modes just by right clicking the scroll bar.

image  image

Wednesday, April 27, 2011

UN publishes report on war crimes committed against Tamils, What can you do to stop it?


After long sleep and strong opposition from big powers like Russia, China and India[Yes same India, the country of Gandhi] and Sri Lanka, these big power’s loyal slave, UN publishes its report on war crimes committed against innocent Tamils. This report brings hidden truth about Sri Lanka and its masters India and China. How these big powerful countries ignored rights and lives of two hundred thousand Tamils and massacred them without any witness.

It finally tells the tale of why Sri Lanka government didn't and don't let any media including Red Cross into their country.

What you can do?

  1. Read this report. Truth may not be pretty but you have to know it. Strength of the Truth lies on our hands. Truth is like light, the more you know it, brighter it gets and tougher it becomes for the criminals.
  2. Share this report, Tweet it, blog it, Facebook it. Spread the truth. If we ignore this, then we encourage these murderers.
  3. Stop buying products from Sri Lanka, China and India[Yes same India, the country of Gandhi] . You may feel like, how can we stop buying thing made in China? At least stop buying one thing. Changes will happen if we all come together.

 Report Of The Secretary-General’S Panel Of Experts On Accountability In Sri Lanka.

BBC reports war crimes committed against Tamils


Yesterday BBC reported war crimes committed against Tamils in Sri Lanka quoting UN report on Sri Lanka’s war crime. You can read the full UN’s full report here, REPORT OF THE SECRETARY-GENERAL’S PANEL OF EXPERTS ON ACCOUNTABILITY IN SRI LANKA

You can read BBC’s report here

BBC News - Sri Lanka: UN says army shelling killed civilians -

BBC News - Sri Lanka 'war crimes': Main allegations -

UltraWinGrid default (active) row selection and bad exception handling


I have a UltraWinGrid bound to a BindingSource object data source .   This is how I display list of rows in the grid.

The only difference between the two methods is, last line in the second method, This is an classic bad example exceptions.

By default, UltraWinGrid selects a row if no row is selected, I was trying to disable this behavior, I couldn't find any straight property or method to do this. I found ActiveRow  returning the selected row and it has a setter. So I thought setting ActiveRow to null would disable the selection. But it doesn't. I have couple of problems with this line,

ultraWinListGrid.ActiveRow = null;
  1. It doesn't do what it looks like doing
  2. It doesn't tell me what happened and why it didn't do it.
  3. It doesn't prevent me doing things it can’t do.

So, How did I solve this, that's an another poor encapsulation story. Take a look here for a workaround.

Tuesday, April 26, 2011

Different ways to open application/programs in powershell

I wanted to test start-up speed of Firefox, IE and Chrome. So I wanted to write a small script to open all these browsers in same time and see which browser opens faster.
If I wanted to write it in batch file, it would be something like this.

You can do the same thing in Powershell like this,

By the way winner is Chrome, I love you Firefox, but you have to start up faster :(

Friday, April 22, 2011

Sync your blog with Twitter and Facebook using twitter feed


If you post something on your blog and you want it to be tweeted to your twitter account or facebook account, 


just does that. Super cool thing is they don't ask you your twitter user name and password and bank info, They use oAuth, it takes you to twitter site, you authorize twitterfeed to update your twitter feed, Bingo, You have it.

If you want your posts to be written on your facebook wall, You can do that with twitterfeed too.   But I have twitter synced with my facebook already, so now having twitterfeed to tweet my posts to my twitter account, I am hoping my post will be broadcasted to twitter and twitter will write it to my facebook wall.

Sri Lanka – evidence of ongoing repression and abuse.


Channel 4 publishes another story about Tamils who forced to live in camp controlled by army.  For full story go here

Tamils - victims of genocide and warcrime.

“You can bend it and twist it... You can misuse and abuse it... But even God cannot change the Truth.” - Michael Levy

Truth always brings itself out. One form or another. It is just matter of time. Some people see it right away and some never see it and some don't want to see it. Because it’s never pretty and hurts like hell. The longer you hide it, bigger its vengeance. This post is for the people who don't see the truth or don't want to see the truth.

This is video about Isai Priya, A Tamil girl found naked and dead during the Sri Lanka’s war against terrorism. Nobody deserves this. Nobody.

Video by Channel 4

Channel 4 obtains more video of war crime executed by SriLanka troops. And UN Investigator authenticates the video.

Kill everybody, Finish them all. Orders from the top Sri Lankans army.

CNN's Becky Anderson talks with a U.N. special investigator Prof. Philip Alston

Photos allege Sri Lanka war massacre - AJE - Al Jazeera English

Sri Lankan soldier pulls out a naked woman’s dead body in the battle ground and – Headlines Today

Al Jazeera questions the SriLankan army bombed on no fire zone.

Another video of Tamil victims of Sri Lanka armies brutal attack.

Thursday, April 21, 2011

var vs dynamic in C#


var is just another C# syntactic flavor. C# compiler infers the types for us.

Lets take a look at this code snippet,

    int intX = 10;
    var intY = 20;  

It may look different in the surface, but both are type of Int32 in IL.


var is static typing, this means that resolutions are verified at compile time. If we try to access a method or property that doesn't exist or beyond the access level, compiler stops the compilation. No more soup for you. Its like Soup Nazi.

    string testString = "Hello";
    testString.toString(); //Compile time error

In the other hand, dynamic uses dynamic typing. If you try to access the method or property that doesn't exist then compiler wont stop you from compiling the code. Compiler changes its role as a controller to helper. It assumes that we know what we are doing and move out of our way.

    dynamic testDynamic = "Hello Dynamic";
    testDynamic.toString(); //Run time error.  

Both var and dynamic have their purposes in the framework. Its all come down to using the right tool for the right job. var provides support for anonymous types.  It provides better readability, Imagine using LINQ chaining without anonymous methods.

    class Person
    {     public string Name { get; private set; }     public Person(string name)     {         Name = name;     }
    //Convert Person to SuperPerson without creating yet another class
    List<Person> persons = new List<Person>() { new Person("Ordinary Joe"), new Person("Regular Rick") };
    var superPersons = persons.ConvertAll(p => new { Name = p.Name, SuperPower = "Fly" });  

dynamic comes with its own set of features, It also provide better readability. Having dynamic objects in .NET, makes programming COM easy and readable. Code that is tough to read is tough to maintain and extend.

    // Before the introduction of dynamic.
    ((Excel.Range)excelApp.Cells[1, 1]).Value2 = "Name";
    Excel.Range range2008 = (Excel.Range)excelApp.Cells[1, 1];

    // After the introduction of dynamic, the access to the Value property and
    // the conversion to Excel.Range are handled by the run-time COM binder.
    excelApp.Cells[1, 1].Value = "Name";
    Excel.Range range2010 = excelApp.Cells[1, 1];  

You can change dynamic type from one to another with out casting or boxing/unboxing.

    dynamic value;
    value = 10; //Now it is Int32 
    value = DateTime.Now; //Now it is DateTime  

dynamic also adds another great feature, dynamic member. Any code that has access to a dynamic type can change its type or add new properties or add new method.

dynamic enables us doing reflection like coding without paying heavy performance penalty. Take a look at these micro ORMs like dapper-dot-net and Massive. They are so tiny and super fast. its like too good to be true.


  1. Using Type dynamic - MSDN
  2. Access Office Interop Objects – MSDN
  3. Implicitly Typed Local Variables (C# Programming Guide)
  4. Dynamic Language Runtime Overview
  5. Massive: 400 Lines of Data Access Happiness
  6. StackOverflow dynamic vs var

My top 5 shows at MIX 11


Knockout JS: Helping you build dynamic JavaScript UIs with MVVM and ASP.NET (FRM08)

An Overview of the MS Web Stack of Love (FRM02)

NuGet In Depth:  Empowering Open Source on the .NET Platform

NuGet In Depth: Empowering Open Source on the .NET Platform

Scaffolding – ASP.NET, NuGet, Entity Framework Code First and More

Scaffolding – ASP.NET, NuGet, Entity Framework Code First and More

Mono: State of the Union

    Different ways to create threads in C#


    Dual cores and Quad cores are long gone, Hexa and Octa are kicking the dusts. Its time to brush-up multi threading.

    First lets see different ways to create threads,

    Most of examples are taken from and C# 4.0 in Nutshell.

    Monday, April 4, 2011

    WPF Brushes are freezable

    Brushes are freezable objects. Thus, you can make changes to Brush objects so long asthe Freeze method has not been called. After the Brush.Freeze method is called, the brushbecomes read-only and no further changes can be made.
    MCTS Self-Paced Training Kit (Exam 70-511): Windows Application Development with Microsoft .NET Framework 4

    Saturday, April 2, 2011

    How do I have code in my blog?

    My brian is wired to syntax highlighted code. When I see some code and its not syntax highlighted, It takes me longer to parse and umderstand code. Lately I have been using few websites to display code in my blog. Unfortunately there is no magic bullet yet.
    • gist.github: Decent site, No private store and No AutoHotkey support :)

    • snipplr: Supports private code snippets and tags. Doesn't add background color to code snippet, if your site’s background is not white, you have to edit the embed script every time you paste.

    ;Auto type Master Password by sending AutoType command to KeePass

    1. ^+c::
    2. {
    3. KeyWait, LWin
    4. Send, ^c
    5. Sleep 50
    6. Run,
    7. }

    View this snippet on Snipplr

    • pastebin: Supports AutoHotKey :). Color theme is not my cup of tea. But I am going to give a try.

    Sunday, March 20, 2011

    எளிமையான மனிதர்கள்


    ஜேம்ஸ் ஸ்ப்ரிங் 40 வயதை நெருங்கப் போகும் சராசரி அமெரிக்கர்களில் ஒருவர். 40 வருட வாழ்க்கையை புரட்டிப் பார்க்கையில் வெற்றிடமாய் உணருகிறார். 40வது பிறந்த நாளின் போது யாருக்காவது உதவி செய்து வெற்றிடத்தை நிரப்ப நினைக்கிறார்.

    கூகுளின் உதவியால், போதை பொருள்களுக்கு அடிமயான பெற்றோர்களால் கடத்தப் பட்ட இரண்டு சிறுவர்களைப் பற்றி அறிகிறார். தாத்தா பாட்டின் பாதுகாப்பில் இருக்கும் நான்கு வயதான அந்த சிறுமி இவரின் மகளை நினைவு படுத்துகிறார். சிறுமியின் பெற்றோர்கள், வீட்டு உரிமயாளரைக் கொன்றுவிட்டு, சிறுமி மற்றும் பிறந்து சில மாதங்களேயான குழந்தையுடன் மெக்சிகோ தப்பிசெல்கிறார்கள்.

    காவல் துறையை தொடர்பு கொண்டு, இந்த சிறுவர்களை கண்டுபிடிப்பதில் உதவி செய்ய முன்வருவதாக தெரிவிக்கிறார். இந்த வழக்கில் அதிக ஆர்வம் இல்லாத காவல்துறை, இவரின் உதவும் கரத்தை மறுக்கிறது. தானாக இந்த சிறுவர்களை கண்டு பிடிப்பதற்காக, மெக்சிகோ செல்கிறார். வழி நெடுக்கில் சிறுவர்களை கடத்திய பெற்றோர்களின் படங்களையும், தகவல் தெரிவிக்க தொலைப் பேசி எண்களையும் விட்டு செல்கிறார்.

    பயனம் தொடர்கிறது. ஒரு சிறிய மெக்சிக ஊரை கடக்கயில் சிறுவர்களின் இருப்பிடம் பற்றி துப்பு கிடைக்கிறது. மெக்சிக காவல்துறை பெற்றோர்களை கைது செய்கிறது. முதல் முறையாக சிறுவர்களையும், பெற்றோர்களையும் பார்கிறார். அவர்களைப் பார்கையில் இரக்கம் இல்லாத கொலைகாரர்களாக தெரியவில்லை. சராசரி பெற்றோர்களாக தெரிகிறார்கள். பெற்றோர்களின் மேல் பாசமாய் இருக்கும் சிறுமியைப் பார்கையில், மன நிரைவிற்கு பதிலாய் பாரமாய் உணர ஆரம்பிக்கிறார்.

    கொலைகாரர்களை சட்டத்தின் முன் கொண்டுவந்ததிலும், சிறுமியை தாத்தா பாட்டியிடம் சேர்த்ததிலும், நிறைவாக உணர்ந்ந்தாலும், ஒரு குடும்பத்தை பிரித்த வலி இன்னும் இவரின் மனதில் நிற்கிறது.

    எதிராளியும் நம்மைப் போல சராசரி மனிதன் என்பதை உணரும் போது, சண்டை மேலும் கடினமாகிறது.

    சிகாகோ மக்கள் வானொலியில் ஒலிபரப்ப பட்டது. இதை கேட்க. [12வது நிமிடத்தில் இருந்து ஆரம்பிக்கிறது].

    Viana Carelli and Faith Carelli rescued by reporter in Baja, returned to family in Soquel

    Saturday, March 19, 2011

    Auto type Firefox master password


    If you restore Firefox with multiple tabs loading and you have master password set for Firefox, you will be asked to enter master password for several times. It makes even worst if you have other extensions like Sxiper installed, Seems like they try to access the password store every time they load a webpage.  This AutoHotKey script will detect Firefox master password window and send Ctrl + Alt + A to KeePass, which then will auto type the master password.

    Shortcut (.lnk) file parser


    In my AutoHotKey file I wanted to add some hot strings to access some of my favorite folders and programs. Only problem is I have so many shortcuts to do it manually.

    Here is how I did it in PowerShell,

    Here are some other way to do it,

    Editing shortcut (.lnk) properties with Powershell

    Windows shortcut (.lnk) parser in Java?

    Reading the target of a .lnk file in Python?

    Saturday, March 5, 2011

    Coercion Value in WPF


    Lets see what is the meaning of word coercion before we start,

    Coercion ( or ) is the practice of forcing another party to behave in an involuntary manner (whether through action or inaction) by use of threats, intimidation, trickery, or some other form of pressure or force. Such actions are used as leverage, to force the victim to act in the desired way. ...

    Here we are setting value of the slider to 500 and setting minimum and maximum value to 0 and 100. As you can see value is beyond Min-Max range of slider control. You would think, either it should throw some error during compile/run time or just return the value. But it returns 100 when you query slider’s value property.

    Why does it behave this way? Two reasons,

    Tuesday, March 1, 2011

    WPF Books


    The best coverage I have read is in Chris Anderson's excellent book Essential Windows Presentation Foundation. If you are working with WPF, and need a deep understanding of not just the workings of the framework, but the design motivations behind why certain things are the way they are - I would urge you to read this book cover-to-cover.  You should also check out Adam Nathan's work WPF Unleashed, and Programming WPF by Chris Sells and Ian Griffiths - both excellent books as well. Now that you have that information, let me see if I can put things in a simple perspective.