Skip to content

Instantly share code, notes, and snippets.

View apparentlymart's full-sized avatar
⌨️
I may be slow to respond.

Martin Atkins apparentlymart

⌨️
I may be slow to respond.
View GitHub Profile
@apparentlymart
apparentlymart / README.md
Created June 28, 2021 16:20
Terraform MIME types module

The idea here is to parse the typical mime.types format used by web servers like Apache HTTPD to infer Content-Type values based on filename suffixes, and then convert the result into the map structure expected by the shared module hashicorp/dir/template.

This can therefore get a similar effect to serving files from a static web server, using the same mime.types as was used on that server in order to ensure selection of the same content types.

@apparentlymart
apparentlymart / keybase.md
Created November 2, 2019 01:29
Keybase Proof

Keybase proof

I hereby claim:

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

To claim this, I am signing this object:

@apparentlymart
apparentlymart / insteon_decode.go
Created August 17, 2019 21:23
Insteon RF decoding in Go
package main
import (
"bufio"
"bytes"
"fmt"
"os"
)
var frameStartN = []byte(`0011000101010101`)
@apparentlymart
apparentlymart / generic_set.go
Created July 27, 2019 17:11
A prototype Set implementation using the second round of Go Generics proposal with contracts
// Package set is an adaptation of an existing Set implementation I wrote (that
// originally used interface{} as its underlying type) to the current Go 2
// Generics proposal at the time of this writing:
// https://go.googlesource.com/proposal/+/4a54a00950b56dd0096482d0edae46969d7432a6/design/go2draft-contracts.md
//
// This adaptation retains the existing feature that a set can be of any type,
// without that type needing to be extended with any additional methods, as long
// as the caller can provide a separate Rules type that provides the necessary
// additional operations. Generics allows the compiler to check the requirement
// that only sets with the same rules can be used together, which was previously
@apparentlymart
apparentlymart / terraform-pr-migrate.go
Created June 14, 2017 19:16
Terraform Provider PR migration helper
//
// This is a helper program to do some of the more tedious steps of migrating
// Terraform provider commits from an older PR in the main Terraform repo to
// a new PR in the new provider repo.
//
// Specifically it:
// - Retrieves the PR commits from the Terraform repo
// - Computes the diff for each commit that the PR introduced
// - Does basic rewriting of paths in the diff for conventions in the new repos
// - Tries to apply the rewritten diff, creating new commits in the current repo
@apparentlymart
apparentlymart / go-here.sh
Created April 1, 2017 15:46
Helper bash script for creating and activating GOPATHs
# Note: this is written for and tested only in bash
function _go-here {
DIR="$1"
export GOPATH="$DIR"
export PATH="$GOPATH/bin":$PATH
echo Activating GOPATH="$GOPATH"
}
function go-here {
@apparentlymart
apparentlymart / diverge.js
Last active October 19, 2016 04:33
Highland Diverge Stream, pull edition
var _ = require('highland');
var items = [
'a',
'b',
'c',
'd',
'e',
'f',
@apparentlymart
apparentlymart / keybase.md
Created September 21, 2016 23:40
Keybase Claim

Keybase proof

I hereby claim:

  • I am apparentlymart on github.
  • I am apparentlymart (https://keybase.io/apparentlymart) on keybase.
  • I have a public key whose fingerprint is BBE3 1AF5 8D12 1501 A495 FE10 6D98 B19B CF7A CB7A

To claim this, I am signing this object:

@apparentlymart
apparentlymart / extract-certs.py
Created September 12, 2016 00:48
Python script to extract generated TLS certificates and keys from a Terraform state
import errno
import json
import os
import os.path
tf_state_path = os.path.join(os.path.dirname(__file__), "..", "terraform.tfstate")
tf_state_file = open(tf_state_path, 'rb')
tf_state = json.load(tf_state_file)
tf_state_file.close()
@apparentlymart
apparentlymart / .padstone.hcl
Last active May 23, 2016 03:38
Padstone v2: Multiple targets, like a Makefile
# Variables are set on the command line:
# padstone build version=v0.0.1 ami
variable "version" {
default = "dev"
}
provider "aws" {
region = "us-west-2"
}