Skip to content

Instantly share code, notes, and snippets.

View sshbio's full-sized avatar

Sina Sharafzadeh sshbio

View GitHub Profile
@m-esm
m-esm / event-loop-delay-check.js
Last active January 29, 2020 19:19
Check event loop health by checking it's delay
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');
@mattdesl
mattdesl / about.md
Last active September 29, 2023 20:08
interactive audio sketch
@mikowl
mikowl / oneliners.js
Last active March 28, 2024 20:52
👑 Awesome one-liners you might find useful while coding.
// 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);
@ccnokes
ccnokes / axios-instance-config.js
Created July 6, 2017 16:23
Good default configuration for axios in node.js
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 }),
@mstijak
mstijak / error.js
Created November 13, 2016 21:49
Google Bot Crawl Debugging
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';
@agouriou
agouriou / nginx.conf
Last active April 5, 2024 15:57 — forked from Stanback/nginx.conf
Example Nginx (> 1.9) configuration for adding cross-origin resource sharing (CORS) support to reverse proxied APIs. Handle error status (4xx, 5xx) and expose headers.
#
# 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
@ivan-loh
ivan-loh / gist:ee0d96c3795e59244063
Last active March 3, 2021 13:26
Node.JS ( & pm2 ) Process Memory Limit
# 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
@diegopacheco
diegopacheco / redis.md
Last active August 3, 2019 18:29
How to Install Redis 3 Amazon Linux OS / CentOS

Install Redis cluster on Amazon Linux OS

sudo yum -y upgrade
sudo yum install -y gcc*
sudo yum install -y tcl
sudo wget http://download.redis.io/releases/redis-3.0.4.tar.gz
sudo tar xzf redis-3.0.4.tar.gz
cd redis-3.0.4
cd deps ; sudo make hiredis jemalloc linenoise lua ; cd ..