Skip to content

Instantly share code, notes, and snippets.

@deweysasser
deweysasser / terraform-generate-version-pin
Last active December 2, 2022 00:44
create a terraform version pin suitable for module
#!/bin/bash
set -ueo pipefail
# Purpose: generate a terraform versions.tf.json file for all providers
if [ -z "$*" ] ;then
set .
fi
for dir in "$@" ; do
(
@deweysasser
deweysasser / update-toc
Created February 24, 2021 16:11
A script to compute an table of contents for a Markdown file and update the file, replacing the section called "Contents" with a table of contents.
#!/bin/bash
set -ueo pipefail
# Purpose: update the TOC in markdown files
trap 'rm tmp$$' 0
gentoc() {
echo ""
@deweysasser
deweysasser / git-work
Last active November 5, 2019 17:37
A 'git work' subcommand that implement useful branching/pushing patterns for git feature branch workflows.
#!/bin/bash
# Purpose: Add a 'git work' subcommand with useful features:
# -- create new working branches, always from master
# -- support and enable a naming pattern for worrking branches
# -- be smart about where we're pushing merge requests
# -- keep track of working state
# Command Summary:
# git work <command>
@deweysasser
deweysasser / debug.txt
Created November 20, 2017 03:39
Terraform Debug Log
2017/11/19 22:37:16 [INFO] Terraform version: 0.11.0 ec9d4f1d0f90e8ec5148f94b6d634eb542a4f0ce+CHANGES
2017/11/19 22:37:16 [INFO] Go runtime version: go1.9
2017/11/19 22:37:16 [INFO] CLI args: []string{"C:\\tools\\cygwin\\bin\\terraform.exe", "plan"}
2017/11/19 22:37:16 [DEBUG] Attempting to open CLI config file: C:\Users\dewey\AppData\Roaming\terraform.rc
2017/11/19 22:37:16 [DEBUG] File doesn't exist, but doesn't need to. Ignoring.
2017/11/19 22:37:16 [INFO] CLI command args: []string{"plan"}
2017/11/19 22:37:16 [INFO] command: empty terraform config, returning nil
2017/11/19 22:37:16 [DEBUG] command: no data state file found for backend config
2017/11/19 22:37:16 [DEBUG] New state was assigned lineage "302697b4-4f77-499e-ab15-f2ee4f74e6a0"
2017/11/19 22:37:16 [INFO] command: backend initialized: <nil>

Keybase proof

I hereby claim:

  • I am deweysasser on github.
  • I am deweysasser (https://keybase.io/deweysasser) on keybase.
  • I have a public key ASD4fIo0NcSi3jxRVm1EoaGiN1z-WyKvqoororJ7eCQJCwo

To claim this, I am signing this object:

@deweysasser
deweysasser / .bash_profile
Created March 23, 2017 19:11
Reattaching to SSH agent in GNU screen
if [ -z "${STY}" -a -t 0 ]; then
reattach () {
if [ -n "${SSH_AUTH_SOCK}" ]; then
ln -snf "${SSH_AUTH_SOCK}" "${HOME}/.ssh/agent-screen"
SSH_AUTH_SOCK="${HOME}/.ssh/agent-screen" export SSH_AUTH_SOCK
fi
exec screen -e^Oo -A -D -RR ${1:+"$@"}
}
fi
@deweysasser
deweysasser / WriteSet.java
Created March 22, 2017 22:27
An interesting pattern of ACID multi-file writes in Java
import java.io.BufferedOutputStream;
import java.io.BufferedWriter;
import java.io.Closeable;
import java.io.File;
import java.io.FileOutputStream;
import java.io.FileWriter;
import java.io.IOException;
import java.io.ObjectOutputStream;
import java.io.OutputStream;
import java.io.OutputStreamWriter;