Category Archives: Technical Publications

News, analysis, and research on various domains of Information Technology

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

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

JavaScript-logo-top

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

Dynamically Update FusionCharts XML Attributes

This snippet of code adds the functionality to dynamically update FusionCharts DataXML root attributes (also known as "chart attributes") on-the-fly using JavaScript.

In case user requires to update chart cosmetics like turn off animation or change chart caption, this script will allow developers to do that in one line of code!

Continue reading