Wednesday, July 26, 2006

Validation of Host Name in Java .....

We needed to write a validate function for validating the host name. After reading RFC 1123 and RFC 952, here is what we required ....

1). It can contain only dots, dash and alphanumeric characters.
2). It cannot be more than 63 characters in length.
3). The first character must be an alphanumeric.
4). The last character cannot be a dot or dash.
5). There should atleast be one alphabet (This is for Linux).

This is the code we have written ......

public static boolean validateDomainName(String domainName) {
if((domainName == null) || (domainName.length()>63)) {
return false;
return domainName.matches(domainNameRule) && domainName.matches(oneAlpha);

where String domainNameRule = "("+domainIdentifier + ")((\\.)(" + domainIdentifier+ "))*";
String oneAlpha="(.)*((\\p{Alpha})|[-])(.)*";
String domainIdentifier="((\\p{Alnum})([-]|(\\p{Alnum}))*(\\p{Alnum}))|(\\p{Alnum})";

Monday, July 24, 2006

Back on TRACK ..... !!

Play : Walk from Lonavla to Thakurwadi via the Central Railway tracks.
Cast : Prashant, Sabhtarsha, Amol and Pratik.
Genre : Adventure,Stupidity and Broken Limbs.
Rating : Y.

The seeds for this trip were sown last year itself but somehow it didn't get a good crop. Nevertheless, as the saying goes ... its never too late to implement a great plan. We discussed this plan .... late Friday night and got a decent number of approvals ... 6 to be precise. Anyhow, it was decided that we would call each person on Saturday and let him know if we are surely going on Sunday morning. If you are curious to know the plan ... here it is.

Travel from Pune to Lonavla via a local. Get down. Then start walking via the railway tracks till Khandala. Explore a bit of Khandala and walk forward and disappear into some enticing trail in the hills or the valley. Atleast, this is what we planned. What followed did contain the constituents of the plan but the extras involved made this trip one of the most toughest and enjoyable ones. One that we will remember for aeons to come.

No trip ha started without a bit of humour or a bit of confusion. And this was no exception. We were supposed to meet outside the ICICI bank ATM at Pune station. "We" over here means Prashant, Sabhtarsha and I. Amol was supposed to board the train from Dapodi.I arrived at station at 7 30 am. Sabhtarsha joined me at around 7 35 am. I went over to the Ticket Booking centre and was greeted by a long queue running upto the entrance of the building. The local was scheduled for 8 am. We were already on the defensive. I had one eye on the length of the queue and the other on the area the minute hand was covering with every passing second. I was glad to see the ticket master going through his daily routine in extremely quick time. By the time my turn came I was very relieved coz the time was hardly 7 50 am. But I dont think the relief was permanent.

The ticket master said that you dont get local tickets at this window. There is a separate line for local train tickets. I couldnt resist punching myself for not having seen that. Kindly enough, he agreed to give me one way tickets to Lonavla. I had to settle for this coz I couldnt afford to stand in another queue and miss out on the train though I would have preferred having return tickets. But then another argument ensued. The total fare was Rs. 52. I had given him a Rs. 100 note. He asked me for Rs. 2 as change. I didn't have any change having just removed money from the ATM. I told him I didn't have change. He asked me to get it and take back Rs. 50. I said I was alone ... from where will I get the change. He was clever though (OR I was dumb). He told me how can I be alone if Im getting a ticket for 4 people. I had to rush back to Sabhtarsha and get Rs. 2. Not seeing Prashant with Sabhtarsha at 7:55 am was something I observed but couldnt spend time asking about him. I went back and got the remaining money from the ticket master.

After gathering enough breath, I went back to Sabhtarsha. He said that he spoke to Prashant and that he was coming in 5 minutes. By the way, Prashant had gone to Nihilent to park his bike and was going to come from somewhere other than the main entrance of station to board the train. I dont know what struck Sabhtarsha and myself when we decided that we will go to the platform and atleast get on the train and then wait for Prashant. Im glad we took that decision.When we were walking on the station flyover to get to the platform. we couldnt see the train. The watch said 7 59 am. Were we late ? Was our watch not in sync with the Railways time ? What we didn't realise that a local is not as long as an express train. As we started descending the stairs, we could see the tail of the train. We ran and got onto one of the bogies. But Prashant was still absconding. A call went out to Amol to inform him that we were in the middle bogie. We called Prashant. He said ... "Arey do minute mein aa raha hai". And the train set off. We didn't want anyone to miss out but sadly Prashant was missing out.

Sabhtarsha and I were confused, trading expletives to Prashant, with sighs of disgust, to utter silence in the backdrop of commotion in a local train compartment. Just then Prashant called and said that he had just boarded the last bogie of the train. Sometimes it doesnt matter whether we are happy or sad .... expletives just dont stop. But we couldnt hear anything what Prashant was saying. So we told him that we would meet him at Lonavla. But now there was another problem. Lots of people got on at Shivajinagar and we got pushed inside. We had told Amol that we are at the entrance of the bogie. We had to SMS him and ask him to board the train anyhow irrespective of the bogie. We reached Dapodi in another 15 mins. After the train chugged out, we called Amol. He said he had boarded the train. We were relieved. But the very next moment, Sabhtarsha got the delivery report for the SMS we sent to Amol. That meant that Amol was oblivious to where we were.Still, I guess we were destined not to screw up ... atleast for the moment. We asked Amol to meet at Lonavla.

The one thing worrying us was that there was sunshine outside. I couldnt wait for Kamshet. I thought if it is sunny there, then it will be sunny in Lonavla too. Luckily we were greeted by heavy rain just after Kamshet. That brought a smile to our face and Lonavla beckoned. We were tempted to alight at Malavli looking at the mist clad Lohgad and Visapur fort but resisted it. We reached Lonavla at 9 30 am and Prashant got a second round of expletives from Sabhtarsha and I.Prashant, as usual, had a script ready which was as always .... shit. We had Omlette and Burji in a nearby hotel and hot tea at a tapri with heavy rain outside. We had started on the right note .... in Lonavla's context.

We set foot at Lonavla's railway tracks and started our journey to Khandala. Also, this was the grand picnic premiere for Amol's new Digicam. We started off by getting a pic clicked on a oil tank mail train.

But somehow, the thing that brought us here still hadnt showed up. RAIN. We trudged along clicking pics as and when a pretty spot presented itself. It was as if the climate was playing games with us. Sunny at times, overcast and gloomy otherwise. It seemed like we alighted the train as well as the rain at Lonavla. We greeted our first tunnel with excitement and the camera had a busy time.

We reached Khandala at around 11 am and there still wasnt any sign of rain. Amol and Prashant were already getting frustrated and Sabhtarsha and I being the people who suggested the plan were already facing the brunt of the frustration.

We stepped out of Khandala station to explore something.I knew of a lake nearby but it was quite dirty and not worth having a swim as thought by Prashant and I. We got back to the tracks and started walking forward from Khandala station. Our patience paid off and we were surrounded by thick grey clouds followed by heavy rain. We found a small hill and got on top of it and relished every drop interspersed with biscuits and chilly Shankarpaali brought by Sabhtarsha. We again set off rejuvenated after the spell of rain.

The tunnels frequented us more often now until a really long tunnel came our way. We just analysed what would happen if a train comes while we are in the tunnel. Would we have enough space to avoid the train. We decided to risk it. More than half way through the tunnel. we heard the horn of a train with its typical electric locomotive hiss. We ran for our lives leaving behind the analysis to dogs and scraped out of the tunnel gasping for breath.I dont know how many trains and idle locomotives passed us but one thing I can tell you is that whether or not you are on the same track as the train .... it looks menacing with every centimetre it makes.

One thing that we realised is that the rain had deserted us. To make things worse, there were sections of bright sunlight. We surely didn't want that. On our way we found some steps leading upto the Tata Power centre. Initially we thought that the steps were quite less but they took the energy out of us by the time we reached the top. There were huge pipes over there. Amol and I promptly sought refuge over there while Sabhtarsha and Prashant ventured out to explore new trails. Unfortunately Prashant didn't find anything interesting while Sabhtarsha found a short 20 metre path which led us to the same steps via which we had come up. :). We didn't have an option but to proceed via the tracks again. We were having a discussion throughout of whether we should proceed walking towards Karjat or return to Khandala and explore something away from the tracks. But we decided to trudge along. We were digging a hole for ourselves coz Khandala was going further away and Karjat looked a long way off.

We kept talking to people we met on the way and were informed that there are engines which go from Lonavla to Karjat (I mean just engines ... not an entire train) and that they halt at stations and can drop you till Karjat if you request. We reached Monkey Hill station at around 2 pm. There was a person there who advised us to get onto an engine which was soon arriving and head to Karjat. At first we thought it is a good idea. But then we asked some people if there was a waterfall ahead since we really needed some water to freshen us up. When told that there are plenty of waterfalls ahead, we decided to skip the engine journey. We thought that if we can play around in a waterfall, we could walk another 20 kms easily. We walked around for half a km when we saw this raliway overbridge underneath which flowed a really kool waterfall. But to reach there, it required quite an effort. We decided to give it a shot ... we hardly had options.

Getting down to the waterfall was a joyride and the moment got to us. Prashant stripped to his lingerie. :). Sabhtarsha stripped to shorts while I was in my pyjamas. Amol decided to play cameraman. We yelled, we swore, we sang, we slipped, we posed and we enjoyed to the hilt.

Amol clicked some stunning pics including the patent CoV reverse pic. After enjoying for close to half an hour, we put on our clothes and with rejuvenated spirit set our foot on the tracks for the umpteenth time in the day. As we had promised ourselves, we were ready to walk the remaining 17 kms to Karjat. Or atleast, thats what we thought.

Within a km from the waterfall, we were already feeling the after effects of the walk since morning. We were stopping more often, removing our shoes, stopping at smaller waterfalls and doing every other thing in order to save our legs from further assault from the tracks. We went to the extent of walking briskly for 10 minutes and covering a distance of a km in that time but that only caused more damage.
We stopped by a small railway crossing and the caretaker told us that Thakurwadi is just 4 kms from there and we can get an engine from there to Karjat. But he also said that an engine would stop here in the next few minutes which will drop him to Thakurwadi. We couldnt believe our luck. The engine came in 5 minutes time. Prashant got onto it. But Sabhtarsha and I kept talking to the engine driver regarding whether he can drop us till Karjat. He said he would drop us only till Thakurwadi and I guess both of us were not in a state of logical thinking and we decided against boarding that engine. I dont know why. Poor old Prashant had to jump off an engine in motion. We both are very sorry about it. After that, Prashant really gave us a mouthful.

We were really struggling to walk now and we had hardly made any progress on Karjat. Thakurwadi was still close to 3 kms away. We hardly spoke to each other. We kept asking people how far Thakurwadi is and all we heard was 30 mins ... 20 mins ... 15 mins ... it seemes we were walking slower than snails. We could hear the sound of an engine horn for about 5 mins without any difference in decibels. There was a train stationed somewhere closeby or an engine for that matter. But however fast we tried to walk, we coulndt see the train. Finally that same train passed by and we realised that it was Sinhagad Express which halted at Thakurwadi !!. Rubbing salt in the wound almost. We reached Thakurwadi in another 10 mins and spoke to the station master. He told us something which almost made us faint. He said that the engine stops around 100 meters before Thakurwadi. This meant that we had to walk back 100 meters but that sad part was that the engine has already arrived much to our dismay. We had only one option. Get Set Go. Yes, we had to run after all the strenuos walking. Every thud on the ground felt like a broken bone. We reached the engine and Prashant, Amol and I promptly jumped to its rear and were almost suspended in air. But still, Sabhtarsha was busy having a conversation deep in the Bhor ghat with the engine driver. He thought that the driver was calling us inside the cabin. We yelled at him and he too was added to the suspension-from-air list.Prashant, Sabhtarsha and Amol were standing while I sat on the circular thing that joins 2 bogies. There was grease all around and we surely looked like mine workers.

But the next 10 minutes were the most thrilling we could have hoped for. Its such an amazing sight to be at the back end of a railway engine and watching the valley and the hills pass by one by one at a fair pace. On one occasion we had 3 small tunnels one after the other with less than 10 meters between them. It looked like day at one moment and night at the other. If there was a time when I missed a handycam, this was it as I could have shot it coz I was the only one sitting. The engine dropped us close to half a km before Karjat station.

One of our office colleagues, Ganesh, called Sabhtarsha and asked him whether he was at Karjat station. The reason being Ganesh was travelling to Mumbai via the Deccan Express and he just saw all of us loitering around the station. :).

I was cramping up severely and reached platforn number 1 of Karjat close to 10 minutes after the others had reached. Sabhtarsha got us tickets for Pragati but only till Lonavla. The plan was to get down at Lonavla since we wudnt get place in Pragati considering the Sunday evening rush. Pragati chugged into the station at 6 pm. To our surprise, all 4 of us got seats. Prashant and I talked about going via Pragati till Pune even though the tickets were only till Lonavla. We had to convince Amol and Sabhtarsha though. Amol being the daredevil that he is didn't seem to have a problem and agreed to what Prashant said. But then Prashant had a tough time convincing Sabhtarsha. Finally, we did manage to convince Sabhtarsha. The point of contention being .... we had 2 tickets .... Pragati tickets till Lonavla and the local train tickets removed in the morning from Lonavla to Pune. But both of them were deemed invalid as far as travelling to Pune is concerned. The former due to the fact that they were only till Lonavla while the latter due to not travelling within one hour of issuing them. That was hilarious.

Along the way to Lonavla from Karjat, we keenly observed all the points we has just been to, albeit walking and realised how cozy it is be in a train rather than on ur foot. The waterfall point gave us immense pleasure... so did the tunnels. We realised how late we would have been if we would have continued walking till Karjat. By the time Lonavla came and went, Sabhtarsha and I were seated in the doorway of our compartment. He was trying to convince me to get down wherever the train stops while I was trying to coax him to take the risk of ticketless travelling at this moment. He was citing his previous encounters with TC's to prove the danger associated with it while I was elaborating on a few my own on how to get out of such situations. A train journey looks better when seated in the doorway of a compartment. Belive me !!. The population in the compartment gradually decreased at each station after Chinchwad and the dreariness also began to tell on us. We planned to get out at Pune station on the opposite side of the platform to avoid the TC.

We arrived at Pune station at 8 pm and got out from the opposite side of platform no 2 (ie facing platform no 1). Somehow we managed to escape via Comesum.

A great day indeed. Not too heavy on the pockets. An experience worth old wine. One thing is for sure. Any 1 of us who travels from Lonavla to Karjat by train will surely recollect all the fun and and fatigue we faced. Cheers mates !!

Tuesday, July 11, 2006

Mystifying Panchgani

Panchgani and Mahabaleshwar are 2 places I have always been planning to visit in the last 4 to 5 years but somehow things haven't clicked. Add Goa to that list. I know its a crime nowadays not to visit Goa. Anyways this time round, I was not gonna miss Panchgani atleast. So lets get the onus on Panchi as it is fondly called.

The day was July 3, 2006. It was Amruta, my fiance's birthday. I feel I should have blogged about this much earlier but the charm and fragrance of Panchi has lingered on for close to 10 days now ..... I was having a bath at around 7 am when Amruta called me and told me that she will be coming to my place and that we would then go to some nice place. I didn't have much time to react but I knew that it was not going to be Lonavla again. Amruta came home at around 8 am. We had a light breakfast and I asked her whether she would like to go to Panchgani. She obliged. So on your marks ... get set .... go ... to Panchgani.

The one thing I was worried about was Katraj Ghat. It had screwed me on several occasions before and I had to detour and head via Saswad. But I guess this occasion was a wee bit too much for it to try its luck although the road was as pathetic as you can imagine. Amruta was enjoying her special day ... busy with the handycam with her patent commentary in the background. Once Katraj Ghat was annexed, what followed was a dream drive to the most heavenly destination I have been to. After ofcourse, Tirumala.

Hills, lakes, bridges, ghats, landscapes, fog, mist, waterfalls, tunnels, a smooth road and heavy rain. You name it and we had it. The higlight of the drive was Khambatgi Ghat. The fog was so thick that I even tried switching on the headlights of my car. But the only solution was to drive very very slowly as it contained S turns and U turns. Good that it is one-way. I guess they are modelling Katraj Ghat on the lines of Kambhatgi Ghat.

There was a right turn from the main highway around 30 kms before Satara. We gladly took that turn and headed towards Wai village. Already the scenic beauty of the place was getting better. Wai itself is a beautiful place with the Table Land of Panchi overlooking it and we just couldn't wait to reach Panchi. We had some Vada Pavs at Wai and headed towards Panchi. Amruta, being a big fan of waterfalls asked me to stop at once such waterfall and we enjoyed ourselves over there.

We reached Panchi at 12 30 pm and we were amazed to see the number of schools passing by. Panchi is renowned for its residential schools. As with many places in Pune, finding a place to park my car was a task.

We went right uptil the starting point of Table Land and parked the car there. We were greeted by 2 horsemen promising to show us around some 8 points for Rs. 500. Being regular visitors to Fashion Street, we bargained and got it down to Rs. 200. Believe me, a horse ride amidst the fog can be one hell of an experience with gusts of wind threatening to blow you away any moment.

The horsemen (acting as guides) showed us all the 5 table lands. It was breathtaking to watch all 5. Some very close, others quite a distance away. We started off with Paanch Paandav Point. There are 5 stones shaped in the form of a human foot placed on of of the Tables. (Tables can be visualised as a flat plain land with a radius of say 150 meters). The biggest foot is of Bhima. All this is only if u wanna believe it. Thats wat the guides prescribe.

Next came One Tree Point. There is a place on the Table where there is only one tree. Apparently this is the tree under which Aaamir Khan puckered up to Karisma Kapoor in Raja Hindustani or atleast thats what the guides told us.

After that we went to Shooting Point. This is the point at which most of the Bollywood songs and scenes are shot. Lots of wind here reminding me of Wind Point at Sinhagad. From shooting point we can also see Sydney Point names after some Mr Sydney for starting a strawberry plantation there. We also saw Gliding point where there are people who teach you how to glide but it is closed during the monsoons. Big B had a scene here during the making of the movie Yaarana.

The guides urged us to have a horse ride alone and we didnt want to let this oppurtunity slip by coz the guides assured us that the horses are trained and that they wont run wild. It was too tempting an offer to refuse. And Amruta and I kindly obliged. There is no better thrill to gallop away.

After that, we went to Monkey Point which is situated in a kind of a jungle like location. There is a cave over there with plenty of squirrels running around but sadly no monkeys. :(. But the jungle is quite a sight still.

Finally, we noticed what time it is and realised we need to head back home before night sets in. We had some junk food including Bhutta, chips and tea and headed back home. Reached home at around 7 pm. What a wonderful day. Panchi rocks !!