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
/node-v0.4.8/build'
Build failed:  -> task failed (err #1): 
	{task: cxx_link node_main_4.o,node_4.o,node_buffer_4.o,
node_javascript_4.o,node_extensions_4.o,node_http_parser_4.o,
node_net_4.o,node_io_watcher_4.o,node_constants_4.o,node_cares_4.o,
node_events_4.o,node_file_4.o,node_signal_watcher_4.o,
node_stat_watcher_4.o,node_timer_4.o,node_script_4.o,
node_os_4.o,node_dtrace_4.o,node_string_4.o,node_stdio_4.o,
node_child_process_4.o,platform_darwin_4.o,node_crypto_4.o,
eio_1.o,http_parser_2.o,ev_1.o,ares_strcasecmp_1.o,ares_free_string_1.o,
ares_options_1.o,ares_send_1.o,ares_parse_txt_reply_1.o,
ares_parse_ptr_reply_1.o,ares_nowarn_1.o,ares_search_1.o,
ares_gethostbyname_1.o,ares_getsock_1.o,ares__timeval_1.o,
inet_ntop_1.o,ares_parse_a_reply_1.o,ares_getopt_1.o,
ares__close_sockets_1.o,ares_expand_string_1.o,
ares_destroy_1.o,ares_cancel_1.o,
ares_parse_aaaa_reply_1.o,ares_parse_ns_reply_1.o,
ares_version_1.o,ares__get_hostent_1.o,ares_writev_1.o,
ares_expand_name_1.o,ares_free_hostent_1.o,
ares_parse_mx_reply_1.o,ares_gethostbyaddr_1.o,
ares_query_1.o,ares_data_1.o,ares_init_1.o,
ares_fds_1.o,inet_net_pton_1.o,ares_strerror_1.o,bitncmp_1.o,
ares_getnameinfo_1.o,ares_library_init_1.o,ares_mkquery_1.o,
ares_process_1.o,windows_port_1.o,ares_parse_srv_reply_1.o,
ares_llist_1.o,ares_timeout_1.o,ares__read_line_1.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
Done

		
Advertisements

YUI 3

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
India
No: 08284 – 231585

Great Outdoor Island
0-98440-42152
0-94483-64152
http://www.thegreatoutdoorsindia.com/

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.

Sunday

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: , , ,