Setup MongoDB Sharding

mongodbSharding is the process of partitioning data across multiple servers using a shard key. It solves the problem with horizontal scaling. As the size of the data increases, a single machine may not be sufficient to store the data. With sharding, you add more machines to support data growth. If you are new to MongoDB then please read my previous post how to start mongoDB.

Sharding setup requires the following:

  • Mongodb Configuration server – this stores the cluster’s metadata
  • Mongos instance – connecting the config server(s)
  • Individual mongodb instances – these act as the shards.

Continue reading

Advertisements

Search Engine with PHP & Elasticsearch

elasticsearch-logo

In this tutorial, we’re going to take a look at Elasticsearch and how we can use it in PHP. ElasticSearch is an open-source and distributed search engine which is very much scalable. We can use it to perform fast full-text and other complex searches. It also includes a REST API which allows us to easily issue requests for creating, deleting, updating and retrieving of data. You can read about Elastic Search at: https://www.elastic.co/products/elasticsearch

Installing Elasticsearch

Download ElasticSearch from https://www.elastic.co/downloads/elasticsearch. This tutorial will assume you’re using a Windows environment. For Windows – it’s a Zip file – one can extract it into C:\elasticsearch-2.2.0\.
Continue reading

Getting Started with MongoDB

mongodbMongoDB is a cross-platform, document oriented database that provides, high performance, high availability, and easy scalability. MongoDB works on concept of collection and document.

Install MongoDB On Windows
To install the MongoDB on windows, first download the latest release of MongoDB from http://www.mongodb.org/downloads. Make sure you get correct version of MongoDB depending upon your windows version.

MongoDB need a folder (data directory) to store its data. By default, it will store in “C:\data\db”, create this folder manually. MongoDB won’t create it for you. You can also specify an alternate data directory with –dbpath option to mongod.exe, for example:
Continue reading

Creating an Android Application with PhoneGap

phonegap-logoPhoneGap is an open source mobile framework that enables you to create cross-platform apps that run on various mobile devices including iOS and Android. You write your web app in HTML, JavaScript and CSS, and PhoneGap helps you to turn it into native apps, most likely Android or iOS.

There are two ways to make your web app into an Android app using PhoneGap. One is a no-pain ultra easy way, and another way is a manual way using Cordova CLI with an Android SDK.

Option 1: Android Apps with PhoneGap Build

Using PhoneGap Build is absolutely painless. All you need to do is zip up your web app, upload it to Adobe PhoneGap Build cloud, and the service takes care everything for you. You don’t even need to download and set up SDK or emulators.

  • Write a web app
  • Zip it up
  • Upload the zip file to PhoneGap Build cloud. Click Ready to Build. Edit the name of the app and upload an app icon too.
  • Download the apk and install it on your phone

Option 2: Full Development with PhoneGap Cordova CLI

You can install Cordova command-line interface (CLI) tools and Android SDKs for full development with taking advantage of the plugins that enable for you to use hardware APIs, push notifications and more, and debugging.

Continue reading

Node.js for Beginners

nodejsNode.js – in simple words – is server-side JavaScript. It has been getting a lot of buzz these days. I should make it clear that I’m not an expert on Node.js. I decided to learn Node.js recently due to its increasing popularity. The programming industry moves incredibly fast and it’s dangerous to fall behind. Learning new languages is important because if you don’t you’re likely you’ll get left behind and out of a job.

Node.js is a server-side version of JavaScript. That means all the things all them cool things about JavaScript apply here. It also means if you’re already quite familiar with JavaScript you’re going to have a nice advantage.

Creating Hello World

Let’s create a hello world. First head over to http://www.nodejs.org and download node.js. When it’s installed and ready create a new JavaScript file with the following:
Continue reading

Calling RESTful Web Services in Android

androidWeb services make it easy for mobile devices to communicate with applications running on a web or application server. I am sharing how to implement an Android client for services implemented according to the REST approach. This tutorial shows how you send HTTP requests, parse JSON string responses and display the results in a ListActivity, showing a progress dialog while loading.

Already I have written a Restful web services using PHP and MySQL. You can refer here.

This file contain Asyncronous server request to get json data and parse that json data.
Continue reading

Status Bar Notification in Android

androidA notification is a message you can display as an icon at the top of the device which we call notification bar or status bar. The user can expand the notification bar and by selecting the notification the user can trigger another activity. In this tutorial we are going to see how to send Notifications with sound from your Android Application and open the Notification in a new Activity.

Creating Activity

The notification is sent when the button is clicked. It is initialised by the function startNotification(). We use NotificationCompat builder to create the notification. setContentTitle() is used to set the title message. setContentText() is used to set the notification message. setTicker() is is used to set the Alert message. setSmallIcon() is used to set a icon image for our Notification. setSound() is used to set sound for Notification. NotificationView.java is the result class which is Initialised, and it opens when the notification is clicked. build() is used to display the notification.

Continue reading