Archive for the ‘Technology’ Category

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


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 –

Categories: General, Technology

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.

Talk in MSRIT

September 5, 2009 Leave a comment

(The blog is on YDN also.

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 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=’’
4. Read from a HTML page
select * from html where url=’’ 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

The documentation can be found at