Building Single Page Web Applications with Backbone.js, JaxRS, MongoDB, and OpenShift

Backbone.js is a mature, popular, and lightweight javascript library which aims to bring structure to your client-side code. The goal of backbone.js is to bring MVC, a software architecture pattern, to client side development.Actually, backbone.js is an MV framework where view is also responsible for controller logic as well. In this blog, we will build a simple social bookmarking application.

In brief, MVC is a programming design pattern for separating the different concerns of your application. The M corresponds to Model and is used to define domain object. The V corresponds to View and is responsible for display logic. Finally, the C corresponds to Controller and is responsible for user interactions and interactions between Views and Models.

You can find source code of the application here Backbone.js is used by Linkedin, Foursquare, Wunderkit, Groupon, etc to build complex applications. You can view the full list here.

Read full blog at

Best Practices For Horizontal Application Scaling

best practice is a technique or methodology that, through experience and research, has proven to reliably lead to superior results. In this blog post, I will talk about few best practices that I have learned over the years which might help you in designing scalable web applications.

But before we talk about scaling best practices, we should define the meaning of scalability. Most of the people confuse scalability with performance. Performance refers to the capability of a system to provide a certain response time. Scalability can be defined as ease with which a system or component can be modified to fit the problem area in such a way that the system can accommodate increased usage, increased datasets, and remains maintainable. A system can be performant but might not be scalable. For example, a web application can be very responsive and fast for 100 users and 1GB of data, but it will not be considered scalable if it can’t maintain the same speed with 100 times the data with 100 times the users. You achieve scalable architecture when you can handle more load by adding more of the same stuff. You want to be able to scale by throwing money at a problem which means throwing more boxes at a problem as you need them.

Read full blog at

How To Build Location-Aware Web Applications using HTML5 and MongoDB

We all use location aware applications in our day-to-day life. Applications like Foursquare, Facebook places, etc help us share our location (or places we visit) with our friends and family. Applications such as Google Local help us find out which businesses are near our current location. So, if we need a good coffee shop recommendation, we can ask Google Local to find us all the coffee shops near our location. This not only helps the customer, but also helps businesses reach the right audience and sell their products more effectively. It is a win-win situation for both consumers and businesses.

To build such an application , you need the geolocation of the user. According to Wikipedia, “Geolocation is the identification of the real-world geographic location of an object”. Until now, there was no standard way to find the location of a user in a web application. We could use an open source library like Google Gears to get the geo location of a user but this library is not under development anymore and should only be used with older browsers, which do not support W3C GeoLocation API. The W3C GeoLocation API is a specification that provides standard scripted access to geographical information associated with the hosting device. Geo Location support is not officially part of HTML 5 specification but people use it interchangeably and most commonly you will hear about GeoLocation APIs with respect to HTML5. This API provides an abstraction layer on top of how geolocation information of a user is gathered. All modern browsers support the GeoLocation API. The below table is taken from

Read full blog at

How To Enhance Location Aware Apps with Google’s Directions Service

In my previous blog post, I talked about how we can use HTML 5 GeoLocation capabilities to build location aware applications with JAXRS and MongoDB at the backend. Today, we will extend the LocalJobs application we built in that blog post with Google’s Direction Service. It is recommended that you first read my previous post and then continue with this blog entry. The Directions Web Service allows applications to obtain Driving, Bicycling, and Walking directions through an XML/JSON REST interface. All of the features of the Map API v3 Directions service are supported, including “avoid highways”, “avoid tolls”, and waypoint optimisation.To see the application in action, just go to Enter skills such as java , php , mongodb , etc. and press the “Find Jobs” button. The Browser will then ask you to allow the application to use your computer’s location. Click on “allow” and you will see results as shown below:

Read full blog at

How To Build Real-Time Location-Aware Applications using MongoDB , WebSockets , and HTML 5 GeoLocation API

One of the advantages of OpenShift or any other Platform as a Service is that it gives developers the power to turn their ideas into applications. As a developer, you are only concerned about writing code and the platform manages and scales the underlying infrastructure for you. I am also a developer and I love to write code.

A few days ago, I came up with a very simple idea to show messages in real-time on a map. A user posts a message via the application user interface, the application captures the user’s current location using an HTML5 Geo-location API, and then displays the message on a map. If another user posts a message from some other part of world, the first user will see that same message in real-time. As users start posting messages, they will see all of the messages appearing on the map.

Read full post at

How To Run Apache Tomcat 8 on OpenShift

OpenShift PaaS gives developers the ability to try out new unsupported frameworks, programming languages, and servers. Today, while learning about WebSockets I learned that the current development version of Apache Tomcat i.e. version 8, has support for JSR356. JSR356 provides standard Java API for WebSockets. Although Apache Tomcat 7 provides support for WebSockets, it uses its own proprietary API. So, in order to test the JSR356 standard based WebSockets support in Apache Tomcat 8, I decided to give it a try. However, rather than installing Apache Tomcat 8 on my local development machine, I decided to install it on OpenShift.

Read full post at

Load Twitter Page using JavaScript

Today I had to look at twitter page which was very long. Twitter load results when you reach the bottom of the page. And each time twitter load very few results so it was becoming very tiring to see page in one go. So, I decided to do this task programmatically using JavaScript. Open the chrome developer console and run these three lines.

function A(){console.log("Scrolling ...");window.scrollTo(0,document.body.scrollHeight)}

function B(){window.setInterval(A,1000)}


Download JDK 7 update 25 via wget

To download Oracle JDK 7 via wget run the following following command

$ wget --no-cookies --no-check-certificate  --header "Cookie:" ""

$  mv jdk-7u25-linux-x64.tar.gz\?AuthParam\=1372827196_48b20a1d74cd809579eb76e369de596b jdk-7u25.tar.gz