Behind the scenes of hash table performance in ruby 2.4

Behind the scenes of hash table performance in ruby 2.4

Bookmark and Share

Ruby 2.4 got released this Christmas with a lot of exciting features. One of the most underrated features in ruby 2.4 is hash table improvements. Before going into details about implementation, let’s first check the benchmark to know how this change gonna affect your ruby application.

Some benchmarks are:

Getting keys and values of a hash


Ruby 2.3.3


ruby 2.4.0

Yeah, the above two operations executed ~ 3 times faster on my laptop. Though these numbers can vary with your machine and processor, the performance improvements will be significant on all modern processors. Not all operations became 3 times faster , average perfomence improvement is more than 50%

If you are a ruby developer and excited to know what are the new features in ruby 2.4, then this feature gonna make your application faster and you don’t have to change anything in the code for that. Because these changes are backward compatible. If you are curious to know what happened behind the scenes of this performance boost, then continue reading.

Hash Table

In computing, hash table (hash map) is a data structure that is used to implement an associative array, a structure that can map keys to values. Hash table …

Read More

How to format Git log for meaningful information

Bookmark and Share

Git is a wonderful piece of software that makes life easier and more productive for a programmer. But sadly most developers don’t use it up to their full potential so we are going to blog about various simple and advanced usages of git as a series. In the first article of the series, we are going to talk about git logs.

Git log is a great feature, that allows us to keep track of our works. There are different options available under git log command, which help us to customize the output of git log and also to filter the log.

Git Graphs

The –graph option draws a graph representing the branches and its structure of commit history. –oneline is used to display commit message and its hash in a single line, which is used along with –decorate, which helps us to easily see which commit belongs to which branch.

Custom formatting

This lets you display each commit however you want in printf style. For example %cn,  %h and %cd which represents committer name, abbreviated hash and committer date respectively.

Filtering the output

Git log can be filtered by different filters and format output

By amount

It displays latest n commits and …

Read More
Kochi : Truly the Queen of the Arabian Sea

Kochi : Truly the Queen of the Arabian Sea

Bookmark and Share

Before you set afoot on the land known as the “God’s Own Country”, you can see lush greenery covering up the suburb developed structures and providing that much needed fresh air to breathe. Kochi is a coastal city built on the ethos of communal integrity, cultural unity & truly to love nature. While under the colonial rule of the British Empire, they had laid the foundation on which Kochi is standing today.

Kochi is the Business Capital of Kerala and home to more than 2.1 million people. It is a rapidly developing metropolitan city and is one of the selected cities to be developed as a Smart City under the Smart Cities Mission of Government of India.

It also home to Kerala’s ever growing IT/ITES Industry, Infopark – an IT park developed by the Government of Kerala. Recently, World Trade Center opened its splendid office spaces here. Special Economic Zone for hardware manufacturing, Oil Refinery with a capacity of refining 9.5 million metric tons per annum to name few achievements. Kochi has a sprawling blend of industries.

While you are at Cochin a.k.a Kochi to attend Ruby Conf India 2017 we just felt it would be …

Read More

Chartkick: data visualization made easy with Ruby

Bookmark and Share

Recently, I’ve been using Highcharts, Google charts and Chart Js for visualizing dynamic data in my projects. But it was difficult to integrate it with the rails application. However, for every problem in Ruby, there is a gem out there to save your day and Chartkick, a Ruby gem exclusively available for data visualization is truly a savior. Chartkick can work with Highcharts, Chart.js and Google charts to create dynamic and interactive charts that draw data from the Rails application. And the best part, you just need to write one single line of Ruby code. Isn’t that amazing and powerful!

Let’s begin with Installation

For installation, all you have to do is adding this line to your application’s Gemfile:

Then you have to choose your charting library.
In case, if more than one charting library is loaded, choose between them with the following code:

P.S:- highcharts is the default adapter is nothing else is defined.

Using Chartkick

Once it’s installed, you can start playing around with chartkick. For example:

In the above example, I have just shown you how we can make a line chart.Similarly, you can create Pie chart, Column chart, Bar chart, Area chart, Scatter chart, Geo charts, Timeline(Google …

Read More

How to write your own Rack middleware

Bookmark and Share

How to write your own Rack middleware

Rack is a Ruby package which provides an interface for a web server to communicate with the application. It is very easy to add middleware components between the web server and the app to customize the way your request/response behaves. The middleware component sits between the client and the server, processing inbound requests and outbound responses. Rack Middleware is an implementation of the pipeline design pattern for web servers using Rack.

For example with Rack, we can have separate stages of the pipeline:

  • Authentication: Checks whether the login details are correct or not when the request arrives.
  • Authorization:  It performs role-based security. i.e. checks whether the user is authorized to perform the particular task.
  • Caching: Return a cached result if the request is already processed.
  • Decoration: Enhance the request to make downstream processing better.
  • Performance & Usage Monitoring: Status get from the request and response.
  • Execution: actually handle the request and provide a response.

Next, we will see how to build our own rack middleware.

Building your own …

Read More