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 / zshasum
Last active September 29, 2018 22:27
#!/usr/bin/env bash
args=()
while [ $# -gt 0 ]; do
case "$1" in
--) shift; break;;
-?*) :;;
-) break;;
*) break;;
esac
@nilium
nilium / agentr
Last active August 31, 2018 23:04
Lazy script to run ag and entr in conjunction with a series of commands.
#!/usr/bin/env bash
prog="$(basename "$0")"
want() {
for bin; do
if ! hash "$bin" 1>/dev/null 2>&1; then
echo "$bin: not installed" 1>&2
exit 1
fi
@nilium
nilium / codf.md
Last active July 9, 2018 03:53
Codf rationale draft 2

Codf exists primarily to make expressive, structured configuration easy to use. Expressive in this case means, more or less, relatively complex but easy to read and write. There are cases of progams like this in the wild, such as nginx, where configuration is integral to making use of them. Codf takes inspiration from nginx in particular, along with other curly-braced config languages. The goal is to provide structure for programs where the status quo of JSON-equivalent languages do not.

With that in mind, codf is the result of several years of building programs that require configuration to define their runtime behavior. This includes several programs whose configuration borders on scripting. These programs need configuration not only for inputs (sockets, files, DBs) and outputs (metrics, logs, more DBs), but also tasks, schedules, data pipelines, state transitions, and so on. Without these, the programs are mostly inert and do nothing — this makes configuration crucial to

@nilium
nilium / codf.md
Last active July 8, 2018 21:22
Codf rationale draft

Codf

codf (godoc) is a personal config language for declaring structured config files with support for a range of built-in types. It's meant to scratch an itch I've had over configuration in Go programs for some time.

@nilium
nilium / args.go
Last active March 26, 2018 01:07
Boring multi-command dd-like argument parsing
// args.go is a CLI arg parser for ipexec and other tools I've written but not released.
// It is here mainly as a backup since I don't feel particularly compelled to make a package out of it.
// TODO: Figure out which version is newest and update this.
package main
import (
"net/url"
"strconv"
@nilium
nilium / qwerty.txt
Created February 17, 2018 05:41
Advantage 2 Config
[escape]>[caps]
[caps]>[escape]
[kp-caps]>[kp-escape]
[up]>[down]
[down]>[up]
[kp-right]>[kp-down]
[kp-left]>[kp-up]
[intl-\]>[=]
[kp-insert]>[kp-lalt]
[kp=]>[kp=mac]
@nilium
nilium / expand.go
Created December 4, 2017 20:54
expand package for Go to handle ${VAR:-foo} style expansions
// Package expand is used to handle basic ${VAR:-DEFAULT} style text interpolations.
//
// It currently only supports ASCII variable names, since you probably won't see variations on that
// in the wild.
package expand
import (
"bytes"
"strings"
@nilium
nilium / recover-vim
Created July 24, 2017 17:25
Dumb little script to find and ostensibly let someone list / recover vim swap files
#!/usr/bin/env bash
# vim: set tw=80 sw=2 ts=2 et :
# USAGE: recover-vim [-h|-help] [CMD...]
#
# See usage text below for more information.
case "$1" in
[-/]h|[-/]help|--help)
cat <<'USAGE'
USAGE: recover-vim [-h|-help] [CMD...]
@nilium
nilium / multi-instance-run
Last active May 4, 2017 20:00
run script to spawn a runsvdir subprocess for a multi-instance service
#!/usr/bin/env sh
# vim: set ft=sh tw=80 sw=2 ts=2 et :
#
# Environment Variables:
# SV_INSTANCES -- the number of instances to spawn under ./instances
# SV_STOP_WAIT -- controls the shutdown wait time for instances
# SV_NAME -- controls the name of the service -- must not contain directory
# separators. Defaults to the basename of the current directory.
#
# If an env file is present in the current directory and readable, the run
@nilium
nilium / zap_proto.go
Created April 7, 2017 15:18
Zap protobuf marshaler -- maybe eventually document it, test it, put it in a repo.. 'til then, snippet.
package pbzap
import (
"encoding/base64"
"fmt"
"reflect"
"sort"
"strings"
"sync"