Tom's Blog · Abelo

String split into tokens in JavaScript

Some languages provide special classes to solve that problem, e.g. StringTokenizer in Java. In JavaScript, we do not have specialized methods or classes. However, we have a powerful mechanism which is regular expressions.

Unique identifiers generation in Node.js

Generating a unique identifier is sometimes a straightforward job. All you need is to get an index of integer type and increment it any time you need an identifier. The things get more complicated if an id needs to be unique in a distributed environment. In this post, I am sharing a couple of approaches to generated unique identifiers in Node.js. The solutions can be used in a single process as well as the distributed environment.

Random values in JavaScript and Node.js

There are several different ways of generating random values in Node.js (JavaScript). Some methods use only base JavaScript functions (e.g. Math.random()), Others require additional modules. Generated values also differ from method to method. Some may return only numbers whereas others return a base64 string or universally unique identifiers (UUID).

JSON and JSONP correct MIME types

JSON (JavaScript Object Notation) and JSONP (JSON with padding) formats seems to be very similar, and therefore it might be very confusing which MIME type they should be using. Even though the formats seem to be very similar, there are some subtle differences between them.

Measurement of Node.js execution time

In this post, I will share how to measure execution time easily in Node.js. Many developers use JavaScript Date class in order to measure execution time. In the following example I will use setTimeout in order to simulate execution time.

Images with data URI scheme using Node.js

In this post, I will share how to embed an image data directly into the document with data URI scheme in Node.js and Jade. The data URL scheme specification is RFC 2397. This process will basically require conversion of an image into base64 format.

Winston logs rotation based on time

In this post, I am sharing how to rotate Winston log files based on time and date pattern.

Github tarball download

Github provides a feature of downloading entire repository from a single URL (a tarball). The downloaded repository file is combined into a single file using Linux tar command. The archive file is also compressed using gzip compression.