February 25, 2009

Tauba Tauba

`Emosanal Atyachar' has to be the most brilliant song in a while. While initially it sounded almost repulsive, it now makes me laugh every time I listen to it. The devil is, as they say, in the details.
Bol bol why did you ditch me,
zindagi bhi lele yaar kill me,
bol bol why did you ditch me whore...
Ha ha ... modern devdas, indeed.

IMDB, and official links.

February 23, 2009

`calculable' textboxes using jquery

Here's some code to make your textboxes calculable. Demonstration here.

(function($) {
            $.fn.calculable = function() {
                return this.each(function() {
                    $(this).focus(function(e) {
                        var expr = $(this).attr('calcExpr');
                        if (expr) {
                            $(this).val(expr);
                        }
                    }); // end focus
                    
                    $(this).blur(function(e) {
                        try {
                            var expr = $(this).val();
                            var calculated = eval('with(Math){'+expr+'}');

                            $(this).attr('calcExpr', expr);
                            $(this).val(calculated);
                        }
                        catch (e) {
                            $(this).attr('calcExpr', '');
                        }
                    }); // end blur
                }); // end each
            };
        })(jQuery);

Yes, it uses eval. Doesn't evaluate on initial load. Provides no way to post the expression to the backend.

Expect improvements, and submit patches, once this goes into source control.

edit: Now available in a github repository.

April 04, 2007

Back to gym

I have started training in the gym again. Who wouldn't, after seeing what it can do for you? Though I doubt that a 45 minute workout, 4 days a week, is going to get me anywhere close to that.

March 23, 2007

Yet another puzzle


We pick two numbers a and b, so that a>=b and both numbers are within
the range [2,99]. We give Mr.P the product a*b and give Mr.S the sum
a+b.

The following dialog takes place:

Mr.P: I don't know the numbers
Mr.S: I knew you didn't know. I don't know either.
Mr.P: Now I know the numbers
Mr.S: Now I know them too

Can we find the numbers a and b?


I must admit ... my feeble mind couldn't comprehend that this puzzle even had solution when I first saw it. However, now I know that it does, and am still trying to work it out. If you are a bit impatient - Google around, you'll find the answer.

December 19, 2006

Identify yourself, civilian

This is the message you get at forum.nokia.com upon entering the username/password -

"The credentials you provided cannot be determined to be authentic."

Nice.

December 14, 2006

Equilateral triangle from an A4 sheet (solution)

If you don't know what the problem was, go here.

So, here's the solution. All we needed to do was find the point on the dashed line (left fig.) which would give us our equilateral triangle. Which can be done by folding the paper as shown in the figure in the right. Simple, eh?

Click here to see the figure.

I'll post pictures of the origami too, soon :)

Update:
Someone asked for a clarification, so here it is (image).

Once you get the point, fold along that point and one of the bottom corners. Tear. Repeat with the other corner. Done.

December 07, 2006

A4 for origami?

The day before yesterday, I sat down to make an origami at my office desk. Now, Origami can be a bit daunting, so I had chosen a simple one to begin with. However, the first step itself proved to be a hurdle.



Hmm. Now the only paper easily accessible in our office is A4 size (yes, I used discarded sheets of paper). Which brings me to my question - how do you get an equilateral triangle from an A4 sheet? Using the minimum number of folds too, or else the paper will be too crumpled for use.

If you have a solution, you may post it as a comment :)

August 25, 2006

Three steps to be organised

As I prepare for my life in a (mostly) unfurnished room, I came up with three rules that I feel will keep me organised:
  • Decide where each item goes
  • Put item in it's place
  • Put item it's original place after use
Simple, isn't it?

August 15, 2006

August 10, 2006

Real absraction

I used to think that the girl from my favourite wallpaper was an artist's creation, till I happened to see this.


Nice. I guess I should read the artists' comments more often ...