This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
const httpError = require('http-errors') | |
exports.wrap = (f, status = 200) => (req, res, next) => { | |
Promise.resolve(req).then(f).then(r => { | |
if (status === 204) res.status(204).end() | |
else res.status(status).json(r) | |
}).catch(next) | |
} | |
exports.httpError = httpError |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/bash | |
sudo apt install -y libxcb1-dev libxcb-keysyms1-dev libpango1.0-dev libxcb-util0-dev libxcb-icccm4-dev libyajl-dev libstartup-notification0-dev libxcb-randr0-dev libev-dev libxcb-cursor-dev libxcb-xinerama0-dev libxcb-xkb-dev libxkbcommon-dev libxkbcommon-x11-dev autoconf libxcb-xrm0 libxcb-xrm-dev automake | |
cd /tmp | |
# clone the repository | |
git clone https://www.github.com/Airblader/i3 i3-gaps | |
cd i3-gaps | |
# compile & install |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
root = true | |
[*] | |
charset = utf-8 | |
indent_style = space | |
indent_size = 2 | |
end_of_line = lf | |
insert_final_newline = true | |
trim_trailing_whitespace = true |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
const { inspect } = require('util') | |
const os = require('os') | |
const isProd = process.env.NODE_ENV === 'production' | |
const isDev = process.env.NODE_ENV === 'development' | |
const eff = f => x => ((f(x), x)) | |
const noop = () => {} | |
const now = () => new Date().toISOString() |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
const { promisify } = require('util') | |
/** | |
* Mysql tools factory | |
* @param {(Connection|Pool|PoolCluster)} db Conection | |
* @returns {Object} | |
*/ | |
module.exports = function tools (db) { | |
const query = promisify(db.query).bind(db) | |
const end = promisify(db.end).bind(db) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
const events = ['uncaughtException', 'SIGINT', 'SIGTERM', 'SIGQUIT', 'SIGUSR2'] | |
module.exports = function onClose (cb) { | |
let called = false | |
const handlers = {} | |
events.forEach(ev => { | |
const handler = (...arg) => { | |
if (called) return | |
called = true | |
cb(ev, ...arg) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
if (process.env.NODE_ENV !== 'production') require('dotenv').load() |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
export default (fn, delay, id = null) => (...arg) => { | |
clearTimeout(id) | |
id = setTimeout(fn, delay, ...arg) | |
} |