Harsha Vashisht is a Software Engineer working for Yahoo! out of Sunnyvale, California. You can contact him at mail@harsharv.com, rvharsha@yahoo.com, rvharsha@gmail.com. He is a YDN Evangelist and has done talks/ dev support in numerous hack events.

Installing Node.js on Mac OsX

Node.js intrigued me and I wanted to hack with Node.js & CouchDB. I read about Node.js and wanted to install it on my Mac. Here is the guide to install Node.js quickly on Os X.

1. If you are running Snow Leopard then the process is simple. Download the latest package from http://sites.google.com/site/nodejsmacosx/ and install it. Done!!

2.If you haven’t upgraded to Snow Leopard and still running on Leopard (like me) then you have made your life miserable. I encountered with a problem in OpenSSL. Apple pushes a very old version of OpenSSL with Leopard. I spent an entire day looking at ways to compile the code to work for Leopard. The errors encountered were as follows:

1. Link error

collect2: ld returned 1 exit status
Waf: Leaving directory `/Users/harsharv/Downloads/nodejs
Build failed:  -> task failed (err #1): 
	{task: cxx_link node_main_4.o,node_4.o,node_buffer_4.o,
ares_strdup_1.o -> node}
make: *** [program] Error 1

This problem is solved by upgrading OpenSSL.

2. You have managed to upgrade OpenSSL from 0.97 to 1.* and when you enter the command “node” you get the error

dyld: unknown required load command 0x80000022
Trace/BPT trap

The solution for this was very simple. Compile with out Open SSL 😀
Let me aggregate them. The steps are as follows:

  1. Download the latest source code from http://nodejs.org/#download. Example:http://nodejs.org/dist/node-v0.4.4.tar.gz
  2. tar -xzf node-v0.4.4.tar.gz
  3. cd node-v0.4.4
  4. ./configure –without-ssl
  5. make
  6. make install
  7. cd build/default/node
  8. node



September 23, 2010 2 comments

My colleague asked me to write a blog on YUI 3 and the prize for that is a very nice tee shirt. So here is my blog about YUI 3. It is awesome. Now I am going to collect my tee shirt 🙂

Categories: Uncategorized

Location based applications

September 1, 2010 Leave a comment

Technology has influenced man in every dimension. In fact, it has given birth to a few new dimensions that has changed the way in people do business. Lets look at this banal GPS enabled Mobile App that enables me to start the application and look at the near by businesses. I can look at the eateries close by, shopping centers, hospitals and ATMs. This is helpful for 90% percent of my use cases. This is a simple application that triggers my imagination and broadens hope for more useful and creative location based applications. For businesses: Nike Outlet offering 50% discount, Restaurant running a food festival, or arts exhibition, it would be very effective to target people who are in the vicinity of the business. The next big companies in the Internet world would be bridging the gap between businesses, their offers and common man who is around these businesses.

You are here

Foursquare is a new generation Location based application that took the latter to the next level. It helps people to find out if there are friends around the places they are visiting: eateries, shopping centers and events and then decide if they would want to meet or avoid these friends. People would trust the reviews of known people more and this results in a pattern in which a group of people would visit the business center. Lets take the case of a person – G, visiting a restaurant – X.  G checks into the restaurant, puts up his location on the Internet for his friends to see. G loves the spicy food and writes a review saying that he loved the place and he would definitely come back. G’s friends see the review and they would want to try the new place next time they went out for dinner in X’s neighborhood. Though the event of G’s friends visiting the restaurant can’t be guaranteed (even though the probability is high), G’s negative review of the restaurant would certainly stop his friends from dining at X.

Business centers should put these applications to good use to grow their businesses. Ads can be targeted more effectively with such applications. This gives a new life to the clichéd model of business – ad broker – end consumer in the Internet world. Next five years will see a proliferation of such applications with nuances, most of them being start-ups. Many big companies will try to move their heavy bandwagon in this direction. The following can ensure success of the new paradigm:

  • Quality Data – All the local businesses and their offers, events must be there in the database. More businesses.
  • Ease of use of the application – End user should do very minimal kung fu to use the application and get the necessary data. This is a very important factor for any application to be successful.
  • Simple presentation of the data in a very useful format – The data should be presented in a form that is strikingly convenient.

Business opportunity is immense and is waiting to be exploited. The game has just begun.

Image Courtesy: Nokia – http://www.oviapplications.com/tag/location-based-services/

Categories: General, Technology

Team outing – Dandeli and Karwar

February 13, 2010 Leave a comment

End of year was partying time at Yahoo!. We had a pretty good budget for a team outing. After some quick research I proposed a plan to go to Dandeli and Karwar. The challenge was to find a place which would interest people of two different walks of life. A place in midst of nature, less tourists but with awesome facilities and offering an array of awesomeness. We had a rich spoilt brat who would go to Oooty and stay inside the Taj Hotel for two days and another person who would drive 1000 KM to stay in the midst of a forest.

I booked a brand new TT from Ambassador Tours & Travels for Rs 10 per KM. We left at 8 PM on 17th Dec to Dandeli. The route was Bangalore – Hassan – Hubli – Dharwad – Dandeli. We reached Dandeli at 10 AM. The reason for the delay was that we stopped at a dhaba for dinner and later there was a major traffic jam for 3 hours owing to a truck accident.

I had booked accomodation at Kulgi Nature Camp at Dandeli. Kulgi Nature Camp is a government run unit which is 8 KM from Dandeli, in the midst of Teak forest. A deluxe tent (with attached bathroom) costs Rs 500 per room. They are constructed cottages made to look like tents. These tents have moderate facilities and okish toilets. Alcohol is banned in the vicinity of the camp. Food can be ordered an hour before and is amazing. It is more satisfying then most of the hotels in Dandeli. It costs around Rs 25 per meal.

Bison River Resort organizes white water rafting. One should contact them directly and strike a deal for Rs 950 per person. It is safe and an amazing experience. Most of the people didn’t know how to swim. It is totally worth the money. Also, other then water sports Dandeli doesn’t have much to offer. Safaris have minimal animal sightings.

Next day we left to Karwar at 10 AM. The direct route to Karwar from Dandeli is terrible. We reached Karwar at 2.30 PM. There are not many good hotels on the way and we suffered as we had thought of having breakfast on the way. The Great Outdoor Resort is on Kurumgad Island.

Kurumgad Island is a remote haven, located 4 km into the Arabian Sea from Karwar. This tortoise-shaped island, 6 km from Baithakola in Karwar harbor, offers a beautiful view of the sea. Tourists can enjoy exotic beach walks, nature walks, swimming, fishing, bonfires and barbecues, dolphin spotting, boat rides and snorkeling. The best time to visit is from September to March.

There is a small Narasimha temple here, which has many legends associated with it. A fair is held every year on the full moon day during the Pushya (December – January) month. Thousands of devotees congregate at this island on this particular day to offer prayers. An old fort is there on this picturesque island. Kurumgad Island can be reached by travelling by ferry from Sadhashivgad Boat Jetty on the backwaters of River Kali at Karwar. This island is 1 km from Devbagh Beach.

Great Outdoor island is a bang for the buck. They charge around Rs 1600 per person for lunch, dinner with barbecue and next day’s breakfast. There is a generator for electricity and a small spring forms the source for fresh water. If the spring dries up, water is a major problem. So, summer is a wrong time to go to the island.

We saw dolphins on they way to the island. There is a small private beach and water sports are a big let down. The sunset from the resort is very beautiful. Suns sets into the ocean mesmerizing everyone who is witnessing the spectacular event.

Next day we headed back to Bangalore.

Contact Details:
Kulgi Nature Camp
Kulgi village
Haliyal Taluk
Karnataka – 581325
No: 08284 – 231585

Great Outdoor Island

Exceptions – Kick start guide to designing exceptions for your system

February 13, 2010 Leave a comment

The main problem with exception handling is knowing when and how to use it. Exception designing requires discretion, experience in OO programing and knowledge of the users of your system.

What is an Exception?
An exception is an event, which occurs during the execution of a program, that disrupts the normal flow of the program’s instructions. When an error occurs within a method, the method creates an object and hands it off to the run time system. The object, called an exception object, contains information about the error, including its type and the state of the program when the error occurred. Creating an exception object and handing it to the run time system is called throwing an exception.

Types of Exceptions:
There are two types of exceptions:

  1. Checked Exceptions
  2. Unchecked Exceptions

Checked exceptions represent invalid conditions in areas outside the immediate control of the program (invalid user input, database problems, network outages, absent files) Checked exceptions forces the user to use a try-catch block to catch the exception.

To quote from The Java Programming Language, by Gosling, Arnold, and Holmes : “Unchecked run time exceptions represent conditions that, generally speaking, reflect errors in your program’s logic and cannot be reasonably recovered from at run time.” . Unchecked exception doesn’t impose the use of try-catch block and this is caught at the highest level. They are subclasses of RuntimeException, and some examples are IllegalArgumentException, NullPointerException and IllegalStateException.

Checked or Unchecked Exceptions?
There are many arguments for and against both checked and unchecked, and whether to use checked exceptions at all. What I am going to say below is what sounds best to me (and a couple of people around me at Yahoo!).

Why custom defined exceptions?

In the above diagram the user of the system should be aware of exceptions A,B,C which are some custom exceptions of internal components. So, the user has to import A,B,C. It is highly impractical and illogical for the user of the system to be aware of the internal exceptions. So it makes sense to wrap all the internal exceptions in a custom exception Z. The user of the system will have to know about and import only z.

Let us consider that we are building a Banking software. The component built by us will be used by another team. The diagram below adds more clarity to our understanding.

When to use custom unchecked Exception?

Use unchecked exceptions when the user of system can’t recover from the error.

When to use custom checked Exception?

Use checked exceptions when the user of system can recover from the error.

What should be avoided?

One should avoid creating an Exception explosion. Try to limit the number of custom defined exceptions as it would become inconvenient for user of the system.

What can be my next steps?

Look at Decorator pattern to improvise the design.

Duty free shopping – Dubai vs Bangalore

October 14, 2009 1 comment

Duty free shopping in Dubai is slightly more expensive then Bangalore. Glenfiddich 12 year old was $4 costlier in Dubai compared to Bangalore and Jack Daniels was $4 costlier compared to LAX.

The sad part about Bangalore airport is that the collection is bad. They didnt have JD in stock. So, on comparison with Dubai and Bangalore, Dubai has more variety but a couple of dollars costlier. It is better to buy stuff at the Dubai airport then Bangalore airport.

Trek from MM Hills – Nagamale – Gopinatha

September 5, 2009 7 comments

It had been a long time since my last trek / trip. Sent a mail eco club of Yahoo! asking if people wanted to join me. The response was over whelming. There was a waiting list for the trek!!!! Prajwal was laughing his ass off.

After making the necessary phone calls and preparations, we were ready for the trek.

Friday night and Saturday:

So, totally 19 of us left for MM Hills on a Friday night (around 12 PM). Stopped at Maddur coffee day, had some coffee and reached MM Hills at 6 AM. The forest department was not yet open. We went and had idlis in a roadside restaurant and took VIP guesthouse to freshen up. We went to the forest office, called the ACF and made them open the office. ACF Prabhar is one of the survivors from Special Task Force. He has escaped death from Veerappan’s hands 4 times. We made the payments. We were unnecessarily charged for porters (they call it the Transportation charges) and no porters accompanied us. We were charged for 3 guides and only one came along. So kindly be wary about that.

We bought some vegetables and curds so that the villagers could cook for us. The TT then dropped us at the starting point of the trek, which is 2km from the forest office. The vehicles went back to the Forest Dept office. The trek was moderately difficult. We were walking to Nagamaale, which was around 12 KM from MM Hills. Nagamaale is a village with no motorable road connections. The villagers have to walk 6 to 15KM to MM Hills, Palar or Gopinatha for any transport. Naagamale has a Shiva temple. The specialty of the temple is that a huge rock has split (most probably because of an earth quake) and looks like a Snake’s hood is right above a Shiv ling. A lot of local people go this temple and as a result we find umpteen number of Tea shops on the way along with small kids selling buttermilk for Rs 2 per glass. Half way to Naagamale is a village called Indignatha. There are jeeps, which go to Indignatha and charge Rs 30 per head. We reached Indignatha at around 1.30 PM. We had multiple cups of tea and glucose biscuits. It was lunchtime and the teashops would prepare food on request. The waiting period is one hour. I had carried around 30 dry chapatis and chutney powder, pickle along with me. These chapatis and Nataraja Rajagopalan’s (nraja) obattu was our lunch. There is a sweet water well and well is dirty. Luckily I had carried enough water and others filled up there bottles.

Naagamale is 4 KM from Indignatha – we had to cross just one hill. We picked some buttermilk and raw mangoes along our way. The route is a stone way to avoid the walking path from getting screwed due to rains. Luckily for us the whole day was cloudy and we didn’t have to face the harsh sun. At the top of the hill, the rain god showered his blessings. We pulled our raincoats, clicked some amazing photos and reached Naagamale by 5. We had a big temple choultry for us. Gopalv pulled his sleeping bag out and dozed off. I thought poker to Manish Chauhan, Rajesh, Sanchit, Bharat, Madan Epuri and others. Some of them were playing rummy, which is not so interesting. The dinner was served at around 7.30. The menu was very simple. Rice, sambar and curds. We finished 2 buckets of rice and sambhar along with curd. Most of them slept off and later in the night Gopal, Pushkar, Rajesh, Karthikay and myself started playing with Gopalv’s camera ( Nikon D 300, I wish I could buy it right now). End of day one and we dozed off like babies.


I got up at 7 (cos of lack of sleep in TT) and was the last one to get up. We washed up. The water looks like as some phenyl has been added to it. We went to the temple. It is 1 KM from the village and on top of another hill. The sun was playing hide and seek with us, hiding behind the clouds and showing itself to us. We came back and had Chitraanna for breakfast. We decided to go to Gopinatha (10 KM) from Naagamale as it was closer to Hogennakal falls. The route is downhill and was easy. Our guide Veeranna had left a message with the Forest office using his walkie-talkie, asking the vehicles to come to Gopinatha. We reached Gopinatha at 2 and the TT’s were waiting for us. Gopinatha is the village of Verappan and his lands can be seen. We bid farewell to Veeranna and headed to Hogenakkal falls. We had lunch near Hogennakal falls (Karnataka side) – Omelet and meals. The coracle ride costs Rs. 150 per head for 2 hours and it is expensive compared to the Tamil Nadu side. The boatman / coracleman took us near the falls and the water was spraying on our faces. Hogennakal water is very dirty from the Karnataka side. He avoided taking us to the Tamil Nadu side where the main falls exists. We forced him to take us on the TN side. A body massage on Karnataka side costed Rs 200 where as on the TN side it was Rs 100. Around 7 of us got our whole body massaged and took bath in the falls. We were good as new and could have trekked for another 10KM 🙂

We left Hogennakal at around 6, had dinner in a dhaba at 12.20 near Maddur and reached home at around 2AM.

Overall, it was a good experience and gave us a break that we wanted.

Details: Website: http://www.mysterytrails.com/MMHillsToNaagaMale.htm

Contact details: Deputy conservator of forests, Kollegal Division

E-mail: dcfkollegal@mysterytrails.com

Phone: 08224-252027 Fax: 08224-252027

Cost: Talk to the clerks not to charge you unnecessarily and it should not cost you more then Rs 500 per head for both the days including everything. Best time to go: Post monsoons so that you can see wild animals Safety: The guide carries a gun and it it pretty safe

Distance from Bangalore – MM hills – 260 KM

Trek difficulty: Moderate

Categories: trek Tags: , , ,

Talk in MSRIT

September 5, 2009 Leave a comment

(The blog is on YDN also. http://developer.yahoo.net/blog/archives/2009/03/pipes_yql_talk.html)

On a bright Monday morning, I was giving a talk on Pipes, YQL and web development to a bunch of students in MSRIT. After meeting the HOD of the Computer Science Department and other senior professors, I was taken to the seminar hall. There were at least 100 people in the room. They were all students – under grads, who were in third and fourth year of their Engineering. I was a bit skeptical of they being able to digest what I was going to feed them. But in the end I was pretty happy with the outcome.

First, I spoke to them about web development and how it was discouraged in the present day Universities in India.

Then we spoke about Pipes for half hour. Most of them appreciated the beauty of Pipes. Some of them had already started thinking of using Pipes in their projects. We did a quick demo; where in the news about “Lok Sabha Elections 2009″ was aggregated from various sources (news sites and search) and the data was consumed /displayed else where.

Then we had a look at YQL and that is when I realized the beauty of the YQL console. It is not only easy to write SQL style queries, YQL scores in being easy to demo, evangelize and play around with.
We also touched upon writing open tables with simple examples(Twitter).

In the end we also looked at the other useful services of Yahoo! like BOSS, YUI and what has been built using it.

The Q&A section was Pipes centric. Some questions about licensing and other operators in Pipes.
A couple of them who were building websites for their department and batch were interested in YUI. I wanted to show them YUI Grid Builder but the internet failed on us. So they had to settle for pointers on YUI.

There were two people who came up later and asked if there was any location based services of Yahoo! They were building a low cost GPS system and they were happy to find out Fire Eagle and Geo helped their cause.

I really wish the PR could have arranged for some goodies. The event was overall successful, served its cause.

The feedback that I got was more than satisfactory.

YQL – makes you want to hack more

September 5, 2009 Leave a comment

Yahoo! Query Language (YQL)

YQL is a SQL like Query Language developed by Yahoo! to provide a single interface for all the properties of Yahoo! which have exposed their APIs. The best part of YQL (unlike most of the other (*)QLs) is the concept of open tables, in addition to the 50+ Yahoo tables. You can as well fetch a RSS feed, select what is required, massage them and display it.

What makes YQL even more attractive then other (*)QLs is the Console. Developers can type their queries in the console, test them and get the REST URL for the query.

For quick understanding, let us say that a developer has to:
1. Search for photos from Flickr Search the web for data, photos
2. Search for local business
3. Fetch weather info
4. Fetch(add) events from(to) Upcoming
5. Fetch contacts, updates, profiles from profiles (social)
6. Fetch RSS and render it

The developer can use YQl for the above operations. Sample YQL queries are as below:
1. Flickr photo search
select * from flickr.photos.search where text=’Angelina’
2. Search the web
select title, abstract from search.web where query=’Taj mahal’
3. Read RSS
select title from rss where url=’http://twitter.com/statuses/user_timeline/15722583.rss’
4. Read from a HTML page
select * from html where url=’www.harsharv.com’ and xpath=’//body/div[@id=”doc2″]/div[1]/h1′
5. Social: Fetch contacts for a user
select fields.value from social.contacts where guid=[the guid]
6. Social: Updates for a user
select * from social.updates where guid=[the guid]

Other SQL commands like limit, in, joins, sub-queries, unique hold good too.

Overall, YQL is one of the big hit promises that Yahoo! has shown recently. I personally appreciate and love it. It makes me want to hack more. I will use YQL in situations where I would use pipes.

More examples can be found and tried at http://developer.yahoo.com/yql/console

The documentation can be found at http://developer.yahoo.com/yql/guide

Coastal Karnataka

September 5, 2009 Leave a comment

Half of office was in holiday mood. We decided to hit Coastal Karnataka. We (7 Yahoos – Prajwal, Sanchit, Ritesh, Saurabh, Ram, Swaminathan and me and 4 non Yahoos Ganesh, Jayanth, Shegde, Rahul Panicker) left Bangalore at 9.30 PM on 24th Dec (Wednesday) in a Tempo Traveler. We stopped at a dhaba on Tumkur Road for dinner and then continued the journey. We reached Kundapur at around 9 AM and had breakfast at Sharon’s. From Sharon’s, a guide took us to the Amgol tropical island resort which was 9 km from Sharon’s. It is a small island in a river (name I forgot) and had beautiful cottages and was really peaceful. We have to take a boat to this island and the ride is fun. The facilities on the island are good (although slightly over priced) and we had fun. Next day, we checked out and headed to Marvanthe beach. We stayed at Turtle Bay Beach Resort. The resort has a private beach and is an amazing place. There were 3 rooms and we convinced the guy that 11 of us could squeeze in. We had lunch and booked for a boat ride to a nearby island. The fishermen take tourists on boat rides for some extra money. We saw a couple of crabs and other sea creatures in the island and we swam (most of them with the help of floating jackets) in the Arabian Sea. After the boat ride we continued to swim and went pretty deep inside. It was fun with the wonderful sun set in the background. Finally, when I was getting out of the beach, I lost a golden ring that was gifted to me by my father. After playing poker for 2 consecutive nights, we left the resort and left to Murudeshwar. Murudeshwar is 50 km from Maravanthe. It has an awesome Shiva statue and a huge gopura on a small hillock right by the sea. The sight is breath taking. Murudeshwar is commercialized and is heavily crowded. As we dint find any accommodation there, we decided to try the water sports. Finally 5 of us (Ritesh, Sanchit, Swami, Saurabh and me) decided to do Snorkeling. We were going to Nethrani Island which was 22 km from the shore. The speed boat ferried us 4km and Swami started freaking out. To tell truth, my legs were also a bit shaky. The guide told us their morning trip was brilliant and they had seen a shark. After comforting ourselves by saying that we will quickly get on the boat if we see a shark, we continued the ride. It was a no moon day and the sea was getting rougher and rougher and the ride was getting bumpier and bumpier. The guide told us that the sea had become to rough and it was risky to continue further. We headed back to the beach with mixed feelings, feeling happy that we didn’t have to jump into water which is 1 km deep and feeling sad that we couldn’t see the colorful fishes and coral reefs. We left Murudeshwar and checked for accommodation in Marvanthe. No rooms were empty. After a small part of the group started wining that they wanted to head back to Bangalore, we left for Bangalore after having dinner at Sharon’s in Kundapur. We reached Bangalore at 10 AM next day.

Quick facts:
Distance: Kundapur to Bangalore :450 km
Kunapur to Maravathe: 16 km
Maravanthe to Murudeshwar: 50 km

Route: Bangalore -> Shimoga -> Kundapur