Author: Rajeshwaran SP

  • Implicit Variable in C# 2008

    C# 2008 allows for creating implicit variables using the ‘var’ keyword. But the usage of ‘var’ cannot be truly justified for just declaring a ‘int’ or ‘string’ in code as shown in example below.

    var intNum = 5;
    
    Console.WriteLine("intNum is a: {0}", intNum.GetType().Name);
    Console.WriteLine("intNum is defined in: {0}", intNum.GetType().Namespace);
    

    The output of the above program is

    intNum is a: Int32
    intNum is defined in: System
    

    Here instead of using int in the declaration, we have used ‘var’ keyword. There is no difference between using ‘int’ or ‘var’ in the above example.
    The real usage of ‘var’ comes in LINQ. Consider the following code.

    int[] numbers = { 10, 20, 30, 40, 8, 7, 6, 2 };
    var resultSet = from i in numbers where i < 10 select i;
    
    foreach (var i in resultSet)
    {
    Console.Write("{0}", i);
    }
    
    Console.WriteLine("resultSet is a: {0}", resultSet.GetType().Name);
    Console.WriteLine("resultSet is defined in: {0}", resultSet.GetType().Namespace);
    

    Here resultSet is declared as a ‘var’. From the code, we understand that anytime, the resultSet will be an array of integers. But ‘resultSet.GetType().Name’ gives a surprising result.

    resultSet is a: d__0`1
    resultSet is defined in: System.Linq
    

    So ‘var’ has its best usage in LINQ. So why use it in a normal program when the datatype can be used in itself.

  • Barath Sister's Marriage @ Tanjore

    Last weekend, I and my college mates have been to Tanjore to attend, our friend Barath sister’s marriage. He had been to Australia to pursue his MBA degree and had turned up for the event. So we wanted it to be a get together after a long time. I was not able to board the bus on Friday night. So a group of 12 had travelled leaving me out to Tanjore.

    During the day, Barath and others had been to the Big Temple @ Tanjore, Sivagangai Park and to movies ‘Siva Manasula Sakthi’ and ‘Vennila Kabadi Kulu’.

    Myself, Srikanth and Sakthi took to travel on Saturday. Since it was an auspicious day on Sunday (Muhurtha Naal, when a lot of marriages and ceremonies take place), all buses towards Tanjore and other places were full. We didn’t have our tickets reserved. We waited from 9.30 pm till 11.30 pm without seats. Atlast, when all hopes of getting a decent bus was shattered, we got a AC bus to travel. God Save! Begin the journey.

    We reached Tanjore at 6.30 am on Sunday. The marriage function was from 9.00 am to 10.30pm. ‘Long time no see’ wishes, curses for not coming on friday and welcome chats later, we were in the marriage. Lot of people had come to attend the marriage, most of them Barat’s relatives. After the marriage, the lunch was really a feast. Nearly 25 different items served on ‘Banana Leaf’. Great sumptous meal.

    Then we relaxed a bit in the afternoon chatting with Barat, pulling each others legs. At 4 pm, we had tiffin. That was when we saw a group of small boys (school kids) playing in a ground nearby. Ratish, our captain wanted a bet match. Considering the fate of those small kids we chose to have a friendly match.

    It was great fun, with us getting thrashed by them for runs and our players failing in all parts of the game. It was really like Chennai 28 team getting beaten up by the Beach Boys (Chennai 600028 movie). In the true spirit of the game, actually all our players played using left hand so that the kids could have all the fun.

    Then we took to ‘TN07 AL 4777’ movie and then bucked ourself into SETC bus at 10.30 pm. One more trip to be frozen in memory. Really good time spent with friends after a very long time.

  • Avoid flickering in dynamically rendered control in Windows App

    Here is a tip shared by Kannan, a colleague of mine on how to avoid flickering when rendering controls dynamically in a Windows Application.

    Enable double buffering, so that the flickering does not happen.

    Add the following after the ‘InitializeComponent’ method.

          SetStyle(ControlStyles.UserPaint, true);
          SetStyle(ControlStyles.AllPaintingInWmPaint, true);
          SetStyle(ControlStyles.DoubleBuffer, true);
    

    That’s it.

  • My PC

    Here’s a list of what is there in my PC, after what Yuvi had posted on his.

    • WAMP (For Apache, MySQL and PHP).
    • WordPress Local Install where I play with PHP.
    • TextPad.
    • VS 2008 Express Edition.
    • Ruby (I rarely use it).
    • SQLYog as a front end MySQL client
    • FireFox & Chrome.
    • VLC  Media Player.
    • Lots of movies for my room-mates viewing pleasure.

    That’s it.

  • DOCTYPE blues

    Yesterday I was working on the layout for a new site. I missed the DOCTYPE declaration in the HTML. The page had the main content included inside a div.

    Following is the CSS that I used.

    body {
          font-family: Georgia;
          font-size: 14px;
    }
    #main-content p{
          margin: 0;
          padding: 0;
          padding-bottom: 15px;
    }
    

    This worked perfectly and rendered well on Firefox and Chrome. But when I opened the same page in IE, the font was too large for all content inside the ‘main-content’ div. Also in order to center the page, I had used ‘margin: auto’ on the page container that encompasses all content in the body as below

    #page-container {
          width: 760px;
          margin: auto;
    }
    

    This too didn’t seem to work in IE as the content was left aligned instead of centered, but rendered ‘centered’ in Firefox and Chrome.
    Looking out for a solution on the net, I found that missing the DOCTYPE declaration was the cause for the issue. Here is the reason.

    Without the DOCTYPE declaration, the browser has rendered the page in quirks mode. Adding the DOCTYPE made the browser render the page following the rules set by the standard.

    So never forget your doctype declarations.

  • Dealing with Computer Overheating : Thermal Issues

    Here I am about to share, some gyaan I got from when my computer failed due to thermal issues.

    Computer Overheating symptoms are when your system shutdown abruptly, after running for quite some time. Modern BIOS are so designed to prompt the user with messages on the next boot, to indicate problems relating to over heating. In my case, BIOS POST message clearly as

    ‘Previously the system was shutdown due to a thermal breakdown. Please service your unit’

    The first step to fix this was to go for cleaning the dust that had accumulated over the heat sink and so the other parts of the computer too. Then, service the CPU by cleaning it and then before placing the heat sink  back, apply a litte thermal grease, so that the contact is made properly between the heat sink and the CPU.

    In chennai, we don’t get thermal paste in computer service shops. You need to look into petty shops in Ritchie Street, Mount Road. I bought one from New Version Computers, Meeran Sahib Street. You could get one for Rs. 5/- to Rs. 10/-

    Once done, its time to boot. Viola! the system is up and running and I am happily posting about taking care of the my PC.

  • The White Tiger

    I just completed reading ‘The White Tiger’, a novel by Aravind Adiga. It is really fast. Interesting point about the book is the way Adiga had portrayed India, Delhi and Bangalore. There are controversies surrounding the way he had treated Nepalis, Tamilians in his novel. Forgiving those, I found it to be entertaining.

    The story is about a person moving from rags to riches, in a crooked way. It is written as a narrative by a person living in the backyard slums of Delhi, moving to Delhi to become a car driver and then a entrepreneur in Bangalore. He discusses the pitiful state of the drivers, the poor in the towns and cities of India.

    ‘Anything is possible, provided you find a way’, is the gist of the book.

  • Obama's Inaugural Speech

    All news channel have been reporting on President Obama taking the oath of the President’s Office of United States throughout yesterday. His inaugural speech was really one of its class. In the charismatic voice of Obama, it even sounded one of the best heard in the lifetime.

    Here are a few excerpts from his speech, that I liked.

    Talking to the other nations watching him take the oath he said:

    “And so to all other peoples and governments who are watching today, from the grandest capitals to the small village where my father was born:  know that America is a friend of each nation and every man, woman, and child who seeks a future of peace and dignity, and that we are ready to lead once more.
    On this day, we gather because we have chosen hope over fear, unity of purpose over conflict and discord.”

    In his speech, the emphasis are always on the words ‘America’, ‘We’, ‘Hope’. That is why he has been drawing crowds. It is not only America that is looking at him, it is the entire world. A true leader’s speech.  So optimistic when he says, ‘We are ready to lead once more’.

    “We remain a young nation, but in the words of scripture, the time has come to set aside childish things.  The time has come to reaffirm our enduring spirit; to choose our better history; to carry forward that precious gift, that noble idea, passed on from generation to generation:  the God-given promise that all are equal, all are free, and all deserve a chance to pursue their full measure of happiness.

    In reaffirming the greatness of our nation, we understand that greatness is never a given.  It must be earned.  Our journey has never been one of short-cuts or settling for less.  It has not been the path for the faint-hearted – for those who prefer leisure over work, or seek only the pleasures of riches and fame.

    Rather, it has been the risk-takers, the doers, the makers of things – some celebrated but more often men and women obscure in their labor, who have carried us up the long, rugged path towards prosperity and freedom.”

    Calling the Americans to work, rather than bask in the past glory. It was really a speech that can be treated as a ‘wake up call’. He may not deliver what he had promised, but he has been inspiring, which can make people work.

    “What is required of us now is a new era of responsibility — a recognition, on the part of every American, that we have duties to ourselves, our nation, and the world, duties that we do not grudgingly accept but rather seize gladly, firm in the knowledge that there is nothing so satisfying to the spirit, so defining of our character, than giving our all to a difficult task.”

    “On this day, we come to proclaim an end to the petty grievances and false promises, the recriminations and worn out dogmas, that for far too long have strangled our politics. “

    Let this be a speech to the world. Let a new era of responsibility start throughout the world. Let us all work together for saving the earth and leave the world a better place for the coming generation.

    All the best Obama on your new office.

  • Trip to Valparai

    Last saturday and sunday, I and my friends were on a trip to valparai. The trip was actually a treat arranged by Nirmal (my school friend) as he is travelling to Australia in couple of weeks. It was supposed to be seven people by plan who were to take the trip. Last minute sickness and work at office, forced Dinesh and Srikanth to opt out of the trip. We started as per plan at 9 pm from Chennai on Friday night, in a bus from Parveen Travels onward towards Coimbatore. Myself, Sakthi, Nirmal, Sam and Guru.

    Nirmal, was the highlight of the trip. We made fun of him all through the trip. He is a great sport that he just smiled everything off. We reached Coimbatore at 8 am on Saturday. From there we hired a cab for the entire trip.

    Vaalparai is a not so well known tourist location, located on the western part of Tamil Nadu. Known for its wonderful dams, and hills, its enjoys lovable climate all through the year. Rainfall is the highest in this place. It is not well developed as Nilgiris or Kodaikanal. Hotels and Lodges are few and not so good. But it is worth visiting for its scenic beauty and clean and wonderful weather.

    From Coimbatore the route to reach Vaalparai is via Pollachi. Nirmal was insisting on having the famous ‘Pollachi Ilaneer’ (tender coconut). Our boy Sakthi, took to work, cutting the tender coconut for us. When it comes to workmanship, believe me, Sakthi is at his best. We proceeded to take our bath at the Monkey Falls. (Censored…)

    From there, at around 3 pm, we reached Vaalparai. We visited, Aaliyar Dam, Balaji Temple, Suicide Point and local spots in Vaalparai. All were tired by then, and so the day ended at Hotel Green Hills. On sunday, we checked out of the hotel and proceeded towards the Sholaiyar Dam enroute to Athirapalli Falls.

    Athirapalli Falls, a marvel. One must visit this place in one’s lifetime. It is the same falls from where Kamal Haasan jumps off in ‘Punnagai Mannan’. We spent nearly 3 hours there. Then we started back home from there, touching Trissur, Palakad and Coimbatore.

    It was a trip to remember. Thanks to Nirmal.

    Edit: Photos of Valparai Trip.

  • Carom

    Latest addition to our house, ‘The Palace’ is a new carom board. So it means lesser time being spent on my computer. Carom is easier than cycling in ‘chennai’ city. But it won’t count as a physical activity!
    So anybody visiting our house in the near future, be prepared to face a ‘Battle of Fingers’, on the carom board. Winners get sweets! Losers have to pay Rs. 500 /- to the company (which is none other than myself). You will get a cup of tea and whatever snacks available in the fridge at the moment of play. So buck yourself up and head to our house.
    Happy blogging!