Although nowadays we have Email, SMS services integrated in most of web applications, sometimes there could be need of documentation for future reference which users may want to reuse later based on their need. Similar requirement we had in one of our web application where we wanted to provide option to user to generate single or bulk PDF files out of any HTML templates they have in their account. There was different features around the generation of PDF document but major work was involved in…

Read complete blog post

In my previous post, we discussed how we were able to sync our files and folders with Google Drive. You can refer the post here - Once we were done with the sync setup - next step is to ensure sync was accurate and timely i.e changes made in our application are accessed instantly in Google and more important changes made in Google are available in our application. We needed this without an impact on the…

Read complete blog post

This is a one of the part of some of articles I wanted to publish for the things I learned or had less of web content when we were integrating a feature for Google Drive Folder Sync. Basic goal was to connect a Google Drive Folder and upload files from our app to Google and vice-versa. In this article we want to focus mainly on the uploads from our application.

Why do we need the Pre Generated Id for Files?

We are using Google Drive API V3 for this feature -

Read complete blog post

In the previous article, we have seen how to configure DigitalOcean Droplet. Now let's proceed further to set up our application repository and Ngnix with Phusion Passenger on the DigitalOcean droplet.

1. Install RVM and Ruby

We will install ruby using Ruby Version Manager(RVM) as it gives more flexibility to manage multiple ruby versions on the same system over rbenv, chruby, etc. Import RVM GPG key, before installing RVM:

gpg --keyserver hkp:// --recv-keys

Read complete blog post

String encoding is something that we don't really think until we see

     Encoding::CompatibilityError: incompatible character encodings: UTF-8 and ASCII-8BIT 

Or when users complains about missing special characters like "" (apostrophe copied from Microsoft Word) or when "菜医生" becomes "иЏњеЊ»з”џ".

Before we go into encoding problems, lets understand what encoding is.

A string can be considered as an array of bytes:

irb(main):001:0> "world".bytes
=> [119, 111, 114, 108, 100]

Here 119 me…

Read complete blog post

Recently while working on one of our project we came across requirement where we wanted Hubspot integration with our application for ease of sales team to manage user's data and understand their interactions and trends in application. I will quickly explain few things about Hubspot here in my article.

What is Hubspot?

In brief, Hubspot is a CRM which helps you monitor and fine tune many things regarding your application. Based on my analysis I will shortly list down few most important of them…

Read complete blog post

In software development you are destined to deal with lots of code that is not written by you. What would be more stressful than debugging the code that you barely understand. You might have been in the situation where you have been assigned a bug and you have to traverse through lots of file which you have no idea of, just get to root cause of the issue. Being in these situations many times, I have learned few tips and tricks for debugging and would like to share it here.

Checking where the

Read complete blog post

A regular expression is a pattern describing a certain amount of text and is a type of shorthand to describe a search pattern. It can be used to find text which matches a pattern within a larger text, to replace the matching text or to split the matching text into groups. Regular expressions power of extracting specific text from documents resides in their ability to replace many lines of code with as little as one line.

Some terms used in regular expressions:

  1. Literal - A literal is any…

Read complete blog post

Ruby is too dynamic. We can do almost anything in runtime, from creating the classes at runtime to creating methods dynamically.

If you are coming from some other language, it would be shocking for you too know that nothing is private in ruby. You can access private and protected method from anywhere you want.

You can call this a flexibility or a curse. But a smart developer knows when to utilize the power of extreme flexibility that Ruby provides and when to stay away from it.

Is this all…

Read complete blog post

What is Lazy Enumerator

Ruby 2.0 lazy enumerator allows you to iterate over infinite values and take the values you want for your calculation.This code would result in an infinite loop.

range = 1..Float::Infinity
range.collect { |x| x*x  }.first(10)

The code results in an infinite loop because the Enumerable#collect is eager.It means that first collect processes all the values from the first array and then save it in the second array.Since we have an infinite range here first method would…

Read complete blog post

Ruby Comments

There are basically two types of comments in Ruby. And they work in the same way as follows:

The block comment

The comment block is created with the =begin and =end delimiters.

def welcome
    This will print the welcome message.
    You can also add your custom message.
  puts "Welcome to ruby comments learning :)"

The line comment

This is the simple comment where you place an octothorpe(#) as the first non-whitespace character of the line, and…

Read complete blog post

Few weeks back I was reading a blog about concurrency limitations in Ruby (which we all are aware since long) and how Elixir is evolving. Thus I was extremely curious to know this new dynamic functional programming language "Elixir", the two decades old Erlang language & Erlang Virtual Machine (VM) known for running low-latency, distributed and fault-tolerant systems. This article is a result of my curiosity about Elixir and Erlang.

This article does not cover (i.e. out of scope) installation…

Read complete blog post

This is very useful Ruby command to share your local folder with everyone on the same network.

Thanks to Rohan! As we were working on something and he wanted me to share my local folder quickly.

Rohan shared this Ruby command with me and since then every now and then I am using it in office to share stuff with teams. Command is:

ruby -rwebrick -e '>PORT_NUMBER,:DocumentRoot=>”DIRECTORY_PATH").start'
  ruby -rwebrick -e

Read complete blog post

If you have an application which creates notes, learning how to integrate evernote to sync notes will be very handy.

You may refer this ruby gem - evernote_oauth which has useful methods to access your existing evernote notebooks, create notebooks and notes, etc. The gem is well documented.

Refer this blog to understand and see code to create note on evernote - Create Note on Evernote

If you refer the code in the above blog to create a note - just this particular snippet -

n_body = "<?xml…

Read complete blog post

In our current app, there was a requirement to have a nice editor which will provide the basic functionalities like bold,italic and also image upload We decided to use redactor-rails gem Github-Documentation-Link(Github Doc) .

So i took following steps:

  • In Gemfile i included:
gem 'redactor-rails'
  • Then for image uploading and storing i included two more gems as:
gem 'carrierwave'
gem 'mini_magik'
  • Bundle it.
rails generate redactor:install
rails generate redactor:config
  • In…

Read complete blog post

If you want to send any notification message from your rails application, its easy to send it with following steps:

1) To send notification to your flowdock group, you will need email-address of flowdock grouYou can get it from flow-settings of your group.

example: "[email protected]"

2) In your application, define mailer class and send email-message to above email.

class UserMailer < ActionMailer::Base
  default from: "[email protected]"

  def flowdock_notification(post)

Read complete blog post

Apipie-rails is a DSL and Rails engine for documenting you RESTful API. Instead of traditional use of #comments, Apipie lets you "describe the code by code". This brings advantages like:

  • It uses ruby syntax
  • Reusable doc for other purposes (Best for validations)
  • Easier to extend and maintain

apipie-rails gem owner has documented it in very nice way with examples. Refer Github Documentaion(github doc)

Path to documentation:

The documentation is available right in your app (by default…

Read complete blog post

Code Review

Hello Everyone, I have reviewed a codebase of one of our projects. It was a good experience.

Few good things.

1) Really clean code.
2) Small methods.
3) I had to travel 5 months back commits to find some bad code. :)

Things to improve on:

1) Found less specs, But it is possible that specs have been covered already.

Overall Thoughts:

The code is super clean, liked it!. fantabulous work folks!


1) Code:


This can be…

Read complete blog post

In one of the projects(ACES), we came across a functionality: to parse huge(50mb+) XML files. Here efficiency was very critical piece, as file size was huge. Also we wanted the results of parsing quickly for further analysis so the effective time was less and application performance was unhampered.

We chose SAX Parsing Technique(DOM vs SAX)

There are two ways to parse an xml file, DOM and SAX. SAX being more efficient as it process the xml file incrementally, thereby memory utilization is…

Read complete blog post

This topic is about using Redis and LUA script in Rails.

Before proceeding, you may like to read Introduction to LUA script with Redis

Redis doesn't have any command to calculate total number of keys

We'll use zrangebyscore to find number of members between index range.

Instal redis-rb

Start rails console

Prepare a dataset based on timestamp

 > t10 = 10.minutes.ago
=> 1386935151
> t20 = 20.minutes.ago
=> 1386934568
> t30 = 30.minutes.ago
=> 1386933971
> t40 = 40.minutes.ago

Read complete blog post