Traditionally there are a few ways to statically add css to a page, and via JavaScript it can also be dynamically added by either creating a link
element with rel="stylesheet"
and href
set to a css file location, or creating a style
element with css definitions as its content. Now there is a 3rd way: importing css directly from within an ESM script tag, similarly to the way of importing JavaScript resources, via a feature called CSS Module scripts
.
When dealing with large text files such as parsing log files, it is always preferred to load/iterate the content line by line instead of reading everything into memory for efficiency and performance reasons. In Nodejs, it has always been a hassle because the way of reading line by line looks hacky and too low-level from a daily user’s perspective. However, that’s not the case any more thanks to a PR merged into the latest version of v18.11.0
, there is now FileHandle.prototype.readLines
builtin which makes it very convenient to use.
In other programming languages such as Java, Ruby and Python, there are Thread.sleep()
, sleep
, and time.sleep()
methods to pause the execution of the current thread and wait after specified time to continue the execution, and when used together with loops, it can help address race condition issues for example. In node.js, and generally JavaScript, the way to pause and wait may not seem very obvious and frequently seen due to the nature of single-threaded, event-driven, and asyncronous architecture. However, since the use of wait
and retry
is still needed and helpful under certain circumstances, it is possible to simulate similar functions and effects in nodejs or JavaScript.
It becomes annoying sometimes if ssh connection gets terminated very soon if no messages sent between the ssh server and client for sometime but there are ways to keep it alive for long or forever from either client or server side.
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.
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.
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.
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
.
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.
Following Upgrade socket.io from v2 to v3, this post is about upgrading socket.io
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).