Skip to content

Instantly share code, notes, and snippets.

View johnhpatton's full-sized avatar

John H Patton johnhpatton

View GitHub Profile
@johnhpatton
johnhpatton / Dockerfile
Created July 11, 2024 19:03
MySQL Dockerfile
FROM bitnami/mysql:5.7 AS initial
ENV ALLOW_EMPTY_PASSWORD=yes
ENV MYSQL_MODE=""
USER root
RUN apt update && \
apt install -y unzip && \
apt-get clean && \
@johnhpatton
johnhpatton / install-latest-docker-compose.sh
Last active July 8, 2024 22:21
Install latest docker compose
UNAME_M=$(uname -m)
UNAME_S=$(uname -s)
UNAME_S=${UNAME_S,,}
[[ $UNAME_M =~ amd64|x86_64 ]] && ARCH=x86_64 || ARCH=aarch64
URL_GITHUB_DOCKER_COMPOSE_RELEASES_API="https://api.github.com/repos/docker/compose/releases/latest"
URL_GITHUB_DOCKER_COMPOSE_RELEASES_DOWNLOAD_PREFIX="https://github.com/docker/compose/releases/download"
DOCKER_COMPOSE_LATEST_VERSION=$(curl -s "${URL_GITHUB_DOCKER_COMPOSE_RELEASES_API}" | grep '.tag_name' | sed -r 's/^[^:]*:.*\"(.*)\".*/\1/')
URL_GITHUB_DOCKER_COMPOSE_DOWNLOAD="${URL_GITHUB_DOCKER_COMPOSE_RELEASES_DOWNLOAD_PREFIX}/${DOCKER_COMPOSE_LATEST_VERSION}/docker-compose-${UNAME_S}-${ARCH}"
BIN_DOCKER_COMPOSE=${DOCKER_CONFIG:-$HOME/.docker/cli-plugins/docker-compose}
@johnhpatton
johnhpatton / build-loki-docker-driver
Created July 8, 2024 15:58
Build loki docker driver
cd ~/src
git clone git@github.com:grafana/loki.git
cd loki
make LOKI_DOCKER_DRIVER=loki PLUGIN_TAG=latest docker-driver
make LOKI_DOCKER_DRIVER=loki PLUGIN_TAG=latest docker-driver-enable
function logbashrc() {
[[ $- =~ i ]] && echo "$1"
return 0
}
function pathadd() {
local option=""
local retval=0
if [[ "${1:0:1}" = "-" ]]; then
option=$1 && shift
logbashrc() {
[[ $- =~ i ]] && echo "$1"
return 0
}
pathadd() {
local option=""
local retval=0
if [[ "${1:0:1}" = "-" ]]; then
option=$1 && shift
#!/bin/bash
# May be required to avoid SSL certificate validation.
# NOTE: manually validate the CA in this case.
export INSECURE=${INSECURE:-true}
# Set to user id for access:
OPENCONNECT_USER="USERNAME"
# Set to server without scheme, use what's configured in client config:
@johnhpatton
johnhpatton / bashrc
Created June 22, 2022 11:38
a pretty good .bashrc
logbashrc() {
(( INTERACTIVE )) && echo "$1"
return 0
}
pathdedup() {
local retval=0
local opt= dir= deduped=
# default to PATH
@johnhpatton
johnhpatton / install-mac-golang.sh
Last active June 21, 2022 16:37
Installs golang on mac
#!/usr/bin/env bash
ARCH=$(uname -m)
TEMPDIR=/tmp
echo "Installing some python packages..."
python --version
python -m pip install azure-cli
python -m pip install ansible
@johnhpatton
johnhpatton / install-mac.sh
Last active June 21, 2022 16:25
Install Mac Things
#!/usr/bin/env bash
TEMPDIR=$(mktemp -d)
pushd "${TEMPDIR}"
[ ! -d "$HOME/bin" ] && mkdir -p "$HOME/bin"
echo "Installing homebrew..."
/bin/bash -c "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/HEAD/install.sh)"
@johnhpatton
johnhpatton / keyvals.conf
Created February 17, 2022 02:24
Nginx Plus KeyVal to hold whitelisted IP address blocks
stream {
# Set resolver to a name server that can resolve the domain
# for the zone_sync_server DNS to all webtier IPs.
resolver 10.0.0.1;
server {
listen 9443 reuseport;
zone_sync;
zone_sync_server api.prod.int.example.com:9443 resolve;