Skip to content

Instantly share code, notes, and snippets.

View joemiller's full-sized avatar

joe miller joemiller

View GitHub Profile
@joemiller
joemiller / git-diff-size-check-total-only.rb
Last active December 17, 2025 08:00
proof of concept script for checking the size of staged git commits and rejecting based on individual file or overall total
#!/usr/bin/env ruby
MAX_DIFF_SIZE_MB = 4 # MB
def bytes_to_mb(bytes)
bytes.to_f / (1024*1024)
end
total_diff_bytes = 0
@joemiller
joemiller / auto_shutdown.service
Last active December 16, 2025 15:47
bash script + systemd units for auto-shutting down an idle machine (no active ssh logins)
[Unit]
Description=Auto shutdown service
[Service]
Type=oneshot
ExecStart=/auto_shutdown.sh
@joemiller
joemiller / he-dns-update.sh
Last active October 28, 2025 09:36
script for updating dynamic DNS records on he.net (hurricane electric)
#!/bin/bash
#
# Script for updating DNS records on Hurricane Electirc's DNS system (https://dns.he.net).
#
# The record will be updated with the IP address that originates the request.
#
# Usage
# -----
#
# Create config file `/etc/he-dns-update.conf`:

Loki log ingestion issue

Loki stops ingesting logs from promtail. The error messages are a stream HTTP 499 errors in the gateway component which is based on nginx. Ex:

10.194.148.169 - - [17/Feb/2022:21:08:28 +0000]  499 "POST /loki/api/v1/push HTTP/1.1" 0 "-" "promtail/" "-"
10.194.90.195 - - [17/Feb/2022:21:08:28 +0000]  499 "POST /loki/api/v1/push HTTP/1.1" 0 "-" "promtail/" "-"
@joemiller
joemiller / cert-renewal-visualizer.html
Created June 11, 2025 22:58
Certificate Renewal Timeline visualizer (developed by Claude. Used to simulate CA + leaf renewal with cert-manager which does NOT clamp leaf expiration to CA expiration)
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>Certificate Renewal Timeline Visualizer</title>
<style>
body {
font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
margin: 0;
@joemiller
joemiller / userscript.js
Last active May 28, 2025 21:47
Tampermonkey script to add "select all / deselect all' buttons to Buildkite's `input` modal when used with multiple selections
// ==UserScript==
// @name Buildkite Select All Button
// @namespace http://tampermonkey.net/
// @version 1.1
// @description Adds a "Select All" button to Buildkite pipeline input modals (skips "!! APPLY ALL STACKS !!")
// @author You
// @match https://buildkite.com/*
// @grant none
// ==/UserScript==
@joemiller
joemiller / Dockerfile
Last active August 26, 2024 07:39
convert RFC 3164 syslog messages to RFC 5424 for ingestion into Loki/promtail
FROM balabit/syslog-ng:3.35.1
COPY syslog-ng.conf /etc/syslog-ng/syslog-ng.conf
@joemiller
joemiller / mk-test-certs.sh
Created December 29, 2015 22:32
helper script for making a new CA and signing client (leaf) certs, including making java keystore (JKS) files. useful in creating test fixtures
#!/bin/sh
# helper script for making a new CA and signing client (leaf) certs, including making java keystore (JKS) files. useful in creating test fixtures
#
# Example:
# ./mk-test-certs.sh
# ==> Creating new CA: certs/ca.key, certs/ca.crt
# Generating a 2048 bit RSA private key
# ....................................................+++
# ...............................+++
# writing new private key to 'certs/ca.key'
@joemiller
joemiller / netpps.sh
Last active January 12, 2024 15:39
shell: quick linux scripts for showing network bandwidth or packets-per-second
#!/bin/bash
if [ -z "$1" ]; then
echo
echo usage: $0 network-interface
echo
echo e.g. $0 eth0
echo
echo shows packets-per-second
@joemiller
joemiller / gke-np-ip-utilization.rb
Last active January 6, 2024 01:05
GKE node-pool pod IP CIDR range usage calc script
#!/usr/bin/env ruby
#
# Show GKE per-node-pool pod IP CIDR range utilization.
#
# Usage:
# gcloud container clusters describe <cluster-name> --location <loc> --format=json | ./gke-np-ip-utilization.rb
require 'json'
require 'ipaddr'