How to convert stream to buffer in Nodejs

In Nodejs when dealing with non-text files (e.g. images) IO operations such as transferring via network or reading from disk, there is a big chance to receive the content as stream.Readable, and before we can process the complete data in memory such as calculating the bytes size or image dimensions, we need save the stream to buffer and here are a few ways.

Intellj IDEA eslint and alias resolving issues

I’m using a perpetual fallback license version of Intellj IDEA Ultimate for daily development but recently I noticed two issues in JavaScript development environment related to ESLint and module alias resolution. Luckily for either issue I managed to find a solution.

Upgrade rails from 5.2 to 6.0

The main things to handle during upgrading API centric application’s rails version from 5.2 to 6.0 include configuration tuning and deprecation warnings fixing.

Upgrade to ruby 2.7.6

Ruby v2.7.6 is the latest version before v3.0 at the time of this writing and upgrading to v2.7.6 may encounter a breaking issue if the application uses libraries that depend on BigDecimal.

How to handle bigint in json stringify

As we know the BigInt type is availble in JavaScript as a data type able to represent any arbitrary large integer number, which is a good supplement when a value exceeds what number could represent. However, when working with applications where you need exchange data with JSON format, the bigint values become a problem because JSON does not know how to serialize bigint values by default, in such cases, one solution is to convert the bigint into string as this post shows.

Upgrade from v3 to v4

Following Upgrade from v2 to v3, this post is about upgrading and its associated packages to the latest versions as of when this post is written and the only setting changes seem to be from the redis-adapater and the way to import client io this time (for our specific use case).

Upgrade from v2 to v3 and its related libraries such as and had a few breaking changes in either functions or behaviors since v3 which might cause issues during the v2-to-v3 migration. This post lists what was encountered and how to solve it for specific use cases based on hands-on experience.

JS resources

Since I find myself writing code more and more in JavaScript nowadays regardless of backend or frontend development, I figure out I should at least give it a look seriously, the first time in more than 10 years, and here are the resources I find useful while diving into this long overlooked programming language.

How to protect files in linux with gpg

When working under shared linux machine or environment, sometimes it is necessary to hide or protect some files that contain sensitive information, fortunately there is a tool called GnuPG that most Linux distributions already have pre-installed and we can conveniently make use of this tool and this post is about how easy and quick we can use it for a very basic scenario.

Where is ruby defined? defined?

Ever wonder where ruby’s defined? is defined? Because it looks so like a method, you might end up trying to check out a bunch of places, such as: Object, Kernel, BasicObject, or even Class or Module, but only to find no luck locating it in any of such places. Well, only until you’ve realized it, the answer is pretty simple: defined? is not a method but an operator or a keyword.