StoryBook - UI Component explorer for frontend developers

In recent days, UI Components have become building blocks of a website or an application. And these UI Components need to be examined and tested properly before building User Interfaces.

Node.js Media Conversion Guide

While recording a live video on a browser, have you ever wondered how to convert videos from different browsers into one standard format? There are multiple challenges during audio-video compression, conversion, editing etc., especially with respect to quality and size of the file.

Sorting by columns in a table in Backbone.js

Have you ever wanted a quick code look up for sorting by columns in a table using Backbone.js? Also sorting those in ascending and descending orders? Then, you are at the right place!

Android - Gradle Build Configuration

Android uses Gradle, an advanced build toolkit, to automate and manage the build process, while allowing you to define flexible custom build configurations. One of the most important file in Android application development is build.gradle, which is used in the process of building an android app. Let’s see how we can configure android builds with build.gradle.

bundle add command

Ruby’s bundler introduces a new command to add a gem to the Gemfile.

Request Header Manipulation in Phoenix specs

Recently while writing specs for a Phoenix application, I came across this scenario, where I needed to pass a jwt token in request-headers for authorization of Users.

Separate gitconfig for work and play

Use conditional config to separate gitconfig for work and personal projects.

Create Custom Exceptions in ES6

Creating elegant custom exceptions is easy with ecmascript classes.

ES7 class properties

class properties in ES7 can be used to write elegant React components.

Understanding Ruby's &method

Method#to_proc - just like Symbol#to_proc

Symbol-to-proc in Ruby

Understand how array.inject(&:+) works.

Traits in Factory Girl

FactoryGirl’s traits are an outstanding way to DRY up your tests and factories.

Transient attributes in Factory Girl

How to use transient_attributes?

Introduction to Android App Shortcuts

In the latest version of Android, Nougat 7.1 (API 25), Google introduced a new feature called App Shortcut. This allows you to create shortcut for specific action or screen in your app that can be opened directly from launcher to associated screen.

Animations using CoordinatorLayout in Android

With the introduction of Material Design, motion and animations became the integral part of Android applications. To make the development easier, Google introduced a new Android Design Support Library. This lets developers focus on the features that make their applications unique rather than focusing on animations part.

Wrap parameters in Rails

ActionController::ParamsWrapper in Rails is responsible for wrapping the parameters hash into a nested hash.

Pgcli - better command line interface for postgres

Today I came across pgcli. It is a database console for postgres with syntax highlighting and more importantly autocompletion!

Debugging Push Notifications with Knuff

Debugging and testing Push notification is always tricky and time consuming. Knuff OS X app along with Knuff iOS app can make our lives a little easier to debug and test push notification.

Using ActiveModel::Dirty for tracking changes

ActiveRecord comes with a mechanism to track changes to your model with ActiveModel::Dirty. Lets put it to some use.

JS for loop with delay in each iteration using IIFE

Ever wondered how you can do each iteration of a for loop with some delay? That means, the code block in for loop body will be executed until the condition goes wrong, but with a delay in each iteration.

MVVM Design Pattern

As we are familiar with MVC design pattern and it is one of the standard approach to build iOS Applications. MVVM is very similar to MVC. It formalizes the tightly coupled nature of the view and controller and introduces a new component view-model.

Managing Webview flow in iOS with Swift

In many native iOS applications, webviews are used to perform certain tasks. Once the initial urls is set to webview, it becomes difficult to intercept redirection url(if any), which is handled by webview. But sometimes we need to intercept these urls to perform specific actions.

Initializing Arrays in Ruby

A new array can be created by using two different ways in ruby and can contain different types of objects.

How to use Observers in Rails

Observer pattern provides a simple mechanism for one object to inform a set of interested objects when its state changes.

Behind the scene - Rails Migrate

All migration files in Rails are by default prefixed with the timestamp which serves as the version number for the migration file. For an instance a migration file with name 20160310141700_create_users.rb is prefixed with timestamp 20160310141700.

Adding dependent validations using jQuery Validate

While validating one of the many forms, I came accross a situation where a form field’s presence was dependent on another DOM element, depends property of jquery-validate plugin came to resue.

Dynamically modifying(read adding and removing) rules using jQuery validate

Got some hidden fields in a form which needs validation(at some later point say, when made visible)? Lets learn how to remove or add validation rules dynamically using jQuery Validate plugin.

Custom Inquirer Similar To ActiveSupport's StringInquirer

This is in continuation with the ArrayInquirer post. Lets see how to implement a Custom Inquirer for a Rails model similar to ActiveSupport StringInquirer and ArrayInquirer.

React Native Progressbar

React-Native has a pretty ordinary progressbar which does not allow a lot of customizations, but creating your own with animations is fairly simple.

Static vs Class vs Global Functions in Swift

Almost every projects contains Utility Functions. With the introduction of Swift, there are multiple ways to write such functions.

Defer keyword in Swift

defer is a new keyword indroduced in Swift 2.0. With this statement you can declare clean-up code, that is executed just before the current scope ends.

Checking Swift coding style and conventions using Swiftlint

SwiftLint is a tool which enforce to follow Swift style and conventions, based on GitHub’s Swift Style Guide.

How to add helper in mustache

In my previous post I gave an brief overview about mustache and how we can render templates with it.

Binding mouse events to disabled input elements

Do you know, you can’t bind mouse events to a input element once it is disabled?

Rails 5 introduces ArrayInquirer

Rails 5 introduced ArrayInquirer as a new member to Inquirer family which initially consisted of well known StringInquirer.

Use Opendiff as default git difftool

Get the diff of files/directories using git difftool.

Intro to Protocol Oriented programming

Apple had added a new feature to the protocol i.e. protocol extension.While it may only seem like a minor feature at first, but this improved feature in swift allow us for a new type of programming i.e. protocol-oriented programming.

Headless Browsing using Poltergeist

Avoiding a third party redirect can be solved with simulation of user browser actions.

Extend Core Classes in Rails

In my previous post, I have explained how to extend ActiveRecord::Base. In this post, I will explain how to extend core ruby or rails classes in rails.

CSS3 animation

CSS animations make it possible to animate transitions from one CSS style configuration to another.

Using Decorator Design Pattern in Ruby

The intent of decorator design pattern, as described in Design Patterns by the Gang of Four is to attach additional responsibilities to an object dynamically. Decorators provide a flexible alternative to subclassing for extending functionality.

Using gon in rails to pass data to javascript

Very often, I have come accross the situation where I need ruby variables in javascript file. Recently, I got to know about a wonderful gem gon which does the work for you. Lets see with an example.

UI Testing with Espresso Android (Test a Button Click)

To start testing with Espresso, first you need to add the espresso dependency in your app level build.gradle.

TODO and FIXME as warnings in Xcode

In Objective-C Xcode generate compile time warning by using #warning preprocessor directive in your code. Unfortunately, this is not available when using Swift.

Send POST data without a HTML form

Recently while working on one of the projects I encountered a situation where I had to post some nested-data to a controller method and this data wasn’t associated with any model hence rails fields_for was of no help.

Adding custom validations using jQuery Validate

I generally use jquery-validate plugin for frontend validations. It comes with handful of validator methods. Sometimes we need custom validations. Lets see how to add one.

Overriding Devise's after_sign_in_path_for

Devise by default redirects the user to the previous url (if present) after authenticating. This is a very useful default to have. But this behaviour is lost if we override the after_sign_in_path_for method in our application.

Upload a file directly to Google Drive from a server

I had a huge directory that was to be shared with my client and I was having a limited internet access. I came across this interesting project. I downloaded the required version on the server, chmod +xed it and ran gdrive about. It asked me to get a token from the web by pasting a generated URL. I ran gdrive list and voila, I could see all my Drive files listed in the terminal.

Chisel Refactoring

Last night I was watching Sandi Metz’s podcast on Bikeshed and one question in the QnA striked me.

Template rendering with mustache

In some widgets rich websites we are often faced with a situation where we need to update all the widgets on a page based on change of a particular attribute.

Handling acronyms in rails

The ActiveSupport::Inflector handles a lot of the semantic rules in Rails, including acronyms.

Eager Load in Rails

Database is considered an expensive resource, and while developing our application we should be particular about the number of DB queries made, in general fewer the DB queries executed, the better the performance.

Extend ActiveRecord::Base

In this post, lets see how to extend ActiveRecord::Base class to add custom methods.

Speedy array operations with Ruby 2.4

Ruby 2.4 has optimized Array#min and Array#max methods. Here are some benchmarks.

Generate md5 hash for gravatar with liquid filters

Gravatar URL’s are generated by creating a hash from your email address. Here we are going to create a liquid-filter for this.

Javascript Inheritance and the prototype chain

It is often required to extend existing object or class to add new methods or override existing methods. Almost All the Object Oriented Programming Languages provide this feature using inheritance.

FactoryGirl with Non ActiveRecord Classes

Creating FactoryGirl for ActiveRecord classes is quite handy. Here we will learn creating FactoryGirl for NonActiveRecord classes.

Running a background process in upstart mode in Ubuntu

You dont have to put the & symbol to put the process in background. It will work without that. Sample configuration:

Calling a binary of a specific version of a gem

I never knew this exisited. It seems it is not documented anywhere and I have no idea how it works, but yes:

RSpec predicate matchers

Rspec has a pretty handy feature called predicate matchers to test predicate methods on your classes.

Sass mixins as functions

Sass mixins are pretty handy if you want to re-use same snippet of css at multiple places. But did you know they can act like functions as well?

Working with click events in modals

If we have click events bound to elements inside a bootstrap modal, clicking on the element closes the modal. Here is a trick to prevent that.

Use Rails Enums carefully

ActiveRecord enums are really handy but they can be equally evil if not used properly.

Spying with Rspec

Spying is used to assert if a method has been called, here we will see how to use spies with Rspec.