E8a35961cc9ac2aca01c3a173f5c8d4a
About Rohan Daxini
Ruby, Elixir & C lover | Life Long Learner | Founder at Kiprosh | CTO at Realvolve. My favourite quote these days - "Keeping mind happy makes work effortless. This is the skill for productivity."
All blog articles by Rohan Daxini

enter image description here

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...

Read complete blog post

One of the coolest feature I came across in Elixir - our code documentation becomes our unit tests. I was amazed by its simplicity when I saw it in action in sample app I was writing. I feel this is one of the most incredibly and helpful feature I saw in any modern programming language in recent times. (Python has similar functionality using Python’s doctest.)

Let me explain this by giving a quick demo using few simple examples: Math functions sum and multiply.

Lets say this is our Maths...

Read complete blog post

E8a35961cc9ac2aca01c3a173f5c8d4a
Rohan Daxini

Here are few Rails and general developer tips & tricks to

  • improve code readability
  • do things Rails way
  • improve productivity

They say "Good code is like a good joke: It needs no explanation".


1) idiomatic code

Instead of this code...

def delete(notes)
 notes = notes.where('notes.from = (?)', 'evernote')
 notes.any? && notes.map(&:destroy)
end

Better way is...

def delete(notes)
 notes.where('notes.from = (?)',...

Read complete blog post

We recently upgraded one of our app to Ruby 2.2.2

Bundle installed failed ...... crying about well known issue of Error installing gem with native extension, but this time for Gem json -v 1.8.3

Detailed error shows

Fetching: json-1.8.3.gem (100%)
Building native extensions. This could take a while...
ERROR: Error installing json:
 ERROR: Failed to build gem native extension.

 /usr/local/rvm/rubies/ruby-2.2.2/bin/ruby -r ./siteconf20151209-13741-vqcxt1.rb...

Read complete blog post

E8a35961cc9ac2aca01c3a173f5c8d4a
Rohan Daxini

Recently I started learning React.js and developed this sample ToDo list App fully in React.js

Here is my github repo for this ToDo app.

The app has basic ToDo functionality to add new todo, edit (inline), delete a todo item, drag & drop to sort or change order.....without any backend to keep things simple for now. Its vanilla html css react.js and jQuery. I have used jQuery plugin jquery-editable for inline text editing of todo.

Rohan Pujari helped me to fix couple of bugs along with...

Read complete blog post

Few days back, we were facing problem establishing communication between a Webview control and a Titanium UI or vice versa.

We were integrating Facebook authentication in our Titanium mobile app using Titanium Facebook mobule where we stumbled upon this issue. We wanted to trigger FB Auth Titanium module specific code on click of an HTML Login button tied with a jQuery click event. The FB auth module checks if Facebook mobile app is installed on the device and opens this mobile app for...

Read complete blog post

Rails has provision to provide order of indexing on a column for better performance of like queries. The varchar_pattern_ops improves the performance of like queries by 4x.

For example, lets have this like query on name column (that has sequential index.)

Select * from users where name like 'John%'

We might have added a regular Rails index in migration for this name column as

add_index :users, :name - This will generate a sequential index.

The same can be made 4 times faster using btree index...

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)...

Read complete blog post

E8a35961cc9ac2aca01c3a173f5c8d4a
Rohan Daxini

How do we customise Titlebar in ActiveAdmin show view? For example, in the attached screenshot, I have breadcrumb as Admin / Orders / Order #11834 in my show view. Instead of that I want to customise it and display it just as "Admin / Orders / Order# 43872378123 & Transaction# MwlDdTc3RW" or just "Admin / Orders / Transaction# MwlDdTc3RW".

Its fairly easy,

In app/admin/order.rb

show title: proc{ |order|
 order.transaction_number.present? ? 
 "Transaction#...

Read complete blog post

We have integrated Chargify for one of our application. Recently we observed that few of our test users, that are more than 6 months old, are unable to login in our staging site, which is connected to Chargify TEST Mode.

We noticed that auto cancellations are happening (once a day) for these users in their Chargify subscription records. This was strange behaviour, we thought either this is happening due to our "Dunning" settings or due to "unpaid" state changes for credit card expiry. After...

Read complete blog post

If you are using Sidetiq to set recurrence to schedule background jobs, then you may want to be aware of this known and reported issue with 'recurrence'. (btw, recurrence schedule is done using ice_cube gem)

This is likely an issue in Ruby 1.9.3 but I have posted comments on this article here Link to SO question(http://stackoverflow.com/questions/20936305/sidekiq-sidetiq-recurrence-every-2-hours) along with git issue to clarify if its an issue with Ruby 2.0 and above. References at the bottom...

Read complete blog post

On your MAC OSx, if you have upgraded to latest Ruby 2.1.5 (or even 2.1.2) then there are high chances that you will face issues installing "nokogiri" gem. You might face errors like

ERROR: Failed to build gem native extension.

Following are the steps to resolve these issues on your Mac OSx

1) brew install libxml2

2) Read complete error dump on console while you do "bundle" or "bundle install". You would notice that there are useful tips to fix this on your PC, example

for Building Nokogiri...

Read complete blog post

This post is an extension of Abhijit's article here - http://kiprosh.com/blog/180(Customizing Devise authentication, to disable or enable user authentication.) It helped me to add further customization to check if user has active chargify_subscription and then only proceed to login otherwise show custom message instead of default devise message.

Here is what we did (2 step process).

1) In our user model (specifically user_extensions) override devise method active_for_authentication as follows...

Read complete blog post

Title: Issue installing gem 'eventmachine' while Migrating to Ruby 2.2.0 (specifically on OSX 10.10.1 Yosemite and XCode 6.1.1)

On my MAC, having OSX 10.10.1 Yosemite and XCode 6.1.1 (a recent upgrade), I faced couple of critical problems while migrating one of our app to latest Ruby 2.2.0

The bundler would scream for gem "eventmachine" version 1.0.3 or 1.0.4 installation. Errors such as these would terminate/halt bundler to carry out gems installation process on local - Failed to build gem...

Read complete blog post

E8a35961cc9ac2aca01c3a173f5c8d4a
Rohan Daxini

Recently, in one of our in-house app, we faced issues with RSolr that failed all our builds in CircleCI.

We faced following RSolr specific errors in our CircleCI builds for the repo.

RSolr::Error::Http:
RSolr::Error::Http - 500 Internal Server Error
Error: Severe errors in solr configuration.

Check your log files for more detailed information on what may be wrong.

If you want solr to continue after configuration errors, change:

...

Read complete blog post

Recently we had a bug in Knowbuddy app where search was not able to find anything based on sub keywords or sub text.

Example - Lets say we have an article that has keyword "dedicated" in subject or body or in tags. Now if we try to search using keywords say | cat | cate | ted | dedi | dicat | dedi | then outcome was zero search results.

This issue was due to the way indexing was done along with missing query configuration in Solr . We fixed the indexing and seaching conf in...

Read complete blog post

Following is an handy list of frequently used Linux (Ubuntu flavour) console commands

Find Files

find . -name '*.cnf'
find . -name 'hello.workd'

The dot here represents all files and folders in current path

Mysql DUMP - Import and Export

1) Export

mysqldump -u username -p database_name  file_name_to_save.sql

2) Import

mysql -u username -p database_name < filename.sql

Install LAMP on Ubuntu

sudo apt-get install tasksel
sudo tasksel
sudo tasksel install lamp-server

Install Apache2 on...

< filename.sql

Read complete blog post

(Please note that the below mentioned steps and troubleshooting is not for Heroku. These are specifically for dedicated servers, VPS etc.)

Following are the steps to debug, troubleshoot and fix commonly faced Sidekiq and Redis related issues in RoR app.

1. Firstly, make sure Sidekiq URL is working.

URL - http://staging.app.com/sidekiq

In case if the app has restricted access to Sidekiq web url then we need to login as admin user to view sidekiq web administrator page.

2. If this url shows...

Read complete blog post

Lets say we need to benchmark and evaluate the performance of code snippet.

This is how we can easily do on Rails console using "Benchmark.ms"

1.9.3-p392 :001  Benchmark.ms do
1.9.3-p392 :002  "john mark McMillan".split(" ").collect{|word|word[0] = word[0].upcase; word}.join(" ")
1.9.3-p392 :003? end
 = 0.015000000000000001 
1.9.3-p392 :004  Benchmark.ms do
1.9.3-p392 :005  "john mark McMillan".gsub(/\b\w/) { |w| w.upcase }
1.9.3-p392 :006? end
 =...

Read complete blog post

Sharing tips that hopefully will help you in your respective projects / engagements or daily work to become an "effective , good and valued" Software Craftsmen.

By the way, this is not copy pasted from some external blog or posts. I have jotted this down for all of you with the hope and belief that it helps you professionally as well as personally, the way its helping me immensely. Please feel free to send me your tips that helps you become a better craftsmen and I would love to share those...

Read complete blog post