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