Skip to content

Instantly share code, notes, and snippets.

View nateberkopec's full-sized avatar

Nate Berkopec nateberkopec

View GitHub Profile
@nateberkopec
nateberkopec / heroku-inventory
Created March 4, 2026 21:37
heroku-inventory: Catalog all Heroku resources (formation, dynos, addons, buildpacks, config, metrics) for a team or app as JSON
#!/usr/bin/env bash
set -uo pipefail
usage() {
echo "heroku-inventory: Catalog Heroku resources" >&2
echo "" >&2
echo "Usage:" >&2
echo " heroku-inventory --team <team-name>" >&2
echo " heroku-inventory --app <app-name>" >&2
echo "" >&2
@nateberkopec
nateberkopec / README.md
Created March 3, 2026 00:38
Puma worker TERM/restart benchmark (Docker + k6): app, scripts, final artifacts, and results summary

Worker TERM/restart benchmark (Docker + k6)

This benchmark reproduces the scenario discussed in chat:

  • 4 Puma workers
  • open-model traffic at 12 req/s (k6 constant-arrival-rate)
  • synthetic Rack app with ~250ms service time
  • service alternates CPU and IO slices randomly every ~10ms
  • compare threads=5 vs threads=25
  • during traffic: kill one worker, wait for restart, let it serve ~5s, then kill a different worker (round-robin)

Unslopper local run notes

This repo is just a scratchpad for running the Unslopper model locally with llama.cpp.

What worked

  • Install llama.cpp via Homebrew.
  • Use the GGUF Q8_0 quant (the bf16 repo is too large for typical Mac memory).
  • Use llama-completion with a Qwen-style chat template prompt file and --no-conversation so it does a single completion and exits.
  • Redirect logs away from stdout so the output file is clean.
@nateberkopec
nateberkopec / Dockerfile
Created January 23, 2026 00:33
Puma closed_socket? tradeoff benchmark
FROM ruby:3.3-slim
RUN apt-get update \
&& apt-get install -y --no-install-recommends build-essential \
&& rm -rf /var/lib/apt/lists/*
RUN gem install puma -v 6.4.2
WORKDIR /app
COPY config.ru puma.rb /app/
@nateberkopec
nateberkopec / agent-rm-rf-hooks.md
Last active February 25, 2026 18:26
Protecting Against Autonomous Agent rm -rf Commands

Protecting Against Autonomous Agent rm -rf Commands

Protecting Against Agent rm -rf Commands

AI coding agents can run shell commands. Sometimes they run rm -rf by mistake. This deletes files forever. While of course I always read and approve all tool calls manually, by hand, and never let my agents work except under direct supervision 100% of the time, sometimes I miss things.

How It Works

  1. Hooks catch rm -rf before it runs
  2. Refuse the command with a clear error telling you to use trash
@nateberkopec
nateberkopec / README.md
Created January 21, 2026 20:34
Puma JSON logging demo - response to issue #3865

Puma JSON Logging Demo

This demo shows how to achieve JSON-formatted boot messages from Puma using existing configuration options. This is in response to GitHub Issue #3865.

Summary

Puma already supports custom log formatting via two DSL options:

  1. log_formatter - A block that transforms each log message string
@nateberkopec
nateberkopec / n_plus_one_where.rb
Created January 4, 2026 22:14
Rails N+1 query that cannot be fixed with includes() - using where() in instance method
# frozen_string_literal: true
require "bundler/inline"
gemfile(true) do
source "https://rubygems.org"
gem "rails", "~> 8.0"
gem "sqlite3"
end
Senior Product Engineer
Job Type: Full-time
Kaysville, UT and Remote (United States Only)
Salary Range: 180-220K DOE
Who We Are:
At Bark we’re doing something special to make the digital world a safer place for
children. Our work isn't just another job; it's a chance to make a real impact on the lives
of children and families.
Imagine using cutting-edge machine-learning to empower parents to partner with their
kids, providing them with the tools and alerts they need to ensure their child's safety and
@nateberkopec
nateberkopec / gh-ai.fish
Last active October 7, 2025 09:09
Fish function to have AI write commit messages w/rerolling
function gc-ai
# Check required dependencies
if not command -q gum
echo "Error: gum is not installed. Install it from https://github.com/charmbracelet/gum"
return 1
end
if not command -q bat
echo "Error: bat is not installed. Install it from https://github.com/sharkdp/bat"
return 1
@nateberkopec
nateberkopec / gh_watch
Created August 6, 2025 22:37
Watch GitHub PR status with audio notifications
#!/bin/bash
set -e
if [ $# -eq 0 ]; then
echo "Usage: gh_watch <github-pr-url>"
echo "Example: gh_watch https://github.com/hyfn/xpo/pull/4974"
exit 1
fi