Skip to content

Instantly share code, notes, and snippets.

View hartsock's full-sized avatar

Shawn Hartsock hartsock

View GitHub Profile
@hartsock
hartsock / README.md
Last active October 24, 2026 22:52
Gerrit alone, then Gerrit with a store: animation for JGit change 1255942

Gerrit alone, then Gerrit with a store

Animated data flow for JGit change 1255942, Resolve promised blobs through the file object database.

Gerrit alone, then Gerrit with a store

Steps 1 to 3 are a Gerrit server alone, the normal mode: clients take a filtered clone and stock git lazy-fetches any skipped blob from Gerrit itself. Nothing on the server changes beyond uploadpack.allowFilter.

Steps 4 to 8 add an external store. An offload job copies blobs over a size limit to the store, writes a manifest and repacks them away as a promisor pack. When a review or a fetch needs such a blob, the resolver proposed in the change reads it back and JGit installs it only if the bytes hash to the promised object id. Clients are unchanged.

@hartsock
hartsock / claude-dgx1.sh
Last active September 15, 2026 15:02
claude-dgx1 — route Claude Code inference to a local llama.cpp DGX endpoint
#!/usr/bin/env bash
#
# claude-dgx1 — run Claude Code but route inference to our local NVIDIA DGX
# Spark (dgx1.home.lan) using the model currently loaded there,
# instead of Anthropic. I use llama.cpp on my NVIDIA DGX Spark.
#
# This is a thin wrapper around the `claude` binary. At startup it asks the
# llama.cpp model manager on dgx1 which model is currently `loaded`, then
# re-points Claude Code's API at that endpoint and forces the model name —
# without touching your real ~/.claude/settings.json.
@hartsock
hartsock / codex-dgx1.sh
Last active September 15, 2026 14:57
codex-dgx1 — route Codex CLI inference to a local llama.cpp DGX endpoint
#!/usr/bin/env bash
#
# codex-dgx1 — run Codex CLI but route inference to our local NVIDIA DGX Spark
# (dgx1.home.lan) using the model currently loaded there, instead
# of OpenAI. I use lama.cpp on my NVIDIA DGX Spark.
#
# This is a thin wrapper around the `codex` binary. At startup it asks the
# llama.cpp model manager on dgx1 which model is currently `loaded`, then
# re-points Codex's "model provider" at that endpoint and forces the model
# name — without touching your real ~/.codex/config.toml.
@hartsock
hartsock / .zshrc
Created October 6, 2025 16:14
~/.zshrc
export IP_ADDR=`ipconfig getifaddr en0`
export PS1="%n@$IP_ADDR:%~ % # "
export PATH="$HOME/bin:$PATH"
@hartsock
hartsock / logs_to_json.py
Created March 6, 2025 19:10
Tries to interpret arbitrary log data with embedded python and json objects as valid JSON. This is probably not safe. This really only understands the Python and JSON when they are on their own lines.
#!/usr/bin/env python3
import collections.abc
import json
import numbers
import sys
###############################################################################
# converts a stdin text stream of python data and json data into pure json
# this script should eventually get deleted
# this script has NO smart flow control
@hartsock
hartsock / repeat.sh
Created October 4, 2022 13:50
Repeat the rest of the CLI 30 times. Example: `repeat.sh echo "foo"`
#!/usr/bin/env bash
STOP=30
i=0;
while [ $i -le $STOP ]
do
i=$((i+1))
echo -n "${i} :"
exec "$@"&
echo
@hartsock
hartsock / setup.py
Created May 14, 2021 18:03
A super generic Python3 setup.py
import io
import os
from setuptools import find_packages, setup
# Author @hartsock
#
# Why: copy into a directory with some python scripts you want to call a "library"
# How: pip3 install -e .
#
@hartsock
hartsock / upgrade-photon.yml
Created October 22, 2019 17:38
An Ansible playbook for upgrading VMware Photon OS 2.x to 3.x
---
- hosts: photon
remote_user: root
tasks:
- name: pip prerequisite
command: bash -c "tdnf -y install python-pip"
- name: python prerequisites
command: bash -c "pip install -I pexpect"
@hartsock
hartsock / sshd.go
Created August 14, 2019 17:07 — forked from jpillora/sshd.go
Go SSH server complete example - Read more here https://blog.gopheracademy.com/go-and-ssh/
// A small SSH daemon providing bash sessions
//
// Server:
// cd my/new/dir/
// #generate server keypair
// ssh-keygen -t rsa
// go get -v .
// go run sshd.go
//
// Client:
@hartsock
hartsock / gist:9199a1382423fa46305d92d74b0d5838
Created August 14, 2019 16:42 — forked from devinodaniel/gist:8f9b8a4f31573f428f29ec0e884e6673
Generate SSH RSA Private/Public Key pair with Golang
// This shows an example of how to generate a SSH RSA Private/Public key pair and save it locally
package main
import (
"crypto/rand"
"crypto/rsa"
"crypto/x509"
"encoding/pem"
"golang.org/x/crypto/ssh"