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 / index.html
Created May 15, 2016 19:48
Golang and Terminal.js web terminal
<html>
<head>
<script src="/terminal.js/dist/terminal.js"></script>
<style>
#terminal {
background: #000000;
color: #ffffff;
display: inline-block;
padding: 10px;
}
@apparentlymart
apparentlymart / iptables-round-robin.sh
Last active August 30, 2023 21:45
round robin to three ports on the same host with iptables
# The following example shows a way to use iptables for basic round-robin load balancing, by redirecting
# packets two one of three ports based on a statistic counter.
#
# TCP packets for new sessions arriving on port 9000 will rotate between ports 9001, 9002 and 9003, where
# three identical copies of some application are expected to be listening.
#
# Packets that aren't TCP or that related to an already-established connection are left untouched, letting
# the standard iptables connection tracking machinery send it to the appropriate port.
#
# For this to work well, connections need to be relatively short. Ideally there would be an extra layer
@apparentlymart
apparentlymart / Proposal.md
Created December 5, 2015 20:17
HTML Social Network

HTML Social Network

Back in July of 2008 I started thinking about HTML microformats for linking together and discovering social objects on the web.

I later discussed this with folks at the Internet Identity Workshop and after a few rounds of discussion we ended up working on Activity Streams instead, which shifted the focus to machine-readable descriptions of actions on social objects. However, the social object research here was the initial basis of what went on to become the "Object Types" in Activity Base Schema, after many iterations.

@apparentlymart
apparentlymart / Terraform-State-Ideas.md
Last active December 24, 2022 17:10
Terraform State Integrity Issues

Issues with Terraform State Management

The idea of "state" is the lynchpin of Terraform, and yet Terraform's workflow is fraught with gotchas that can lead to the loss or destruction of state. This doc is a set of notes about issues I've encountered, what caused them, and in many cases ideas about how to improve Terraform to avoid or reduce the chances of them.

Each of these scenarios has occured at least within my team. Each time one of these occurs it erodes people's confidence in Terraform, giving it a reputation for being fragile and unforgiving of errors. This this document is not written just to criticize but rather to identify ways in which the situation could be improved.

@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 / Makefile
Created September 14, 2014 02:16
LLVM Protothreads Implementation
protothread: protothread.o
gcc protothread.o -o protothread
protothread.o: protothread.s
as protothread.s -o protothread.o
protothread.s: protothread.ll
llc-3.4 protothread.ll
@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 / 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 / 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 / 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`)