Steps to deploy a Node.js app to DigitalOcean using PM2, NGINX as a reverse proxy and an SSL from LetsEncrypt
Create free AWS Account at https://aws.amazon.com/
I would be creating a t2.medium ubuntu machine for this demo.
| # Install NVM manually (https://github.com/creationix/nvm) | |
| # Install bass (https://github.com/edc/bass) | |
| # Add code below to your config.fish | |
| function nvm | |
| bass source ~/.nvm/nvm.sh --no-use ';' nvm $argv | |
| end | |
| nvm use default --silent |
Steps to deploy a Node.js app to DigitalOcean using PM2, NGINX as a reverse proxy and an SSL from LetsEncrypt
Create free AWS Account at https://aws.amazon.com/
I would be creating a t2.medium ubuntu machine for this demo.
| 'use strict'; | |
| /*****************NATIVE forEACH*********************/ | |
| Array.prototype.myEach = function(callback) { | |
| for (var i = 0; i < this.length; i++) | |
| callback(this[i], i, this); | |
| }; | |
| //tests |
| // 3D Dom viewer, copy-paste this into your console to visualise the DOM as a stack of solid blocks. | |
| // You can also minify and save it as a bookmarklet (https://www.freecodecamp.org/news/what-are-bookmarklets/) | |
| (() => { | |
| const SHOW_SIDES = false; // color sides of DOM nodes? | |
| const COLOR_SURFACE = true; // color tops of DOM nodes? | |
| const COLOR_RANDOM = false; // randomise color? | |
| const COLOR_HUE = 190; // hue in HSL (https://hslpicker.com) | |
| const MAX_ROTATION = 180; // set to 360 to rotate all the way round | |
| const THICKNESS = 20; // thickness of layers | |
| const DISTANCE = 10000; // ¯\\_(ツ)_/¯ |
| function doGet(e){ | |
| let id = '1fK1zbSNw7jZuEB14iS8n6t9p7PV4tFQW8fJpnJMpFWA'; | |
| if('id' in e.parameter){ | |
| id = e.parameter['id'] | |
| } | |
| let html = '<h1>Laurence Svekis</h1>'; | |
| const url = 'https://docs.google.com/feeds/download/documents/export/Export?id='+id+'&exportFormat=html'; | |
| const param = { | |
| method :"get", | |
| headers : { |
This focuses on generating the certificates for loading local virtual hosts hosted on your computer, for development only.
Do not use self-signed certificates in production ! For online certificates, use Let's Encrypt instead (tutorial).
All of the below properties or methods, when requested/called in JavaScript, will trigger the browser to synchronously calculate the style and layout*. This is also called reflow or layout thrashing, and is common performance bottleneck.
Generally, all APIs that synchronously provide layout metrics will trigger forced reflow / layout. Read on for additional cases and details.
elem.offsetLeft, elem.offsetTop, elem.offsetWidth, elem.offsetHeight, elem.offsetParent| export const useLocalStorage = (key: string) => { | |
| const setItem = (value: unknown) => { | |
| try { | |
| window.localStorage.setItem(key, JSON.stringify(value)) | |
| } catch (error) { | |
| console.log(error) | |
| } | |
| } | |
| const getItem = () => { |