Skip to content

Instantly share code, notes, and snippets.

Avatar

joe miller joemiller

View GitHub Profile
View setup-pki-vault-server.sh
#!/bin/bash
#
# Start the server in dev mode:
#
# bash setup-pki-vault-server.sh
#
# In another window, generate a cert:
#
# VAULT_ADDR=http://127.0.0.1:8200 VAULT_TOKEN=root vault write pki/issue/any common_name=foo
#
@joemiller
joemiller / renewer.go
Created Jun 16, 2021
demo of vault token renewer go routine from internal project
View renewer.go
type VaultDriver struct {
vaultClient *vaultapi.Client
project string
}
func (d VaultDriver) TokenRenewer(ctx context.Context) error {
renewer, err := d.vaultClient.NewRenewer(&vaultapi.RenewerInput{
Secret: &vaultapi.Secret{
Auth: &vaultapi.SecretAuth{
ClientToken: d.vaultClient.Token(),
@joemiller
joemiller / foo.sh
Last active Sep 24, 2020
demo of bash vars global scope by default
View foo.sh
#!/bin/bash
foo() {
op=$1
# local op=$1
echo "foo: op is $op"
}
main() {
op="main"
@joemiller
joemiller / installer.sh
Created May 22, 2020
install script for autotag, generated with godownloader
View installer.sh
#!/bin/sh
set -e
# Code generated by godownloader on 2020-05-22T18:17:38Z. DO NOT EDIT.
#
usage() {
this=$1
cat <<EOF
$this: download go binaries for pantheon-systems/autotag
@joemiller
joemiller / poc.py
Last active May 7, 2020
POC getting cpu% from cgroups
View poc.py
#!/usr/bin/env python
# Usage:
# curl -sL https://gist.githubusercontent.com/joemiller/d89002a0d169cbb977e735df20e4ebd7/raw/poc.py | python | sort -rnk3 | head -n10
# or with a different INTERVAL:
# curl -sL https://gist.githubusercontent.com/joemiller/d89002a0d169cbb977e735df20e4ebd7/raw/poc.py | INTERVAL=60 python | sort -rnk3 | head -n10
import os
import time
def main():
@joemiller
joemiller / disable-gcp-accounts-daemon.sh
Last active Apr 10, 2020
disable and stop google-accounts-daemon
View disable-gcp-accounts-daemon.sh
sed -i -e 's/accounts_daemon = true/accounts_daemon = false/' /etc/default/instance_configs.cfg.template
/bin/google_instance_setup
systemctl restart google-accounts-daemon
@joemiller
joemiller / stackdriver.json
Created Feb 11, 2020
stackdriver webhook payload v1.2 example
View stackdriver.json
{
"incident": {
"incident_id": "0.lj2va6zdkemq",
"resource_id": "",
"resource_name": "foobar appserver",
"resource": {
"type": "gce_instance",
"labels": {
"instance_id": "8979287136362607111",
"zone": "us-central1-c"
@joemiller
joemiller / gceproject.go
Last active Jan 29, 2020
gceProject() golang function that implements multiple methods of determining the GCP project it is being run within
View gceproject.go
package main
import (
"context"
"errors"
"log"
"os"
"time"
"golang.org/x/oauth2/google"
@joemiller
joemiller / # gnupg - 2019-12-03_17-43-27.txt
Created Dec 4, 2019
gnupg on macOS 10.15.1 - Homebrew build logs
View # gnupg - 2019-12-03_17-43-27.txt
Homebrew build logs for gnupg on macOS 10.15.1
Build date: 2019-12-03 17:43:27
@joemiller
joemiller / pdns-recursor-cache-stats.rb
Last active Oct 11, 2019
quick 1-time script to parse pdns_recursor cache hit ratio and qps across a range of hosts
View pdns-recursor-cache-stats.rb
#!/usr/bin/env ruby
#
# Usage:
#
# $ ruby pdns-recursor-cache-stats.rb
#
# Might need to use sudo or run as root to access the pdns_recursor control socket
#
uptime = 0