Skip to content

Instantly share code, notes, and snippets.

@jpluscplusm
jpluscplusm / dec2ip.awk
Created February 5, 2020 22:32
AWK IPv4 to/from decimal
#!/usr/bin/awk
# 1-liner: awk '{for(i=0;i<4;i++){byte=$1%256;ip="." byte ip;$1-=byte;$1/=256}}END{sub(".","",ip);print ip}'
{
for(i=0; i<4; i++) {
byte = $1 % 256
ip = "." byte ip
$1 -= byte
$1 /= 256
}
@jpluscplusm
jpluscplusm / log-indent-test.sh
Created December 3, 2019 21:39
Shell log formatter with increment/decrement indentation thingy
#!/usr/bin/env bash
set -ueo pipefail
outofbandlogstring="This string must NEVER appear in the script's stdout/err ..." # or, like, simply "§" ...
function enter() {
echo "$@"
echo "${outofbandlogstring}+2"
}
@jpluscplusm
jpluscplusm / vpnc-script-aws
Last active July 12, 2018 12:53 — forked from alext/vpnc-script-aws
vpnc script to route all AWS IP ranges over VPN.
#!/bin/bash
# vpnc-script wrapper for use with openconnect that routes all AWS IP ranges over the VPN.
# Pass any additional IP ranges to be routed as args to the script.
#
# Requirements: bash, curl and jq.
#
# Example usage:
# openconnect https://vpn.example.com/profile --script '/path/to/vpnc-script-aws'
#
@jpluscplusm
jpluscplusm / instance.tf
Created July 13, 2017 11:10
Dagnammit, Terraform
resource "aws_instance" "instance" {
ami = "ami-32rrg4334f"
instance_type = "t2.small"
subnet_id = "subnet-abc123dasf"
key_name = "key"
associate_public_ip_address = false
vpc_security_group_ids = [
"${aws_security_group.1.id}",
@jpluscplusm
jpluscplusm / test.bats
Last active July 22, 2017 01:34
Per-file setup/teardown support for BATS
setup() {
# Global setup
if [ $BATS_TEST_NUMBER -eq 1 ]; then
{
echo export FOO=bar
} >${BATS_TMPDIR}/bats.import.$PPID
fi
. ${BATS_TMPDIR}/bats.import.$PPID
# Per-test setup as per documentation
@jpluscplusm
jpluscplusm / .gitignore
Last active September 17, 2016 00:03
Terraform Makefile wrapper with remote state mgmt/bootstrap
/.terraform/terraform.tfstate*
/plan.out
/.plan.out.*
@jpluscplusm
jpluscplusm / awk-ad
Last active August 22, 2016 15:21
AWK invocations for ASCII-delimited operation
#!/bin/bash
# ASCII-delimited input and output
awk -vFS="\x1F" -vRS="\x1E" -vOFS="\x1F" -vORS="\x1E" "$@"
@jpluscplusm
jpluscplusm / infra-secret-management-overview.md
Created May 9, 2016 18:54 — forked from maxvt/infra-secret-management-overview.md
Infrastructure Secret Management Software Overview

Currently, there is an explosion of tools that aim to manage secrets for automated, cloud native infrastructure management. Daniel Somerfield did some work classifying the various approaches, but (as far as I know) no one has made a recent effort to summarize the various tools.

This is an attempt to give a quick overview of what can be found out there. The list is alphabetical. There will be tools that are missing, and some of the facts might be wrong--I welcome your corrections. For the purpose, I can be reached via @maxvt on Twitter, or just leave me a comment here.

There is a companion feature matrix of various tools. Comments are welcome in the same manner.

@jpluscplusm
jpluscplusm / index.md
Created April 29, 2016 21:12 — forked from lusis/index.md
Docker "Best Practices"

This is a copy/paste from an internal wiki on how we should use docker

This guide is to serve as an outline of internal best practices to using Docker. The idea is to give enough information to allow engineers to create containers for new stack components while minimizing the cleanup required to make them production ready.

Concepts

Before we get to the practices, it's important to understand WHY we are doing this. The key concepts we're concerned about with broad Docker usage are provenance, determinism, repeatability and auditability.

Provenance

Provenance refers to knowing WHERE something comes from. Generally with the end use of software, this is easy:

  • Maven artifacts are pulled from central