A interactive & generative site with canvas-sketch and Tone.js.
Live Demo:
const interval = 1000; | |
const acceptableDelay = 3; | |
let lastCheck = 0; | |
(function checkEventLoop() { | |
const now = Date.now(); | |
if (lastCheck) | |
if (now - lastCheck > interval + acceptableDelay) { | |
console.log('\x1b[31m', 'event loop delay', (now - lastCheck - interval) + 'ms', '\x1b[0m'); |
A interactive & generative site with canvas-sketch and Tone.js.
Live Demo:
// Inspired by https://twitter.com/coderitual/status/1112297299307384833 and https://tapajyoti-bose.medium.com/7-killer-one-liners-in-javascript-33db6798f5bf | |
// Remove any duplicates from an array of primitives. | |
const unique = [...new Set(arr)] | |
// Sleep in async functions. Use: await sleep(2000). | |
const sleep = (ms) => (new Promise(resolve => setTimeout(resolve, ms))); | |
// or | |
const sleep = util.promisify(setTimeout); |
rebase
vs merge
).rebase
vs merge
)reset
vs checkout
vs revert
)git rev-parse
)pull
vs fetch
)stash
vs branch
)reset
vs checkout
vs revert
)const axios = require('axios'); | |
const http = require('http'); | |
const https = require('https'); | |
module.exports = axios.create({ | |
//60 sec timeout | |
timeout: 60000, | |
//keepAlive pools and reuses TCP connections, so it's faster | |
httpAgent: new http.Agent({ keepAlive: true }), |
window.onerror = function (message, url, lineNo, colNo, error) { | |
console.log(arguments); | |
let container = document.createElement('div'); | |
container.style.color = 'red'; | |
container.style.position = 'fixed'; | |
container.style.background = '#eee'; | |
container.style.padding = '2em'; |
# | |
# CORS header support | |
# | |
# One way to use this is by placing it into a file called "cors_support" | |
# under your Nginx configuration directory and placing the following | |
# statement inside your location block(s): | |
# | |
# include cors_support; | |
# | |
# A limitation to this method is that Nginx doesn't currently send headers |
# Plain Ol' Node | |
node --max-old-space-size=1024 app.js # increase to 1gb | |
node --max-old-space-size=2048 app.js # increase to 2gb | |
node --max-old-space-size=3072 app.js # increase to 3gb | |
node --max-old-space-size=4096 app.js # increase to 4gb | |
node --max-old-space-size=5120 app.js # increase to 5gb | |
node --max-old-space-size=6144 app.js # increase to 6gb | |
# For pm2 | |
pm2 start app.js --node-args="--max-old-space-size=1024" # increase to 1gb |