Archive for March, 2007

Linking to localhost?

Ever wondered how many people are linking to localhost files from their websites or blogs? Today, I found out an easy way to get the latest localhost linkers!

I installed wordpress locally and was testing it using the URL http://localhost/. The incoming links section of the Wordpress dashboard showed the following blogs which are linking to localhost. Very funny!

Localhost linking!

If you check your localhost installation, you might find my blog as well! Pretty neat way to get more traffic - eh?

Internet Explorer 7 rocks!

Internet Explorer 7.0Today I upgraded Internet Explorer from version 6 to the latest version 7. The download requires genuine windows validation 3 times! Apart from that that 20MB download went smooth.

This review is based on my experience of using IE for just one hour! IE 7.0 simply rocks! The interface is sleek and the performance is unbelievable (for a microsoft product, that is  :-)) . Here are some of the interesting features of Internet Explorer 7.0,

1. Improved screen rendering. Now reading a webpage seems easier probably due to enhanced anti-aliasing.

2. Minimal, but effective UI - The UI is similar to Windows media player and is quite intuitive. All the frequently used features are easily accessible.

3. The tabbed browsing - This was probably the only reason I was using Firefox. IE 7.0 contains this feature and is better than Firefox when it comes to opening new tabs (new tab appears just near the old tab)!

IE 7.0 tabs

4. Reduced startup time - I have a 1GB, 1.8GHZ machine and IE 7.0 starts in a flash!

Another noticeable feature is the Live search which appears on the right of URL field. It is quite tempting to use it instead of Google, nice try Microsoft! :)

So overall, I am very much pleased with IE 7.0. If you are using IE 6.0, I recommend immediately upgrading it to IE 7.0 (If you have genuine windows  :-))

PHP notes for Java programmer (4) - classes

Here is the last set of PHP notes which cover object oriented programming in PHP. The notes conclude with a set of supplementary notes. The entire list of PHP notes are available here.

PHP Notes - Object oriented programming

1. To call class methods without an instance, use scope resolution operator(::) else use (->). Check the following example,

class test {
 function f1() {
  echo “hello”;
 }
}

test::f1();

$t1 = new test();
$t1->f1();

2. In PHP, __autoload function (automatically called) can be used to simulate “import” functionality. This is very handy if you store your classes in separate PHP files. For example,

<?php
function __autoload($class_name) {
    require_once $class_name . ‘.php’;
}

$obj  = new MyClass1();
$obj2 = new MyClass2();
?>

3. PHP has constructors (__construct()) and destructors (__destruct()). There is no chaining of constructor or destructor calls. Use parent::__construct() for the same.

4. Method and properties can have “public”, “private” or “protected” visibility.

5. Use const keyword to define constants inside classes.

6. PHP has the standard class constructs - abstract, extends, interface, implements etc.

7. It is possible to overload method calls and member access using __call, __get and __set. This will be triggered only if the accessed attribute or method doesn’t exist! isset() and unset() can also be overridden using __isset() and __unset().

8. For serialization methods __sleep and __wakeup. All methods starting with __ are reserved as magic methods in PHP!

9. To perform shallow copy, use clone directive. It is also possible to define a __clone() method.

10. PHP supports reflection paradigm. For more details, checkout http://www.php.net/manual/en/language.oop5.reflection.php

11. PHP supports type hinting for object and array types. For example, function f1(array $a) { }

12. A typical PHP class declaration is shown below,

class Test extends T1 implements T2 {

 public $a;
 
 public function testmethod($value) {
  $this->a = $value;
 }
}

13. PHP exception handling is similar to Java. It is also possible to extend the base “Exception” class. Here is a sample use of exception,

try {
    $error = ‘error message’;
    throw new Exception($error);
} catch (Exception $e) {
    echo ‘Caught exception: ‘,  $e->getMessage(), “\n”;
}

PHP supplementary notes

1. For maximum security always validate user input. You don’t want to be a victim of SQL injection attack!

2. For database access, provide least access rights needed by the application.

3. On a production system it is better to disable error reporting.

PHP notes for a programmer - 10 minutes quick tutorial

Following is a set of notes I made during my study of PHP programming language. This assumes that you are familiar with one of the OOP languages (Java, C++ or C#). I hope this would be really helpful if you are looking for a 10 minute quick tutorial for PHP!

0. Starting PHP development

1. Introduction to PHP

2. PHP types and variables

3. Control structures and functions in PHP

4. Object oriented programming in PHP

Tutorials

In this page you will find all the tutorials I have written in my blog. All the posts are grouped here based on the topic. This is continously updated so stay tuned for more tutorials!

1. PHP Notes for a practising programmer

PHP notes for Java programmer (3) - control structures and functions

Here is the 3rd set of PHP notes. With this all the core PHP language features are covered. The only thing left is the OOP support in PHP - classes and interfaces. For classes, I will cover only the PHP 5 features (PHP 4 has a different model). Stay tuned for the final set.

PHP Language Reference Notes - control structures and functions

1. There are two equality operators in PHP. == is for “equals” and === is for “identical”. “===” return true only if both operands are of the same type!

2. @ is an error control operator in PHP. This works only on expressions and will suppress error messages. Handy if you don’t want to expose errors to the page being displayed.

3. Backticks (“) can be used as the execution operator in PHP. for example $output = `ls`; will contain the directory listing in linux.

4. There are two types of logical operators - “and”,”&&” , “or”, “||”. The “or” operator has less precedance than “||”.

5. In arrays, “+” operator indicates union. “==” checks whether same key/pair value exist in arrays, while “===” also checks for their order (identical).

6. Following are the control structures in PHP,

if ($a > $b) {
   echo “a is bigger than b”;
} elseif ($a == $b) {
   echo “a is equal to b”;
} else {
   echo “a is smaller than b”;
}

while ($i <= 10) {
   echo $i++;
}

do {
   echo $i;
} while ($i > 0);

for ($i = 1; $i <= 10; $i++) {
   echo $i;
}

switch ($i) { // switch can work on strings!
case “apple”:
   echo “i is apple”;
   break;
case “bar”:
   echo “i is bar”;
   break;
case “cake”:
   echo “i is cake”;
   break;
}

7. There are two forms of else if in if blocks. It can be “else if” or “elseif”.

8. All control structures has an alternate form which uses colon(:) and end<type>; For example, if($a): endif;

9. PHP has a shortcut form of for, the foreach. Consider the following example,

<?php
$arr = array(1, 2, 3, 4);
foreach ($arr as $value) {
   echo $value;
}
?>

10. The break statement takes an optional parameter indicating how many levels needs to be skipped. For example, break 2;

11. The continue statement takes an optional parameter indicating how many levels needs to be skipped when going to the next iteration. For example, continue 2; Also note that continue applies to switch statement as well!

12. The declare construct can be used for profiling. For example, declare(ticks=1) { //code here }. This works along with register_tick_function(). The registered function will be called for every n low level instructions, where n is the number of ticks.

13. To include another PHP file use either include() or require() construct. require() will cause a fatal error if the required file is missing. To avoid multiple includes of the same file, use include_once() or require_once().

14. In PHP, it is possible to define functions inside functions! Function visibility is global but the outer function must be called before you can call the inner function!

15. There is no function overriding or overloading in PHP.

16. Function arguments can be passed by value or reference. To pass by reference prefix variable with &. PHP also supports variable function arguments.

17. Default function argument values are possible and they should be ordered from right to left. For example,

function test($a, $b=”value”) {
}

18. PHP also has variable functions. This can be used for implementing function callbacks!

function f1() {
 echo “hello”;
}
$functionvar = “f1″;
$functionvar();

On why I need more idiots to read this blog!

First of all, I am sorry if the title was insulting. But I couldn’t find a better title than it for what I am going to say!

Some of you would have already noticed the presence of Google Adsense on this blog. The primary aim of this blog is not to make money, but at the same time I hoped that it would atleast cover my hosting expenses ($100 a year).

Now here is the interesting part. This blog is completing 2 months this week. So far I had around 1800 page views as you can see from the following Google Analytics report. I know, it is pretty low compared to A-list blogs, but still I was expecting some earnings from these impressions.

 jaysonjc.com page views

Next let us look at my Google Adsense earnings from this site. There is no surprise there! - It is a total of $0.00!

Now frankly this is very discouraging. But I know adsense does work. As you can see, guys like John Chow (a nasty guy who would probably bring down the whole internet!) and Amit Agarwal does make sacks of dollar notes every month. So what is the reason why I am not getting any adsense revenue?

I did a bit of research and I think there are mainly two reasons for this,

1. I don’t have enough ad units on the page. Some think that having less ads gives more money. In my blog, I don’t think it works!

2. The most important reason I think is that most of my blog readers are intelligent. Even those who come to this site via Google search are pretty intelligent. I guessed it from what my readers are searching to reach this blog.

So in order to get more advertising money, I need to gather an audience which is less intelligent. If I could get an army of idiots coming to this site, I am sure my adsense income will skyrocket!

I think the easiest way to do that would be to write about Paris Hilton, Britney Spears and American Idol. Don’t worry I have no such plans, yet. :)

Vadanappally beach in Kerala

Last week, I went to vadanappally beach with some of my cousins in Trichur. It is not a crowded beach and is an ideal place if you are thinking of spending some time in meditation or introspection! Here is an interesting photo from the trip.

Kadal nakku
We are admiring a piece called kadal nakku (fish bone). On top of it we could see some crawling mollusc type creatures.

PHP notes for Java programmer (2) - types and variables

PHP Language Reference Notes - Types, Variables and Constants

1. It is not possible to mix XHTML declaration with PHP. Once way to solve this is to use <?php echo(”<?xml version=”1.0″ encoding=”UTF-8″?>\n”); ?>

2. A PHP instruction is terminated by a semicolon (except for code blocks such as an if block).

3. Three types of comments are possible - /*comment*/, //comment and #comment. Be careful when you mix them!

4. PHP supports eight basic types. They are boolean, integer, float, string, array, object, resource and NULL.

5. PHP types are weak and are dynamically typed. PHP variables are prefixed by dollar sign($).

6. Type conversion is easy! You can cast types or use settype() method. For example $intvar = (int)”100″ is a valid statement in PHP!. This is equivalent to   $v1 = “100″; settype($v1,”integer”);

7. Boolean literals true and false are case insensitive.

8. Integer overflow causes a variable change its type to float!

9. PHP has no native support for unicode strings.

10. String literals can be expressed in 3 forms - single quoted, double quoted and using heredoc syntax.

11. Single quote strings don’t evaluate the string content. Hence if variables are inside strings, they are not interpreted.

12. Double quote strings are evaluated. Hence if there are variable or special characters, the corresponding value is output. For example echo “hello $val” will print “hello world” if $val=”world”.

13. String characters can be accessed using index operation. For example, $v1[4];

14. Use complex syntax in double quoted strings for evaluating complex expressions!. For example,  $v1 = “hell”; echo “{$v1}o”; - The output is hello.

15. For string concatenation using dot(.) operator. For example “Hello”.” World”

16. By default arrays in PHP are associative in nature. Hence array(”0″,”1″,”2″) and array(”0″ => “0″, “1″ => “1″, “2″ => “2″) are identical.

17. $v1[] = “100″; extends an array by adding the element “100″ to it. The key will be maxkey + 1;

18. PHP supports callback functions.

19. PHP variable scope rules are a bit strange. A globally declared variable is not visible inside a function snippet. For example following won’t print “hello” since $a inside test() is a different variable!

<?php
$a = “hello”;
function test() {
  echo $a;
}
test();
?>

20. Keyword global can be used to refer global variables in functions. For example,

<?php
$a = “hello”;
function test() {
  global $a
  echo $a;  // prints hello
}
test();
?>

21. Another alternative is to use $GLOBALS superglobal! In the above example,  $GLOBALS[’a'] returns the value of $a.

22. Another interesting PHP variable property is that variables declared in a code block is visible below the code block! Consider the following example,

<?php
$check = true;
if($check) {
  $a = “hello”;
}
echo $a; // prints hello
?>
23. PHP has something called variable of variable. For example,  $a = “hello”; $$a = “world”; echo “$a $hello”; // This prints “hello world”.

24. In PHP, constants are declared using define. There is no need for a dollar sign to refer a constant. For example,  define(”PI”,3.14);echo PI;

25. PHP has a large number of magic constants. Values of some these depend on the context they are used. For example, echo __LINE__; will give you the current line number!

PHP notes for Java/C# programmer - set 1

Are you a Java/C# programmer looking for a crash course on PHP? Here is an easy way. In the next 5 days I will be going through the entire PHP documentation and will be taking notes which are relevant and unique to PHP.

I am a hardcore Java programmer and hence by following me you can quickly learn PHP! My notes will be mainly based on the online PHP manual. Here is the first set of PHP notes.

General PHP Notes

1. PHP - PHP:Hypertext Preprocessor is an open source general purpose scripting language.

2. PHP can be used for server side scripting, command line processing and as a GUI application (PHP-GTK).

3. PHP is changed to a proper object oriented language from version 5 onwards and allows OOP paradigm.

4. First sample program, the famous “Hello World”,

<html>
<head><title>Hello World</title></head>
<body>
<?php echo “Hello World” ?>
</body>
</html>

5. PHP exposes a set of superglobal variables accessible from anywhere. For example, $_POST superglobal can be used to extract http post parameters. $_POST is an associative array.

6. If the HTML form field name contains a dot(.), it is converted to an underscore(_) automatically by PHP. For example, if the text field name is “user.name”, you should use $_POST[”user_name”] to retrieve its value!

7. There are a couple of mailing lists available for PHP. It is at http://www.php.net/mailing-lists.php. So far I have only subscribed to “Announcements”.

Next set of PHP notes on the language features will be published tommorrow.

Starting PHP development

I have recently started on PHP programming (been postponing it for years!).  The official PHP manual seems to be the only source needed to learn PHP. It is pretty big and I think it will take a week for me to cover it.

An interesting feature of the online PHP manual is the inclusion of “User Contributed Notes”. Sometimes these notes are more informative than the manual entry :). But sometimes they can be misleading as well.

For testing out the scripts, I am using XAMPP Lite - An all in one Windows installer which contains  Apache 2.2.4 + PHP 5.2.1 + MySQL 5.0.33 + phpMyAdmin 2.9.2 + Openssl 0.9.8d + SQLite 2.8.15. Download, extract and run setup_xampp.bat and you have everything running in 5 minutes!

Also I am looking for a good PHP book which can be used as a single offline reference. PHP 5 Unleashed by John Coggeshall appears to be good, but I am yet to make a decision.

The art of being at the wrong place at the wrong time

I don’t think any explanation is needed for the following one!

Wrong time, wrong place

It is probably photoshopped, but too good to miss. You can check out other similar ones here.

Google Hack - Running more than one Google Talk

Here is a cool trick which allows you to run more than one instance of Google Talk. I found it quite useful since I could keep my wife’s ID also logged on all the time.

Right click on the Google Talk shortcut and then add “-nomutex” as a parameter in the target field. The diagram on the right should clear any doubts you have! Voila! now everytime you click on Google Talk you get another session.

Google Talk trick

Twitter tricks, tips and tools

Twitter!These days Twitter is everywhere and there seems to be a global conspiracy to promote it. In case you don’t know what Twitter is, welcome back to earth!

Twitter is a global community of people answering just one question - “What are you doing”? You can create an account and then start sending your current status using either mobile, instant messengers such as Google talk or direct from http://twitter.com/.

This process of sending “what you are doing right now” is called twittering! If you want to see what someone else is doing, you can add him as a friend and you will get updates on what he is doing right now!

Another interesting feature is the ability to embed your current twitter status on your Website or blog. For example, in my site on the right side bottom you can see my current status!

I usually update my twitter status from Google talk. But these days twitter bot is down most of the time. Using SMS on mobile is ruled out since it costs around Rs. 5 per message! So the only option left is to use the Website which obviously is cumbersome.

It is probably one of the most addictive, useless and time wasting concept man has invented! But I have put together a list of twitter tips, tricks and tools for all the Twitter maniacs out there :)

Twitter based Websites

Twitter badges - Twitter provides a set of Javascript and Flash badges using which you can display your or your friend’s current status.

Twitter timeline - Official Twitter where all the latest public updates are available.

Twitter commands - Official list of all Twitter commands you can use.

Twitter API - Want to build something based on Twitter? Try the Twitter API.

Twittervision - This is a combination of Google maps and Twitter. You can see live twittering which will popup on the map. Very addictive! They have added a digg type “like” and “dislike” buttons for each twitter that is shown.

Twitter search - Search Twitter for stuff. Looking for links? Try searching “tinyurl”.

Twitterholic - Catch the most popular Twitters based on followers, friends, updates or favorites!

Twitter Tools

Twitterrific - This is a Mac client for publishing and reading twitters.

Twitteroo - This is a Windows client. The main advantage is the automatic shortening of URLs.

Twapper - This is a mobile client for Twitter. Use it if you don’t want to be flooded with SMS messages.

Twitter Firefox Search Plugin -  Post updates to Twitter right from your Firefox search bar!

Tweetbar - This is a Twitter sidebar for Firefox and Flock.

Twitter tools - Twitter tools plugin for Wordpress if you are too lazy to create badges.

Twitter hacks

Binny has written a shell script for twittering. This is based on Twitter API.

RSS to Twitter - Here is a PHP script to feed RSS to Twitter!

Is there anything I missed? Let me know, I will add it here.

Top 10 traits of a good programmer

As I have written in one of my earlier posts, this is the 9th year of professional programming for me. In this post I will summarize my thoughts on what makes a good programmer (master programmer or chief programmer as called by some). I wouldn’t call myself a master programmer yet, but I am pretty sure I know the traits that define a good programmer.

Now before I go into the details, let me first clarify what the term “programmer” means to me. A programmer is not someone who blindly implements whatever design is given to them. Many software service companies in India are under this impression. This myth is purposefully floated around mainly because 90% of the programmers in these companies have less than a year of programming experience. So  coding/programming has to be projected as a mechanical activity!

So who is a programmer? A programmer is someone who has fairly good understanding of computer systems, can write good code, is intelligent and can visualize a software solution for a particular software requirement. He looks at the software requirement and starts thinking - How do I build this thing? How I can design the interface so that it is most user friendly? What happens when there is huge data volume? How do I ensure that no one hacks into my program (especially for Web applications)? How do I reduce coding effort? How do I ensure future additions have minimum overhead?

So as you can see it is much more than just mechanical coding.

Ok no more preaching! Here is my top 10 traits for a good programmer.

1. Think! -  This is the most important trait of a good programmer. He never jumps into anything. Given a problem, he first thinks over it. The more he thinks, the more ideas, questions and alternate solutions come to his mind. I see the lack of thinking as the primary source of all problems a novice programmer face. When he comes across a problem, he doesn’t think. Instead he bangs his head on it or asks for help from another guy. Sometimes you need to ask for help, but think on the problem or bug before you run across to your technical lead!

I will give an example of the importance of this “Think” factor. Sometime back we had a requirement to build around 40 interfaces. This basically required scripts to be written to transform data from a set of tables in one database to another. The estimates were done like this,

1 interface = 5 days and hence 40 interfaces = 40×5 = 200 days of build effort.

When I started on the project, everything was in place. The team, the effort of 200 days and the schedule. Then I thought over it. I saw that if a generic framework is written for the transformation, I could externalize the transformation rules into an XML file. The generic framework took me about 10 days to build. Then for all the 40 interfaces, the time taken was 5 days (since only tranformation rules were to be written). So my team got a lot of free time! :)

2. Learn! - Learn Baby, learn! A good programmer has a burning desire to learn new things every day. It is almost 15 years since I started programming. And even today, I spent a lot of time learning new things. When it comes to programming, every program you write teaches you something. I have fairly good knowledge of Java, C, C++, C# and Qbasic (yes qbasic is my first love!). Just recently I have started learning PHP.

Nowadays learning trait is something which I see less and less in my professional life. The learning itself is so formalized and force fed that people are bored with it.

By learning, I am not talking about taking professional certification. Sorry to say this, but I have nothing but contempt for many of the professional certifications (for example the Sun certifications). In India, it is very easy to manipulate the system and there is a lot of fraud happening on the certification front.

3. Help others! - This to me is the golden rule of programming. “Help other as you would want others to help you”. In my case, I think much of the programming wisdom I possess has come from helping others solve their problems! I used to sit till late hours and help others solve their programming problems or bugs. The advantage was,
 a) Immense experience in solving programming problems.
 b) Various ways people see a particular problem. Also you come across interesting/weird/strange ideas!
 c) Empathy towards programmers. The difficulty they face in their day to day job.

Unfortunately as I grew older and came in touch with extremely process centric enviornments, I realized that “Help others” is not something officially appreciated.

4. Lead by example! - Another important trait if you are a senior programmer or architect. Many times I have come across senior technical architects who say - “It is simple, you just do this and do that”. I am 100% sure that many of them can’t code what they so confidently say as “simple”!

If you are a technical lead or a lead programmer, lead by example. Write code in front of your team members. You will get more trust, respect and support from your team!

5. Know everything! - Ok, that doesn’t sound right. I will rewrite it - Know a bit about everything. For example, If you are a core Java programmer, you should also know about SQL programming. It also helps if you know a bit of regular expressions or a scripting language. For example, I have recently gone through XML specification twice even though I have no professional need right now. But someday I will need it.

6. Know basics of computer science! - There are many programmers out there who doesn’t have the basic knowledge of computers or their inner workings. This is very essential. Many of the programming difficulties that people face is due to the lack of knowledge of how computers work! If needed take a computer science course.

7. Perfect it as much as you can! - Nobody is perfect. You can’t write perfect code in the first iteration. Refactoring is the mantra. Analyse your code, find code fragments that can be reused and refactored.

8. Use tools! - Many programming tasks can simplied if you use appropriate tools. For example, in all my projects I use Ant to automate build and deployment process. You will be surprized at the time you save!

9. Explore code! - If you want to improve your coding skills quickly, one thing I recommend is exploring code written by others. If I would have said this 10 years back, you would ask me- “Where can I find good code?”  But now the scene is completely different. Open source movement has revolutionized everything.  There is so much good open source code out there that I feel overwhelmed by it!

10. Be Humble! - Humility is the last of the top 10 traits a good programmer should have. But it is not the least! As you get more and more experience, it is very natural to feel arrogant. The moment you become arrogant, you loose the trust and respect of your fellow programmers.

I have come across many who are intelligent and technically quite good. But again I have no respect for them simply because they are arrogant. Being arrogant also shows how ignorant you are!

Remember, no one is perfect. You can also make mistakes. If someone points it out, thank him and accept his valid comments.

Closing thoughts

Now you might be thinking - Why is this guy not talking about “design patterns”? Why is he not talking about “Ruby on Rails”? What about extreme programming? What about open source contribution? Linux? and so on.

My dear friends, In my opinion talking about design patterns or practising pair programming(as in XP) etc. are not one of the top 10 traits. Being aware of design patterns definitely helps, but I think you will anyway come across it yourself if you are a regular programmer or if you explore code written by others!

Again I want to stress my first point. A good programmer is someone who can build a “good” software system given a software requirement. The “good” here means - correct, optimized, reusable, extensible and elegant. Everything else (tools, language, methodology) are just tools to achieve it.

Programming is not for everyone. If you don’t have the passion for it, quit and find another job. If your company doesn’t recognize your talent, quit the company.

Further Reading

Here are a couple of good books for exploring further on this subject. If you know a good one do let me know by commenting below.

The Mythical Man-Month: Essays on Software Engineering, 20th Anniversary Edition - The good old classic by Frederick P. Brooks.

Code Complete, Second Edition by Steve Mcconnell - A must read.

The Pragmatic Programmer: From Journeyman to Master by Andrew Hunt and David Thomas - I endorse the apprentice method

Expert One-on-One J2EE Design and Development (Programmer to Programmer) by Rod Johnson - A must read if you are a J2EE guy.

Your thoughts are welcome!

iREEADD THIS spam hits Orkut

Orkut SpamThese days, spammers are everywhere. The latest spam to hit Orkut is the “iREEADD THIS” spam. I got this message from 5 of my Orkut friends. This clearly shows how easy it is to mislead people! Here is what the mail contains,

HEY ITS DIANNA, FROM THE DIRECTOR OF ORKUT,EVERYBODY SORRY FOR THE INTERRUPTION BUT ORKUT IS CLOSING THE SYSTEM DOWN BECAUSE TOO MANY BOTTERS ARE TAKING UP ALL THE NAMES, WE ONLY HAVE 57 NAMES LEFT, IF YOU WOULD LIKE TO CLOSE YOUR ACCOUNT, DONT SEND THIS MESSAGE, IF YOU WANT TO KEEP YOUR ACCOUNT ,SEND THIS MESSAGE TO EVERYONE ON YOUR LIST. THIS IS NOT A JOKE, YOU’LL BE SORRY IF YOU DONT SEND IT. THANKS DIRECTOR OF ORKUT, TIM BUISKI. WHOEVER DOESNT SEND THIS MESSAGE, YOUR ACCOUNT WILL BE DEACTIVATED AND IT WILL COST YOU $ 10.00 A MONTH TO USE IT.

As you can see it looks incredibly obvious that it is a spam(Upper case, full of grammer mistakes and they have only 57 names left!). But what surprised me was that 5 of my friends forwarded it to me! Surely they don’t want their accounts to be deactivated!

Another puzzling thing is the motive of this spammer. There is no link. Hence he/she must be doing this just for the kick of it :)

Programmer for 8 years - and still enjoying it

Just last week I realized that it is over 8 years since I started my programming career (In India guys are ashamed to call themselves programmers, they would rather say “software engineer” or “senior software engineer” or “consultant” etc.). Last time I counted my experience as 5 years and obviously that was 3 years ago!

In Indian software industry, any guy who completes 3 to 5 years of programming career automatically becomes a manager. So essentially no programming/design after 3 or 5 years. Instead the guys start to do what is called “project management”. Something which terrifies me. It is a sheer waste of human talent and experience.

After 8 years of programming I realized an interesting fact. My ability to design software systems or code a software component reached its peak only after 6 years of programming. Ok, it may not be same for all, but it seems that you need to have atleast 5 years of solid programming experience to become a master programmer.

Another ability I acquired recently is the ability to troubleshoot a programming problem instantly. Also during code reviews, a glance at the code gives you lot of design/code improvements even when it is written by an experienced coder!

In most of the software organizations, human resources team(HR)  has no idea about the different types of talent employees possess. There cannot be any exceptions. Everyone has to have the same talent and same aptitude. So that means they cannot imagine a guy with 8 years of experience as a programmer. HR thinks, this guy must be either a lunatic or a total looser to remain as a programmer even after 8 years!

Following is a hypothetical conversation. But it could happen anytime :)

Tech support : You have all tools needed on your system - Microsoft Word, Excel and Outlook Express.

Me: I need Java compiler.

Tech support : I don’t believe you. You are too old for that. Get a written approval from the CEO.

Hiding sub categories in Wordpress - a quick hack

Here is a quick hack to hide sub categories in Wordpress. This has the added advantage that even though sub categories are not visible, they will still get crawled by search engines. For example, the categories you see on the right are only the root categories.

All you have to do is to add the following line to the Wordpress stylesheet.

.children { display: none; }

This works because the secondary level categories have “children” as the style class.

Quick Java Tips - List conversions

Here are some quick Java tips. This is based on my recent code reviews.

1. How to convert HashMap keys to an ArrayList?
new ArrayList(map.keySet());

2. How to convert an Array to an ArrayList?
new java.util.ArrayList(java.util.Arrays.asList(array));

3. How to create and initialize a List in one step?
java.util.List = java.util.Arrays.asList(new String[] {”1″, “2″});

Why I hate digg’s RSS feed

Digg!I have subscribed to feeds provided by Digg, Reddit and Stumbleupon. These feeds let me know what is hot on the internet. When it comes to the number of breaking stories, Digg is much bigger than Reddit and Stumbleupon.

But there is one thing that irritates me about Digg’s feed. They don’t provide direct link to the news item being reported. Instead the RSS feed link goes to the Digg story. This means that every time I have to go through Digg to see the news item. It also means that when I share the news, people see the Digg news not the actual news item.

Reddit is smart. The main story links to Reddit, but they also provide a link in the RSS. Hence even though I can only share the Reddit link, I can directly click on the link provided inside the feed and checkout the story without additional clicks.

StumbleUpon is the best. Everything points to the original story reported.

I guess the reason for not linking directly in Digg is that they want maximum Adsense impressions. Also they seems to be looking for more pagerank via shared feed items. So looking from another perspective, they are the most clever among the lot :)

It would have been nice if Google Reader provided a mechanism to directly share a URL, instead of allowing only feeds to be shared.