Skip to content

Instantly share code, notes, and snippets.

View estahn's full-sized avatar
👨‍💻
ʕʘ̅͜ʘ̅ʔ – ʕ•̫͡•ʕ*̫͡*ʕ•͓͡•ʔ-̫͡-ʕ•̫͡•ʔ

Enrico Stahn estahn

👨‍💻
ʕʘ̅͜ʘ̅ʔ – ʕ•̫͡•ʕ*̫͡*ʕ•͓͡•ʔ-̫͡-ʕ•̫͡•ʔ
View GitHub Profile
@estahn
estahn / README.md
Created April 4, 2023 11:26
Windows AD Named Locations
https://ip-ranges.amazonaws.com/ip-ranges.json
jq -r '.prefixes[] | select(.service=="EC2") | .ip_prefix' ip-ranges.json | awk 'sub("$", "\r")' > aws-ec2-ip-ranges.txt

Upload aws-ec2-ip-ranges.txt

@estahn
estahn / !kubectl-secrets
Last active August 15, 2023 07:48
Simple shell function to read out Kubernetes secret in plain text
function kubectl-secrets () {
kubectl get secrets $@ -ojson | jq '{name: .metadata.name, data: .data | map_values(@base64d)}'
}
@estahn
estahn / domains.py
Last active September 29, 2023 10:55
Export AWS Route53 Domains to a CSV for Excel people
# Export AWS Route53 Domains to a CSV for Excel people
#
# Usage:
#
# python3 <(wget -q -O - https://gist.github.com/estahn/33ee9f0ecede6416a168489a7a24ee24/raw/5eef9122e573ff23bcd40732856565c37c708efd/domains.py)
#
from itertools import chain, starmap
import pandas as pd
from pandas.io.json import json_normalize #package for flattening json in pandas df
@estahn
estahn / rds-init.sh
Last active May 5, 2022 14:08
A workaround to get all data loaded into AWS RDS MySQL. When a read replica is restored from a snapshot, the replica won't wait for all the data to be transferred from Amazon Simple Storage Service (Amazon S3) to the Amazon Elastic Block Store (Amazon EBS) volume that's associated with the replica DB instance. The replica DB instance is availabl…
#!/bin/bash
host=$1
user=$2
password=$3
echo '' > $0.queue
databases=$(mysql -h $host -u $user -p$password -e "show databases" -sN | grep -v information_schema | grep -v mysql | grep -v sys)
for database in $databases; do
for table in $(mysql -h $host -u $user -p"$password" -N -B -e "show tables from \`$database\`"); do
@estahn
estahn / aws-iam-delete-user.sh
Last active February 3, 2022 11:59
A script to delete AWS IAM users programmatically.
#!/usr/bin/env bash
_process_user() {
_detach_policies $1 &
_delete_access_keys $1 &
wait
_delete_user $1 &
}
_detach_policies() {
@estahn
estahn / keybase.md
Created April 26, 2018 05:23
keybase.md

Keybase proof

I hereby claim:

  • I am estahn on github.
  • I am estahn (https://keybase.io/estahn) on keybase.
  • I have a public key ASC2Q8Hprpg4hYZylH_pXmBCVxFxZif6J5JqVOWf0CYHPwo

To claim this, I am signing this object:

#!/bin/sh
KUBECTL=$(which kubectl)
echo "CURRENT VERSION:"
kubectl version
echo ""
curl -o ${KUBECTL} -LO https://storage.googleapis.com/kubernetes-release/release/`curl -s https://storage.googleapis.com/kubernetes-release/release/stable.txt`/bin/darwin/amd64/kubectl
chmod 755 ${KUBECTL}
@estahn
estahn / metabase.service
Last active January 30, 2023 14:25
Systemd file for Metabase
[Unit]
Description=Metabase server
After=syslog.target
After=network.target
[Service]
WorkingDirectory=/home/data/tools/metabase
ExecStart=/usr/bin/java -jar /home/data/tools/metabase/metabase.jar
Environment=MB_JETTY_PORT=8080
User=data
@estahn
estahn / create.js
Last active May 19, 2017 23:32
lambda-formation Custom::Route53::HostedZone
var handler = require('lambda-formation').resource.create;
var util = require('lambda-formation').util;
var aws = require("aws-sdk");
var uuidV4 = require('uuid/v4');
/**
* Creates a Hosted Zone and supports delegation sets
*
* Type: "AWS::Route53::HostedZone"
* Properties:
---
AWSTemplateFormatVersion: '2010-09-09'
Metadata:
Version: 1
LastUpdated: 2017-05-16 16:58:35
UpdatedBy: estahn
Comments: Generated by cfn-ansible
Description: >