Author: Rajeshwaran SP

  • Monday Morning

    Monday morning, felt Tom miserable…

    So is the case with me. Today is monday and I feel as if the whole world is enjoying while I am grunting. When I left home to office, I was feeling even worse, my roomies, Sri and Sakthi were sleeping comfortably, while I have to rush to office. Working at an office that takes 1 hour to reach is really terrible. Can’t blame it anybody but myself for still putting up at a rented house far away from office. There are pros and cons to this.

    On the pros first,

    • you have the freedom to leave office early saying that you have to travel long.
    • you never need to come to office on saturday or sunday for a production support and put that task on the person residing nearer to office.
    • you get a topic to discuss about which is this post.

    On the cons,

    • you have to push yourself to start early.
    • there are the evils of public transportation spoiling your mood.
    • missing the early morning sleep… heavens….

    Here I am writing on about a spoiled monday morning. Friday… where are you?

  • C#: Null coalescing operator

    C# has a ?? operator, which is called the ‘Null coalescing operator’. The ?? operator is a infix operator used on nullable types or objects. If the operand on the left is null, it returns the value of the expression on the right, else it is the left operand itself.

    Here is an example showing how it is used.

        int result;
        int? num = null; // num is null
        result = num ?? 10; // sets result to 10.
        Console.WriteLine(result);
        num = 5; // num is 5.
        result = num ?? 10; // sets result as 5.
        Console.WriteLine(result);
    
  • Installing Rails : Local gem install

    After a unsuccessful installation of rails that took nearly 5 hours, I decided to get rid of Ruby. But the geek inside me, wanted me to go for the kill. That started the quest of successfully installing and deploying rails on WAMP server. Here are the steps.

    Requirements:

    Installation Instructions:

      Install WAMP and Ruby on the machine.
      Extract the Ruby Gems Zip file to any location and open a command prompt window.
      Run setup.rb from the command prompt in the location where the zip was extracted.
      Open command prompt and navigate to the folder where the downloaded gems are located.
      Install Rake using the following command.
    gem install rake-x.x.x --local
    
      Here x.x.x stands for the version number, for example, to install rake-2.3.2.gem run it as ‘gem install rake-2.3.2 –local’.
      Install Active Support, Active Record, Action Pack, Action Mailer and Rails using the command as below
    gem install gem-x.x.x --local
    
      Replacing the gem- to the current gem to be installed.

    This will get Rails installed on the machine. The total install time should be close to 10 minutes.

  • Rails Installation

    Installing Rails needs a lot of patience. The command is simple “gem install rails”. But it is a resource hungry and a time consuming installation.

    I started the installation at 00:00:00 HRS and it is 03:22:23 HRS now and the installation is still going on.

    And look at the memory footprint of the ruby program that is installing rails.

    Mem footprint
    Mem footprint

    And here is the Performance Statistics:
    Performance Stats

    Why is an installation taking such a long time?

  • Words from Gandhi and Einstein

    Of late, I have been reading ‘The story of my experiments with Truth’, the autobiography of Gandhiji. There is one passage in it that summed up world, life and its purpose.

    I think it is wrong to expect certainties in this world, where all else but God that is Truth is an uncertainty. All that appears and happens about and around us is uncertain, transient. But there is a Supreme Being hidden therein as a Certainty, and one would be blessed if one could catch a glimpse of that Certainty and hitch one’s wagon to it. The quest for that Truth is the summum bonum of life.

    Truth or God is uncertain.

    I would like to add a parallel thought to it. Einstein’s theory of relativity too states the same uncertainty as

    All uniform motion is relative, and that there is no absolute and well-defined state of rest

    At the quantum level, Science meets Philosophy. That is why Einstein is known to have said

    Science without religion is lame, religion without science is blind

    Great men think alike.

  • Real Police – Thief chase

    Two days back, when I was on my way to the office, at the Park Town station, this incident happened.

    It is not unusual to see people at the Park Town station, crossing the railway paths and not using the sub-way. It has to be partly blamed on the authorities too for such a poor maintenance of the sub way. During the rainy season, it is flooded that people are forced to cross over to the other platform by crossing the railway lines.

    But that day was sunny. As usual, I was there at 7.30 am to catch the morning train to Tiruvanmiyur. When I emerged out of the subway, I could see two Railway Police Force (RPF) Officials hiding on the entrance to the subway. There were talking to the people nearby. As I entered the platform, there were people who were signalling to the men crossing the railway lines not to cross. That is when I realized what had been happening.

    The RPF men could not be seen from the other platform, when someone crosses the railway lines and reaching the other end, they would be caught by these two men and complaint filed. It reminded me of one of our childhood play called ‘Police-Thief’ (‘Thirudan – Police’ in Tamil) where one would play police and others would play thief hiding from the police. The game play was the police to figure out all the thieves from the hiding spot.

    It was happening the other way round here, the police were hiding and the people had to figure that there were police hiding and use the subway instead of crossing the railway lines.

    After all, Life is interesting!

  • நாய் பெற்ற தெங்கம்பழம் போல்!

    நாய் பெற்ற தெங்கம்பழம் போல்!
    ஸ்ரீகாந்த் தின் நண்பர்கள்!
    – உவம விளக்கம் தருக.

    நாய் – உவமை.
    ஸ்ரீகாந்த் – உவமேயம்.
    போல் – உவம உறுப்பு.

    உவம விளக்கம்:
    நாய் ஒரு தேங்காயை பெருமானால், அது தானும் பயன் பெறாமல், பிறரையும் அண்ட விடாமல் அலையும். அது போல, ஸ்ரீகாந்த்…. நிற்க.

  • Widescreen Monitor on ASUS A8V-VM running VIA/S3G Deltachrome display.

    I got a new SAMSUNG SyncMaster 2033sw, monitor, as my 10 yr old Philips has been running into issues for quite some time now. My PC in Neyveli (hometown) runs on AMD Athlon 64 on a ASUS A8V-VM series motherboard.
    The display adapter is an on board solution provided by VIA/S3G.

    When I connected the new monitor, the screen resolution was 1024 x 768 and the maximum supported by VIA/S3G Deltachrome IGP is 1280 x 768. This new one has a optimal resolution of 1440 x 900 (32 bpp). Searching on internet on various forums made me feel bad on choosing a wide screen monitor. Everyone said that a BIOS flash was required, which I least preferred.

    But a simple driver update left to Windows Hardware Update utility did the trick. All is needed is just a Update Driver using the Add/Remove Hardware Wizard.

    So Just update the driver if you are running into issues on the resolution. If that too doesn’t help, then resort to flashing the BIOS.

    Edit: Download driver for Windows XP.

  • Configuring ThunderBird 2.0 for Gmail App Account

    After fiddling around for half an hour, here is how I got to configure Thunderbird as client for Gmail App Account.

    1. Enable IMAP in Gmail App Mail Settings.

    2. In Thunderbird, select Tools -> Account Settings.

    3. Select Add New Account.

    4. In the New Account Setup dialog, Select Email Account. Click on Next.

    5. Set Your Name and Email Address in the Next Step. Click on Next.

    6. In the Server Information, Select the type of incoming server as IMAP.

    7. Enter the incoming server name as imap.googlemail.com (for outside US and imap.gmail.com for US).

    8. Enter the outgoing server name as smtp.googlemail.com (for outside US and smtp.gmail.com for US). Click on Next.

    9. Enter the Incoming User name as your email address (user@domain). I used raasukutty@raasukutty.com.

    10. Enter the Outgoing User name as your email address. (e.g. raasukutty@raasukutty.com).

    11. In the Account Settings Window displayed (Tools -> Account Settings), for the Server Settings, verify that the port number is 993.

    12. In the Outgoing Server, set Port Number as 587, and for Use Secure connection, set TLS.

    13. Now click on the Inbox. You will be asked for the password. And that completes it.

  • Math.Round

    Math.Round has been improved in C#.
    Consider the below piece of code:

    Console.WriteLine(Math.Round(10.4)); // Rounds to 10.0
    Console.WriteLine(Math.Round(10.7)); // Rounds to 11.0
    Console.WriteLine(Math.Round(10.5)); // Rounds to 10.0
    

    There is nothing surprising about the first two statements.
    In the third statement however, 10.5 is rounded to 10 not 11. C# provides for a way to specify how the middle point has to be treated.
    A enumeration ‘MidpointRounding’ that defines how mid points are treated.

    Console.WriteLine(Math.Round(10.5, MidpointRounding.AwayFromZero)); // Rounds to 11.
    Console.WriteLine(Math.Round(10.5, MidpointRounding.ToEven)); // Rounds to 10.
    Console.WriteLine(Math.Round(11.5)); //Rounds to 11.
    Console.WriteLine(Math.Round(11.5, MidpointRounding.AwayFromZero)); // Rounds to 12.
    Console.WriteLine(Math.Round(11.5, MidpointRounding.ToEven)); // Rounds to 12.
    

    ‘AwayFromZero’ – Rounds the number to the next highest value.
    ‘ToEven’ – Rounds the number to Even number.

    So for a odd fraction, the default round will round it to the lesser number and any of the above overloads will take it to the Next number.