railsA couple of weeks back I was asked by a client to quote for a 25 page ecommerce website. After looking at his requirements I quoted him $450, which is quite low by any standards. The client called me with a surprised tone in his voice and told me that in that amount he would be able to buy a new computer and he was willing to pay me not more than $200 for the same. This is not an isolated case, but one from a dozen or so client interactions. I don’t want to imply that the clients are cheap; all of the clients I have dealt with are very good business people. Its just that they don’t know the value of software; and one of the main reasons for that is piracy.
Read More

hasta la vista MIR

Posted in: books | July 10, 2008 |   ( 7 ) Comments

Yesterday while rummaging through my library I came across a little gem – On the way to Super Elements by G.N. Flerov, A.S .Ilynov – Mir Publishers Moscow. A wonderful book by the now defunct Mir publishers. This is one of the several books from Mir that I have treasured in my library. These books were responsible, in no small part, for my intellectual growth and my affaire d’amour with science books.

But these excellent books however have become an unfortunate casualty of the fall of the former Soviet Union. Not only were the books excellent in themselves but the prices were ridiculously cheap, especially during my college years, when a limited amount of money was fated to satisfy my various youthful desires – at about USD 0.25 you could get a hardcover book of 100 pages with multi-colored graphics.
Read More

The Luhn algorithm also known as the “modulus 10″ or “mod 10″ algorithm, is a checksum formula which can be used to validate credit card numbers. Developed in the 1950′s by IBM scientist Hans Peter Luhn and described in U.S. Patent 2,950,048. A PHP implementation is shown below.

 
function LuhnCheck($strDigits)
{
    $sum = 0;
    $alt = false;
    for($i = strlen($strDigits) - 1; $i >= 0; $i--) 
    {
        if($alt)
        {
           $temp = $strDigits[$i];
           $temp *= 2;
           $strDigits[$i] = ($temp > 9) ? $temp = $temp - 9 : $temp;
        }
        $sum += $strDigits[$i];
        $alt = !$alt;
    }
    return $sum % 10 == 0;
}

Data structures are one of the core elements of computer science and they are also fun to program. But being a web developer the opportunity for implementing them in any application is quite rare. But then I thought, What the heck! I can just code for the joy of it, and it will also help me brush up on my DS skills. So here it is, a single linked list implementation in PHP for whoever may care. I will be posting other data structure and algorithm implementations here, so keeping watching. The code is given below.
Read More

Benchmarking PHP code

Posted in: php,tools | June 24, 2008 |   ( 1 ) Comment

Code tuning is an essential part of programming. But most programmers would rather try to complete the project in hand then spend time optimizing a piece of code. A well tuned and optimized code block can speedup your application by an order of magnitude or even more.

Many people confuse profiling with benchmarking. A profiler is a analysis tool that lets you measure the performance of code at runtime. Profiling an application lets you find bottlenecks in your application code. You can find which part of your code is taking most of the time, you can than optimize that part of code. For example if there are 4 functions in your application, profiling may report the following distribution:
Read More

ClickHeat is a wonderful PHP software that lets you add Heatmaps for your webpages. Heatmaps are visual representation of clicks on a HTML page, showing hot and cold click zones. It can be useful to see at a glance which webpage areas are getting the most clicks as this areas get redder in color while the areas receiving less clicks are white. The software has many options to tweak, and the heatmaps can be added on a per page basis.

A sample heatmap image is shown below. You can also use the clickheat class in your own PHP applications. The software doesn’t require any database, only GD graphics library must be enabled on the server, which in most cases already is.

You can view a heatmap for the index page for this site here. I’ve presently only added click log for the index page, so try clicking on the index page links to update the heatmap.

username : visitor
password: visitor

If you don’t see any changes in the heatmap, click on the “log my clicks” link in the right corner or try logging out and then logging in again.

heatmap