Monday, December 17, 2007

Weekend??

Thank God its Friday, is a phrase used quite frequently, especially software professionals. After all the preoccupation with work for 5 days, its time to relax and enjoy! However, the way I spent this weekend makes me think otherwise!!! Whether its because of lack of planning or some other factor is hard to tell. Got up early morning on Saturday (Trust me, 8.am is really early), dropped my friend to the airport and suddenly I realize I'm running short of ideas to spend the weekend.
Well, this has never happened to me before. So I take out a book and start reading. Its been hardly 15 minutes of reading when I realize I have to hunt for a new place to stay! Supposed to vacate our current flat at the end of this month. So I take my bike out, and set out on a wild goose chase! I had no intentions of hunting for a new place, so no effort made in this respect. After loafing around on the Bangalore streets, I finally have lunch and come back to the flat. Sit idly for about an hour then head straight to office. Office? on a weekend? I was never a workaholic. Well, atleast I can surf the net. And thus, I spent the entire evening in office, doing nothing! Nothing at all!!! Came back at night, watched TV till midnight, but wasn't getting any sleep! Nor was in a mood to read. So just lie down, waiting for the sleep Gods to be pleased. Fortunately, they were helpful and responded soon. The next day I hoped should be better. I get up at 10.30 and decide to indulge in my favorite activity! Take my bike, go on a long ride, not knowing where to go! Just follow the road, take a random direction at a junction, take a tea break at a tea shop and move on!!! Finally after travelling around 80-100 km, I reach back to the flat and again go back to office :( in the evening, this time with a genuine intention to work (Not really). I just play some online games for about half an hour. Then I find a friend online on gtalk. A friend whom I always enjoy chatting with :) Well thats it! The evening ended
with chatting. After dinner, I head to office again, this time with Shivam and Roshan, both of whom, currently loaded with work. And what do I do? Just give them company and chat again!!! And finally decide to write this! To remind me to plan things, to avoid boring times :) After all, boredom is a really nasty bug!!!

Wednesday, November 28, 2007

Addiction to work or procrastination???

Well friends, its been a very long time since the last post! Obvious excuse is a lack of time! Although that's a blatant lie, I don't generally enjoy lying, so let me confess. Laziness has become an integral part of me and I'm finding it hard to part with it. Hey, wait a minute, what is this post supposed to be about? I couldn't think of a title which would justify the following, so I just stuck to one which would sound less harsh...

I've been in the office from 10am to 3am ie 17 hours today! Let me reflect on what I've done in those hours... Well, here is the work flow. Check my mails, go out for tea, check my mails (this time obviously no mails to reply to), start working for about an hour, spend some time in the restroom, go out for tea, browse the internet, work for another hour or so, have lunch (a late lunch), go out for tea, work for another half an hour, browse the internet, then work for another half an hour. Its dinner time by now. So I go out and have dinner. Then I don't feel sleepy, so come back to office, work for another half an hour (work is almost done, but not yet complete), browse the internet. Finally, at about 2am, I decide to finish whatever is left (hardly 1-2 min job). Then start the orkut business! Eventually, tired of orkut, I think of posting this piece of gibberish!!! If you have taken the trouble to read so far, then take some more to leave your comments, giving me and other like minded people some advice on how to rid oneself of this dangerous habit. I'll try my best not to repeat this thing. Bye for now.

Tuesday, August 14, 2007

Places to visit in India I - Shivasamudram Falls


Of the many picnic spots in and around Bangalore, I would rate Shivasamudram as one of the best. This waterfall is located around 120 km from Bangalore, towards Mysore (Mandya district). Though the road is very good for most part of the journey, it becomes terrible during the last 20km or so. Although you can go through the shorter Kanakapura route, I would recommend people to take the Mysore road till Maddur and then take a left at Maddur junction cause of the terrible road! After about an hour long bike ride from Maddur, you will reach a 3 way junction. The left goes to Gaganchukki (also known as eastern falls) while the road going straight takes you to Bharachukki (western falls)


Gaganchukki
There is a watchtower on this side of the waterfall which gives you a panoramic view of the waterfall. On the way to the watchtower, you will be greeted by a huge board shown in the photograph!
Well be wary of the monkeys near the watchtower! Towards the left of the watchtower, you will see a hydroelectric plant which is said to be the first to be built in Asia. There is nothing much to be seen here.


Bharachukki
This is the place where you can enjoy to the fullest! If you belong to the adventurous lot, then u can take a dip in the turbulent Cauvery waters. Sitting underneath the falls and letting the water current massage your body is a great experience! However you need to be extra cautious. A slight step in the wrong direction can turn you into an offering to the Gods of adventure!!!

Overall, Shivasamudram is a must visit place!

Thursday, July 26, 2007

Credit cards, the unnecessary evils

Thank God, its the last week of the month! With salary just a few days away, its time to party! Alas, not enough funds!!! Does this situation sound familiar? If yes, then you probably have fallen prey to the necessary (or unnecessary) evil called the credit card.

Well, credit card is the first hurdle to effective wealth management especially for salaried people. The credit card business is really flourishing these days. How many times have you received calls from credit card companies, offering lifetime free credit cards? The calls won't stop coming until you accept one of their offers! Its really hard to reject their offers. 'I am calling from xxxx, and we are offering you a lifetime free credit card. You will get 20% cash back on booking air tickets. You also get one rupee back on every hundred rupees spent on your credit card. In addition, you also get blah, blah, blah...'. You don't want a credit card, so you say, 'Thank you, but I am not interested right now'. 'Why sir? You are getting it free for lifetime. You get this, and this, and this, and that on the card...'. Well, you just cannot refuse, especially if the person at the other end has a sweet female voice ;) Chances are that you will go for one of the cards eventually...

Initially, we are a bit tentative to use the dreaded card. But alas, once we use it, we get into the habit. Now, we end up using the credit card for each and every transaction, however small or big it may be, mostly because of the seemingly attractive offers you get. The result? A long monthly bill statement, consuming more than half of your monthly salary...When you analyze your bill statement, you agree with all the billing details. But you just keep wondering, how it adds to so much. I myself have once paid a bill of 32k(without interest), but have stopped using it. Now, I just use it for booking travel tickets... If you have absolutely no control over your credit card, then chances are that you can't pay your bill on time, and you end up paying a hefty interest the next time...

Some people will use 2-3 credit cards and then use one to pay the bill of another. While they continue to repeat this cycle, they end up paying a transaction charge every time. Little do we realize that we become used to staying in debt.

I won't say you should not use a credit card. Use it only when needed, for example when booking travel tickets. For making general purchase, get into the habit of using a debit card. Atleast, you will stop spending wastefully when your account balance reaches a certain threshold. Still better use hard cash! Atleast you would know how much you have in your wallet and how much you can spend at that moment. This seems like an obvious and useless advice at first. But it certainly ain't as useless as it might seem to be! I hope this post will make you think twice before swiping!!!

Thursday, July 12, 2007

Getting and setting cursor position in Design mode HTML controls

Well this post is for people who have used or might use Javascript in their life. Imagine you creating a WYSIWYG text editor in javascript and wanting full control over how the text should be displayed. Say for example you display the text after processing the user input. The processing is done as the user types. One approach which immediately comes to the mind is to use a hidden textarea control to capture the key events and display the processed text inside a div element. You will have to create a custom cursor inside the div for the user to know where he is typing. The cursor problem can be best solved using some character like say '|' inside an absolutely positioned div and then toggling the display of the div with the help of a timer. So far good! But now, imagine you want to go to the middle of a previously typed word and edit it. Where would you show the cursor? You will need to calculate the position of the cursor when the user presses any key, or clicks the mouse button. Needless to say, it is not easy to manipulate the cursor position. Say for example you had the word "foobar" and wanted to insert a 't' before 'b'. You will somehow need to calculate the desired cursor position in pixels and then display it accordingly. How to calculate? Well, not my cup of tea...

In such situations, the only feasible approach seems to be to turn design mode on for the control. So you use an iframe and set its design mode property to true. You no longer need a hidden textarea control to capture the keystrokes. You can capture the key events, process the user input and then display it inside the design mode iframe. Now the big question of reading and setting cursor position! Gecko based browsers support the W3C specified API. For example in firefox, you have the properties anchorNode, anchorOffset, focusNode and focusOffset which help you to determine and set the cursor position wherever you want to. You get the DOM reference and also the offset required. So pretty fine! (The details can be found in the Midas specification). But what about IE? IE's API doesn not even come close to the W3C API in this case (as in most cases). I was playing around with the design mode control last month and was stuck here. I did a lot of search on the internet but could not find any satisfactory way to get and set the cursor position in IE. One inefficient way found over the internet, to read the cursor position was to move the cursor to the left by some arbitrarily huge number, using the method moveStart on a selection object. This method will then return the number of characters moved which will give you the cursor position. You will use something like

document.selection.createRange().duplicate().moveStart(1000000, "characters");

This method will work fine for small text. But as you keep typing, the editor will become slower and slower. Setting the cursor position is also another problem. You will need to calculate the offset in characters from the start of the editable iframe and then use moveStart followed by collapse. This is doubly slow. The complexity of this technique would be O(n) where n is the offset number of characters from the start position. This is clearly unacceptable for large text input. I continued to hunt for a better approach. Eventually, my friend Shivram suggested a unique hack. He found a post on the internet where some person was using the method pasteHTML of the range object in IE to insert some image at the cursor position. You can paste HTML at the current cursor position using this method. The hack was to create a dummy DOM node and insert at the current cursor position using pasteHTML. Then using the DOM attributes, you can get the required DOM reference. The dummy node can then be removed from the DOM tree. So the following hack solved the problem with a complexity of O(1)

getNodeAtCursor = function() {
    var range = document.selection.createRange().duplicate();
    range.pasteHTML('<span id="foo"></span>');
    var temp = getElementById("foo");
    var n = temp.parentNode;
    removeElement(temp);
    return n;
};

The offset can be obtained by finding the length of the previousSibling of the dummy span.
Thus you get the DOM reference as well as the offset number of characters relative to the node without having to iterate over all the nodes before the one under consideration. Not a clean way, but certainly quite efficient for large text. Let us hope future versions of IE conform to the W3C standard as in Firefox and eliminate the need to use such hacks.

Well, I hope this post helps somebody who might be stuck with getting and setting cursor position in design mode controls especially in IE 7 and below. Cheers!!!

Sunday, July 1, 2007

Height of absent-mindedness

What am I doing still in Bangalore? I was supposed to be in Goa by yesterday evening. Did I say I missed my flight? Well, friends close to me will say nothing new! This one is a totally irresponsible and absent minded guy is what they'll say to themselves. And why not? I have done that before too.

Yesterday, I had a flight to Goa at 14:30 hrs. What do I do? I leave by 13:20 from my flat, about 25 kms from the Bangalore airport, get into an auto at about 13:25. On time I thought! But alas, the auto simply doesnt seem to cross 30 kmph on a lonely Bangalore road. Lonely, compared to the standards associated with Bangalore!!! Finally, I make it to the airport. As I didn't have any check-in baggage, I thought I would finally make it. I reach the boarding counter at 14:15 and is nicely greeted by the lady there! Then all of a sudden, she says, 'Sorry sir, all seats filled up!' Then what do I do? I meet the airlines supervisor, and take out my entire frustration on her :( 'I have a valid ticket. The receptionist at the boarding counter says all seats filled. Do you mean to say you have given my seat to somebody else? How on earth can you do that?' The lady just listens patiently and even though I was on the verge of shouting, manages to keep her cool and is very polite. 'I understand sir, that there might be some problems due to which you couldn't make it 30 minutes prior to the departure. But I'm extremely sorry, we cannot make any adjustments now and let you board the plane. But as a special case, we can reschedule your flight for tomorrow. However, you will have to pay the difference in the fare as an additional charge'. Frustration had already gotten the better of me by this time. After a lot of argument with another supervisor, I just ask for a refund. 'You will get only the taxes as a refund', is his final say. Well, I wasn't feeling well that day. Was feeling a bit feverish in the morning and also a bit of nausea. So I go back to my flat after that and have a good nap. And its after the nap that I suddenly realized how wrong I was. There was absolutely no need for me to take my frustration on the airlines staff! I couldn't make it on time and it was totally my mistake. Well, I've another flight in about 2.5 hrs from now. I'll see if I get a chance to apologize to the airlines staff today...

As I've said earlier, my misery with flights is not a new thing at all! About two months back, I went to the airport 23 hrs after my flight's scheduled departure. But as we all know, today can't be yesterday, and I decided to take a bus to Bangalore. That time, I had nothing to say, even for the sake of an argument ;) In another separate incident, I had a bus ticket from Chennai to Bangalore. In this one, I just forget my ticket at the place of residence and reach the Chennai Mofussil bus stand. The gentleman at the KSRTC booking counter was not as gentle as I expected and simply refused to help me. I had to buy another ticket to be able to travel. After all, absent mindedness, has a price to pay!!! Nevertheless, I still believe the gentleman could have acccepted a valid photo Id proof and let me travel, without additional charge as the booking counter was computerized and had the details of the passengers stored...


Ok, its time for me to leave. I don't want to miss today's flight. Hope to catch you soon...

Wednesday, June 20, 2007

The thrills of bungee jumping

16 June 2007! Bungee jumping in Bangalore! Well, the moment i heard this, there was a sudden rush of adrenaline. I'd always yearned for an opportunity to try this adventure sport. As a child, I was fascinated by the giant wheel experience, but this I knew would be much more thrilling. So the next day(which luckily happened to be a Sunday), I take my bike and rush to Green Country Public School, the venue of the much awaited event, along with my friend at about 4pm. Well, we weren't the only two adventure seekers! After registering, we had to wait 3 long hours, before taking a jump. So decided to indulge in the other complimentary events. First tried our hands at river crossing over a rope which was too simple. There wasn't any river below :( Then tried artificial wall climbing which was a bit tricky. You need to really plan your moves, choosing the right stones for clinging onto, and also for resting your legs. Well, I managed to climb it without any problems thanks to my skinny structure! Being thin has its own merits :) Then tried jumaring which wasn't as easy as the above two. The hands hurt quite a lot!!!

Finally at around 8pm, did our turn to take a bungee jump arrive. The setup wasn't in a valley or a bridge but consisted of a huge crane (about 50-60m high). To the crane was hooked a small trolley. With our feet tied together, and fastened to an elastic rope, one had to limp towards the trolley which would then take you to the highest point along with the instructor. The scary moment was when the latter told you to stay right at the edge of the trolley. Well, that's not all, you are supposed to hold your hands together in front, leaving all hopes of not falling, into the hands of the instructor, who would hold a belt fastened around your waist. Of course, you are supposed to fall, but the very thought of he letting you go was frightening. Then all of a sudden, you fall off the edge as he lets you go, and then you are left speechless as you just relax and enjoy the effect of free fall, until the tension in the rope starts pulling you back. And then you oscillate vertically in the air for some time, which seems like an eternity. Time just slows down. And then, when the support crew pull you down, you just think, why was the height so less? Why did it end so soon? Why does time seem to just fly??? Well, I think I have enough reasons to indulge in bungee jumping on a frequent basis. Hope to get a chance to jump deep inside a valley someday...

Friday, June 15, 2007

Welcome to my world

Hi! This is my first post here, so let me introduce myself. I'm a very handsome, tall, dark, intelligent man with a charismatic personality. Oops, was I talking about myself??? Well, a pretty ordinary looking confused guy with average intelligence and a weird sense of humour is what I am. A software engineer by profession, I am basically a jack of all trades! My interests range from reading, playing chess, cricket, programming, biking and yes, how can I forget orkutting? Accordingly, my posts can also be related to almost anything in this universe. A word of caution! The posts can get too weird and nonsensical, so read at your own risk!!!

Well, this was just an introductory post and I don't want to turn you off after the very first post. So time to say goodbye for now... Hope to catch you soon :)