Sign API request using Postman pre-request scripts

When we are about to test a dynamic API request via Postman and realize that we need to pass a freshly generated signature in the headers, what do we generally do? For each request, we generate the signature using server-side code and copy-paste it in the headers. Sounds like a tedious job, doesn’t it? We faced a similar situation in our application where we had to pass a signature in the headers while testing an API. The signature was generated by encoding all the request parameters using the user's secret key. If any of the request parameters changed, we

Building Rails 5 application with Angular 5

This article shows the very basic application set up required to host a rails application with Angular 5 framework Angular - Is a modern javascript framework for building web application in javascript,html and type script(super script of javascript) Such kind of working will have two separate servers. One server will be hosting rails part and the second server will be hosting the angular part. The HTTP request raised will have a different origin header, than that of the server hosted, and hence the request will fail. A cross-origin HTTP request (CORS) is used when the request is raised

Scaling Enterprise SaaS Platform with Microservices

Spoiler Alert: This article is not about Microservices architecture or how microservices works. In this article, I will share what we have learned in scaling one of the large SaaS platform, our ongoing improvements and how Microservices architecture is playing a key role in scaling this SaaS platform. This SaaS Platform has experienced tremendous growth in the past 18 months. It has now become one of the leading CRMs in North America. Everyone’s definition of “scale” and “growth” can differ based on specific numbers or metric a company is targeting i.e. revenue, user base, or others. We are

Distributed indexing and searching with Apache SolrCloud

Since quite some time, we use Apache Solr in one of our project for indexing data to search it faster from Solr server instead of always searching it from main database and creating bottleneck. We use Sunspot gem which is ruby library for rails application to implement Apache solr. Recently we thought to implement Apache SolrCloud architecture in same application to manage our daily growing Solr data more efficiently with this powerful feature of Apache Solr. In brief, you can consider it as a another database where your data is indexed and stored as xml documents. You can query this

Hubspot CRM - how, what and benefits

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 in order to give you more insights about it - Closely monitoring user interactions with your

Rails i18n pluralization

Sometimes we need to show different text based on some count. Like for example: if box_count == 0 message = "No boxes present" elsif box_count == 1 message = "Only 1 box present" else message = "There are #{box_count} boxes" end You can refactor this to make use of i18n locales power. In en.yml you can do - en: boxes: message: zero: No boxes present one: Only 1 box present other: There are %{count} boxes And in view we can use: <%= t('boxes.message', count: 2) %>

Fragment caching and sweeping strategy

Rails provides three types of caching techniques: page caching action caching fragment caching The rails_guides_on_caching is the best place to know how it works. This article is to demonstrate fragment caching the Rails Way with various data-stores and clearing those cached fragments on ActiveRecord callbacks on CRUD operations. Rails ActiveSupport::Cache::Store is responsible to do all the read and write operations. 1. The setup By default caching is disabled in rails. You will find the following config commented out in production.rb # Use a different cache store in production # config.cache_store = :mem_cache_store You

Quick Tips for Programming

I thought to create a quick tip post which is kind of lesson learnt, so that every time I learn something can add here and which could help others too. These examples here are not something I have created to support the points which I have mentioned below. Whereas these are the real code snippets of a project. Where team has written code in this manner and given feedback to improve their code. So I thought it would be better if I write a Lesson learnt post which could help other to be aware of mistake they can make while

Example usage of Redis - LUA script in Rails

This topic is about using Redis and LUA script in Rails. Before proceeding, you may like to read [ Introduction to LUA script with Redis][1] Redis doesn't have any command to calculate total number of keys We'll use [zrangebyscore][2] to find number of members between index range. Instal [redis-rb][3] 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 => 1386933374 This is non-realistic data, may vary for you. Populate redis with Sorted Set > redis = Redis.new # initialize redis => # zadd -