How to generate X.509v3 self-signed certificate in PEM format with Node.JS

I thought this would be way harder, but thanks to the node-forge library and their perfect documentation, this was a breeze! After some experimentation I have modified their example code to have the very basic way to generate a X.509v3 self-signed certificate in PEM format. // import libraries const forge = require(‘node-forge’); const crypto = require(‘crypto’); const fs = require(‘fs’); …

Markdown cheat sheet for Visual Studio Code

Here is a cheat sheet that I found somewhere that will work with Visual Studio Code MD files: “# README” <!– M A R K D O W N   C H E A T  S H E E T –><!– Headings –># Heading 1## Heading 2### Heading 3#### Heading 4##### Heading 5###### Heading 6<!– Italics –>*This text* is italic\*This text\* is not italic_This text_ is italic<!– Strong …

How to fix connection timeout problem with MongoDB

Some of us have encountered a problem problem right after installing MongoDB, turns out we can’t connect. I personally get this: root@ghost:~# mongo MongoDB shell version v4.2.8 connecting to: mongodb://127.0.0.1:27017/?compressors=disabled&gssapiServiceName=mongodb 2020-10-30T12:10:51.955+0100 E QUERY [js] Error: couldn’t connect to server 127.0.0.1:27017, connection attempt fa iled: SocketException: Error connecting to 127.0.0.1:27017 :: caused by :: Connection timed out : connect@src/mongo/shell/mongo.js:341:17 @(connect):2:6 2020-10-30T12:10:51.958+0100 …

How to list IP tables in Linux

This is helpful for when you can’t access your localhost (127.0.0.1). Specially if you are having trouble accessing MongoDB after installation. Here is the command: iptables -L –line-numbers Sources: https://dba.stackexchange.com/questions/181693/mongodb-exception-connect-failed

How to locally configure a replica set in MongoDB

This post will guide you through the steps to set up a local replica set with two members and one arbiter. In a production environment the steps must be almost the same except that instead of starting three local MongoDB instances in different ports you would start an instance of MongoDB on each server with its own configuration file. This …

Permission Table for Linux (quick reference)

I am sure you have wondered what is the right permission for your file and tried to understand how it works, why there are numbers and letter and what all that mess means. Well here is a table that puts it in a very simple way, I am assuming you already know binary system, Linux and have a mind sharp …

How to parse JSON files in Node.JS ?

Quick tip using fs: let data = fs.readFileSync(“myFile.json”, ‘utf8’); console.log(typeof JSON.parse(data)); There is another way to do this that requires less effort. Using require directly, like so: const data = require(“myFile.json”); console.log(typeof data); Or you can create a function like this with fs also: function loadAlgorithms(fName) { let data = fs.readFileSync(fName, ‘utf8’); return JSON.parse(data); } Hope it helps.

How to pack NodeJS project into a tarball?

Today I needed to install my brand new NodeJS-developed CLI application in my computer. Important! Don’t forget to add this to your package.json file:  “bin”: {    “skynet”: “./bin/skynetApp.js”   }, It’s basically the name of the command and the NodeJS file it will execute, in this case the command name is skynet and every time this is typed in a terminal window it …