Skip to content

Instantly share code, notes, and snippets.

View deyhle's full-sized avatar
🎯
Focusing

Ruben Deyhle deyhle

🎯
Focusing
View GitHub Profile
@malko
malko / makeTemplate.js
Created March 21, 2017 11:03
dynamic es6 template string to template methods
//const tpl = makeTemplate('hello ${name}')
//const name = 'world';
//tpl({name});
const makeTemplate = (templateString) => {
return (templateData) => new Function(`{${Object.keys(templateData).join(',')}}`, 'return `' + templateString + '`')(templateData);
}
@jdx
jdx / boot.js
Last active March 16, 2023 18:08
zero-downtime node.js app runner
// This script will boot app.js with the number of workers
// specified in WORKER_COUNT.
//
// The master will respond to SIGHUP, which will trigger
// restarting all the workers and reloading the app.
var cluster = require('cluster');
var workerCount = process.env.WORKER_COUNT || 2;
// Defines what each worker needs to run