First hustle at Ruby Rampage

Ruby Rampage Experience! Excellent read.

Innocent Blogging

Ruby Rampage brings about a challenge of building an application within the time span of 48 hours. A challenge that galvanized me into participation. It was my first experience. As the competition approached, my levels of excitement and anxiety kept scaling up.; not because I was creating an application for the first time, but it was the first time I had a tight time constraint to build an entire end-to-end application.

Questions like “What could be built?”, “Who should I team up with?” started storming in my head. Right when I was trying to figure out my ways, one of my colleagues approached me with an opportunity to be the fourth member in their existing group of three “Rampagers”.  There you go – problem-1 solved! Now, it was time to tackle problem-2; What should we develop?

During a gift exchange event in our office, the idea of GIFT GALORE had…

View original post 641 more words

Posted in General | Leave a comment

Sending Multiple Push Notifications Simultaneously with Ionic framework

I am an experienced Web developer mostly working on Ruby on Rails, Mysql, Javascript, AngularJs. I was curious if this knowledge will be enough to help me in developing a native mobile app!

I Googled and found a few frameworks like Ionic, PhoneGap, Kendo UI, etc. that I could play around with. Using these frameworks, I assumed that I will become a “Mobile Developer”. But wait… using these frameworks will make one a Hybrid Mobile App Developer– which suits me just fine! 🙂 Of all the frameworks I was toying around with, I was impressed with Ionic because of good documentation and availability of lots of plugins.

After starting development in Ionic, everything was going smoothly until I hit the requirement to integrate Push notifications! I checked for an Ionic plugin for Push Notifications. I found phonegap-plugin-push which is well documented but has some glitches. I shall discuss these below to save others from the issues I faced.

Associating a page to a notification

Usually, on receiving a mobile notification, tapping on it should open the screen of  the relevant app. Though this is a basic need for any mobile app, the documentation for phonegap-plugin-push plugin did not mention anything about it. Even after spending a few hours reading through various posts and articles, I did not find any solution. I was quite surprised! Finally, I decided to resolve this myself. The web developer in me triggered a thought of trying it the AngularJS way because the requirement was similar to redirect to page.

Maybe, this is the way to do this in Ionic but I haven’t found any documentation on this. If you know of some better way, please educate everyone by commenting on this post. Nevertheless, I am putting down my way in this blog. Lets get started.

In the section below, I am going to explain how to setup push notifications and then how to open the respective page after clicking the Notification.


$ cordova plugin add phonegap-plugin-push --variable SENDER_ID="XXXXXXX"
  • SENDER_ID is your Project Number in the Google Developer Console. Please check the installation step here.

After installation and configuring the SENDER_ID, we can use PushNotification.init()

Below is my app.js code added in $ionicPlatform.ready(). The method reads the deviceID and sends it to the server every time the application is launched. Now, the registered mobile is ready to received push notifications.

var push = PushNotification.init({
   android: {
   senderID: SENDER_ID,
   forceShow: true
 ios: {
   alert: 'true';,
   badge: 'true';,
   sound: 'true';
 windows: {}

push.on('registration', function(data) {
   // you need to send this registrationId to server 
   // to store to send push notification and require 
   // for to generate ARN
   // I am storing this Id in $rootScope and sending 
   // to server after login

push.on('error', function(e) {
 // e.message

In push.on(‘notification’, function(data) {}) , we open the relevant page on notification click.

push.on('notification', function(data) {
  switch (data.count) {
    case 'records':
      $state.go('dashboard.index', {file: data.additionalData.file});
    case 'handouts':
      $state.go('dashboard.records', {activeTabIndex: 1, file: data.additionalData.file});
    case 'vaccinations':

On receiving the notification, push.on(‘notification’, callback) will be executed. In callback you get data parameters. Here  is list of callback parameters.

I am passing data.count value and using that value, we  open the required page.

In above example, check case 2 – I am passing extra parameter that opens the relevant.

Sending Multiple Push Notification Simultaneously On Mobile

In one more scenario, I had to simultaneously send more than one push notification to user. This adds a little more complexity if the user has installed the app on more than one device (mobiles).

The problem is that if more than 1 notification is generated by the server at the same time, then notifications randomly get dropped (Basically not all were delivered to the mobile).

The solution is to pass the data.notId parameter in the values as an integer and for each notification and  it should always be incremented 😉

This may seem trivial for seasoned Ionic developers, but for a newbie it could be a nightmare.

Hope this blog may help to save few hours.

Posted in Javascript, Mobile Development | Tagged , | Leave a comment

Design Patterns used in mina gem

How often do we look inside a Gem to see what’s inside it? Well – there is SO MUCH to learn from the code. Sanjiv digs inside the Mina gem and unearths the various design patterns that it uses.

An excellent article for developers to learn design patterns not from the book but directly from the implementation. It’s always easy to relate to something concrete that just read about it.


Mina is popular gem for fast deployment of simple ruby on rails apps. I found these design patterns being used in mina and we can learn how to use them from these real live implementations.

  1. Singleton Design Pattern.
  2. Delegation Pattern

If you are unfamiliar with Design patterns, I strongly recommend reading  Gang Of Four’s Design Pattern book. You can also have a quick wiki reference.

Singleton Design Pattern

In simple terms, Singleton design pattern mean there should be single instance of class, hence mostly used to provided global state of app.

The Singleton module implements the Singleton pattern. We include this module in a class for implementing singleton pattern. Mina gem uses the singleton pattern for storing configuration options to accessed data globally.  Here is the code from `lib/mina/configuration.rb`

1: require 'singleton' 2: module Mina 3: class Configuration 4: include Singleton 5: 6: module DSL 7: def self.included(base) 8: [:set, :fetch, :remove, :set?, :ensure!…

View original post 570 more words

Posted in General | Leave a comment

Pro-tip: Scaling properly with Nginx worker_process and max_pool_size

Sometimes, it the things around us that work but need to be configured properly to scale up. Nginx configuration are just like that.

Shweta talks about her experience with scaling up performance by tweaking the nginx parameters to improve API performance drastically.

Learn with fun

This post talks about worker_process and passenger_max_pool_size options for nginx and how these configurations play an important role for scalability.

Recently our client reported that API performance was  bad and it was taking a few minutes to respond! But, when we tested this API this was quite efficient and was responding in few milliseconds. What was wrong? As the number of users increased, the number of concurrent requests to the server had also increased. Initially, it was only 100’s of request per second coming to a server but now it was about 4 k requests per second and we realised that we had not scaled our server to handle this load.

When this problem arrived I thought of breaking down the problem in steps.

  • First I checked RDS instance. It was using 20%
  • I revisited all queries they were optimized enough. So database was not bottleneck
  • Sent unauthorized request to the server so with less processing…

View original post 578 more words

Posted in General | Leave a comment

Using SVG to draw graphs easily and fast!

So often we look for the simple way out. For example, to generate graphs, we search for the best possible libraries and make the front-end un-necessarily heavy. Sometimes, we need to think out of the box and can use SVG to create simple graphs.

Anuja talks exactly about how they used SVG to create simple line and bar charts in their light-weight mobile friendly application.

Fun To Learn

Do you want to draw a graph in HTML? Are you a backend developer and not a UI developer? How will you go with this? You will surely search for some available library to draw a graph even if graphs are simple. In our project, we also have simple bar and line graphs for weekly and monthly tracking respectively. Initially our UI team designed bar graphs. As is often the case, after few days there was a requirement of line graphs.

I was worried about timelines. We had an option to ask UI team to give us the static graph and integrate the API. But we would need to explain them the requirement in detail and the design. This process seem too time consuming. So I thought, that instead of wasting time in that, it would be better to work on this and learn something new. So I decided to work on this new…

View original post 601 more words

Posted in General | Leave a comment

Searching on steroids

ElasticSearch is one of the popular Search Indexing engines today. Yogesh takes us on an interesting tutorial for integrating ElasticSearch into a Rails app – right from the initial thought-process till execution and performance.

Happy Coding !!!

There are plenty of indexing/search servers available out there like Solr, Sphinx, ElasticsearchGoogle Search Appliance and many more.

But out of all the above, Elasticsearch is gaining more attention to it because of it’s popularity. This post is going to tell you only about it and it’s integration in Rails.

So, how would someone describe what an Elasticsearch is ?

From God’s perspective, it’s an open source, distributed, RESTful, search engine i.e. it has a very advanced distributed model, speaks JSON natively, and exposes many advanced search features, all seamlessly expressed through JSON DSL and REST API’s.

♦ Inception

Standard way of using ES in any application is to use it as a secondary data store i.e. data will be stored in some kind of SQL/NoSQL database and then continuously upserting required documents from it into ES, pretty neat.

Some of us might think why not use database itself…

View original post 1,116 more words

Posted in General | Leave a comment

Houston, we got attacked

Yogesh talks about configuring and securing your Redis server to avoid attacks. Voice of experience rules!

Happy Coding !!!

Houston, you there ?? We’ve had a problem here.

One of our EC2 instance which has Redis server on it, got hacked out of nowhere.
Just before we knew it is hacked, we were screwing up with Redis configuration and thinking what could go wrong with it.

Houston – Roger that, give us more details.

Well, we’ve recently shifted our Redis server to new EC2 instance. The reason we had to do that was because, our Sidekiq processing got much bigger and we couldn’t afford it alongside the Nginx + Passenger. So we took a call to separate it out.

But while configuring Redis, we think we made some mistake :(.

Houston – What is that ?

Basically, we wanted the Redis to listen to all of our Passenger instances . Though by default, it listens on localhost because it’s  bind directive is set to , it’s possible to listen on multiple interfaces by providing multiple IP…

View original post 355 more words

Posted in General | Leave a comment