Skip to content

Instantly share code, notes, and snippets.

View nilium's full-sized avatar
🍉
internal screaming intensifies

Noel nilium

🍉
internal screaming intensifies
View GitHub Profile
@nilium
nilium / kv
Last active December 28, 2018 02:00
A few shell scripts for creating JSON from a shell
#!/usr/bin/env bash
while [ $# -gt 0 ]; do
jq -nc --arg k "$1" --arg v "$2" '{($k): (try ($v|fromjson) catch $v)}'
shift; shift
done | jq -sc add
@nilium
nilium / serial.vim
Created December 27, 2018 18:16
Vim plugin to write/update a serial number comment
" serial.vim
" Noel Cower
"
" Plugin to insert serial strings based on a local timestamp.
"
" For example:
" Serial 20181227100403
"
" The above is this file's serial, inserted using :SerialUpdate. It can
" be updated with subsequent calls to :SerialUpdate. You can create
#!/usr/bin/env bash
# FIXME: Names with non-ASCII characters can throw off alignment of
# columns.
usage() {
cat <<HELPTXT 1>&2
git-wordiness [OPTIONS]
List general sums about commit messages (i.e., wc output).
@nilium
nilium / git-mr
Last active December 27, 2018 00:15
#!/usr/bin/env bash
# Copyright 2018 Noel Cower
#
# Permission is hereby granted, free of charge, to any person obtaining a copy
# of this software and associated documentation files (the "Software"), to deal
# in the Software without restriction, including without limitation the rights
# to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
# copies of the Software, and to permit persons to whom the Software is
# furnished to do so, subject to the following conditions:
#
@nilium
nilium / jsonkv
Created December 20, 2018 23:57
Short bash script to create a JSON object from a sequence of key-value arguments
#!/usr/bin/env bash
case "$1" in
-h|--help)
echo 'Usage: jsonkv [-h|--help] [--] KEY VALUE...' 1>&2
exit 2
;;
--)
shift
;;
esac
@nilium
nilium / gce-inventory
Last active March 18, 2019 16:57
Ansible dynamic inventory script to pull GCE hosts
#!/usr/bin/env bash
set -e
usage() {
echo 'Usage: gce-inventory [--help|--list|--host HOSTNAME]' 1>&2
}
LIST_MODE=true
LOOKUP_HOST=
@nilium
nilium / 1p-NOTICE.md
Last active January 12, 2019 18:33
A CLI tool to fuzzy-find 1Password vault items and copy / format them.

1p can now be found at

@nilium
nilium / fup
Last active January 6, 2019 05:15
Short script to upload a file to a GCS bucket and print its public URL
#!/usr/bin/env bash
prog="$(basename "$0")"
## Defaults
# : ${FUP_BUCKET:=YOUR-BUCKET}
# : ${FUP_URL_PREFIX:=https://CUSTOM-URL/}
: ${FUP_PAR_UPLOAD_THRESHOLD:=100M}
: ${FUP_URL_PREFIX:=https://storage.googleapis.com/${FUP_BUCKET}/}
@nilium
nilium / messages.go
Last active November 19, 2018 08:18
// This is an example message reader/writer with length prefixes and digests
// (in the example's case, using hmac-sha1) to try to confirm that the entire
// correct message was read.
package main
import (
"bytes"
"crypto/hmac"
"crypto/sha1"

Keybase proof

I hereby claim:

  • I am nilium on github.
  • I am nilium (https://keybase.io/nilium) on keybase.
  • I have a public key ASA9ZYQ-ovUYaqBiWNB9MPYWyy-cDcIQZym8orvks3qGvAo

To claim this, I am signing this object: