Skip to content

Instantly share code, notes, and snippets.

🏳️‍🌈
Breaking things

Noel Cower nilium

🏳️‍🌈
Breaking things
Block or report user

Report or block nilium

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
@nilium
nilium / gomodgraph
Created Mar 20, 2019
Tool to generate graphs of Go module dependencies
View gomodgraph
#!/usr/bin/env bash
# Based on https://github.com/go-modules-by-example/index/blob/master/014_mod_graph/README.md
OPEN=0
TYPE=svg
case "$1" in
-)
OUT=/dev/stdout
;;
'')
@nilium
nilium / Dockerfile
Last active Feb 18, 2019
Dockerfile to cross-compile Go binaries for a target platform and produce a Docker image for the target platform
View Dockerfile
# Dockerfile to cross-compile Go binaries for a target platform
#
# Usage:
# $ docker build --platform linux/arm .
# Cross-compile package for target platform from build platform
FROM --platform=${BUILDPLATFORM} golang:1-alpine AS build
ADD . /tmp/go
WORKDIR /tmp/go
@nilium
nilium / GNUmakefile
Created Jan 19, 2019
Terraform makefiles (bmake, gmake)
View GNUmakefile
TF_MODULES := $(shell find . -type f -iname '*.tf')
.PHONY: all plan apply
all: plan
plan: tf.plan
apply: tf.plan
terraform apply $<
@nilium
nilium / docker-ports
Last active Jan 3, 2019
Script to display docker containers with exposed / bound ports in dzen2
View docker-ports
#!/usr/bin/env bash
# Usage: docker-ports [format] <dzen2-args...>
#
# Displays open docker ports using dzen2.
#
# Example:
#
# $ docker-ports -fn 'PragmataPro-9' -dock
format_ports() {
@nilium
nilium / kv
Last active Dec 28, 2018
A few shell scripts for creating JSON from a shell
View kv
#!/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 Dec 27, 2018
Vim plugin to write/update a serial number comment
View serial.vim
" 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
View Updated version of the old git-wordiness script
#!/bin/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).
View git-mr
#!/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 Dec 20, 2018
Short bash script to create a JSON object from a sequence of key-value arguments
View jsonkv
#!/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 Mar 18, 2019
Ansible dynamic inventory script to pull GCE hosts
View gce-inventory
#!/usr/bin/env bash
set -e
usage() {
echo 'Usage: gce-inventory [--help|--list|--host HOSTNAME]' 1>&2
}
LIST_MODE=true
LOOKUP_HOST=
You can’t perform that action at this time.