Categories
Nginx

Nginx: worker_connections are not enough

You have to increase the number of worker_connections to fix this issue. You can also increase the number of worker_processes(default = 1), so the total amount of connections your server can handle would be worker_processes * worker_connections /etc/nginx/nginx.conf Worker processes: Nginx worker process that handles the incoming request. Set this to worker_process auto; to automatically adjust the number […]

Categories
VS Code

How do I Collapse and Expand functions in Visual Studio Code

Fold folds the innermost uncollapsed region at the cursor: Ctrl + Shift + [ on Windows and Linux ⌥ + ⌘ + [ on macOS Unfold unfolds the collapsed region at the cursor: Ctrl + Shift + ] on Windows and Linux ⌥ + ⌘ + ] on macOS Fold All folds all regions in the editor: Ctrl + (K => 0) (zero) on Windows and Linux ⌘ + (K => 0) (zero) on macOS Unfold All unfolds all regions in the editor: Ctrl + (K => J) […]

Categories
Node JS

Global fetch added in Node v18

Starting from Node.js v18 the fetch API is available on the global scope by default. So we don’t have to install the node-fetch or other packages to make HTTP requests. The new global fetch is based on the undici package. Example:

Categories
PowerShell

How to Read JSON files in PowerShell

In this tutorial, you will learn how to read JSON files in PowerShell. Read from user.json file. user.json file. Read from URL

Categories
Node JS

How to use top-level await in Node.js

Top-level await enables developers to use the await keyword outside of async functions. Starting from Node.js v14 top-level await is available and it is only available in ES modules. This means you can not use it with common js modules. Async/await Async/await is the syntactical modification of promises to avoid chaining. It makes the code a lot cleaner and easier to understand. […]

Categories
VS Code

How do I jump to a closing bracket in Visual Studio Code?

Mac Cmd+Shift+\ Mac with french keyboard : Ctrl+Cmd+Option+Shift+L Windows Ctrl+Shift+\ Windows with spanish keyboard Ctrl+Shift+| Windows with german keyboard Ctrl+Shift+^

Categories
VS Code

How to remove empty lines in Visual Studio Code

Open your code in Visual Studio Code From Edit Menu, select Replace or use a shortcut key (command + Option + F on Mac or Ctrl + H on Windows) In the find box type \n\n In the replace box type \n Make sure the ‘Use Regular Expression’ is selected Select the ‘Replace All’ button

Categories
Node JS

How to Use ECMAScript Modules in Node.js

In this post, you’ll learn how to enable and use ES modules in Node.js. Starting version 13.2.0, Node.js has stable support for ES modules. The ECMAScript modules (in short ES modules) is a JavaScript modules format that uses import and export statements. By default .js files in Node.js are considered CommonJS modules. To make .js files as ES modules simply set “type” field as “module” in the package.json, { […]

Categories
Unix/Linux

Basic file and directory-based commands

ls -la – for listing folder contents,  where the l option stands for long listing and the a option stands for all files (including the ones starting with a dot) touch – for creating an empty text file cd – for changing directories, both in absolute and relative terms pwd – for showing the current directory mkdir and rm – for creating and deleting a file or directory cp and mv – […]

Categories
Javascript

How to call a function repeatedly every 5 seconds in JavaScript?

The setInterval() method in JavaScript can be used to perform periodic (in milliseconds) evaluation of expressions or call a JavaScript function.  The setInterval() method continues calling the function until clearInterval() is called, or the window is closed. 1 second = 1000 milliseconds. Parameters: This function accepts the following parameters:   function: This parameter holds the function name which is to be called […]