ProTips: Elastic Search & Rails

Learn with fun

In this blog post I am not going to tell you about how to setup elasticsearch with Rails. There are plenty of blog posts available for that. I referred this blog post to begin with elastic search and rails.

In this blog post, I will be showing how to set “ignore malformed” option. This may sound trivial but unfortunately the usage is neither in the ES-rails documentation nor I could find any content on the web.

I spent a few hours digging in the ES-rails code and finally deciphered it. Hope this helps you save the time.

Problem

Recently we started using elastic search in our project. One of the table had around 9 Million records. After configurations/setting we started the indexing. Monitored a few thousand records and indexes were correctly getting generated. However, at the end found out that the indexing of 5k records failed.  I was puzzled, why only…

View original post 566 more words

Posted in General | Leave a comment

SQLite storage in Ionic 2

Tech Blog

In my last blog I promised to provide step by step guide to implement on phone storage. The main purpose of storing data on phone (offline support) is to reduce load time and optmize the downloads.

In this blog I am sharing my experience on how to use storage with Ionic 2.

There are different ways of integrating storage with Ionic 2 app. I was considering two options, 1) use local-storage which is collection of key-value pairs within application or 2) use SQLite database. I chose SQLite database. The reason being,  local storage has key value structure, its hard to query large amount of data, plus it has limitation of 10 MB data.

There are few other blogs, but I found them little convoluted. So, I tried to simplify steps. Let’s see, step by step procedure.

Step 1: Basic Installation

Install latest version of Ionic and Cordova by –

Step 2: Start…

View original post 550 more words

Posted in General | Leave a comment

RoR Tips & Tricks Series – #2

Tip : count is incorrect if used with limit in mongoid

Database : Mongodb

1.
campaigns = Campaign.all
campaigns.count
=> 211943

2.
campaigns = Campaign.limit(1000)
campaigns.count
=> 211943

campaigns[1001]
=> nil

I was expecting count as 1000 for second query, but it came out to be same as first one. But actual objects stored in campaigns array are 1000 as it gives nil for 1001st index.

I spend quite some time while writing program to figure out this. I don’t have answer to this. This works correct if your database is mysql or postgres.

Someone may give answer to this and someone will save time in figuring it out.

Posted in General | Leave a comment

Sidekiq “reliable_fetch”​, not so reliable! Well sometimes…

Rails development and Sidekiq go hand in hand. One or the other time you must have gone into problem where jobs go missing. Wondering why?
Sahil explains!!

Let's make learning fun!

Recently, in one of my projects, I came across a situation wherein I was required to parse a CSV uploaded by the end user. For performance reasons, I choose to create a new Sidekiq worker for each row in my CSV. All these rows (workers) were running in parallel (standard Sidekiq behaviour). I wanted to execute some logic ONLY after all rows (workers) had finished processing. Sidekiq Pro let’s you do this by creating a batch of workers. Sidekiq has a Batch API that provides success and failure callbacks for such scenarios.

Everything was working well in development and staging environment. Until a day when a customer reported that he is not receiving success/failure report for his jobs. I tried to reproduce the scenario described by the user but, couldn’t. Not even for the same customer account. But, then I was able to reproduce it and again I couldn’t.

Confused???…

View original post 529 more words

Posted in General | Leave a comment

Ionic 2 : Issues and Challenges

In the tech world you always want to be upto date and when a new version of a framework or library is released you tend to & want to upgrade. We also did the same by upgrading our Ionic 1 app to Ionic 2. But it turned out to be very challenging. Nougat just made it even more cumbersome. Swati talk about the challenges/issues and solutions.

Tech Blog

In my last blog we have seen the key benefits of Ionic 2. It includes speedup factor, organized directory structure, easy navigation, generator commands, set of native API and support for cross platform.

However, if you are thinking of migrating from Ionic 1 to Ionic 2, you may face different challenges or issues. You may either find ready solutions to these or you may have to implement solution yourself. I have successfully upgraded my project and hence would like to share my experience, with the issues I faced, and the way I solved these. Hope it will help. Lets see the issues one by one :

Handle Hardware Back Button

Many times we stuck at particular problem, trying to find solution. But unfortunately we do not get anything. Same thing happened with me. I was trying to handle hardware back button manually with the help of method provided by Ionic 2 :

But the problem was, whenever…

View original post 1,085 more words

Posted in General | Leave a comment

Benefits of Ionic 2

Ionic is world’s most popular cross platform mobile development technology. Recently Ionic2 was released. Swati takes us on an interesting tutorial to understand the key benefits of migrating to Ionic2.

Tech Blog

Ionic is world’s most popular cross platform mobile development technology. Basically its hybrid mobile app development framework. Build on top of Cordova, which enables us to build app along with web technologies. The goal behind developing Ionic is to give web developers a way to use their skill-set to build mobile applications.

Recently Ionic 2 has been launched. Conceptually Ionic 2 is similar to Ionic 1. In Ionic 2 controller hold all logical part and view is handled by template, except controllers are classes. Like this there are many key differences. Ionic 2 is build on the base of Angular 2 which uses typescript. All controllers are written in .ts file. Hence while building a app, these files get converted into .js files. This is the process of ‘Transpiling’. Transpiling does not allow logic to be directly available through debugging.

Now a days Ionic 2 is top choice for fast development…

View original post 647 more words

Posted in General | Leave a comment

RoR Tips & Tricks Series – #1

I am staring this series of blog posts. This will cover few tips and / or tricks from ROR. We as developer come across a situation, where we struggle to solve the problem. Once solved we realise that, in our trial and error efforts we have found some trick, which is not documented.

This blog post is an effort to  collect such tips and tricks and make developers life easy !!!

Tip : .first and .last returns same object on mongoid 5

Database : Mongodb

There are 2 ways to overcome this problem.

Simple query that comes in mind is to use “all[-1]”. But this is expensive. Instead use order to get last document. Here is the benchmark of both queries. Collection used for this benchmark has size as 35783 documents.

Benchmark.ms { Unit.all[-1] }
    => 5881.32297800621
Benchmark.ms { Unit.desc(:id).first }
    => 3.993231992353685
Posted in General | Leave a comment