Google Drive Folder Sync - Webhooks
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 - http://kiprosh.com/blog/google-drive-file-upload-pre-generated-file-id-for-uploads. 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 performance - without polling Google to find out updates and nor writing any custom logic comparing timestamps to
Google Drive File Upload - Pre Generated File Id for Uploads
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 - https://developers.google.com/drive/v3/web/about-sdk. The
Use Spring to run RSpec quicker
Use spring to run RSpec - with spring - bundle exec spring rspec spec/controllers/api/v1/ Finished in 47.14 seconds (files took 1.58 seconds to load) 72 examples, 0 failures without spring - bundle exec rspec spec/controllers/api/v1/ Finished in 48.84 seconds (files took 29.23 seconds to load) 72 examples, 0 failures One of the reasons for RSpec tests being slow is the initial application boot time. This happens every time you make changes in your code and takes few seconds every time. You can reduce that by using spring to run your
Introduction to Neo4j - Graph Database
Neo4j is a Graph Database. It uses Graph Data Model to represent the data, unlike other databases which use tables, documents, etc. Graph Data Model or Graph Data Structure is composed of Nodes and Relationships that connect nodes. Neo4j Browser A query workbench and a visualization interface. To install Neo4j and run Neo4j Browser - you can head to https://neo4j.com/download/ and download a community or an enterprise edition based on your requirements. Based on your OS the installation steps may vary - and once you have a Neo4j application installed - you can now choose the location
BombBomb Video Emails Integration
What is BombBomb BombBomb is a platform to record, send and track video emails. BombBomb provides lots of value to users - who can send personalized video email instead of regular text emails. You can learn more about BombBomb here. How to integrate BombBomb We used the BombBomb Javascript API to connect to various BombBomb Services. To begin, include the BBCore and jQuery libraries in your html (The latest version is available at https://s3.amazonaws.com/static.bombbomb.com/js/BBCore.min.js): <script type="text/javascript" src="//ajax.googleapis.com/ajax/libs/jquery/1.
Performance Optimisations on a Rails App
Method Missing Method Missing is one of the concepts of metaprogramming ruby. Although metaprogramming is very powerful it too has some shortcomings especially speed. A normal method is comparatively 1.5x times faster than a missing method. One of our users complained about our calendar page being very slow - on inspecting we found request was taking more than 30 seconds for loading the month view of the calendar and eventually request timed out. The user had lots of activities on that calendar - 2000+. On further inspection, we found our DB query was quite fast but each activity was
Beyond Rails ActiveRecord Series - Postgres AutoVacuum
Postgres uses a mechanism called MVCC(Multi Version Concurrency Control) to track changes in your database. Due to this reason, some of the rows become “dead”. Dead rows are generated by DELETE and UPDATE operations, as well as transactions that have to be rolled back. Refer this link learn more about MVCC. These dead rows keep on adding as there are lots of updates and deletes. Periodic clean up of these dead rows is necessary to not only save space but also maintain the performance of your database queries. The space taken by these dead rows is called bloat. You
Javascript Browser Window Operations in Rails
Recently we developed one feature where we wanted to present a new tab view for an existing smaller form interface whereby users can use the full screen of the new window to move around and use the feature with ease. While we were developing the feature, we came across few challenges and thereby few learnings which we thought would be good to share. 1. Caching existing values. We have around 8-9 forms from where we can use this feature but each of them have different implementation based on the requirement. So before we open the new tab - we wanted
first_or_create caches the existing scope and applies to the model callbacks
We were debugging one issue in our application which was caching the scope we had in where clause for first_or_create in model callbacks - and found one interesting issue - Theconditions in the where clause were cached in after_create callback if we use where().first_or_create, please check example below - Example: Contact.where(first_name: 'Kiprosh').first_or_create Contact Model: after_create :sanitize def sanitize Contact.where(creator_id: 123).solr_index end This should fire Contact.where(creator_id: 123) but instead fires Contact.where(first_name: 'Kiprosh', creator_id: 123) On further
ActiveRecord::RecordNotUnique (duplicate key value violates unique constraint). Key already exists.
Recently I was getting an issue while inserting a new record to one of the table in our database. I was getting this specific error - ActiveRecord::RecordNotUnique (PG::Error: ERROR: duplicate key value violates unique constraint "canonical_cities_pkey" DETAIL: Key (id)=(*****) already exists. Understanding the error The table currently has several thousand entities for canonical cities. But when am trying to insert a new record it builds an canonical_city record and assign it an 'id', say 111, but that 'id' already exist. The primary key which is suppose to auto-increment and generate an unique id