My Blog

Welcome! What is this blog for/What will be blogged here? Well, frankly, only time will tell that ... ;-) The plan is to have stuff like ... what I plan to do/Interesting things that I want to share. My interests and hobbies ... and what I'm doing/not doing for it. Random thoughts/Opinions. Just about anything I feel like writing! have fun!

Thursday, October 28, 2004

Kaprekar 2.2b

Released version 2.2b of Kaprekar Series Generator yesterday night.

This is more of a code refactoring release. The code was changed to be more modular. The serialization, SVG generation and statistics code had crept into the Kaprekar Engine. I extracted those into separate classes - this also fixed some cut-and-paste code.

The only bug-fix in this code is for the progress bar in the GUI - the progress bar would not show the progress while searching for Kaprekar Series with more than 19 digits. This is fixed now. Well I had written the code, but for some reason I didn't invoke it. Ok, I thought it was an expensive call so didn't invoke it. Now I'm keeping track of the heartbeat and invoking it initially every 50 heartbeats and then every 500 heartbeats. It didn't seem to have too much of an overhead.

This change was in preparation of moving Kaprekar Series Generator to Java 1.5 to use the new language features.

Wednesday, October 27, 2004

Google search from Firefox

Cafe au Lait reports that we can do a google search directly from FireFox's location bar.

I tried it:
1. type "uml svg" (without the quotes) on the FireFox location bar.
2. hit enter.
3. voila! You get the page Kaprekar UML Model in SVG on the browser.

Yep, it goes to the first link found in the search (I'm feeling lucky).

You can also do this by typing in keyword:words in the location bar - where "words" is what you are looking for.

It seems we can modify this behavior to show the search result instead:

1. type about:config on the location bar.
2. look for Keywork.URL.
3. Highlight and press Enter on that entry. OR double-click on that entry.
4. The current value is displayed in a pop-up form.
5. Fill in the value and hit Enter (OR Click OK).
6. Restart Firefox.

Now typing in "uml svg" in the location bar should show the search results.

Sunday, October 24, 2004

No more Zip files on Gmail?

This is absolutely crazy! Gmail no longer allows you to attach zip files to your own mails!

You get an alert box stating -

"Sorry, for security reasons, Gmail does not allow you to send this type of attachment."

Well, I created the zip file that I was attaching and I know that it doesn't contain any viruses and that it doesn't pose any security threat! Why is the software overriding that???

If it was just a warning alert that it was fine - here it prevents me from sending my own (safe) mail!

Needless to say, I logged in to my (now neglected) Yahoo mail account and sent the mail from there - Yahoo proudly declared that "No virus threat detected" on the zip attachment.

[Update: The message I sent from yahoo to gmail with the zip attachment bounced back -

Remote host said: 552 5.7.0 Illegal Attachment

[Update: (08-Nov-2004) Gmail now allows zip attachments. ]

Thursday, October 21, 2004

Java Code: Boolean Fun
Over time I've encountered Java code that I feel could have been written better. I'll list out a few example that I encountered recently.

If you do code review you'll want to check PMD, JLint, FindBugs and some such tools [I've mentioned these before while talking of Eclipse Plugins.]

Boolean Fun

Cosider this code

if(str.length() > len) {
    return true;
} else {
    return false;

The Boolean Expression need not be kept in an if-else block, the output of the boolean expression could have easily been returned as

return (str.length() > len);

A more advanced form of this problem was using a ternary operator -

return (str.length() > len ? true : false);

Yes, the ternary operator is absolutely unnecessary here.

This one was really funny!

if(!(x == y))

I wonder why the developer thought of such a convoluted way to write x != y.

Another common problem I have come across when Boolean objects are used. Invariably you'll see

Boolean b = new Boolean(true);

There is no need to create a new instance here, you could just write -

Boolean b = Boolean.TRUE;

Friday, October 15, 2004

PMD: False +ve: UnusedModifier

The PMD bug I reported on tuesday is fixed! As usual the PMD team fixed it pretty fast.

Thursday, October 14, 2004

Google Desktop

Yes, its out! There had been talks about it, but I didn't realize that it will be out so soon.

You can read this article before downloading Google Desktop.

SQL queries using sign()

Mike Chirico writes an interesting way in which we can compare two numbers using the abs and sign functions. At first you would think that he's just playing with them for fun ... at the end of the blog entry he uses it in a SQL query - that was neat!

check it out!

To spoil the fun a bit, the SQL looks like this -
select name,                                                                                        

sum(score*(1-abs(sign(exam-1)))) as exam1,
sum(score*(1-abs(sign(exam-2)))) as exam2,
sum(score*(1-abs(sign(exam-3)))) as exam3,
sum(score*(1-abs(sign(exam-4)))) as exam4
from exams group by name;

Tuesday, October 12, 2004

PMD Bug: False positive for modifier

Found a bug in PMD and submitted it - False +: UnusedModifier

The following Code gives a false positive:

public interface Test {

int size();

Test DFLT_IMPL = new Test() {
public int size() {
return 0;


PMD complains on the line "public int size() {" stating
"Avoid modifiers that are implied by context.

The method "size" in DFLT_IMPL must be declared public. So, I feel that the pmd message is a false positive.

I'm using -
Eclipse: 3.0.1
PMD Eclipse plugin:
PMD Core Engine Plugin: 1.9.0.v3
PMD UI Plugin: 2.0.6.v3

From my past experience, the PMD team have been very fast to respond. I had submitted a bug way back, I can't even recall what it was about. They fixed it pretty fast. In fact, they even mentioned my name in their credits page. I like that! :)

Monday, October 11, 2004

Prospector: Java Code search Engine

Prospector is a search engine for java code.

You can find code snippets by specifying two classes - the object that you have and the object that you want to convert it to.

An example they quote is - you have a url (have = "") of an image and want to load that image (want = "java.awt.Image"). So you search for it and find four snippets of code - one of which could be the one you are looking for.

I searched for way to create a java.lang.Object from a java.lang.Class and got an 223 snippets (in a visible amount of time).

Sunday, October 10, 2004

Murphy's Law

hmm. they've tried to put a formula for Murphy's law ... an outcome of a commission set by British Gas composed of a psychologist, a mathematician and an economist.

((U+C+I) x (10-S))/20 x A x 1/(1-sin(F/10))

Where U is urgency, C is complexity, I is importance, S is skill and F is frequency.

To quote them "So, if you haven't got the skill to do something important, leave it alone. If something is urgent or complex, find a simple way to do it. If something going wrong will particularly aggravate you, make certain you know how to do it."

Wednesday, October 06, 2004

Gmail Bug: More Actions menu

Stumbled across a new bug in Gmail.

The drop-down menu for "More Actions ..." sometimes does not work - all the options in it vanish!

Here are the steps to recreate the problem.

1. Go to inbox.
2. Select the drop down "More actions ..."
3. Instead of selecting one of the options, click on a mail instead. (i.e., outside of the drop-down menu)
4. The mail does not open - which is correct. And the drop-down menu closes - which is also correct.
5. Now select the drop down menu again - the menu does not open up, it does not show any options.

OS: Win 2000 SP2
Browser: Firefox 0.9.2
User Agent String: Mozilla/5.0 (Windows; U; Windows NT 5.0; en-US; rv:1.7) Gecko/20040707 Firefox/0.9.2

Monday, October 04, 2004


It's official! The Ansari X-Prize is won by Scaled Composites!

I've mentioned their flights before.