Skip to content

Instantly share code, notes, and snippets.

View maxmanders's full-sized avatar

Max Manders maxmanders

View GitHub Profile
if executable('asdf')
let g:asdf_go_path = trim(system('asdf where golang'))
let g:go_bin_path = g:asdf_go_path . "/go/bin"
endif
@maxmanders
maxmanders / es.zshrc
Last active June 28, 2021 11:01
Some useful shell functions for those ElasticSearch queries you never remember
#!/usr/bin/env bash
es_get_endpoint() {
local domain_name
local endpoint
domain_name="${1}"
endpoint="$(aws es describe-elasticsearch-domain --domain-name ${domain_name} --query 'DomainStatus.Endpoints.vpc' | tr -d '"')"
if [ "${endpoint}" = "null" ]; then
endpoint="$(aws es describe-elasticsearch-domain --domain-name ${domain_name} --query 'DomainStatus.Endpoint' | tr -d '"')"
@maxmanders
maxmanders / vaultwalk.sh
Created January 24, 2020 13:38
Recursively walk a Vault secret path prefix
#!/usr/bin/env bash
export VAULT_ADDR="http://${VAULT_IP}:${VAULT_PORT}"
vaultwalk() {
local prefix
local secret_keys
prefix="${1}"
if [ -z "${prefix}" ]; then
@maxmanders
maxmanders / tf_0_main.tf
Last active June 18, 2019 14:22
Terraform Issue | Conditionally Using New Resource
locals {
project = "tfternarywtf"
chosen_sg = "${var.security_groups}"
}
data "aws_ami" "ubuntu" {
most_recent = true
filter {
name = "name"
def remove(emails, infile):
try
if emails and infile:
raise ValueError('Specify one or more emails, or a file path, but not both')
pass
except ValueError as e:
print(e)
sys.exit(1)
if emails:
@maxmanders
maxmanders / example.py
Created October 6, 2017 16:32
Apply multiple filters with arguments to a list
def filter_list(*args):
filters = list(args)
stuff = #some Boto3 call with a list of dictionaries
filtered = (s for s in stuff['Foo']
if all([f(s) for f in filters]))
return filtered
@maxmanders
maxmanders / out.sh
Created September 24, 2017 14:43
ZSH CI
max at maxmanders-laptop in ~/dev/dotfiles (master)
$ cat test.sh
#!/bin/bash
set -e
set -o pipefail
ZSH=$(which zsh)
BASH=$(which bash)
ERRORS=()
@maxmanders
maxmanders / shellcheck.sh
Created September 24, 2017 11:28
Bash compatible Zsh And Shellcheck
ZSH=$(which zsh)
BASH=$(which bash)
shellcheck <(sed "s|#\!${ZSH}|#\!${BASH}|g" < .zshrc.d/functions.zshrc)
@maxmanders
maxmanders / kms_example.sh
Created April 13, 2017 11:36
KMS Envelope Encryption Using OpenSSL And AWS CLI
$ echo "secret" > secret.txt
$ key_material=$(aws kms generate-data-key --key-id <CMK_key_id> --key-spec AES_256)
$ echo ${key_material} | jq ".CiphertextBlob" | sed 's/"//g' | base64 -d > key.enc
$ export key=$(echo ${key_material} | jq ".Plaintext" | sed 's/"//g' | base64 -d)
$ openssl enc -aes-256-cbc -pass env:key -in secret.txt -out secret.txt.enc
$ rm secret.txt
$ ls
key.enc secret.txt.enc
$ key=$(aws-fd-full kms decrypt --ciphertext-blob fileb://key.enc --output text --query Plaintext | base64 -d)
$ openssl enc -d -aes-256-cbc -pass env:key -in secret.txt.enc -out secret.txt

Keybase proof

I hereby claim:

  • I am maxmanders on github.
  • I am maxmanders (https://keybase.io/maxmanders) on keybase.
  • I have a public key whose fingerprint is 4D42 A117 3318 1A17 0A98 DDFA 7D04 E21E 3610 854A

To claim this, I am signing this object: