Skip to content

Instantly share code, notes, and snippets.

@irgeek
irgeek / README.md
Last active December 10, 2021 16:42
Finding AMIs after building an image with Packer

Finding Packer-generated AMIs automatically after builds

The basic technique is to have Packer add a tag with a unique value during the build, and use AWS' built-in filtering capabilities to find that specific AMI after the build finishes.

  • template.json - Shows the settings that need to be added to your template
  • build.sh - Shows how to use the template to do a build and retrieve the AMI information
@irgeek
irgeek / ssh-agent.sh
Created January 2, 2015 05:08
Shell script (bash) to persist ssh-agent environment variables...
# Bash script to maintain a persistent ssh-agent across multiple
# invocations of your shell when the parent process launching them
# does not set the necessary environment variables.
AGENT_VARS_FILE="${HOME}/.ssh/agent-vars.sh"
start_agent() {
rm -f ${AGENT_VARS_FILE}
touch ${AGENT_VARS_FILE}
chmod 600 ${AGENT_VARS_FILE}
[[ -s ${AGENT_VARS_FILE} ]] && { echo "Resetting agent file failed. Non-zero length!"; exit 1; }
@irgeek
irgeek / keybase.md
Last active February 19, 2016 01:57
Keybase proof

Keybase proof

I hereby claim:

  • I am irgeek on github.
  • I am irgeek (https://keybase.io/irgeek) on keybase.
  • I have a public key ASDUY2TB580FvHixmDAUwO-oWxA3nWV23WtXPP4HbxTJHwo

To claim this, I am signing this object:

#!/bin/sh
BOOT2DOCKER_CERTS_DIR=/var/lib/boot2docker/certs
CERTS_DIR=/etc/ssl/certs
CAFILE=${CERTS_DIR}/ca-certificates.crt
for cert in $(/bin/ls -1 ${BOOT2DOCKER_CERTS_DIR}); do
SRC_CERT_FILE=${BOOT2DOCKER_CERTS_DIR}/${cert}
CERT_FILE=${CERTS_DIR}/${cert}
HASH_FILE=${CERTS_DIR}/$(/usr/local/bin/openssl x509 -noout -hash -in ${SRC_CERT_FILE} 2>/dev/null)
@irgeek
irgeek / test-ciphers.sh
Last active March 2, 2016 05:29
Script to test SSL cipher availability
#!/bin/bash
#_red() { echo '\e[31m'"$1"'\e[m'; }
#_grn() { echo '\e[32m'"$1"'\e[m'; }
#_ylw() { echo '\e[33m'"$1"'\e[m'; }
test_cipher_proto() {
local cipher endpoint proto proto_flag result ret
cipher=${1}
endpoint=${2}
proto=${3}
@irgeek
irgeek / spiffy.sh
Created June 3, 2016 04:14
Spiffy calculation on the command line!
#!/bin/bash
spiffy_calc() {
local -a FIRST_ARG
local -a ACC
for var in "$@"; do
if [[ ${var} == "in" ]]; then
FIRST_ARG=("${ACC[@]}")
ACC=()
else
@irgeek
irgeek / README.md
Created November 15, 2017 00:15
Australian Marriage Survey Results

Australian Marriage Survey Results

The attached file contains the results of the Australian Marriage Survey in JSON format, scraped from the "Australian Marriage Law Postal Survey 2017 - Response.xls" Excel spreadsheet provided by the ABS here

@irgeek
irgeek / dice.html
Last active September 19, 2018 10:05
HTML/CSS/JS Dice
<!doctype html>
<html>
<head>
<title>Dé de Couleurs</title>
<meta name="description" content="Dé de Couleurs">
<meta name="keywords" content="dice colour random">
<meta charset="utf-8">
</head>
<style type="text/css" media="screen">
* {
#!/bin/bash
_red() { echo '\[\e[31m\]'"$1"'\[\e[m\]'; }
_grn() { echo '\[\e[32m\]'"$1"'\[\e[m\]'; }
_ylw() { echo '\[\e[33m\]'"$1"'\[\e[m\]'; }
_blu() { echo '\[\e[34m\]'"$1"'\[\e[m\]'; }
_fus() { echo '\[\e[35m\]'"$1"'\[\e[m\]'; }
_cyn() { echo '\[\e[36m\]'"$1"'\[\e[m\]'; }
_wht() { echo '\[\e[37m\]'"$1"'\[\e[m\]'; }
_ppl() { echo '\[\e[38;5;55m\]'"$1"'\[\e[m\]'; }
_lgrn() { echo '\[\e[38;5;84m\]'"$1"'\[\e[m\]'; }
@irgeek
irgeek / Makefile
Last active September 12, 2019 14:40
Minimal test case to show aws-cli cloudformation package regression.
S3_BUCKET := cf-templates-1wwumiwcx5krz-ap-southeast-2
S3_PREFIX := 8b87ca7b-869e-4401-baa0-ad0522e32f21
AWSCLI := .venv/bin/aws
all: parent.pyaml
parent.pyaml: child.pyaml
child.pyaml: grandchild.pyaml