Building a Resilient Continuous Deployment System

When was the last time a single developer did something really small and it made big impact? You can list them out or you can read it on Verge, BusinessInsider and on TheRegister. In a nutshell, Azer decided to unpublish left-pad, an 11-line NodeJS module on NPM, and it broke thousands of other NPM module installations that depended on it.

The impact of the absence of left-pad was felt mainly by services having a continuous integration or a continuous deployment system. I can but imagine the countless hours developers had to spend to patch up their CI/CD to prevent or fix a service outage.

The fact remains that our endeavour to deliver software quick and dirty is what has left us vulnerable. Vulnerable to a point where it is both disconcerting as well as lame

Continue reading “Building a Resilient Continuous Deployment System”

Get your bash scripts to sleep (halt execution) on Shippable and Travis

As I write this, it’s been about 36 hours without sleep for me — enough to relate to the importance of sleeping. However, this discussion is around getting a bash script or JavaScript on NodeJS to sleep for a specific duration.

#!/usr/bin/env bash

echo "Feeling drowsy...";
sleep 10;
echo "Woof! Back up after 10 seconds!";

The sleep command in unix allows one to pause execution of a script for a specified duration. It is a very handy tool in times where a script needs to wait for some other asynchronous work to complete. (Kindergarten talks for many!)

Continue reading “Get your bash scripts to sleep (halt execution) on Shippable and Travis”

Postmortem of a UI repaint issue on Chrome

A while back, a section of our users started reporting a UI rendering issue while using Postman. The interesting thing about the issue was that it occurred only on very high resolution monitors. High resolution to the tune of 2k, 3k displays and above (such as Macbook Retina displays.) As such, full HD users did not face this issue. Having said that, it was quite annoying for the ones facing it.

Intermittently, parts of the UI would not redraw itself for no reason whatsoever and usually resizing the app window would fix it momentarily. There was no predictable way to reproduce the issue and nor did we discover the root cause of the issue. The screenshots submitted by our users were the only starting point we had.

Continue reading “Postmortem of a UI repaint issue on Chrome”

Check if UNIX Path has Hidden Directory or File

This snippet of code uses regular expression to test if a path string contains any hidden directory. The use-case was derived from the difficulty in determining whether directory is hidden or not using NodeJS path module. Owing to the possibility of their existence within a long path string, this function returns false if any directory or the terminal file of a path has a name that starts with a dot.

 * Checks whether a path starts with or contains a hidden file or a folder.
 * @param {string} source - The path of the file that needs to be validated.
 * returns {boolean} - `true` if the source is blacklisted and otherwise `false`.
 * @example
 * console.log(isUnixHiddenPath('~/documents')); // prints `false`
 * console.log(isUnixHiddenPath('~/documents/file.txt')); // prints `false`
 * console.log(isUnixHiddenPath('~/source/repo/.gitignore')); // prints `true`
 * console.log(isUnixHiddenPath('~/source/repo/.git/config')); // prints `true` 
var isUnixHiddenPath = function (path) { 
    return (/(^|./).+[^/.]/g).test(path); 

A relevant StackOverflow question is located at and a gist is at

Quick Validating JavaScript Function Before Call

There are many instances where we have to execute a function where we have no idea whether it actually exists or not. Let’s say for example, a function expects another function passed to it as parameter, which would later be executed as callback. A very common usage would be the callback function sent to AJAX requests.

Generally, we would code it with an if-block and check whether the variable (say, callback) is a function or not. If it is, we execute it when we have the work completed (say marked by a variable called workIsDone.)

Continue reading “Quick Validating JavaScript Function Before Call”

Infinite Ways to Detect Array in JavaScript

JavaScript (ECMA script in general) is a miraculous language. It allows us to prove that coding is creativity. One reason for that is the numerous ways a single objective can be coded. For instance, checking whether a variable is an Array, can be done in four different ways. And probably more!

Some months back I had come across this Quora article: What’s the best way to tell the different between an Array and other kinds of objects in JavaScript? There were already five different methods available there from Tom, John, Rick, Ken and Eric. And even I was surprised that I could add one more! I would take some time and explain all the methods with its pros and cons and finally we can conclude upon the best method.

Continue reading “Infinite Ways to Detect Array in JavaScript”

JavaScript Drag Events on iPhone and Other Touch Based Devices

For quite a while this week, we were trying to work on dragging JavaScript elements on iPad and other devices with touch input. For our case, we already had jQuery included in our codes, hence we were tempted to use the touchmove event and depend on native jQuery to do the rest.

Things turned out to be a bit trickier. After implementation, it struck us that with jQuery bound events, event.pageX and other related mouse coordinate attributes would not work. Add to that, we were using the jQuery.event.drag plugin by ThreeDubsmedia to seal of the dirty job of drag-related coding.

Armed with the above two problems, we started to do what we thought would be the fastest solution – modify the jQuery.event.drag plugin for a graceful upscale!

Continue reading “JavaScript Drag Events on iPhone and Other Touch Based Devices”