Skip to content

Instantly share code, notes, and snippets.

Bruno Bronosky RichardBronosky

Block or report user

Report or block RichardBronosky

Hide content and notifications from this user.

Learn more about blocking users

Contact Support about this user’s behavior.

Learn more about reporting abuse

Report abuse
View GitHub Profile
RichardBronosky /
Created Feb 11, 2020
Pattern for using `main` and `exports` in Node.js

Pattern for using main and exports in Node.js


$ cat example-main_and_exports.js
#!/usr/bin/env node

const lib = require('./lib.js')
View curl-bash-env
# curl -sL | bash
cat <<EOF | less
# stdin_is_a_pipe
[[ -p /dev/stdin ]]; echo \$?
$([[ -p /dev/stdin ]]; echo $?)
# stdin_is_a_tty
View tput_256colors
tput init
end=$(( $(tput colors)-1 ))
for c in $(seq 0 $end); do
tput setaf $c
[[ $c -ge $(( w*2 )) ]] && offset=2 || offset=0
[[ $(((c+offset) % (w-offset))) -eq $(((w-offset)-1)) ]] && s=$'\n'|| s=' '

Shell Script Design Goals

  • Don't avoid bashisms unless you know bash will be unavailable
    • Use #!/bin/bash rather than #!/bin/sh
    • If you are going to try to avoid bash, you must test on a system that does not have bash
  • Always include a shebang #!
  • Handle errors
    • Use set -eu (errexit & nounset)
  • Sould be idemponent if read via source
    • Use subshells to avoid leaking unintended variables into the parent scope
View local-bin
#!/bin/bash -eu
[[ -z ${1:-} ]] && \
echo -e "\n""Usage: $0 executable_path [destination_path] ""\n" || \
: $executable_path
exec="$( basename $executable_path )"
dir="$( dirname $executable_path )"
View temp
Thu Nov 14 12:11:48 EST 2019
View temp
Thu Nov 14 12:10:38 EST 2019
RichardBronosky / Fork your own
Last active Nov 14, 2019 — forked from antichris/
Fork your own Gist
View Fork your own

Fork your own Gist

It used to be possible to fork your own gists via the browser using a little JS magic. This is no longer the case. As an alternative, you can use Chris Wanstrath's cli tool to do the next best thing.




AWS Assume-Role requiring only aws-cli and jq



git clone arole
You can’t perform that action at this time.