This file contains 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 | |
# 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" | |
} |
This file contains 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
CWD=$(cd -P -- "$(dirname -- "$0")" && pwd -P) | |
echo $CWD | |
echo ${CWD##*/} |
This file contains 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
#!/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 | |
* |
This file contains 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 = (fn) => ( | |
(...args) => ( | |
new Promise((resolve, reject) => { | |
fn(...args, (err, ...res) => { | |
if (err) reject(err) | |
else resolve(...res) | |
}) | |
}) | |
) | |
) |
This file contains 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 EventEmitter = require('events'); | |
const random = () => ('' + Math.random()).substr(2) | |
class Dispatcher extends EventEmitter { | |
constructor () { | |
super() | |
this.token = `dispatch_${random()}` | |
this.dispatch = this.dispatch.bind(this) | |
} |
This file contains 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 | |
# find all required packages in a directory | |
# usage | |
# findrequire src | |
# findrequire src | xargs npm i -S | |
# findrequire test | xargs npm i -D | |
find $1 -iname "*.js" |\ | |
xargs egrep -h "require\(['][^.]" |\ | |
sed "s/.*require('\([^'']*\)').*/\1/g" |\ | |
egrep -v "^(assert|child|cluster|events|dgram|dns|domain|fs|http|https|inspector|net|os|path|punnycode|querystring|readline|stream|string_decoder|tls|tty|udp4|url|util|v8|vm|zlib)$" |\ |
This file contains 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
#!/usr/bin/env bash | |
# | |
# From https://superuser.com/questions/109213/how-do-i-list-the-ssl-tls-cipher-suites-a-particular-website-offers | |
# | |
# Find cipher suites a website offers | |
# | |
# Usage | |
# |
This file contains 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 | |
# rotate scanned pdf pages by 180° | |
# name all pages | |
help=$(cat <<EOS | |
Usage: rotate-pdf.sh IN.pdf OUT.pdf [PAGES] | |
Read from IN.pdf, rotate PAGES by 180° and write out to OUT.pdf |
This file contains 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 | |
exe=$(cygpath -u "C:\Program Files (x86)\Geany\bin\geany.exe") | |
args="" | |
while (( "$#" )); do | |
arg=$1 | |
if [[ $arg == /* ]] ; then | |
arg=\"$(cygpath -a -w "$arg")\" | |
fi |
This file contains 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 http = require('http') | |
const logger = (req, res, next) => { | |
const time = Date.now() | |
res.on('finish', () => { | |
const {method, url, headers, body} = req | |
const {statusCode} = res | |
console.log('%s %s %s %s %j %s', method, url, statusCode, Date.now() - time, headers, JSON.stringify(body)) | |
}) | |
next() |
OlderNewer