Skip to content

Instantly share code, notes, and snippets.

@vancluever
vancluever / snippet.go
Created December 5, 2016 15:43
NewDockerAPIDriver Function for Packer
// NewDockerAPIDriver loads an instance of the Docker API driver. It will
// also log into a docker registry if the appropriate options are defined.
//
// Configuration is handled in the following order:
// * tls_verify on: Use NewTLSClient
// * This breaks if ca_certificate, client_certificate, and client_key are
// not provided.
// * NewClient, if endpoint is supplied
// * NewEnvClient if all other options have been exhausted.
//
@vancluever
vancluever / teleport-webasset-curl-fail.txt
Created January 2, 2017 02:18
Teleport webassets download fail (fonts and icons)
$ curl -k -v https://127.0.0.1:3080/web/app/assets/fonts/fontawesome-webfont.woff2 > /dev/null
* Trying 127.0.0.1...
* TCP_NODELAY set
% Total % Received % Xferd Average Speed Time Time Time Current
Dload Upload Total Spent Left Speed
0 0 0 0 0 0 0 0 --:--:-- --:--:-- --:--:-- 0* Connected to 127.0.0.1 (127.0.0.1) port 3080 (#0)
* ALPN, offering http/1.1
* Cipher selection: ALL:!EXPORT:!EXPORT40:!EXPORT56:!aNULL:!LOW:!RC4:@STRENGTH
* successfully set certificate verify locations:
* CAfile: /etc/ssl/certs/ca-certificates.crt
@vancluever
vancluever / Dockerfile.teleport.v1.3.1
Created January 2, 2017 02:25
Quick Dockerfile for Gravitational Teleport (http://gravitational.com/teleport/)
FROM ubuntu:latest
RUN apt-get update && apt-get -y install curl make && \
cd /tmp && \
curl -LO https://github.com/gravitational/teleport/releases/download/v1.3.1/teleport-v1.3.1-linux-amd64-bin.tar.gz && \
tar zxvf teleport-v1.3.1-linux-amd64-bin.tar.gz && \
cd teleport && \
make install && \
rm -rf /tmp/* && \
rm -rf /var/lib/apt/lists
@vancluever
vancluever / ipcalcandplan.sh
Created January 27, 2017 21:10
Bash script to calculate a set of subnets off a network address
#!/usr/bin/env bash
# ip_to_decmial takes a dotted-quad IPv4 address and returns the decimal form
# on stdout.
ip_to_decmial() {
local ip_bytes=(${1//./ })
local ip_decimal=0
for n in 0 1 2 3; do
ip_decimal=$(( ip_decimal | ip_bytes[n] << 8 * 3 - 8 * n ))
@vancluever
vancluever / main.tf
Created February 9, 2017 18:34
Sample terraform-provider-acme config
variable "email_address" {
type = "string"
}
variable "domain" {
type = "string"
}
resource "tls_private_key" "private_key" {
algorithm = "RSA"
@vancluever
vancluever / dectoipv4.js
Created February 17, 2017 19:25
IPv4 decimal to dotted quad conversion - https://jsfiddle.net/t7fu2fgy/ - works in Google Apps Script too
function decimalToIPv4(decIpAddr) {
ipBytes = [];
for (i=0;i<=3;i++) {
ipBytes.push((decIpAddr >> 8 * 3 - 8 * i) & 255);
}
return ipBytes.join(".");
}
@vancluever
vancluever / rndpass.rb
Created February 21, 2017 21:58
Ruby random password generation - classic example
PW_RANGE = [*'0'..'9', *'A'..'Z', *'a'..'z'].freeze
password = Array.new(16) { PW_RANGE.sample }.join
puts password
@vancluever
vancluever / wrap.go
Last active March 22, 2017 17:41
GoLang Kata WordWrap (Non-Unicode) - https://play.golang.org/p/zu9k0qjUzU
package main
import (
"bytes"
"fmt"
)
const in = "Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. Ut enim ad minim veniam, quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo consequat. Duis aute irure dolor in reprehenderit in voluptate velit esse cillum dolore eu fugiat nulla pariatur. Excepteur sint occaecat cupidatat non proident, sunt in culpa qui officia deserunt mollit anim id est laborum."
func wrap(old string, ll int) string {
@vancluever
vancluever / terraform-old-remote-config.sh
Last active April 15, 2017 16:01
A paraphrasing of Terraform's old remote config command
terraform remote config \
-backend=s3
-backend-config="bucket=tfstate.foobar.local" \
-backend-config="key=FE/app-frontend/${ENV}/${REGION}/terraform.tfstate"
@vancluever
vancluever / old-tf-run-env.sh
Created April 15, 2017 16:02
Invoking terraform with env and region params (old way)
TF_VAR_env=${ENV} TF_VAR_region=${REGION} \
terraform apply