Tom's Blog


The first 500 Fibonacci numbers


In my previous post High-performance Fibonacci numbers implementation in Go I showed how to implement very efficient Fibonacci number generator in Go. In this post I am going to share some facts and numbers of Fibonacci sequence.

High-performance Fibonacci numbers program in Go


In this post, I would like to share how to implement a high-performance Fibonacci numbers generator in Go. I decided to write this post after I found the following interview question: Interview question Write a program that calculates a given Fibonacci number. Demonstrate the ability to optimise your solution. What approach would you take in order to be able to calculate any Fibonacci number?

GIF image creation in Go tutorial


I would like to share with you a straightforward and elegant way of creating GIF images in Go programming language. Many developers are afraid of images creation or manipulation. However, as you will see, generation of GIF images using out-of-the-box Go libraries is just fun.

Sorting techniques in Go


In this post I am sharing a few interesting sorting techniques in Go. Sorting is one of the most common operations in many programs. Many programming languages provide support to the sorting problem. Go is not an exception in this field. The out-of-the-box sort package provides a mechanism to perform in-place sorting of any collection implementing sort.Interface.

Implementation of the clock angle problem in Go


In the Explanation of an interview question related to the clock angle problem post I shared explanation and detailed solution to the clock angle problem. I provided Java implementation over. In this post, I am sharing the similar solution in Go. I am not going to present the problem and the approach to the solution as it is common to any programming language. I would recommend you read through the post as mentioned earlier for better understanding.

How to get object keys for true values in JavaScript


In this post, I would like to share a few easy ways of extracting keys from an object for truthy values in JavaScript. This kind of problem is quite common. The following examples will help you select the best solution for your case and save you time.

Interview: clock angle problem in Java


Some time ago I ran into the following interview question: Write a program that for a given hour and minutes values calculates an angle in degrees between the hour and the minute hands. Return information whether the minute hand overlaps the hour hand. As an additional subtask, write a method for calculating all times when the minute hand overlaps the hour hand.

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).

String to number conversion in JavaScript


In this post, I am sharing several different ways of converting a string to number in JavaScript.

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.

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 am sharing how to accurately measure code execution time in Node.js. Measurement with Date Many developers use JavaScript Date class in order to measure execution time. The following example illustrates this approach. I use setTimeout JavaScript function to simulate code running for about 1 second and use Date to measure its execution time. Variable start is assigned the test function start time and variable end is assigned the test function execution end time. The difference between these two variables is the test function execution time in milliseconds.

Images with data URI scheme using Node.js


In this post, I am sharing 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.

Rendering IE conditional comments with Jade / Pug


Details on rendering conditional comments for IE browser in Jade or Pug template engine in Node.js Jade template engine was designed primarily for server-side templates in Node.js. It is only intended to produce XML like documents, e.g., HTML, etc. It is whitespace sensitive, so there’s no need to close your tags; Jade does that for you.