Skip to content

Instantly share code, notes, and snippets.

@bdclark
bdclark / docker-login-ecr-sso.py
Created January 6, 2022 16:16
Script to perform docker login to AWS ECR using AWS SSO config
#!/usr/bin/env python
import argparse
import configparser
from shutil import which
import subprocess
import sys
import os
CONFIG_PATH = os.path.expanduser("~/.aws/config")

Keybase proof

I hereby claim:

  • I am bdclark on github.
  • I am bdclark (https://keybase.io/bdclark) on keybase.
  • I have a public key whose fingerprint is C225 60CD B4CD A11C 5C06 4FDF 6F9E 1CD6 C7DE E7E3

To claim this, I am signing this object:

@bdclark
bdclark / mysqldump-s3.sh
Last active November 21, 2023 12:47
Backup MySQL directly to S3
#!/usr/bin/env bash
set -euf -o pipefail
# Set defaults, can be overriden with config_file (-f)
host="127.0.0.1"
port="3306"
user=
password=
excluded_dbs= # must be comma-delimeted, eg "mysql,test,innodb"
included_dbs=
@bdclark
bdclark / user-data-consul-server
Last active September 27, 2020 17:56
CoreOS cloud-config to bootstrap consul cluster
#cloud-config
coreos:
etcd2:
# generate a token from https://discovery.etcd.io/new?size=3
discovery: https://discovery.etcd.io/<token>
advertise-client-urls: http://$private_ipv4:2379
initial-advertise-peer-urls: http://$private_ipv4:2380
listen-client-urls: http://0.0.0.0:2379
listen-peer-urls: http://$private_ipv4:2380
#!/bin/bash
set -e
#
# git-mv-with-history -- move/rename file or folder, with history.
#
# Moving a file in git doesn't track history, so the purpose of this
# utility is best explained from the kernel wiki:
#
# Git has a rename command git mv, but that is just for convenience.
# The effect is indistinguishable from removing the file and adding another
@bdclark
bdclark / hipchat_notify.py
Last active July 29, 2018 17:58
Example python function to notify HipChat room using API version 2
#!/usr/bin/env python
from __future__ import print_function
import requests
import sys
import json
def hipchat_notify(token, room, message, color='yellow', notify=False,
format='text', host='api.hipchat.com'):
@bdclark
bdclark / ldif_export.sh
Last active August 29, 2015 14:04
Simple LDIF export
#!/usr/bin/env bash
set -e
usage() {
cat <<EOF
Usage: $0 H|D|W|M
Export ldif in gzip format, send to S3 bucket
Assumes bucket policy will handle file lifecycles