tag:blogger.com,1999:blog-169163812008-07-14T22:23:53.997-07:00Jungli GeekNarayan Ramanhttp://www.blogger.com/profile/18094480866664974663noreply@blogger.comBlogger54125tag:blogger.com,1999:blog-16916381.post-16841444508459086532008-04-15T00:24:00.000-07:002008-04-16T05:42:35.879-07:00Unicode encode decode error in python emailBeen bothered with these on and off errors in our application while sending email via python:<br />File "/usr/lib/python2.4/email/Generator.py", line 182, in handletext self._fp.write(payload)<br />UnicodeEncodeError: 'ascii' codec can't encode character u'\u2014' in position 4986: ordinal not in range(128)<br /><br />The reason is that Python's email module needs some information about charset used when a MIMEText object is created.<br /><br />Here is a link which explians how to solve this:<br />http://mg.pov.lt/blog/unicode-emails-in-python<br /><br /><br />Links to understand unicode in Python:<br /><br />http://effbot.org/zone/unicode-objects.htm<br />http://www.amk.ca/python/howto/unicodeNarayan Ramanhttp://www.blogger.com/profile/18094480866664974663noreply@blogger.comtag:blogger.com,1999:blog-16916381.post-72497559863214489902008-02-11T20:30:00.000-08:002008-02-11T20:34:22.772-08:00Enduro3So we competed in and completed the <a href="http://www.enduro3.com/">Enduro3</a> race. Sujoy, Sunil and I cycled some 45 kms over mud tracks and hilly roads, trekked another 50, and eventually survived the adventure race unhurt, and still friends. We started around 10:30 am on Friday and finished around 6:30 pm on Saturday, having slept some 4 hrs in between.<br /><br /><span style="font-weight: bold;"> The race</span>:<br />Cycling:<br />From Paud Road to NDA.<br />On some muddy terrain inside NDA. Was good fun.<br />Back on the road, up and down, up and down and up up - ending at Panshet Water Sports Center.<br />(One of us and his cycle have since been divorced.)<br /><br />Trekking:<br />Start from Panshet, walk along the ridge, get totally lost for a couple of hours, reach one end of the lake. (9:30pm)<br />Stop for the night.<br />Do river crossing. Only one in the team had to and Sujoy, you rocked then!<br />Sleep till 2 am. Trussed up in a dryfit t-shirt, the poncho, a full cotton t-shirt, a nice jacket, a monkey cap and inside a sleeping bag. felt good.<br />Wake and start trekking around 3 am.<br />Sleep again from 5 to 6 am because we got lost.<br />Wake (6 am) and trek trek around the lake, on the road, up koshimgarh and trek trek along the ridge till we reached Panshet WSC. (6.30 pm)<br /><br />The lake and mountains were beautiful. The morning trek was quite refreshing and we saw a lot of birds. The sudden burst of wings from a group of quails from under my feet took me totally by surprise. So close were they, our bodies could feel the drumming vibrations of the frantic wing beats. Also saw a hovering black shouldered kite, a grey jungle fowl, a large green barbet(?), loads of red whiskered/vented bulbuls, purple sunbirds, some flowerpeckers, puff throated, jungle babblers, magpie robins, and rufous backed shrikes.<br /><br />The race was tiring, and we lost our way more than once. But it was a lot of fun and it definitely tested our endurance and it feels good to have completed the race and be writing this blog.<br /><br /><br /><span style="font-weight: bold;"> Information for the next time (IT category)</span>:<br />Water was available at a lot of places and was not a problem.<br />Even though the race director laughs at you in the briefing session when you ask him about carrying sleeping bags, know that they are absolutely needed.<br />Do NOT expect flags where you need them.<br />Finish cycling as fast as possible so that you can navigate properly in daylight on the trek. On a moonless night like we had, it was impossible to look at the lake's shape and find our bearings from the map.<br />The river crossing is in a deep part of the lake and you have to swim (and not wade) across. You get a life-vest so you won't drown and there are ropes at water level to pull yourself along. The water is placid and does not have a current. The distance is around 100m I think.<br />The river crossing and rifle shooting timings are only useful when you have a tie. So really don't bother much with these.<br />The rifle shooting was dropped for our event because of time constraints(?).<br />Glucose is the best. Food may be taken but you would be better off with chocolate bars and energy bars.<br />Carry a couple of 1L water bottles per person.<br />Practise with your own cycle, and from well in advance. Don't fatigue your muscles just a day or two before the race.Narayan Ramanhttp://www.blogger.com/profile/18094480866664974663noreply@blogger.comtag:blogger.com,1999:blog-16916381.post-35272265898210604082007-12-19T19:09:00.000-08:002007-12-19T19:52:40.467-08:00Javascript sleep() or wait() in SahiMy previous post on 'Javascript sleep() or wait()' is visited a lot of times and I think I should write how the problem was eventually solved in Sahi.<br /><br />Sahi needs to playback scripts written in javascript on the browser.<br />Let us consider a small example:<br /><br />We are trying to automate an AJAXy mail client application which has an Inbox button, which when clicked, loads a part of the page, and this newly loaded content has a link 'Unread'.<br /><br /><span style="color: rgb(204, 204, 204); font-weight: bold;">_click(_button('Inbox'));</span><br /><span style="color: rgb(204, 204, 204); font-weight: bold;">_click(_link('Unread'));</span><br /><br />When the first line is executed, the Inbox button gets clicked and the script has to wait till the relevant portions of the page load, before it can click 'Unread'.<br /><br />To solve this, Sahi has a script parser which modifies this script to look something like this:<br /><br /><span style="color: rgb(204, 204, 204); font-weight: bold;">steps = new Array();</span><br /><span style="color: rgb(204, 204, 204); font-weight: bold;">steps[steps.length] = "_click(_button('Inbox'));";</span><br /><span style="color: rgb(204, 204, 204); font-weight: bold;">steps[steps.length] = "_click(_link('Unread'));";</span><br /><br />And to execute these steps, it does:<br /><br /><span style="color: rgb(204, 204, 204); font-weight: bold;">var currentStep = 0;</span><br /><span style="color: rgb(204, 204, 204); font-weight: bold;">function execute(){</span><br /><span style="color: rgb(204, 204, 204); font-weight: bold;"> if (currentStep == steps.length) return;</span><br /><span style="color: rgb(204, 204, 204); font-weight: bold;"> window.eval(steps[currentStep]);</span><br /><span style="color: rgb(204, 204, 204); font-weight: bold;"> currentStep++;</span><br /><span style="color: rgb(204, 204, 204); font-weight: bold;"> window.setTimeout('execute()', 1000);</span><br /><span style="color: rgb(204, 204, 204); font-weight: bold;">}</span><br /><br /><span style="color: rgb(204, 204, 204); font-weight: bold;">execute();</span><br /><br />Hope this helps people who are looking for a solution for javascript sleep.Narayan Ramanhttp://www.blogger.com/profile/18094480866664974663noreply@blogger.comtag:blogger.com,1999:blog-16916381.post-71458038336004882462007-12-11T20:48:00.000-08:002007-12-12T04:38:37.330-08:00java -cp does not work?Was trying to get Sahi's batch and shell scripts to work properly since I get a lot of queries regarding database drivers not being found instpite of adding to the classpath.<br /><br />The problem is this. I need to add a mysql driver to Sahi's classpath so that the scripts can access the driver to do some data driven testing.<br /><br />So I had to add the mysql driver to this:<br /><br />java -jar ../lib/sahi.jar<br /><br />Trivially, I added a -cp option so the command looks like this:<br /><br />java<span style="font-weight: bold;"> -cp ../extlib/mysql-connector-java-5.0.4-bin.jar -jar </span>../lib/sahi.jar<br /><br />But this does <span style="font-weight: bold;">NOT</span> work. Why? Because an executable jar should have its classpath in its manifest file and not outside.<br /><br />The way to solve this is to use:<br /><br />java -cp ../extlib/mysql-connector-java-5.0.4-bin.jar;../lib/sahi.jar net.sf.sahi.Proxy<br /><br />So I made these changes on my windows machine, and it worked. Then logged on to my newly installed ubuntu to check if the shell script works with the same changes.<br /><br />Made the necessary semi-colon to colon conversion in the classpath, so it looks like this.<br /><br />java -cp ../extlib/mysql-connector-java-5.0.4-bin.jar<span style="font-size:180%;"><span style="font-weight: bold;">:</span></span>../lib/sahi.jar net.sf.sahi.Proxy<br /><br />The sahi.sh file has a few other lines too.<br /><br />When I ran sahi.sh, it gave me a NoClassDefFound error for net/sf/sahi/Proxy! After hunting around quite a bit on the net to see if there was such a problem on linux, I realized that nobody on the forums seems to understand the problem even when somebody reported it.<br /><br />Eventually I realized that since I had edited the file in windows, it was adding ^M characters at the newlines which was not being recognized by the shell. So I used another editor and got rid of them by deleting and reentering the newlines. (I could also have used dos2unix, but did not have it installed on my machine)<br /><br />I also realized why the people in the forums did not understand the problem. Most of the replies were from people using linux all the time and the question posters would have mostly been using windows but since the problem was on a linux machine would have posted the question on linux forums!<br /><br />Anyway, now things work properly :)Narayan Ramanhttp://www.blogger.com/profile/18094480866664974663noreply@blogger.comtag:blogger.com,1999:blog-16916381.post-100429773439496652007-11-29T03:19:00.000-08:002007-11-29T03:42:34.224-08:00Sahi at FOSS.inI will be presenting on the internal workings of <a href="http://sahi.co.in/">Sahi</a> at <a href="http://foss.in/2007/info/Home">FOSS.in</a> at Bangalore. This is not a demo level session but will involve a deep dive into the internals of the proxy, the script, extending the proxy, adding new APIs and other unmentionables. Hope to meet some interested and interesting people there.Narayan Ramanhttp://www.blogger.com/profile/18094480866664974663noreply@blogger.comtag:blogger.com,1999:blog-16916381.post-22919384798115389902007-11-18T22:05:00.000-08:002007-11-19T10:29:01.334-08:00Cycling trip to god knows whereThe cycle had been well over hauled. Had to replace the fork, both tyres and tubes. But the result was good. A very smooth, no hassles ride. The gear shifts were working well and the rolling was good. Except for the loose pedal shaft which had worn out and kept shaking and threatened to come off anytime. Saturday morning I set out from home at around 9, got the pedal shaft replaced and was on my way by 9.25. Was to meet Shrik near my office which was a good 17 kms away. Reached the office by 10.10. 45 minutes was a decent time and made me feel that I could go the office on cycle at least once a week. Had a vada pav and lime juice.<br /><a onblur="try {parent.deselectBloggerImageGracefully();} catch(e) {}" href="http://bp2.blogger.com/_94EzacITAcY/R0HUttdJsFI/AAAAAAAAABE/QLGgxEp7cmo/s1600-h/P1010031-2.JPG"><img style="margin: 0px auto 10px; display: block; float: left; cursor: pointer;" src="http://bp2.blogger.com/_94EzacITAcY/R0HUttdJsFI/AAAAAAAAABE/QLGgxEp7cmo/s320/P1010031-2.JPG" alt="" id="BLOGGER_PHOTO_ID_5134618931940143186" border="0" /></a><br />Shrik's Hero Octane looked good, and we started at 10.30 towards Hinjewadi. Past Hinjewadi, towards Paud, and we were in the villages and we kept going uphill and then eventually had a long long descent. Rested at the end of it. Had a limca and decided where to go next. Turned right on some local advice and went on a really bumpy bad road for quite a distance. The scenery around was good though it was all villages. Suddenly we were pleasantly surprised to see three woolly necked storks on the side on an inundated field. Took a few snaps and moved on in search of some hotel to eat.<br /><br /><br /><a onblur="try {parent.deselectBloggerImageGracefully();} catch(e) {}" href="http://bp1.blogger.com/_94EzacITAcY/R0HTeddJsEI/AAAAAAAAAA8/HDMxDQRXOX4/s1600-h/P1010027-1.JPG"><img style="margin: 0px auto 10px; display: block; float: right; cursor: pointer;" src="http://bp1.blogger.com/_94EzacITAcY/R0HTeddJsEI/AAAAAAAAAA8/HDMxDQRXOX4/s320/P1010027-1.JPG" alt="" id="BLOGGER_PHOTO_ID_5134617570435510338" border="0" /></a><br />We saw a lot of sugar cane laden tractors and got a sugarcane from one of them. Had some of it and washed ourselves in a nallah. Eventually found a hotel, but we could not get any meals there. Just had vada sambar, pav and a tea. The hotel guy suggested we go a little ahead and go to a Satya Sai temple nearby if we wanted to have a nap. So off we went to the temple, but it turned out to be one steep climb. Half way through we came across a short cement platform and we parked right there and went off to doze in the shade. Half an hour later, a little refreshed, we proceeded and came across Tikona on the right and a lovely lake on the left. It was beautiful. Ahead, after a friendly water break with some locals, we hit a steep long ghat road which was quite a challenge to go up. At the top, rested for a while with tea and a cream roll. Moved on from there down a lovely steep winding road, and then climbed again all the way to the Kamshet Dam and then downhill again to Pavana nagar village. <a onblur="try {parent.deselectBloggerImageGracefully();} catch(e) {}" href="http://bp1.blogger.com/_94EzacITAcY/R0HVOddJsGI/AAAAAAAAABM/WsvSEl4IuJc/s1600-h/P1010024.JPG"><img style="margin: 0pt 10px 10px 0pt; float: left; cursor: pointer;" src="http://bp1.blogger.com/_94EzacITAcY/R0HVOddJsGI/AAAAAAAAABM/WsvSEl4IuJc/s320/P1010024.JPG" alt="" id="BLOGGER_PHOTO_ID_5134619494580858978" border="0" /></a>At a fork where Kamshet was 10 kms to the left, we decided to go right because we were told that the highway was closer in that direction. Was that a mistake! We cycled for a long long distance with no sign of a highway. Twilight became night and we were either guided by the less than half moon, or blinded by the oncoming vehicles. Had a very needed halt where we hogged five bananas each and to wash off the sweet taste I had a tomato too! Tried to hitch a ride back with a few vehicles but no luck. So we kept going and eventually, we went over the Bombay Pune expressway, and down further to join the NH4. We went to the nearest dhaba, which was quite comfortable with beds to rest, had a beer and some not so great food, and chilled out for a while.<br /><br />Around 8.30 we started cycling towards the nearest railway station, Begadewadi, which was hardly a km away from the dhaba thankfully. Got on the Lonavla-Pune local at 9.20 and after getting a few excited and curious glances and comments about our cycles, Shrik got down at Khadki and I at Pune. Pedalled back from the station to home and reached around 10.30, by when Shrik had also reached home. Had a bath and crashed.Narayan Ramanhttp://www.blogger.com/profile/18094480866664974663noreply@blogger.comtag:blogger.com,1999:blog-16916381.post-78996034434482713282007-10-10T22:11:00.000-07:002007-10-10T22:32:13.209-07:00Sahi no longer needs waiting for AJAX callsA new version of Sahi has been released. Download from <a href="https://sourceforge.net/project/showfiles.php?group_id=151639">https://sourceforge.net/project/showfiles.php?group_id=151639</a><br /><br />More details on the release are here: <a href="http://sahitest.blogspot.com/">http://sahitest.blogspot.com/</a>Narayan Ramanhttp://www.blogger.com/profile/18094480866664974663noreply@blogger.comtag:blogger.com,1999:blog-16916381.post-22867740751293607422007-09-18T20:31:00.000-07:002007-09-18T20:37:04.105-07:000=="" is trueDebugging something on Sahi, came across this interesting equality in javascript:<br /><br />0 == "" is true!<br /><br />So are:<br /><br />1 == "1" etc.<br /><br />An easy way to test these out (and any other single line javascript) is to type<br /><br />javascript:0==""<br /><br />on the browser url navigation bar.<br />Yes, it works on IE and firefox.Narayan Ramanhttp://www.blogger.com/profile/18094480866664974663noreply@blogger.comtag:blogger.com,1999:blog-16916381.post-54215010620139055562007-06-24T04:46:00.000-07:002007-06-24T04:57:14.625-07:00Vote for Sahi on SourceForge Community Choice Awards 2007If you like Sahi, nominate and vote for it in the SourceForge Community Choice Awards 2007.<br />Ask your friends, colleagues and other bloggers to express support too. Thanks :)<br /><br />http://sourceforge.net/projects/sahiNarayan Ramanhttp://www.blogger.com/profile/18094480866664974663noreply@blogger.comtag:blogger.com,1999:blog-16916381.post-22701761978418309462007-05-26T03:22:00.000-07:002007-05-26T03:58:10.555-07:00Trip to BR HillsRashmi and I had been to this place called BR Hills near Mysore. It was early April and it was supposed to be a good time for sighting animals. But we were disappointed to know that a forest fire had burnt very large tracts of the forest and since there was no vegetation for the deer and other grazers, they had all moved away.<br />But luck was on our side. On the second night, we saw a bear in the moonlight, quite close to our log hut. It was scratching the ground and lazily moving around, making a lot of rustling noises among the fallen dry leaves.<br />The next day evening, as we were coming back from the safari, we saw a couple of deer, right by our side, totally ignoring us, and staring at something right ahead of us. They called twice, the sharp and loud "cow", the alarm call of the spotted deer. And then, from the grasses to the left, something came out on the road. In a second it vanished around the bend in the road. In a frenzy of excitement we urged the driver to drive down. He had not seen the animal come onto the road, but started driving down slowly to the bend. But the animal was gone.<br />We looked around, excited, frustrated and expectant. Someone saw a movement on the raised bank on the right. There it was, a full grown leopard, moving stealthily towards cover. A few more moves and the vegetation consumed the cat.<a onblur="try {parent.deselectBloggerImageGracefully();} catch(e) {}" href="http://bp3.blogger.com/_94EzacITAcY/RlgSEVSYeeI/AAAAAAAAAAM/hOrbvLPAbXY/s1600-h/BRHills+3811_filtered.jpg"><img style="margin: 0pt 10px 10px 0pt; float: left; cursor: pointer;" src="http://bp3.blogger.com/_94EzacITAcY/RlgSEVSYeeI/AAAAAAAAAAM/hOrbvLPAbXY/s320/BRHills+3811_filtered.jpg" alt="" id="BLOGGER_PHOTO_ID_5068821246248516066" border="0" /></a><br />The now very excited driver guessed it must come out again a bit further and he started moving. And then we spotted it again. A magnificent animal, sitting right there, a few feet away, at a height on the raised bank which let us look at it straight in the eyes. I clicked away shaking with excitement. The leopard was just beautiful. I had never seen one so close and for so long. It just sat and looked at us. And slowly moved back, while still sitting, so that it was covered by some undergrowth. This is exactly how a tiger had behaved a few months back in Bandipur. Slowly creep backwards in imperceptible movements but soon be hidden from view behind some neighbouring undergrowth. <a onblur="try {parent.deselectBloggerImageGracefully();} catch(e) {}" href="http://bp3.blogger.com/_94EzacITAcY/RlgSEVSYefI/AAAAAAAAAAU/q5ONGUx7InA/s1600-h/BRHills+3901_filtered.jpg"><img style="margin: 0pt 10px 10px 0pt; float: left; cursor: pointer;" src="http://bp3.blogger.com/_94EzacITAcY/RlgSEVSYefI/AAAAAAAAAAU/q5ONGUx7InA/s320/BRHills+3901_filtered.jpg" alt="" id="BLOGGER_PHOTO_ID_5068821246248516082" border="0" /></a><br /><br />And then the leopard started moving. It came down the embankment and walked across the road and then down the curvy road which bent in a U to be parallel with us again. And man, was it brilliant. The leopard moved effortlessly, purposefully, silently, stealthily and man, so beautifully. And it was in full view of us all the time!<br />15 minutes had gone by and it was still around! Perfect sighting!<br />And then we started moving towards it, as we had to return to camp, and by then the leopard decided to vanish. And vanish he did. We could not figure out where he went.<br /><br /><br />We were again rewarded th next day with a bear sighting while we trekked nearby! Quite an eventful and satisfying three days!Narayan Ramanhttp://www.blogger.com/profile/18094480866664974663noreply@blogger.comtag:blogger.com,1999:blog-16916381.post-91193714955021323912007-05-26T00:40:00.000-07:002007-05-26T02:29:47.329-07:00Inter-linking of rivers in India is a bad ideaI think inter-linking of rivers in India is a bad idea.<br />Whenever any friend of mine sounds impressed with this grandiose idea, I have felt frustrated and disturbed. We tend to overlook smaller more effective solutions and go for more romantic and glamorous 'solutions'. So I had been hunting around to gather information on this and make a case of it to people who want to understand what the pros and cons of this effort are. Following are a few links which spell out the danger of going ahead with this plan which does not have enough scientific evidence or prior experience to back it.<br /><br /><a href="http://www.saciwaters.org/interlinking.htm"><br /><span style="font-family:Verdana;font-size:85%;"><span class="style4"><strong> The Interlinking of Indian Rivers</strong></span></span></a> <p style="margin-top: 0pt;"> <a href="http://www.saciwaters.org/interlinking.htm"><span style="font-family:Verdana;font-size:85%;"><span class="style4"><strong>Some Questions on the Scientific, Economic and Environmental Dimensions of the Proposal </strong></span><br /> </span></a> </p> <p style="margin-top: 0pt;"> <a href="http://www.saciwaters.org/interlinking.htm"><span style="font-family:Verdana;font-size:85%;">Paper presented at Seminar on <span class="style4">Interlinking Indian Rivers: Bane or Boon?</span><br /> at IISWBM, Kolkata<br /> 17 June 2002</span></a></p>The conclusion of the above goes thus: "<span style="font-family:Verdana;font-size:85%;">At the end of the above review and analysis made on the basis of whatever open information is available on the project for interlinking the rivers in India, there appears a great inconsistency in the declared claims of the project, and their feasibility"</span><br /><br /><br /><a href="http://www.countercurrents.org/en-ghosh150503.htm">This link, by Shailendra Nath Ghosh</a><span style="text-decoration: underline;"></span>, talks about what is wrong with the concept, and what questions need to be answered, to make a proper assessment of this project<br /><br />More <a href="http://www.indiatogether.org/environment/interlink.htm">articles </a>and <a href="http://www.indiatogether.org/opinions/guest/interlink.htm">opinions</a>. Quite insightful.<br /><br /><a href="http://www.sdnpbd.org/river_basin/differntviews/different_views.htm">Bangladesh's views on India's inter-linking of rivers</a> (They too oppose this)<br /><br /><a href="http://www.sdnpbd.org/river_basin/differntviews/documents/spirited_response_to_river_link_supporters.pdf">Narmada Bachao Aandolan's views in "Dams, Rivers and People"</a>: This talks about rehabilitation failures and need for local management and conservation than an imposed, top down solution. They may appear biased because of their image in the press but they are people who have seen and fought unselfishly for rehabilitation of displaced people.<br /><br />"The proposal is even more dangerous as attempting to link up veins of different persons without trying to find out the blood groups of the individuals. He said consequences will be disastrous." from <a href="http://www.sdnpbd.org/river_basin/differntviews/documents/national_citizens_meeting_delhi_rejects_river_link_proposals_as_ill_conceived.pdf">National Citizens’ Meeting in Delhi concludes: River Link Proposals ill conceived, not in national Interest</a><br /><br />More:<br /><a href="http://nwda.gov.in/indexmain.asp?linkid=97&langid=1">ILR in Supreme Court</a><br /><br /><a href="http://www.thehindu.com/2005/10/18/stories/2005101805081300.htm"><span class="storyhead" style="font-size:100%;color:blue;"> Bahuguna opposes interlinking of rivers</span></a><br /><br />I have not included any links which talk about the environmental aspects of this inter-linking. While the impact will be enormously destructive, talking about it seems to turn off people because they cannot see how economic growth and environmental conservation can co-exist. (May these lesser mortals exit soon)<br /><br />So next time you hear of the inter-linking of rivers , doubt it, question it and take the side of what then comes out as true and right.Narayan Ramanhttp://www.blogger.com/profile/18094480866664974663noreply@blogger.comtag:blogger.com,1999:blog-16916381.post-1170422359176065402007-02-02T05:10:00.001-08:002007-02-02T05:19:19.203-08:00Sahi Nightly Build 2006-02-02 releasedReleased another version of Sahi.<br />Added a few fixes to the release made 2 days back.<br /><br />This is a fairly major release with the following changes:<br /><br />* APIS added<br /> _mockImage(pattern, clazz)<br /> _assertContainsText(expected, el, msg)<br /> _enableKeepAlive()<br /> _disableKeepAlive()<br /> _style(el, property)<br /> _execute("commandline command");<br /><br />* Feature additions<br /> Test status on Controller<br /> Launch test from command line<br /> Add line numbers to script in logs<br /> Back button support<br /> Keep-alive support to tackle too many connections in TIME_WAIT issue<br /> regular expression support in all APIs<br /> Safari support<br /> junit style logs added<br /> jira issue tracking added<br /> <br />* Bugfixes<br /> _condition when used with _include was stopping execution of script.<br /><br />Of significance is the regular expression support in APIs.<br /><br />So if you wanted to find a link which looks like "my_link_KJHSA" you could just do _link(/my_link_.*/).<br />Most APIs which took strings as parameters can now take regular expressions.<br /><br />The communication between the browser and Sahi now uses Keep-Alive thus solving the major issue of too many connections in TIME_WAIT state. <br /><br />Documentation is still being added for the new features on http://sahi.co.inNarayan Ramanhttp://www.blogger.com/profile/18094480866664974663noreply@blogger.comtag:blogger.com,1999:blog-16916381.post-1170422351330945192007-02-02T05:10:00.000-08:002007-03-13T06:34:27.776-07:00Sahi Nightly Build 2006-02-02 releasedReleased another version of Sahi.<br />Added a few fixes to the release made 2 days back.<br /><br />This is a fairly major release with the following changes:<br /><br />* APIS added<br /> _mockImage(pattern, clazz)<br /> _assertContainsText(expected, el, msg)<br /> _enableKeepAlive()<br /> _disableKeepAlive()<br /> _style(el, property)<br /> _execute("commandline command");<br /><br />* Feature additions<br /> Test status on Controller<br /> Launch test from command line<br /> Add line numbers to script in logs<br /> Back button support<br /> Keep-alive support to tackle too many connections in TIME_WAIT issue<br /> regular expression support in all APIs<br /> Safari support<br /> junit style logs added<br /> jira issue tracking added<br /> <br />* Bugfixes<br /> _condition when used with _include was stopping execution of script.<br /><br />Of significance is the regular expression support in APIs.<br /><br />So if you wanted to find a link which looks like "my_link_KJHSA" you could just do _link(/my_link_.*/).<br />Most APIs which took strings as parameters can now take regular expressions.<br /><br />The communication between the browser and Sahi now uses Keep-Alive thus solving the major issue of too many connections in TIME_WAIT state. <br /><br />Documentation is still being added for the new features on http://sahi.co.inNarayan Ramanhttp://www.blogger.com/profile/18094480866664974663noreply@blogger.comtag:blogger.com,1999:blog-16916381.post-1165983833206927792006-12-12T19:12:00.000-08:002007-03-14T09:14:45.903-07:00Reward of KabiniCall after alarm call signalled the presence of a tiger very close to us. Chitals stood alert with their tails up and ears perked up giving out the loud shrill call. A loud "Cow" - an abrupt shrill call very close to us. A flurry of running dots as the deer bolt. The lantana bushes still cover the tiger from us. We wait patiently and impatiently, wait intently, expectantly. A few minutes pass. A lull. Long laden lull. The deer grow silent. No more alarm calls. The tiger is gone. Not even a glimpse. <br />The aura of the tiger is no longer felt. Deer go back to their grazing, langurs back to their mischief.<br /><br /><a onblur="try {parent.deselectBloggerImageGracefully();} catch(e) {}" href="http://photos1.blogger.com/x/blogger/4392/1618/1600/423273/IMG_5545.jpg"><img style="float:right; margin:0 0 10px 10px;cursor:pointer; cursor:hand;" src="http://photos1.blogger.com/x/blogger/4392/1618/320/5330/IMG_5545.jpg" border="0" alt="" /></a><br />We move on. Disappointed. The night is closing in. We exit the jungle right on time. Our guide Sivanand suggests we try our luck along the road. Our headlights on, we go at a slow pace. A small herd of wild gaur. Huge animals, very close to us. Unperturbed, happily grazing away. One crosses the road in front of us as we wait. Slow, deliberate, unconcerned by our presence. A few metres ahead, a big tusker. Elephants close to your vehicle are not very comforting. A lone male tusker doubly so. We watch, torchlight on the tusks. The elephant leaves us alone.<br /><br />Alarm calls again. Chital very close. A predator nearby. Experience braces us for disappointment, but optimism still lurks. Sivanand points in the other direction from where we are looking. A smallish stocky animal. Comes out of the cover of the forest. Starts walking on the road. Slightly hurried. Aware of our presence. We move slowly towards it. Our headlights on, but slow enough not to frighten it away. Slow enough to frustrate us to know there is a leopard in front and we cannot see it clearly. Frustrating. <br /><br />It was a good decision. The leopard moved off the road to the right. We moved in slowly. The pale yellow beam lights the animal's rump as it ambles slowly into the bushes. Then it stops and sits down. In the light of the torch. A female, not too big leopard. The eyes glint reddish in the light as she looks at us for a brief moment. Into the light, into our eyes. Lovely. Brief. She gets up and walks on, away into the bushes, into the darkness, and into the jungle. Back to her comfort zone. And we move on to ours.Narayan Ramanhttp://www.blogger.com/profile/18094480866664974663noreply@blogger.comtag:blogger.com,1999:blog-16916381.post-1165065957964007902006-12-02T05:12:00.000-08:002007-02-17T22:30:08.640-08:00Button tag problems and IE 6Discovered that IE and Firefox handle the &lt;button&gt; tag differently.<br /><br />If you have a tag like<br /><pre><br />< button type="submit" name="b" value="abc"><br />Button Text< /button><br /></pre><br /><br />When the form is submitted, the value of the parameter "b" is "abc" in firefox (the value attribute) while for IE, it is "Button Text" (the innerText)<br /><br />Workaround?<br /><br />We needed to submit a form using different buttons and each should send back its respective value.<br /><br />We used <br /><pre><br />< input type="submit" name="b" value="Button Text 1"><br />< input type="hidden" name="Hash_of_Button_Text_1" <br />value="value1"><br /><br />< input type="submit" name="b" value="Button Text 2"><br />< input type="hidden" name="Hash_of_Button_Text_2" <br />value="value2"><br /></pre><br /><br />and on the server, accessed it by<br /><br />params[hash(params["b"])]<br /><br />where hash("Button Text 1") returns Hash_of_Button_Text_1<br /><br /><br>Narayan Ramanhttp://www.blogger.com/profile/18094480866664974663noreply@blogger.comtag:blogger.com,1999:blog-16916381.post-1164649729297303272006-11-27T09:48:00.000-08:002007-03-06T21:41:18.276-08:00Ruby mocking - Using flexstubRuby proves to be as sweet as most people have claimed it to be.<br /><br />Pick testing and and you hit <a href="http://onestepback.org/software/flexmock/">flexmock and flexstub</a>.<br /><br />So how do you use them? Here goes:<br /><br />You have<br /><pre><br />class CA{<br /> def method_1<br /> do_some_processing<br /> if condition method_2<br /> else method_3<br /> end<br /><br /> def method_2<br /> do_some_slow_processing_worth_mocking_out<br /> end<br /><br /> def method_3<br /> do_some_more_slow_processing_worth_mocking_out<br /> end<br /><br />}<br /></pre><br />If you want to test method_1's conditonal logic, with method_2 and method_3 stubbed out, here is how you do it with flexstub:<br /><br /><pre><br />require 'flexmock'<br /><br />class MyTest< Test::Unit::TestCase<br /> include FlexMock::TestCase<br /> def test_method_1<br /> ca = CA.new<br /># do something to make the condition be true<br /># stub some methods of the instance<br /> stub = flexstub(ca)<br /> stub.should_receive(:method_2).once<br /> stub.should_receive(:method_3).never<br /> ca.method_1<br /># Note: method_1 is invoked on ca.<br /># stub.method_1 will fail!<br /> end<br />end<br /></pre><br /><br />So when would you use flexmock?<br />If you wish to mock all the methods being called on an object, you may use a flexmock.<br />A flexmock is an object which will just receive the methods you set expectations for, using should_receive.<br />If you wish to mock only one of the methods of an object but the other methods need to be invoked with the real functionality, <br />use flexstub to mock only that particular method. <br /><br />As you see, method_1 is invoked properly, but method_2 and method_3 are stubbed out.<br /><br />One remarkable thing about this is mocking out an object's new method.<br /><pre><br />flexstub(Customer).should_receive(:new)<br /> .and_return(mock_customer)<br /></pre><br />Anywhere Customer.new is called inside any class during your test, it will return a mock_customer.<br />This is quite powerful, because we no longer need to use dependancy injection for just test purposes.Narayan Ramanhttp://www.blogger.com/profile/18094480866664974663noreply@blogger.comtag:blogger.com,1999:blog-16916381.post-1164618869874865552006-11-27T01:14:00.000-08:002007-02-15T02:22:25.433-08:00So much for security!If you are booking online on Spicejet, beware.<br />The lovely site which says verisign secured etc. actually sends all your credit card information as a query string! <br />So much for SSL!<br /><br />I had written to them around 2 months back and it still remains the same!Narayan Ramanhttp://www.blogger.com/profile/18094480866664974663noreply@blogger.comtag:blogger.com,1999:blog-16916381.post-1161333894977079562006-10-20T01:39:00.000-07:002006-10-20T01:44:54.990-07:00Sahi - New WebsiteSahi has a new look and location at <a href="http://sahi.co.in">http://sahi.co.in</a>.<br /><br />A new release (Nightly Build 2006-10-20) of Sahi is also available. Download from <a href="http://sahi.co.in/content/view/32/53/">here</a>Narayan Ramanhttp://www.blogger.com/profile/18094480866664974663noreply@blogger.comtag:blogger.com,1999:blog-16916381.post-1160400120649520692006-10-09T06:19:00.000-07:002007-02-20T06:49:28.306-08:00Bird FightJust posted an image of a fight between a brahminy kite and a purple swamphen.<br />The swamphen stamps and chases away the kite!<br /><a href="http://indianaturewatch.net/displayimage.php?id=4927">http://indianaturewatch.net/displayimage.php?id=4927</a>Narayan Ramanhttp://www.blogger.com/profile/18094480866664974663noreply@blogger.comtag:blogger.com,1999:blog-16916381.post-1160035512917458422006-10-04T22:49:00.000-07:002007-03-05T23:22:54.003-08:00Jamming thoughtsTravelling alone by car is a sin. <br />Why? It takes too much space on the roads. <br />The bigger the car the worse it is. <br />One car blocks roughly the space of four bikes. <br />So unless there are four people (at least) in a car, we are blocking resources which can be used more effectively. <br /><br />Btw, bikes pollute more than new Euro IV cars (<a href="http://www.cseindia.org/campaign/apc/leapfrog_factor.htm">Source</a>). So the problem is not straight forward. <br /><br />There are a few things to consider:<br /><br />What is the real problem? Road congestion or air pollution?<br />In Bangalore, it is road congestion. And it compounds air pollution. A car caught in congestion pollutes four times more than a running one (<a href="http://www.cseindia.org/campaign/apc/leapfrog_factor.htm">Source</a>). <br /><br />So if we have more free flowing traffic it is a big win. That means bikes are a decent option, and cars are not bad if fully utilized. <a href="http://www.commuteeasy.com">Pooling</a> in any form would help. Walking and cycling really are the best, but may not be feasible for everyone. <br /><br />Pooling is kind of helpful in another way. One shares the stress of commuting and makes us human beings who snap less and who do not yell at the already poor pedestrian and the occasional cyclist.<br /><br />Sad point is how the world sees it as a sign of success if you consume more resources and it may be perceived as below dignity for people to travel by cycle. Applause to those who have persevered cycling in Bangalore and because of their own profile are slowly making cycling be seen as cool and desirable.<br /><br />Sad again that the right things have to be packaged as cool for most of us to accept it.<br /><br />On a happier note, I hear less honking nowadays than I used to. People in Bangalore seem to be maturing to the traffic problem now. Cheers!Narayan Ramanhttp://www.blogger.com/profile/18094480866664974663noreply@blogger.comtag:blogger.com,1999:blog-16916381.post-1159423712183957832006-09-27T22:55:00.000-07:002006-09-27T23:08:32.200-07:00Treepie<a href="http://www.treepie.org">Treepie.org</a> is up again. So if you are a birder and are looking for a site to consolidate your bird lists, join it and manage your lists. <br /><br />I am now linking birds with superb pictures posted by the growing community of excellent wildlife photographers in <a href="http://www.indianaturewatch.net/index.php">India Nature Watch</a> and pictures from google image search.Narayan Ramanhttp://www.blogger.com/profile/18094480866664974663noreply@blogger.comtag:blogger.com,1999:blog-16916381.post-1159185172324185522006-09-25T04:31:00.000-07:002006-09-25T04:59:43.233-07:00Turahalli<a href="http://chirdeepshetty.blogspot.com">Chirdeep</a> and I had gone owl hunting to this place called Turahalli. Do not know if we actually reached there but we did end up on a nice patch with lots of rocks around. No owls, but we managed to see rock agamas. Loads of them. Every rock was ruled by one. <br />Soon bored, bouldering entertained us briefly. <br />Then we came across a neat white cheeked barbet surprisingly sitting on an electric line absolutely unperturbed by our photographic intentions and let us come quite close to it. <br />Also managed a decent shot of a pied bushchat.<br /><br /><a onblur="try {parent.deselectBloggerImageGracefully();} catch(e) {}" href="http://static.flickr.com/95/251252002_66fb528ad6.jpg?v=0"><img style="float:left; margin:0 10px 10px 0;cursor:pointer; cursor:hand;" src="http://static.flickr.com/95/251252002_66fb528ad6_m.jpg" border="0" alt="" /></a><br /><br /><br /><a onblur="try {parent.deselectBloggerImageGracefully();} catch(e) {}" href="http://static.flickr.com/94/251251999_640f5478e7.jpg?v=0"><img style="float:left; margin:0 10px 10px 0;cursor:pointer; cursor:hand;" src="http://static.flickr.com/94/251251999_640f5478e7_m.jpg" border="0" alt="" /></a><br /><br /><a onblur="try {parent.deselectBloggerImageGracefully();} catch(e) {}" href="http://static.flickr.com/92/251256076_d47b8aa4a9.jpg?v=0"><img style="float:left; margin:0 10px 10px 0;cursor:pointer; cursor:hand;" src="http://static.flickr.com/92/251256076_d47b8aa4a9_m.jpg" border="0" alt="" /></a>Narayan Ramanhttp://www.blogger.com/profile/18094480866664974663noreply@blogger.comtag:blogger.com,1999:blog-16916381.post-1154856259773444602006-08-06T02:21:00.000-07:002006-08-06T02:27:19.756-07:00Birding in BannerghattaChirdeep, Nikhil and I went birding on Saturday. Got a few pics.<br /><br /><a onblur="try {parent.deselectBloggerImageGracefully();} catch(e) {}" href="http://static.flickr.com/76/207855908_d95835d264.jpg?v=0"><img style="margin:0 10px 10px 0;cursor:pointer; cursor:hand;width: 320px;" src="http://static.flickr.com/76/207855908_d95835d264.jpg?v=0" border="0" alt="" /></a><br />Purple sunbird in non-breeding plumage<br /><br><br /><br /><a onblur="try {parent.deselectBloggerImageGracefully();} catch(e) {}" href="http://static.flickr.com/60/207855906_1594c2141c.jpg?v=0"><img style="margin:0 10px 10px 0;cursor:pointer; cursor:hand;width: 320px;" src="http://static.flickr.com/60/207855906_1594c2141c.jpg?v=0" border="0" alt="" /></a><br />Plain flowerpecker<br /><br>Narayan Ramanhttp://www.blogger.com/profile/18094480866664974663noreply@blogger.comtag:blogger.com,1999:blog-16916381.post-1154850648352967182006-08-06T00:43:00.000-07:002006-08-06T00:50:48.366-07:00Lighting a mosquito coil ...<a onblur="try {parent.deselectBloggerImageGracefully();} catch(e) {}" href="http://static.flickr.com/57/207823082_ff8d90e81b.jpg?v=0"><img style="float:left; margin:0 10px 10px 0;cursor:pointer; cursor:hand;width: 320px;" src="http://static.flickr.com/57/207823082_ff8d90e81b.jpg?v=0" border="0" alt="" /></a>Narayan Ramanhttp://www.blogger.com/profile/18094480866664974663noreply@blogger.comtag:blogger.com,1999:blog-16916381.post-1154845585163145802006-08-05T23:17:00.000-07:002007-03-01T12:21:30.280-08:00Blog for SahiCreated a <a href="http://sahitest.blogspot.com">new blog</a> for Sahi since there seem to be too many posts just on Sahi here.<br /><br />That said,<br /><a href="http://sahitest.blogspot.com/2006/08/sahi-nightly-build-2006-08-06-released.html">Release 2006-08-06 with file upload facility has just come out</a><br /><br /><a href="http://sahitest.blogspot.com/2006/08/toggling-proxy-on-browsers.html">Toggling proxy on IE became easier with toggle_IE_proxy.exe and ProxyPal</a><br /><br />And tons of thanks to Sriram Narayanan (Ram) for creating toggle_IE_proxy.exe<br />Seen few people who attack someone else's problem with such vigour and effect.<br />Taught me something...Narayan Ramanhttp://www.blogger.com/profile/18094480866664974663noreply@blogger.com