Check if a user’s device is in dark mode with the following code snippet.
To fix the ‘unexpected console statement’ error in Vue.js, open package.json and under section eslintConfig put no-console under rules and restart dev server (npm run serve or yarn serve). This is a same way as we have fixed in Node.js
To fix the ‘unexpected console statement’ error in Node.js, just create a .eslintrc.js in the directory of the project and put the following configuration in it.
In this tutorial we are going to use an npm package called express-rate-limit. Install it using the following command. This library provides a brute-force protection for express routes by rate-limiting […]
Pandas csv module
Use the following syntax to use a string/ varchar column as a number for ordering in MySQL. Example Here Box is of VARCHAR type. Hence I need to cast it […]
Call math.log(x) on a number x to return the natural logarithm of x.
This snippet fetches the list of files in a directory sorting them by their names using os.listdir(). Earlier we used glob() to do this.
Force garbage collection Turn off garbage collection
For simple arrays For Array of Objects
This code snippet exports a JSON / JSON Array to a XLSX formatted file. I used Sheet.js version 0.14.0.
Consider, we have a following bullet list items: To change the default bullet color of a list item, there is no built-in css way to do it instead, we can […]
In this tutorial, we are going to learn about how to concatenate the strings in Ruby. Concatenation means the joining of two or more strings into a single string. Using […]
NoSuchElementException would be thrown when you are trying to read a line/value that is not present in the source. One scenario would be when you try to read content from […]
Let’s take a file sample.txt which has the following contents. To read the 3rd line using Java 8 stream, we can use the following code snippet. If the line number […]
To find out if a file path is a file or a directory we can use fs.statSync(path).isDirectory() method. It returns a boolean, true if the path is a directory.
To get file size in Node.js, the following code snippet would help. statSync() method from fs package synchronously returns information about the given file path the file size in bytes.
StringJoiner is used to construct a sequence of characters separated by a delimiter and optionally starting with a supplied prefix and ending with a supplied suffix. Syntax Examples
Exception in thread “main” org.springframework.dao.EmptyResultDataAccessException: Incorrect result size: expected 1, actual 0
EmptyResultDataAccessException is thrown when a result was expected to have at least one row (or element) but zero rows (or elements) were actually returned. This is a data issue. To […]
You can easily take mongodump from a connection URI by passing –uri flag to the mongodump tool. Syntax Example
This code snippet truncates or cuts off a text string after a certain number of characters and add an ellipsis (...) at the end. Source: Coderrocketfuel