Skip to content

Instantly share code, notes, and snippets.

@commenthol
commenthol / promisify.js
Last active February 26, 2020 13:36
promisify
const promisify = (fn) => (
(...args) => (
new Promise((resolve, reject) => {
fn(...args, (err, ...res) => {
if (err) reject(err)
else resolve(...res)
})
})
)
)
@commenthol
commenthol / json.js
Created November 22, 2016 20:59
print selected JSON data on console
#!/usr/bin/env node
/**
* print selected JSON data on console
*
* using files
*
* curl https://registry.npmjs.com/mergee > /tmp/j
* json /tmp/j versions 0.2.3 name
*
@commenthol
commenthol / cwd.sh
Last active January 23, 2016 07:52
get current working dir of running bash script
CWD=$(cd -P -- "$(dirname -- "$0")" && pwd -P)
echo $CWD
echo ${CWD##*/}
@commenthol
commenthol / cron.sh
Created October 18, 2015 19:14
a cron job for non root
#!/bin/bash
# add the times you'd like to schedule fcmd
times=(8:00 13:00 23:00)
# your commands
fcmd() {
# add your commands here
echo "execute your commands here"
}