Skip to content

Instantly share code, notes, and snippets.

Avatar
💭
I may be slow to respond.

Jörg Henning joerx

💭
I may be slow to respond.
  • Transferwise
  • Singapore
View GitHub Profile
@joerx
joerx / shorten.sh
Created Aug 17, 2020
Shorten AWS region name using regex
View shorten.sh
echo "eu-central-1" | sed -E s'/([a-z]{2})-([a-z]{1})[a-z]+-([0-9]{1})/|\1\2\3|/' # 'euc1'
View settings.json
{
"[terraform]": {
"editor.formatOnSave": true,
"editor.tabSize": 2
},
"terraform.indexing": {
"enabled": false,
"liveIndexing": false,
"delay": 500,
"exclude": [
@joerx
joerx / gist:6e398bb26e5527a948647a15cb76f7f3
Last active Nov 30, 2019
Russian roulette, Terraform edition. Because `rm -rf /` doesn't quite cut it anymore.
View gist:6e398bb26e5527a948647a15cb76f7f3
RISK=5
[[ $(( ( RANDOM % 6 ) + 1 )) -gt $RISK ]] && echo "terraform destroy -target module.production_db -auto-approve"
View gist:50aae01515158b993239be0fc3e12c67
# for discussion and alternatives, see https://unix.stackexchange.com/questions/227662/how-to-rename-multiple-files-using-find
find . -type f -name general.tf -not -path '*/.terraform/*' -exec sh -c 'x="{}"; mv "$x" "${x/general/backend}"' \;
@joerx
joerx / psql.md
Last active Jul 22, 2019
Postgres Cheat Sheet
View psql.md

List databases

\list
\l

Connect

View tomcat-users.xml
<?xml version="1.0" encoding="UTF-8"?>
<!--
Licensed to the Apache Software Foundation (ASF) under one or more
contributor license agreements. See the NOTICE file distributed with
this work for additional information regarding copyright ownership.
The ASF licenses this file to You under the Apache License, Version 2.0
(the "License"); you may not use this file except in compliance with
the License. You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
View helmns
function helmns() {
ctx=`kubectl config current-context`
ns=`kubectl config view -o=jsonpath="{.contexts[?(@.name==\"$ctx\")].context.namespace}"`
echo "Using tiller-namespace $ns"
helm --tiller-namespace $ns $@
}
@joerx
joerx / snippets.sh
Created Dec 21, 2018
Extract docker images from drone yaml
View snippets.sh
images=$(cat .drone.yml | grep "image: quay.io" | grep -v "hb-backend" | sed -e 's/[[:space:]]\{0,\}image: quay.io\/\(.*\)\/\(.*\)/\1\/\2/' | awk -F ':' '{ print $1 ":" ($2==""?"latest":$2) }' | uniq)
@joerx
joerx / script.sh
Created Dec 4, 2018
Delete RDS snapshots
View script.sh
#!/bin/sh
for snap in $(cat deleteme.txt); do
echo delete $snap
aws rds delete-db-snapshot --db-snapshot-identifier $snap
done
@joerx
joerx / script.sh
Created Oct 25, 2018
inspect kubeconfig client cert
View script.sh
#!/bin/sh
# Kubeconfig contains client keys and certs in base64 encoded form. The command below will decode the cert and show the plaintext output
# Note: 'yq' is a yaml wrapper around the awesome 'jq' - https://yq.readthedocs.io/en/latest/
# If anybody has an idea how to get kubeconfig output _including_ certs in json, let me know
cat ~/.kube/config | yq -r '.users[] | select(.name == "ap-southeast-1b.staging.kube.honestbee.com").user["client-certificate-data"]' | base64 -D | openssl x509 -text -noout