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.

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

Monit’s DMCA Takedown Notice for Inspeqtor

While reading Github’s new DMCA policy revamp related post, I stumbled upon an interesting conversation in Monit’s DMCA takedown notice for Inspeqtor. The entire public-facing conversation calls for some thinking. The hackernews conversation surrounding this adds another dimension to this.

Continue reading Monit’s DMCA Takedown Notice for Inspeqtor

Upgrading to Raspberry Pi Model B+

Often my OpenELEC Raspberry Pi would get stuck at pre-boot. The culprit turned out to be a faulty SD card connector. Unclipping the connector pins (as suggested in the elaborate diagnostic wiki on eLinux.org) and soldering on an alternate low-profile SD card adapter (that I ordered from crazypi.com) fixed it.

By that time, I had already ordered the new Raspberry Pi Model B+. My first impression – this is how the original Model B should have been designed!

Continue reading Upgrading to Raspberry Pi Model B+

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.

A relevant StackOverflow question is located at http://stackoverflow.com/questions/8905680/nodejs-check-for-hidden-files/ and a gist is at https://gist.github.com/shamasis/7704671

Knight in Rusted Armour

Stands stooped the knight
Adorned by the faintness of darkness
Covered by the mist of silhouette
And the gleam of golden dust. 

The next daybreak stands far away
And what lies ahead is the deception of dawn
Shadows cast from the vantage of clouds
Revealing the scars of the untold wars. 

Riding upon the moonbeams of agony
His sword had bathed times to a halt
His eyes being the shining glory
Of dreams that are seldom bought

Through the forests he strode
His fears riding his feats of glory
His triumphs leading his way to ditches
With his legends of unwritten stories. 

Whenever he stopped and rested his body
Bereavement was bestowed upon his kins of spear
Where his mind would scamper off to fields
Where truth was but an ally of fear. 

There he stood, lifeless and in pain
His agonies chiseled on to the horse he rode
The armour dropped loose from its lock
Rusted not by age but by faintness of war.

A mentally costly experience of buying a lounger

Beware: Owner wouldn’t think twice before fleecing money from you. If you’re a sharp person and not easily fooled, try your luck.

The above was my original review on Google Plus. The owner called me up on seeing the review and asked me to remove it since in his opinion, nothing had gone wrong. As such, I am doing a follow-up on the review here.

Continue reading A mentally costly experience of buying a lounger

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

Setting Default Variable Value in JavaScript

Often, there are conditions where we need to provide a default value of a variable if it is undefined. As a case study, we will take up the situation, where we are passing a Boolean value to function and if the input is true, some action has to be taken. In case someone does not pass any value, the input is assumed to be true.

Continue reading Setting Default Variable Value in JavaScript

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