Here is something I came across,on bloomberg.com. It's about some fake pfizer drugs being sold in India.
Here is the link
Thought may be I should spread the word!
Thursday, August 09, 2007
Wednesday, August 08, 2007
Friday, August 03, 2007
Nifty this week 30th July - 3rd August
Highlights of the week for the NSE ...
NIFTY
- shedded almost a percent at 4401 end of the week.
- Weekly charts for the past 18 months shows a small downtrend starting last week with a bearish engulfing candle.2 year weekly chart shows there is a good support around 4180 levels on the weekly basis.
- YTD daily sharts shows we are in a short term down trend with resistance around 4450 (20EMA), 4500 (trend line starting the beginning of this rally in April) and resistance around 4370 (50 EMA),
- Should trade between these ranges, breaching of any of these levels on higher volumes will indicate the subsequent direction. Though the outlook is certainly bearish.
BANK Nifty -
- Up almost 150 points (though on lower volumes.)
- Bank nifty is in weekly downtrend with a huge bearish engulfing candle last week.
- Weekly resistance is around 6900 levels (looking at 18 months weekly trendline.)
- A very good support at 6600 (50 day EMA.) and a weak support at 6820 (20 ema)
- Should trade between 6600 to 6900. Crossing of any of these levels on higher volumes will indicate subsequent direction. The tone is still bearish.
Reliance -
- Down almost 65 Rs. for the week.
- A strong weekly support at 1750 level (trend line for the last two years and 50 EMA.)
- A weak resistance at 1825 and a strong support at 1800 levels (trendline starting last july.)
- On a daily chart shows downtrend last week. (with lower volumes on up days and higher volumes on down days.)
- A little bearish, this stock is going to be pivotal in the coming week especially owing to very high weightage in the nifty.
IT stocks -
- Took a beating last week. Nothing much to write about.
State Bank -
- Up almost 135 Rs. on good volumes on weekly charts.
- Shows a strong support around 1550 mark from the daily trend line and 20EMA.
- Resistance around 1650ish.
- This looks strong, unless it takes a beating with others.
In short the next week will pan out depending upon how SBI and Reliance perform. SBI needs to maintain its rally and reliance needs to take a support at 1800 levels.
Global cues indicate weak markets in the coming week. The mild recovery Europe posted early this week was washed out yesterday. Asia is not significantly recovering and S&P500 closing below its 200 EMA indicate a nervousness in the global markets.
Disclaimer: The stocks/indices discussed here are a personal opinion and for informational purposes only. This should not be taken as investment advise in any way. Investments should be done based upon personal opinion and risk appetite.
Credits: All the charts mentioned are taken from icharts.in
NIFTY
- shedded almost a percent at 4401 end of the week.
- Weekly charts for the past 18 months shows a small downtrend starting last week with a bearish engulfing candle.2 year weekly chart shows there is a good support around 4180 levels on the weekly basis.
- YTD daily sharts shows we are in a short term down trend with resistance around 4450 (20EMA), 4500 (trend line starting the beginning of this rally in April) and resistance around 4370 (50 EMA),
- Should trade between these ranges, breaching of any of these levels on higher volumes will indicate the subsequent direction. Though the outlook is certainly bearish.
BANK Nifty -
- Up almost 150 points (though on lower volumes.)
- Bank nifty is in weekly downtrend with a huge bearish engulfing candle last week.
- Weekly resistance is around 6900 levels (looking at 18 months weekly trendline.)
- A very good support at 6600 (50 day EMA.) and a weak support at 6820 (20 ema)
- Should trade between 6600 to 6900. Crossing of any of these levels on higher volumes will indicate subsequent direction. The tone is still bearish.
Reliance -
- Down almost 65 Rs. for the week.
- A strong weekly support at 1750 level (trend line for the last two years and 50 EMA.)
- A weak resistance at 1825 and a strong support at 1800 levels (trendline starting last july.)
- On a daily chart shows downtrend last week. (with lower volumes on up days and higher volumes on down days.)
- A little bearish, this stock is going to be pivotal in the coming week especially owing to very high weightage in the nifty.
IT stocks -
- Took a beating last week. Nothing much to write about.
State Bank -
- Up almost 135 Rs. on good volumes on weekly charts.
- Shows a strong support around 1550 mark from the daily trend line and 20EMA.
- Resistance around 1650ish.
- This looks strong, unless it takes a beating with others.
In short the next week will pan out depending upon how SBI and Reliance perform. SBI needs to maintain its rally and reliance needs to take a support at 1800 levels.
Global cues indicate weak markets in the coming week. The mild recovery Europe posted early this week was washed out yesterday. Asia is not significantly recovering and S&P500 closing below its 200 EMA indicate a nervousness in the global markets.
Disclaimer: The stocks/indices discussed here are a personal opinion and for informational purposes only. This should not be taken as investment advise in any way. Investments should be done based upon personal opinion and risk appetite.
Credits: All the charts mentioned are taken from icharts.in
Tuesday, July 31, 2007
Random Thoughts....
Justice at last...
I often fail to understand the Indian audience. There is this guy who's accused of holding a 'kaleshnikov' goes around the world teaching 'गांधीगिरी' and guess what he's a big hit. It seems no one gave our 'मुन्ना' a toy gun when he was a kid, so when he became 'भाई' he got ihim self a kaleshnikov instead. You know those unfulfilled dreams of childhood. Finally there is justice though. I know this is going to be symbolic and doesn't mean much, but it still a blow in the face of crazy audience... There is going to be a supreme court appeal and if in the worst case Mr. Dutt goes to jail, it's going to be nothing beyond change in address.
Good Job Mr. Y V Reddy
Reserve Bank yesterday increased the CRR by 50 basis points, almost "unexpectedly", squeezing away 150bn rupees in liquidity. This was a great job by Mr. Y V Reddy, who walks his talk. This shows Mr. Y V Reddy is more "concerned about economy than stockmarkets". Great job sir!!
Smiles on the face....
It would have taken a heart to go short yesterday evening. Something told me I should and guess what I did.. The logic (ok it is easier to explain stuff when it proves right.) but here's the logic. Yesterdays rally towards the end resembled something. (see the chart below, taken from icharts.in ). It told me, if there was a chance of going short it was today and if I was wrong, doesn't matter, cover it up with a stop loss at 4550. They say in minyanville , if you are disciplined, you can pretty much do anything. Discipline is the key.. that is the lesson that I have learnt in my short and 'not so much to write home about' trading history.
Oh well and while I finish this markets might have rallied past the dip, but thats market for you!!

Anyone interested in reading charts about Indian stocck markets, icharts.in is your answer. it is really really very neat. It's not yet my dream charting software, but closest to being useful..
Disclaimer: The stuff discussed here about the stocks is a personal opinion and should not be treated as an investment advise in any way. Investments should be done solely on the personal opinion and risk appetite.
I often fail to understand the Indian audience. There is this guy who's accused of holding a 'kaleshnikov' goes around the world teaching 'गांधीगिरी' and guess what he's a big hit. It seems no one gave our 'मुन्ना' a toy gun when he was a kid, so when he became 'भाई' he got ihim self a kaleshnikov instead. You know those unfulfilled dreams of childhood. Finally there is justice though. I know this is going to be symbolic and doesn't mean much, but it still a blow in the face of crazy audience... There is going to be a supreme court appeal and if in the worst case Mr. Dutt goes to jail, it's going to be nothing beyond change in address.
Good Job Mr. Y V Reddy
Reserve Bank yesterday increased the CRR by 50 basis points, almost "unexpectedly", squeezing away 150bn rupees in liquidity. This was a great job by Mr. Y V Reddy, who walks his talk. This shows Mr. Y V Reddy is more "concerned about economy than stockmarkets". Great job sir!!
Smiles on the face....
It would have taken a heart to go short yesterday evening. Something told me I should and guess what I did.. The logic (ok it is easier to explain stuff when it proves right.) but here's the logic. Yesterdays rally towards the end resembled something. (see the chart below, taken from icharts.in ). It told me, if there was a chance of going short it was today and if I was wrong, doesn't matter, cover it up with a stop loss at 4550. They say in minyanville , if you are disciplined, you can pretty much do anything. Discipline is the key.. that is the lesson that I have learnt in my short and 'not so much to write home about' trading history.
Oh well and while I finish this markets might have rallied past the dip, but thats market for you!!

Anyone interested in reading charts about Indian stocck markets, icharts.in is your answer. it is really really very neat. It's not yet my dream charting software, but closest to being useful..
Disclaimer: The stuff discussed here about the stocks is a personal opinion and should not be treated as an investment advise in any way. Investments should be done solely on the personal opinion and risk appetite.
Sunday, July 29, 2007
wordsilearnt.com is up now
A bit of an announcement. I was working part time on an application called "wordsilearnt.com". It is finally up and in a usable state now.
It's basically a simple application, which allows one to save and share the words they learn. I used to come across several new words and didn't do anything about them. Thought this would be a nice useful application and in hindsight I was not wrong! ;-). Or to give it a web 2.0ish name, it is a "social vocabulary building" application. Sounds sexy right? ;-)
I am planning to add a few features in the coming days.
For those who are on facebook, if you like the app, please add this application, so that I can get 5 users and then can submit it to Facebook directory. Here is the application URL on facebook if one wants to add it.
http://www.facebook.com/apps/application.php?id=2397064823
Enjoy!!
It's basically a simple application, which allows one to save and share the words they learn. I used to come across several new words and didn't do anything about them. Thought this would be a nice useful application and in hindsight I was not wrong! ;-). Or to give it a web 2.0ish name, it is a "social vocabulary building" application. Sounds sexy right? ;-)
I am planning to add a few features in the coming days.
For those who are on facebook, if you like the app, please add this application, so that I can get 5 users and then can submit it to Facebook directory. Here is the application URL on facebook if one wants to add it.
http://www.facebook.com/apps/application.php?id=2397064823
Enjoy!!
Monday, July 23, 2007
website screen capture in ruby - HowTo
For one of the projects that I am working on, I needed a website capture utility, that will dump output into a png file. I couldn't find any one-stop-shop for getting it done. There are many websites that have this service (see references towards the end in the post), however I needed something where I have access to the source code, so that I could tweak it to my needs Also something in ruby was prefereable, so that I can integrate it with other stuff I am working on. Google, google and google and finally I hit upon an implementation in ruby called moz-snapshooter.rb, which has got a good screen capture facility that uses 'gtkmozembed' , which is an embeddable Gecko rendering widget that GTK applications can embed. This was pretty much it. All that was needed was the ruby binding for gnome2 libraries etc. They can be found here.
So here is the final deal (on ubuntu Dapper) -
1. Get the ruby-gnome2-all package from here
2. Get the firefox-dev package using apt-get. (Note this is required for building the gtkmozembed.)
3. Get the moz-snapshooter.rb
4. Edit it to your needs
5. Fire ruby moz-snapshooter.rb
Most of the things just work out of the box.
Now comes a little tricky part. All of this requires an X server running. So what if one wants to run it on a headless X server? The answer is Xvfb (which is a virtual frame buffer based X server.) Continuing further.
6. Install Xvfb using apt-get.
7. Finally run the 'ruby moz-snapshooter.rb' inside 'xvfb-run' as follows
xvfb-run -s "-screen 800x600x16" ruby moz-snapshooter.rb
Note to pass -s "-screen 800x600x16" option, since most of the websites work well in that resolution.
Caveats:
1. The libgtk-mozembed-ruby package that comes for 'ubuntu' uses the gtkembed.so library provided by mozilla 1.7.X (which is not compiled with pango renderer. It is better to use firefox-dev library and hence build by hand the ruby-gnome2-all package.)
2. The final output resolution image should be of smaller resolution than the one passed to xvfb-run.
3. This is not 'perfect' yet, but a good starting point.
Here are some samples.
1. Google in 150x100 resolution -

2. paahijen.com in 320x200 resolution -

3. Marathi wikipedia in 640x480 resolution -

References :
1. A pygtk implementation by Andrew McCall
2. moz-snapshooter.rb by Mirko Maischberger
3. Ideum screenshot capture prototype
So here is the final deal (on ubuntu Dapper) -
1. Get the ruby-gnome2-all package from here
2. Get the firefox-dev package using apt-get. (Note this is required for building the gtkmozembed.)
3. Get the moz-snapshooter.rb
4. Edit it to your needs
5. Fire ruby moz-snapshooter.rb
Most of the things just work out of the box.
Now comes a little tricky part. All of this requires an X server running. So what if one wants to run it on a headless X server? The answer is Xvfb (which is a virtual frame buffer based X server.) Continuing further.
6. Install Xvfb using apt-get.
7. Finally run the 'ruby moz-snapshooter.rb' inside 'xvfb-run' as follows
xvfb-run -s "-screen 800x600x16" ruby moz-snapshooter.rb
Note to pass -s "-screen 800x600x16" option, since most of the websites work well in that resolution.
Caveats:
1. The libgtk-mozembed-ruby package that comes for 'ubuntu' uses the gtkembed.so library provided by mozilla 1.7.X (which is not compiled with pango renderer. It is better to use firefox-dev library and hence build by hand the ruby-gnome2-all package.)
2. The final output resolution image should be of smaller resolution than the one passed to xvfb-run.
3. This is not 'perfect' yet, but a good starting point.
Here are some samples.
1. Google in 150x100 resolution -

2. paahijen.com in 320x200 resolution -

3. Marathi wikipedia in 640x480 resolution -

References :
1. A pygtk implementation by Andrew McCall
2. moz-snapshooter.rb by Mirko Maischberger
3. Ideum screenshot capture prototype
Labels:
mozgtkembed,
ruby,
ruby-gnome2,
website screen capture
Friday, July 20, 2007
Best sumanism Ever
Suman has got talent for almost everything. He's one of the smartest coder I have seen. He's a very good singer, a good artist, can cycle for 50kms. I don't know of a thing, which suman can't do, I mean can't do well. But I guess his best talent, is for writing. I'd definitely make a blog dedicated to sumanisms. but this is the best sumanism ever.
"Wikipedia is google in O(1)"
Just too good. !!!
"Wikipedia is google in O(1)"
Just too good. !!!
Thursday, July 19, 2007
just can't seem to get it?
Anybody following the stockmarkets for the past couple of weeks should get puzzled and have shorted it (like me), should get frustrated!! The things just aren't falling in place, but it doesn't matter, the markets are rallying and thats it.
- starting July 2 Indian stock market has rallied by 5 and a half percent.
- In this rally there have been all but two days of decline (which had a 0.25 and 0.43 percent decline.
- If we go back a little, in last month the markets have rallied by almost 10 percent (common is this Shanghai or something?)
- Not a single day of more than half a percent decline in 20 trading sessions, the highest decline is 0.46 percent.)
And all of this comes when
- most of the global markets have shown some intermediate corrections, but bulls at the Dalal street seem to be unfazed by that. Only possible exception is wall-street, which did have a hiccup or two but thats it nothing beyond that. Yeah all of this when a little over billion dollar gotten wiped out in the Bear Sterns Hedge fund, which is just the tip of the subprime iceberg. The dollar is at its weakest against Euro and pound.
- When the crude price is hovering around $75 per barrel
- When we have two successive weeks of increase in inflations. (up by almost .25 percent from its low.)
- When during the days for which I have observed, FIIs though buying in cash segments, have been in net short positions in Stocks futures and Index futures to the tune of 2000 Cr. rupees (not to mention tons of 4400 and 4300 nifty puts, which are going to go down the drain, I suppose)
- When none of the quarterly earnings being spectacular per say. (Infy disappointing, TCS goodish, HDFC okayish, Wipro poor. Only real surprise came from L&T (The stock has appreciated little over 30% already) and Ranbaxy.
- Now all of this is fairly risky, but no one knows where to find a top? The rally resembles almost a panick rally (I agree it is oxymoronic) Usually such situations arise while finding a bottom.
This looks like "someone is printing free cash" to go ahead and buy stock, the question is who? Carry Trade?
The answer just isn't there, or I can't seem to get it...... :-((
- starting July 2 Indian stock market has rallied by 5 and a half percent.
- In this rally there have been all but two days of decline (which had a 0.25 and 0.43 percent decline.
- If we go back a little, in last month the markets have rallied by almost 10 percent (common is this Shanghai or something?)
- Not a single day of more than half a percent decline in 20 trading sessions, the highest decline is 0.46 percent.)
And all of this comes when
- most of the global markets have shown some intermediate corrections, but bulls at the Dalal street seem to be unfazed by that. Only possible exception is wall-street, which did have a hiccup or two but thats it nothing beyond that. Yeah all of this when a little over billion dollar gotten wiped out in the Bear Sterns Hedge fund, which is just the tip of the subprime iceberg. The dollar is at its weakest against Euro and pound.
- When the crude price is hovering around $75 per barrel
- When we have two successive weeks of increase in inflations. (up by almost .25 percent from its low.)
- When during the days for which I have observed, FIIs though buying in cash segments, have been in net short positions in Stocks futures and Index futures to the tune of 2000 Cr. rupees (not to mention tons of 4400 and 4300 nifty puts, which are going to go down the drain, I suppose)
- When none of the quarterly earnings being spectacular per say. (Infy disappointing, TCS goodish, HDFC okayish, Wipro poor. Only real surprise came from L&T (The stock has appreciated little over 30% already) and Ranbaxy.
- Now all of this is fairly risky, but no one knows where to find a top? The rally resembles almost a panick rally (I agree it is oxymoronic) Usually such situations arise while finding a bottom.
This looks like "someone is printing free cash" to go ahead and buy stock, the question is who? Carry Trade?
The answer just isn't there, or I can't seem to get it...... :-((
Tuesday, July 17, 2007
Context Sensitive Ads?
Let me start with a question -
How is Bra Selection in India is related to developing PHP apps with UML and which in turn is related to brass hardware and all of this is related to Pushposters? Confused, check the following....

The best one is the one at the top! I guess they figure out sex of the email viewer from the email address (or possibly its registered somewhere!)
PS: The image is edited a bit.
How is Bra Selection in India is related to developing PHP apps with UML and which in turn is related to brass hardware and all of this is related to Pushposters? Confused, check the following....

The best one is the one at the top! I guess they figure out sex of the email viewer from the email address (or possibly its registered somewhere!)
PS: The image is edited a bit.
Saturday, July 14, 2007
A date with XUL
While working on a firefox extension for a feature on paahijen, I had a loong date with XUL. XUL (pronounced as zool, is an XML based User Interface Language). More stuff about xul can be found at XUL - MDC or XUL planet
Basically, I needed a form where I could copy something to clipboard from a document loaded from a HTTP URL. The problem was, I couldn't use the simple Javascript based methods, as access to clipboard is restricted inside mozilla. So I had to have a XUL window with a XUL button and contents loaded from the URL.
One option is to do all the UI in XUL and use XHR for talking HTTP. So I started with XUL UI. If you thought CSS is a bitch, try XUL and you'd almost fall in love with CSS. In short, for someone short on patience, looking for a quick solution, laying out a XUL UI is not an option. Looking for alternatives, I found an interesting alternative in the tutorial on xulplanet, which uses iframes instead. In my opinion, this is a better approach, unless there is a specific need for Client only UI. First, it is simple, and second you don't need to learn a lot of XULgiri.
So the final solution was a XUL window having a XUL button (on which oncommand was implemented to do clipboard copy) and the HTML document rendered in iframe.
One last issue is - to get contents inside an iframe. The solution is mentioned here.
Guess, thats it, rest of the stuff is quie straight forward.
Basically, I needed a form where I could copy something to clipboard from a document loaded from a HTTP URL. The problem was, I couldn't use the simple Javascript based methods, as access to clipboard is restricted inside mozilla. So I had to have a XUL window with a XUL button and contents loaded from the URL.
One option is to do all the UI in XUL and use XHR for talking HTTP. So I started with XUL UI. If you thought CSS is a bitch, try XUL and you'd almost fall in love with CSS. In short, for someone short on patience, looking for a quick solution, laying out a XUL UI is not an option. Looking for alternatives, I found an interesting alternative in the tutorial on xulplanet, which uses iframes instead. In my opinion, this is a better approach, unless there is a specific need for Client only UI. First, it is simple, and second you don't need to learn a lot of XULgiri.
So the final solution was a XUL window having a XUL button (on which oncommand was implemented to do clipboard copy) and the HTML document rendered in iframe.
One last issue is - to get contents inside an iframe. The solution is mentioned here.
Guess, thats it, rest of the stuff is quie straight forward.
Monday, July 09, 2007
Sunday, July 08, 2007
Scores Do Lie
There are days in your life when you thank God for being born as a human being, being gifted with eyes that can watch and being able to feel emotions. I remember one such day when India beat Australia in a test win at Adelaide and today was yet another day when I watched the two Champions play at the Centre court at Wimbledon. One of the champions have to win and it was the lucky one who won it eventually, but my champion for today is Rafael Nadal, the prince of Clay, nay, the prince of Tennis.
The match started with swiss holding the serve on love and looked like, O No!! we are here for yet another boring three setter, when mr. casual is going to sail through eventually and it just looked far more imminent when Nadal lost his serve on the second game and the Champion was up 3-0 and then we were presented with a quality of tennis that I have not seen in my life. Every challenge Mr. Federer had, Rafa had an answer and soon we were 6-6 Set number one. Tie breakers is Fedex's forte and looked like so when Nadal down from 6-3 was looking ominous to level 6-6, but the lucky fed managed to squirm throught the first set 7-6 (9-7).
Set number two started with Nadal serving first and from the trend I have seen, if you don't break Nadal in first nine games, you are going to loose the set and that is exactly what happened when Federer was broken in the tenth game. 6-4 second set Nadal. Match score 1-1.
Third set was like a boxing match when each player delivered their punches and it went to tie breaker, this time the swiss winning comfortably 7-3. Federer leads 2-1.
Thank God Federer started service in the fourth set and unless he lost the set with odd number of games in the set, he'd be the first to serve in the final, which gives a slight edge. Looks like Federer was in no mood to win the fourth set when a controversial "Hawk Eye" ruled a point in favour of Nadal and Federer was visibly peeved. To the 'naked eye' the ball really looked "OUT". Nadal completed the formalities of the fourth set with a double break and 6-2. Match state 2-2.
Federer serving in the final set. I couldn't hold my nerves and went away just to take a break from the tennis for a few minutes and when I returned I expected the scorelines to be 4-3 Nadal serving. To a kind of pleasant surprise, it was 2-5 Nadal serving. I knew the match was over. and it lasted a little less than five minutes after that when FedEx clinched his fifth title in a row.
The final scores (7-6, 4-6, 7-6, 2-6, 6-2). And these scores do lie, todays champion was Nadal. Federer has lost to Nadal a couple of times before, but it was his horrible play back then. Today Federer was not going to loose, he didn't seem interested in loosing today and played like he _had_ to win this match, but the darling of the crowd was 21 year old spaniard, whose agile court coverage, brilliant passing shots, made federer look like a
"normal" player. Nadal made federer run everywhere and made him win every single point that he had to, to win the championships... Ultimately Federer won, but my champion for today is Rafael Nadal and they say his style of play does not suit the grass courts, guess no one would dare say that after today.
The story of the match was captured in a couple of sentences in the post match interview when Roger said - "I said to Nadal at the nets 'You deserved to win today, I was just lucky one to win this!!'"
Well played both of you and thank you for such a marvellous display of high quality tennis.
The match started with swiss holding the serve on love and looked like, O No!! we are here for yet another boring three setter, when mr. casual is going to sail through eventually and it just looked far more imminent when Nadal lost his serve on the second game and the Champion was up 3-0 and then we were presented with a quality of tennis that I have not seen in my life. Every challenge Mr. Federer had, Rafa had an answer and soon we were 6-6 Set number one. Tie breakers is Fedex's forte and looked like so when Nadal down from 6-3 was looking ominous to level 6-6, but the lucky fed managed to squirm throught the first set 7-6 (9-7).
Set number two started with Nadal serving first and from the trend I have seen, if you don't break Nadal in first nine games, you are going to loose the set and that is exactly what happened when Federer was broken in the tenth game. 6-4 second set Nadal. Match score 1-1.
Third set was like a boxing match when each player delivered their punches and it went to tie breaker, this time the swiss winning comfortably 7-3. Federer leads 2-1.
Thank God Federer started service in the fourth set and unless he lost the set with odd number of games in the set, he'd be the first to serve in the final, which gives a slight edge. Looks like Federer was in no mood to win the fourth set when a controversial "Hawk Eye" ruled a point in favour of Nadal and Federer was visibly peeved. To the 'naked eye' the ball really looked "OUT". Nadal completed the formalities of the fourth set with a double break and 6-2. Match state 2-2.
Federer serving in the final set. I couldn't hold my nerves and went away just to take a break from the tennis for a few minutes and when I returned I expected the scorelines to be 4-3 Nadal serving. To a kind of pleasant surprise, it was 2-5 Nadal serving. I knew the match was over. and it lasted a little less than five minutes after that when FedEx clinched his fifth title in a row.
The final scores (7-6, 4-6, 7-6, 2-6, 6-2). And these scores do lie, todays champion was Nadal. Federer has lost to Nadal a couple of times before, but it was his horrible play back then. Today Federer was not going to loose, he didn't seem interested in loosing today and played like he _had_ to win this match, but the darling of the crowd was 21 year old spaniard, whose agile court coverage, brilliant passing shots, made federer look like a
"normal" player. Nadal made federer run everywhere and made him win every single point that he had to, to win the championships... Ultimately Federer won, but my champion for today is Rafael Nadal and they say his style of play does not suit the grass courts, guess no one would dare say that after today.
The story of the match was captured in a couple of sentences in the post match interview when Roger said - "I said to Nadal at the nets 'You deserved to win today, I was just lucky one to win this!!'"
Well played both of you and thank you for such a marvellous display of high quality tennis.
मर्फ्यै तस्मै नमः
This post is dedicated to omnipresent Mr. Murphy.
Many of us are aware of Murhpy's law. For the uninitiated ones a bit of Wikipediagiri about murphy's law to start with. According to wikipedia, Murphy's law is formed with eight laws explain on the article. There is more about this over there..
Originally, I intended to write this blog in marathi, but some of the folks wont be able to understand it so writing it in english..
There is a proverb in संस्कृत (sanskrit), which says " कालाय तस्मै नमः ||" ("O times, I bow before thee!") . I think Mr Murphy deserves, nay, demands a similar reverence. Hence the saying "मर्फ्यै तस्मै नमः||" . A little bit of sanskrit grammer before we mover further. मर्फी is a "ईकारांत पुल्लिंगी" word like ॠषी, and we need a "चतुर्थी एकवचन" ( ज्याला नमन करायचे त्याची चतुर्थी). Hence the word मर्फ्यै!!
So how does Mr. Murphy proves that he exist? Answer - "In every possible way!". If you are going to give a presentation and the LCD does not like your Ubuntu laptop, it's Mr. Murphy in action. If you are standing at a signal when there is no chance of a shelter and it suddenly starts pouring, it's Mr. Murphy again. I will bet all my wealth (which isn't a lot), if I find a single soul who's not been affected by Mr. Murphy in one way or the other. Thank you Mr. Murphy..
Now a closer look at how much of a celebrity Mr. murphy was in our office. We had coined a special term for "getting murphied" called "मर्फी लागला" and Mr. murphy comes in a couple of sizes S (छोटा मर्फी) and L (मोठा मर्फी). The type of murhpy's explained above belong to the catagory of so called "छोटा मर्फी" (It might remind some of us about a brand of radio called Murphy and some of us might think of the small baby as छोटा मर्फी), where as मोठा मर्फी is when you move to bangalore and your home loan check bounces. Ask aditya about it.
Then there are some murphy people as well. Typically they exist in Cricket teams or all sort of team events, whose presence in a team makes the team vulnerable to Mr. Murphy's infection.
So what are your defences against Mr. Murphy? According to Aditya there are none. But there are chances of lesser harms, if you suffer from a couple of छोटा मर्फी's in a day, then probability of मोठा मर्फी affecting you is substantially (sorry somewhat) reduced. So pray for छोटा मर्फी.
To conclude, in due respect for such a great person "मर्फ्यै तस्मै नमः||" Long Live Mr. Murphy!
Many of us are aware of Murhpy's law. For the uninitiated ones a bit of Wikipediagiri about murphy's law to start with. According to wikipedia, Murphy's law is formed with eight laws explain on the article. There is more about this over there..
Originally, I intended to write this blog in marathi, but some of the folks wont be able to understand it so writing it in english..
There is a proverb in संस्कृत (sanskrit), which says " कालाय तस्मै नमः ||" ("O times, I bow before thee!") . I think Mr Murphy deserves, nay, demands a similar reverence. Hence the saying "मर्फ्यै तस्मै नमः||" . A little bit of sanskrit grammer before we mover further. मर्फी is a "ईकारांत पुल्लिंगी" word like ॠषी, and we need a "चतुर्थी एकवचन" ( ज्याला नमन करायचे त्याची चतुर्थी). Hence the word मर्फ्यै!!
So how does Mr. Murphy proves that he exist? Answer - "In every possible way!". If you are going to give a presentation and the LCD does not like your Ubuntu laptop, it's Mr. Murphy in action. If you are standing at a signal when there is no chance of a shelter and it suddenly starts pouring, it's Mr. Murphy again. I will bet all my wealth (which isn't a lot), if I find a single soul who's not been affected by Mr. Murphy in one way or the other. Thank you Mr. Murphy..
Now a closer look at how much of a celebrity Mr. murphy was in our office. We had coined a special term for "getting murphied" called "मर्फी लागला" and Mr. murphy comes in a couple of sizes S (छोटा मर्फी) and L (मोठा मर्फी). The type of murhpy's explained above belong to the catagory of so called "छोटा मर्फी" (It might remind some of us about a brand of radio called Murphy and some of us might think of the small baby as छोटा मर्फी), where as मोठा मर्फी is when you move to bangalore and your home loan check bounces. Ask aditya about it.
Then there are some murphy people as well. Typically they exist in Cricket teams or all sort of team events, whose presence in a team makes the team vulnerable to Mr. Murphy's infection.
So what are your defences against Mr. Murphy? According to Aditya there are none. But there are chances of lesser harms, if you suffer from a couple of छोटा मर्फी's in a day, then probability of मोठा मर्फी affecting you is substantially (sorry somewhat) reduced. So pray for छोटा मर्फी.
To conclude, in due respect for such a great person "मर्फ्यै तस्मै नमः||" Long Live Mr. Murphy!
Saturday, July 07, 2007
Roger Puhlease
(photo taken from wimbledon.org original copyright ProSport/T. Hindley) Play like you want to win this match and not like you just had a fight with your girlfriend and had nothing better to do and thought of playing tennis better than staying at home.... I know you'd win, still.
Just watched the match concluded bet Roger Federer and Richard Gasquet the Frenchman. The frenchman was a bit crippled in the third set, when Federer was 2 sets to 0 up, so it was a matter of time, till Mr. Federer the prudent swiss businessman, concluded his business on the Centre Court.
I am a great fan of Roger, but when you watch him play, it looks like he plays with a kind of laid back attitude and the worst part is he manages to win most of those matches. I often wonder what make him such a special player. Is it the odd Squash shot he plays, is it the back hand down the line return or is it is ability to win points at will? I just can't find the answers. Unfortunately to the misfortune of other players Roger has improved his serve so much and he serves almost Sampras like which make him much more formidable. In a couple of matches that I saw, I haven't seen him loosing more than 10 points in toto on his serve and when it goes to tie break, it lasts a few minutes.
The trouble with the way he plays is - With this kind of attitude, he's almost never going to win in Roland Garros, where the prince Rafael Nadal rules. It takes special skills, temperament and what the commentator at the end of the final this year said - "Federer needs to be a bit more like warrier to win against Nadal here".
I'd personally have loved to see Djokowic coming to final and every set going to a tie-break, unfortunately he had to drop out, thanks to the injury that's troubling him.
So the stage is set for the Federer - Nadal final at the wimbledon tomorrow, and I would really like Nadal to tease n test Roger, so that he's to raise his game a lot more.
Just out of curiosity, I'd really like to know the stats "How many five setters Roger has played in his career? And how many has he won?" May be I should write to Vijay and Alan (who are wonderful hosts for the tournament).
BarCamping at BarCampPune3
I had a wonderful day at BarCampPune3 today. Infact to be honest, I was a bit skeptical about whether most of the people who said they are coming will show up? And when we reached there, I thought my skepticism was just right, there were something like 23 and a quarter campers out there. But eventually people started joining and soon we were close to 100ish.. Well a lot of us showed up well after 10am the official starting point but eventually I guess, we were a couple of 100 or so, not bad. Barcamping to me was certainly new, but I kind of liked the geekish atmosphere there... (Did he mean 'Geeks', when he said 'Meeks shall inherit the earth?' hahan:-) ).
Something most interesting that I learnt by doing it.. Talking to an audience of 40-50 odd people with sort of diverse backgrounds. There were a few obvious pitfalls, which pilot pointed out. I had talked in front of 20 odd people before, and to be honest I felt pretty confident that I'd do a fine job, but from pilot's remarks, it appears it was kind of a mess. Neverthless important lessons learnt. So let me go over them one by one.
0. DO YOUR HOMEWORK. : What it includes? Atleast give a mock presentation to 2-3 people, plan your talk, your slides and DO NOT DO this at 1AM @ the midnight day before. Very very important.
0.5 Know your Audience: The best way to do this is by asking a couple of quick questions and checking out how much people know about the stuff you are going to talk. This is going to come in handy subsequently.
1. Set the expectations Right: It is very important to do so, when there is a sufficient amount of diversity, and it is obvious that you are not goint to please everyone, but still set their expectations right. Some ways to do this is go over an Overview of your presentations and mention briefly what you are going to cover.
2. Take a brief pause and plan for improvisations: Depending upon responses in 0.5 and 1.0 above, you've to plan a few improvisations. Of course the homework must be done for that. In general the improvisations will include, which topics to stress upon and pay attention to and which topics (slides) to skip. This also implies that you have the flow of slides well in your time.
4. Start presenting: Entertain questions but only at Logical milestones (and not after every slide..)
5. Whenever someone ask questions - Make it a point to "REPEAT the QUESTION", so that the audience knows what the question was and what your answer was refering to.. And answer to question should not look like a conversation bet you and the person from the audience who asked the question.
6. Whenever you've code snippets to explain stuff. They should be Pasted in the presentations. Doing (ALT-TAB) looks Ugly. Often relevant comments should also be included.
7. If you have a demo or something, plan it at the end or at the beginning, No ALT-TABs PLEASE.
One would obviously notice that I had missed on almost all the points above. Also, do not simply look at contents, while watching some interesting Google Videos, but look at How much the person is in Control of situation while presenting. The great skills of presentations lie in "Being in control"
Besides that, Mr Murphy was in control of procedeeings when needed and almost at will, when the Sleek Flat Screen Samsung Monitor Din't like my ubuntu desktop. ("मर्फ्यै तस्मै नमः||", a new phrase which I have coined. Will write in details about it subsquently) So much for the presentation. Coming back to the event... There were a couple of interesting talks that I attended, one of specific mention was about "Pros and cons of setting up your company in India vis-a-vis other options like US, UK or Singapore." This is not the exact title. But a very important point that came out of that, it probably makes sense to register a company in US than in India, if you are doing a startup.
We did a bit of advertising for paahijen as well. :-) It seems that a lot of people had actually seen what we were doing and thankfully none of them said "You Suck!" or were just being nice :-) ... (There was a bit of a goofup in the T we prepared on the 11th hour, which Akshay, noticed but guess not others! :-)
In all certainly a very enjoyable, eventful day! Look forward to more such things in the coming times....
Just before I conclude, a final reminder for me. "Do not assume people know the language you speak". eg. There was this journalist from the mint, namitha, who asked me... Where were you guys working before.. I told we were working at PANTA systems.. A High Performence Computing company.. To me "High Performance Computing" is as much a common word as say a "car", but she was like what does that mean? And I have seen this expressions a few times from others as well. The best answer I find for this is our company makes "Supercomputers like CDAC." Actually that sounds a bit sexy as well :-)
Something most interesting that I learnt by doing it.. Talking to an audience of 40-50 odd people with sort of diverse backgrounds. There were a few obvious pitfalls, which pilot pointed out. I had talked in front of 20 odd people before, and to be honest I felt pretty confident that I'd do a fine job, but from pilot's remarks, it appears it was kind of a mess. Neverthless important lessons learnt. So let me go over them one by one.
0. DO YOUR HOMEWORK. : What it includes? Atleast give a mock presentation to 2-3 people, plan your talk, your slides and DO NOT DO this at 1AM @ the midnight day before. Very very important.
0.5 Know your Audience: The best way to do this is by asking a couple of quick questions and checking out how much people know about the stuff you are going to talk. This is going to come in handy subsequently.
1. Set the expectations Right: It is very important to do so, when there is a sufficient amount of diversity, and it is obvious that you are not goint to please everyone, but still set their expectations right. Some ways to do this is go over an Overview of your presentations and mention briefly what you are going to cover.
2. Take a brief pause and plan for improvisations: Depending upon responses in 0.5 and 1.0 above, you've to plan a few improvisations. Of course the homework must be done for that. In general the improvisations will include, which topics to stress upon and pay attention to and which topics (slides) to skip. This also implies that you have the flow of slides well in your time.
4. Start presenting: Entertain questions but only at Logical milestones (and not after every slide..)
5. Whenever someone ask questions - Make it a point to "REPEAT the QUESTION", so that the audience knows what the question was and what your answer was refering to.. And answer to question should not look like a conversation bet you and the person from the audience who asked the question.
6. Whenever you've code snippets to explain stuff. They should be Pasted in the presentations. Doing (ALT-TAB) looks Ugly. Often relevant comments should also be included.
7. If you have a demo or something, plan it at the end or at the beginning, No ALT-TABs PLEASE.
One would obviously notice that I had missed on almost all the points above. Also, do not simply look at contents, while watching some interesting Google Videos, but look at How much the person is in Control of situation while presenting. The great skills of presentations lie in "Being in control"
Besides that, Mr Murphy was in control of procedeeings when needed and almost at will, when the Sleek Flat Screen Samsung Monitor Din't like my ubuntu desktop. ("मर्फ्यै तस्मै नमः||", a new phrase which I have coined. Will write in details about it subsquently) So much for the presentation. Coming back to the event... There were a couple of interesting talks that I attended, one of specific mention was about "Pros and cons of setting up your company in India vis-a-vis other options like US, UK or Singapore." This is not the exact title. But a very important point that came out of that, it probably makes sense to register a company in US than in India, if you are doing a startup.
We did a bit of advertising for paahijen as well. :-) It seems that a lot of people had actually seen what we were doing and thankfully none of them said "You Suck!" or were just being nice :-) ... (There was a bit of a goofup in the T we prepared on the 11th hour, which Akshay, noticed but guess not others! :-)
In all certainly a very enjoyable, eventful day! Look forward to more such things in the coming times....
Just before I conclude, a final reminder for me. "Do not assume people know the language you speak". eg. There was this journalist from the mint, namitha, who asked me... Where were you guys working before.. I told we were working at PANTA systems.. A High Performence Computing company.. To me "High Performance Computing" is as much a common word as say a "car", but she was like what does that mean? And I have seen this expressions a few times from others as well. The best answer I find for this is our company makes "Supercomputers like CDAC." Actually that sounds a bit sexy as well :-)
Tuesday, July 03, 2007
Wimbledon times...
I remember my school days when we used to almost religiously watch the men's and ladies' singles finals (those were the only matches telecast then on the good old DD). Those were the days when we saw the rise of Steffi Graf, beating Martina in 1988 final. 1988 was a kind of a dream year for a tennis fan like me when both my favorite players, Stefen Edberg and Stffi Graf won the championships.
After the Edberg-Becker era, there was a looong Sampras era and while it came to an end, I'd almost lost interest in the game, till I watched the 2004 final that saw the emergence of new era in Tennis, the Roger Federer era. I distinctly remember a small anecdot about it.. After the final Andy Roddick was asked "Andy you see to be enjoying this rivalry between yourself and Roger?" Andy - "To call this a rivalry, I'd have to start winning a few of those!".
This year though, wimbledon is cursed by the whimsical british summer, almost every single match is interrupted by rain and still we've managed to get to the fourth rounds well almost.. Unfortunately, I haven't watched a single Federer match. Hope I get to watch tomorrow against Perreira.
All the Grand slams are gruelling for the players, and each surface has a peculiarity of its own, but Wimbledon stands different. The meticulously maintained lush green courts, players wearing all white T's, the british idiocyncracies and the unforgettable "Thank you. Quiet please!". It's' all so very different... so very unique and so much enjoyable......
It's my dream to watch a Wimbledon final on the centre court one day and I hope to do so while Roger still rules the court!!!
After the Edberg-Becker era, there was a looong Sampras era and while it came to an end, I'd almost lost interest in the game, till I watched the 2004 final that saw the emergence of new era in Tennis, the Roger Federer era. I distinctly remember a small anecdot about it.. After the final Andy Roddick was asked "Andy you see to be enjoying this rivalry between yourself and Roger?" Andy - "To call this a rivalry, I'd have to start winning a few of those!".
This year though, wimbledon is cursed by the whimsical british summer, almost every single match is interrupted by rain and still we've managed to get to the fourth rounds well almost.. Unfortunately, I haven't watched a single Federer match. Hope I get to watch tomorrow against Perreira.
All the Grand slams are gruelling for the players, and each surface has a peculiarity of its own, but Wimbledon stands different. The meticulously maintained lush green courts, players wearing all white T's, the british idiocyncracies and the unforgettable "Thank you. Quiet please!". It's' all so very different... so very unique and so much enjoyable......
It's my dream to watch a Wimbledon final on the centre court one day and I hope to do so while Roger still rules the court!!!
Friday, June 29, 2007
महावितरण and the art of वितरण!!
महा in english means mega or big, and वितरण means distribution. Thus in short this is the name of the electricity distribution company that distributes electricity to the most industrialized state in India, महाराष्ट्र (maharaashtra), and I live in पुणे (pune) one of the top 10 metros in India. The availability of electricity is a random function. Not to mention, the fluctuations in the voltages, which take their vicitims every now and then. The voltage levels are not so random they range between 160 to 300 with mean being 230ish.
So here are few examples of one's experience with the art of वितरण.
- You read a nice blog by a friend, when you are about to write a comment and just at that moment, the laptop cribs "power disconnected!" and then you are like "O fuck!", and then you wait for a couple of minutes, 'cos you know the electricity is going to come back anytime, its just like waiting for a RockStar at a big concert, he can arrive anytime, next minute in a few minutes but certainly "today"...
- whenever clouds gather in the sky, you can bet all your wealth that the electricity is going to go anytime soon.. Infact a couple of times I have been "disappointed", when, inspite or heavy showers the electricity was intact for good twelve minutes..
- sometimes there is nothing happening in the sky, but lights go off and on a few times in a span of 20 minutes, I believe the guys out there are "testing", that they can indeed turn the electricity off at will, just in case...
- Then there is official loadshading, which is somewhat a random function as well, the only certain thing about it is, "It will happen!"
- If you ever visit, rural parts, its a fun indeed, there you'd find something called "आकडा" hanging on a wire, whereupon a lot of villagers solve the problem of "distribution" by "pulling" the electricity, of course, they can do so only for a couple of hours in a day... thats महावितरण's way of settling the scores..
PS : This blog post was written un-interruped, oh well almost!
So here are few examples of one's experience with the art of वितरण.
- You read a nice blog by a friend, when you are about to write a comment and just at that moment, the laptop cribs "power disconnected!" and then you are like "O fuck!", and then you wait for a couple of minutes, 'cos you know the electricity is going to come back anytime, its just like waiting for a RockStar at a big concert, he can arrive anytime, next minute in a few minutes but certainly "today"...
- whenever clouds gather in the sky, you can bet all your wealth that the electricity is going to go anytime soon.. Infact a couple of times I have been "disappointed", when, inspite or heavy showers the electricity was intact for good twelve minutes..
- sometimes there is nothing happening in the sky, but lights go off and on a few times in a span of 20 minutes, I believe the guys out there are "testing", that they can indeed turn the electricity off at will, just in case...
- Then there is official loadshading, which is somewhat a random function as well, the only certain thing about it is, "It will happen!"
- If you ever visit, rural parts, its a fun indeed, there you'd find something called "आकडा" hanging on a wire, whereupon a lot of villagers solve the problem of "distribution" by "pulling" the electricity, of course, they can do so only for a couple of hours in a day... thats महावितरण's way of settling the scores..
PS : This blog post was written un-interruped, oh well almost!
Monday, June 25, 2007
A very interesting blog post..
Here is a link from the post, called bono I read on the blog by Marc Andreessen, yeah the famous netscape guy, whose welcome message most of us have seen when we installed our Netscape Communicator (which was the best mail reader then...). When I first read the title, I thought marc is going to take us through yet another web platform or something, but this is about the "evils of development aid to africa from the western countries.." I believe there is a lesson for India out there to be learnt too.. A really great post..
Offtopic: I have heard about this book "Everybody loves a good draught", I think I should pick this up from Crossword this weekend.Though, I doubt whether they'd have it...
Offtopic: I have heard about this book "Everybody loves a good draught", I think I should pick this up from Crossword this weekend.Though, I doubt whether they'd have it...
interesting facts about my birthday
One of my friends happens to have a birthday on 21st june. It happens to be the longest day in the northern hemisphere. In marathi it is called "कर्कदिन", I was looking for a name in english, it eluded me somehow. I couldn't find.
Wikipedia is a great place, it has got a page for all the days in a year, so out of curiosity, I happened to check the facts about my birthday.
Some interesting facts that I learnt..
I share my birthday with Charles Chaplin and Lara dutta..
3000 years before I was born, Odyssus returned to Ithaca after the "Trojan War"
34 years before I was born, the psychedelic effects of LSD were discovered on my birthday. Not bad on that one! :-)
Unfortunately, this is the day on which virginia tech massacres took place in 2007. Bad :-((
Interestingly the term "Cold War" was coined by Bernand Baruch thirty years before I was born! :-) awesome!!
There are some other facts as well : like "Launch of Apollo 16", "Chicago bulls" record breaking 70th victory, "syria gained independence"
Wikipedia does not mention one thing though "Abhijit Gadgil" was born on this day !!! Too Baddd...
Quite an eventfull day so to speak! :-)
Wikipedia is a great place, it has got a page for all the days in a year, so out of curiosity, I happened to check the facts about my birthday.
Some interesting facts that I learnt..
I share my birthday with Charles Chaplin and Lara dutta..
3000 years before I was born, Odyssus returned to Ithaca after the "Trojan War"
34 years before I was born, the psychedelic effects of LSD were discovered on my birthday. Not bad on that one! :-)
Unfortunately, this is the day on which virginia tech massacres took place in 2007. Bad :-((
Interestingly the term "Cold War" was coined by Bernand Baruch thirty years before I was born! :-) awesome!!
There are some other facts as well : like "Launch of Apollo 16", "Chicago bulls" record breaking 70th victory, "syria gained independence"
Wikipedia does not mention one thing though "Abhijit Gadgil" was born on this day !!! Too Baddd...
Quite an eventfull day so to speak! :-)
Monday, June 18, 2007
RA-captcha - An idea for ajax based captcha for rails applications.
While working on a new feature for paahijen-Scratchpad, we needed a captcha mechanism to keep the spam-bots out of the door! Since some of our users may not be quite comfortable with typing convoluted roman alphabets, we needed a different system. Honestly, I was too lazy to try out all the Rimage giri to get something useful and somehow wanted a mechanism, which is lightweight, easy to implement (lesser code, no new learning.. ;-) ). Somewhere, I had read about "arithmetic" captcha, and we decided to use it. We just hit upon an interesting idea... to use Ajax for captcha.. Hence the name RA-captcha (rails ajax captcha)..
The idea is fairly simple.. What it basically does is uses link_to_remote to update the contents of a "div" in the form dynamically with a text for a simple arithmetic equation. The equations is so simple that a 5th grade average student can do them without troubles.. eg. the equation will be something like "8 + 2 = " and then an input text box is provided to enter the value.. Though this technique uses "link_to_remote", it is not too hard to use other ajax methods for the rails as the need be!
Here is a simple code that explains the idea... The code is not perfect and I am not a rails expert, Also it doesn't do any validations than minimum.
Create an application "ajax-test" using rails ajax-test
We are going to add a controller called "main" controller and corresponding views. For this example we don't need any ActiveRecord models.
We are going to create the view for this controller and action "index". No layouts..
So create a directory called main inside app/controllers and edit the file
app/views/main/index.rhtml with following contents.
The controller code looks like this.....
How this works is fairly simple. Basically, whenever the first link is clicked an action in the controller called getequ is called, which generates the equation string for us and stores the value for the equation in the session[:capsum] variable. When the form is subimtted, the value of the text field is checked agains the value stored in the session[:capsum] variable. If the values match, the input is allowed, if they don't match the input is not allowed and the view for submit_test is rendered accordingly..
Since, the value the user has to input is only available upon loading the page and updating div, this value simply will never be known to spam-bot to be used without actually loading the page..
---------
The idea looked so simple to me and pilot to be overlooked for so loong. May be there is a catch which I am not getting yet!! Hopefully someone will point out....
PS: Editing html on blogger is a big pain!! eg. it gets rendered. One way out is to change the "<" of each html tag with "<" and then blogger doesn't try to render it.....
The idea is fairly simple.. What it basically does is uses link_to_remote to update the contents of a "div" in the form dynamically with a text for a simple arithmetic equation. The equations is so simple that a 5th grade average student can do them without troubles.. eg. the equation will be something like "8 + 2 = " and then an input text box is provided to enter the value.. Though this technique uses "link_to_remote", it is not too hard to use other ajax methods for the rails as the need be!
Here is a simple code that explains the idea... The code is not perfect and I am not a rails expert, Also it doesn't do any validations than minimum.
Create an application "ajax-test" using rails ajax-test
We are going to add a controller called "main" controller and corresponding views. For this example we don't need any ActiveRecord models.
script/generate controller main
We are going to create the view for this controller and action "index". No layouts..
So create a directory called main inside app/controllers and edit the file
app/views/main/index.rhtml with following contents.
<%= javascript_include_tag "prototype", "effects" %>
<h4>
<%= link_to_remote ( "Click to open form!" , { :before => "Element.show('test-form');",
:url => { :action => "getequ" },
:update => "equdiv" }) %>
</h4>
<div id="test-form">
<%= start_form_tag({:action => "submit_test"}, {:id => "t_form"}) %>
<%= text_area_tag "userinput", nil, :size => "20x10" %>
<p><b>Humans? Please do some simple Math!
<div id="equdiv"> </div><input type="text" name="capval" size="2" />
</b>
</p>
<%= submit_tag "Go!" %>
<%= end_form_tag %>
</div>
<script>
Element.hide("test-form");
</script>
The controller code looks like this.....
There is an additional view defined for submit_post. Which looks like this...
class MainController < ApplicationController
def index
end
def getequ
numbers = (0..9).to_a
@equ = ''
num1 = numbers[rand(numbers.length - 1)]
num2 = numbers[rand(numbers.length - 1)]
session[:capsum] = num1 + num2
@equ << num1.to_s + " + " + num2.to_s + " = "
render(:inline => @equ, :layout => false)
end
def submit_test
if request.post?
if params[:capval].to_i == session[:capsum]
@userdata = params[:userinput]
flash[:notice] = "your input is accepted!!"
else
flash[:notice] = "Sorry you got the math wrong! can't accept your input!"
end
end
# reset the sum so one cannot simply press 'back' buttton and re-use it!!
session[:capsum] = -100
end
end
<% if flash[:notice] %>
<%= "<><b> #{flash[:notice]} </b> </p>" %>
<% end %>
<% if @userdata %>
<%= "You just entered -- #{@userdata}" %>
<p> <%= link_to "again", :action => "index" %>
<% else %>
No input data click <%= link_to "try again", :action => "index" %> to start.
<% end %>
How this works is fairly simple. Basically, whenever the first link is clicked an action in the controller called getequ is called, which generates the equation string for us and stores the value for the equation in the session[:capsum] variable. When the form is subimtted, the value of the text field is checked agains the value stored in the session[:capsum] variable. If the values match, the input is allowed, if they don't match the input is not allowed and the view for submit_test is rendered accordingly..
Since, the value the user has to input is only available upon loading the page and updating div, this value simply will never be known to spam-bot to be used without actually loading the page..
---------
The idea looked so simple to me and pilot to be overlooked for so loong. May be there is a catch which I am not getting yet!! Hopefully someone will point out....
PS: Editing html on blogger is a big pain!! eg. it gets rendered. One way out is to change the "<" of each html tag with "<" and then blogger doesn't try to render it.....
Subscribe to:
Posts (Atom)