Skip to content

Instantly share code, notes, and snippets.

Avatar

Brian Lalor blalor

View GitHub Profile
@blalor
blalor / init.lua
Created Dec 6, 2021
Hammerspoon config for auto-typing passwords from the macOS Keychain
View init.lua
function password_from_keychain(service)
-- 'service' should be saved in the login keychain
local cmd = "/usr/bin/security 2>&1 >/dev/null find-generic-password -gs '" .. service .. "' | sed -En '/^password: / s,^password: \"(.*)\"$,\\1,p'"
local handle = io.popen(cmd)
local result = handle:read("*a")
handle:close()
return (result:gsub("^%s*(.-)%s*$", "%1"))
end
@blalor
blalor / README.md
Last active Jan 7, 2020
Convert YAML to JSON
View README.md

yaml2json

Quick and dirty CLI tool for converting yaml to json.

example

[:~] 1 $ yaml2json <( echo -e '---\nfoo:\n- bar\n- baz' )
{
 "foo": [
@blalor
blalor / README.md
Last active Jan 7, 2020
Diff for JSON data
View README.md
@blalor
blalor / README.md
Last active Jan 7, 2020
download HashiCorp products (macOS)
View README.md

dl.sh

Shell script for downloading HashiCorp binaries.

Requires jq (brew install jq) and gpg (brew cask install gpg-suite).

example

I structure all my binaries as ~/devel/HashiCorp/binaries/<product>-<version>/<product> and adjust paths as needed based on the project I'm working on.

@blalor
blalor / go_clone
Last active Oct 31, 2018
clones a Go project into a new directory and sets up the workspace with direnv
View go_clone
#!/usr/bin/env python
# -*- encoding: utf-8 -*-
## clones a Go project into a new directory and sets up the workspace with direnv.
##
## example:
## $ go_clone git@github.com:hashicorp/nomad.git nomad
##
## * creates the "nomad" directory
## * creates a .envrc with "layout go" in it
@blalor
blalor / nomad-drain-and-wait.py
Last active Sep 27, 2020
systemd ExecStop script for Nomad
View nomad-drain-and-wait.py
#!/usr/bin/env python
# -*- encoding: utf-8 -*-
## in order to cleanly shut down a node with running jobs, the node needs to be
## drained, and then we need to wait for allocations to be migrated away. in
## this script, we:
## * set up a watch for node-update evals for the current node
## * wait for allocations currently running to complete
## * wait for allocations from the watched evals to start running
##
@blalor
blalor / brewviz.sh
Created Jul 27, 2016
homebrew dependency tree with graphviz
View brewviz.sh
#!/bin/bash
set -e -u -o pipefail
{
echo 'digraph G {'
brew list | while read cask; do
printf '"%s";\n' $cask
brew deps $cask | while read dep; do
@blalor
blalor / systemd-nspawn
Created Feb 25, 2016
systemd-nspawn replacement [containers/build#162]
View systemd-nspawn
#!/usr/bin/env bash
## this is a total hack. acbuild needs systemd-nspawn. initially, I tried
## running the go agent in a rkt container, but failed for reasons I forget
## right now (overlayfs problems?). then I ran into more problems with systemd-
## nspawn on CentOS 7.1, and I forget the origin. we're getting closer: in
## CentOS 7.2 I'm able to run acbuild as root outside of a container. but when
## running within the go agent, systemd-nspawn is killed for no discernable
## reason. so, we're back to faking out acbuild by providing this systemd-
## nspawn-alike.
@blalor
blalor / keybase.md
Last active Feb 13, 2016
keybase.md
View keybase.md

Keybase proof

I hereby claim:

  • I am blalor on github.
  • I am blalor (https://keybase.io/blalor) on keybase.
  • I have a public key ASBJhMUPPLE8Bt4qb6oj2khV8Xkz6ylOlVerdzNBi3r0Xgo

To claim this, I am signing this object: