1. Rounding decimal value to 0.0 or 0.5

    Today morning I was need to convert values ranging 0.0 to 1.0 where rounding will be necessary 0.0 or 0.5. For instance, if your original value 7.3 it should be floored to 7.0 and on the other hand if your value is 7.8 it should be floored to 7.5.

    The original code was written by Indian developers where they thousands if-else conditions like

    if (value >= 0.0 && value < 0.5)
         return 0.0;
    else if (value >= 0.5 && value < 1.0)
         return 0.5;
    else if (value >= 1.0 && value < 1.5)
         return 1.0;
    else if (value >= 99.5 && value < 100.0)
         return 100;

    This is one of the worst code ever written but many people do. I have written a function with some mathematical derivatives to solve the problem in 2 lines of code.

            public static decimal RoundToPointFive(decimal value)
                var intValue = ((int) value);
                return intValue + (Math.Round(value%intValue)*(decimal) 0.5);

  2. Oct 18th, 2011     c math
  3.    1


    HOW TO: Setup XDebug on XAMPP and Eclipse

    Before proceeding with the setup, it’s recommended to note down few things which may save couple of hours.

    • Your PHP version [Write a PHP file with <?php phpinfo(); ?> to get the version]
    • Your Windows version (32-bit or 64-bit) [See System Properties]

    Now go to XDebug Download page and you will see Windows binaries with having some version information. Download the XDebug DLL and put it on your {xampp-folder}\php\ext folder and rename the file to php_xdebug.dll. [NOTE: {xampp-folder} is just an alias. Consider it as where you installed XAMPP. Something like C:\XAMPP]

    Now you have to open php.ini located in your {xampp-folder}\php folder. Now search for “[XDebug]” section, if you find anything then just put the lines, otherwise write [XDebug] at the end of the file and write the lines below:


    Hold on, you are not done yet. One more line to make PHP know XDebug DLL.

    If you are using less than PHP v5.3 then add

    If you are using PHP v5.3 and above then add

    If you are using any custom build of PHP with —enable-debug then add

    OK! You are almost done. Search for “[Zend]” section now in PHP.ini, if you find zend_extension_ts, then comment the line using “;”. And that’s it!

    Refresh you phpinfo page and search for “XDebug” and you will see setting of XDebug and you have successfully configured XDebug with PHP.

    Considering you are using Eclipse v3.3 or above, which has built-in XDebug support. All you have to do is, go to “Debug Configuration” as set start URL, click “Apply” and close the window. Now click “Debug” button from toolbar to start debugging.

    PS: There’s a XDebug bug which makes Apache server to crash while debugging with Eclipse. The crash occurs when invalid expressions (watch items) are there. Delete all expression items when terminating or launching your debug session.


  4. Aug 7th, 2010     xdebugphphowto
  5. GMail adds rich text signatures

    You can now use rich text as well as images in your GMail signatures.

    Currently GMail supports hotlinks to images for using images in your signatures. You can use Photobucket or Imageshack to use inline images in your GMail signatures.

    Goto Settings, scroll down on the General tab for Signature section to modify your signature. Also use Insert Image on the Signature textbox toolbar to link images. Make sure you upload your images to above mentioned sites or any image hosting provider that supports hotlinking

  6. Jul 9th, 2010     gmail signature rich
  7. Javascript: Difference between “return false” and “e.preventDefault()”

    Most of the times we just write

    return false;

    or we write


    to stop from executing href element in an anchor tag.

    return false; just stops the propagation and e.preventDefault() makes the default behavior execution of a tag.

    In simple words:

    equivalent to return false; is



  8. Jul 9th, 2010     javascript
  9. plays: 2

    I am loving this song. This song is called Chobbi and currently unreleased by Stentorian.

  10. Mar 16th, 2010     banglamusicstentorian
  11. Thinking ASP.NET in MVC

    My web hosting doesn’t support ASAPI_Rewrite and thus cannot use ASP.NET MVC, and I am in love with MVC and of course ASP.NET.

    I am currently working on mobile site for my local users and trying to implement MVC architecture.

  12. Mar 16th, 2010     mvcasp.netself-thought
  13. My visit to Malaysia. Petronas Twin Towers, Kuala Lumpur.

    My visit to Malaysia. Petronas Twin Towers, Kuala Lumpur.

  14. Sep 30th, 2009