Skip to content

Instantly share code, notes, and snippets.

Avatar

Matthew Adams matthewadams

View GitHub Profile
@matthewadams
matthewadams / release-docker-image-on-codefresh.sh
Created Aug 13, 2018
release-docker-image-on-codefresh.sh
View release-docker-image-on-codefresh.sh
#!/usr/bin/env bash
# This script implements the release branch workflow for docker images built by codefresh.io.
#
# Requirements:
# git
# docker
# TODO: port this from bash to plain ol' sh (regex matching needs to be ported)
@matthewadams
matthewadams / release-helm-chart.sh
Last active Aug 14, 2018
release-helm-chart.sh
View release-helm-chart.sh
#!/usr/bin/env bash
# This script implements the release branch workflow for helm charts.
#
# Requirements:
# git
# docker
# TODO: port this from bash to plain ol' sh (regex matching needs to be ported)
@matthewadams
matthewadams / npm-update.sh
Created Dec 28, 2018
Update all npm packages to their latest versions
View npm-update.sh
#!/usr/bin/env bash
NPM_UPDATE_DEFAULT_PACKAGE_FILE=package.json
NPM_UPDATE_PACKAGE_FILE=$NPM_UPDATE_DEFAULT_PACKAGE_FILE
usage() {
cat<<EOF
Update outdated npm packages to the latest available
$(basename "$0")
View AwaitingPromise.js
'use strict'
/**
* Function that returns a `Promise` that `await`s an `async` function's completion.
*
* @param {Object} [arg={}] The argument to be destructured.
* @param {function} [arg.asyncFn=AwaitingPromise.DEFAULT_FN] An `async` function whose completion is to be `await`ed.
* Defaults to a no-op function.
* @param {boolean} [arg.positive=true] If truey, the returned `Promise` will resolve if `asyncFn` does not throw, and will reject with the error that `asyncFn` throws.
* If falsey, the returned `Promise` will reject with parameter `err`'s value if `asyncFn` does not throw, and will resolve with the error that `asyncFn` throws.
View get-port.js
// stolen from https://gist.github.com/mikeal/1840641#gistcomment-3126524
import { createServer } from 'net'
export default function getPort (port = 80, maxPort = 65535) {
if ((maxPort = parseInt(maxPort)) < (port = parseInt(port)) || isNaN(port) || isNaN(maxPort) || port < 0 || port > 65535 || maxPort < 0 || maxPort > 65535) {
return Promise.reject((() => {
const e = new Error('EPORTSPEC')
e.code = e.message
return e
@matthewadams
matthewadams / hid-remap
Created Jul 9, 2020
macOS HID remap script
View hid-remap
#!/usr/bin/env bash
usage() {
cat <<EOF
usage:
$0 -p productId remappings
options:
-p,--product-id: productId The keyboard product id (from Menu Bar\\⌥\SystemInformation...\Hardware)
You can’t perform that action at this time.