Skip to content

Instantly share code, notes, and snippets.

View boxabirds's full-sized avatar
:shipit:

Julian Harris boxabirds

:shipit:
View GitHub Profile
@boxabirds
boxabirds / tech-writer-agent.py
Created March 29, 2025 20:16
Tech Writer Agent
# Written by Julian Harris https://makingaiagents.substack.com
# [email protected]
# Apache License
# Version 2.0, January 2004
# http://www.apache.org/licenses/
# TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION
# 1. Definitions.
@boxabirds
boxabirds / index.html
Created March 29, 2025 18:48
Tech Writer Animation
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>LLM Code Analysis Visualization (Final Layout)</title>
<style>
body { margin: 0; overflow: hidden; font-family: sans-serif; background-color: #111; color: #eee; }
canvas { display: block; }
@boxabirds
boxabirds / ollama-repro.sh
Created March 29, 2025 14:18
Simple script to test determinism options against ollama
#!/bin/bash
# tries to answer the question "do I have any models installed that can be configured to return deterministic results?"
# Get list of available models
MODELS=$(ollama list | awk 'NR>1 {print $1}')
# Function to test reproducibility for a specific model
test_model() {
local model=$1
local seed=42
@boxabirds
boxabirds / .zshrc-uv
Last active March 17, 2025 02:16
uvshell and uvinstall pipenv emulations
# pipenv is extremely slow but it's very easy to use.
# here are two wrapper scripts to emulate pipenv shell and pipenv install
# add to your .zshrc file
# emulate pipenv shell
function uvshell() {
if [[ -d .venv ]]; then
source .venv/bin/activate || { echo "Failed to activate virtual env"; return 1; }
else
@boxabirds
boxabirds / Node_modules-RAM-disk.md
Created January 25, 2025 03:03
node_modules on Mac RAM disk

Deepseek r1 says this

Key Clarifications

  1. APFS Global Kernel Lock (vfs-layer lock):

    • Not fully bypassed: Even with a RAM disk formatted as APFS, macOS's global I/O lock still technically exists. However, because RAM disk operations are orders of magnitude faster than disk I/O, contention for this lock is drastically reduced. This makes the lock effectively irrelevant for most workflows, as operations complete before significant contention occurs.
    • Not the same as Linux: macOS lacks a true tmpfs equivalent, so while a RAM disk helps, it’s not as seamless as Linux’s in-memory filesystem.
  2. RAM Disk Format:

    • macOS RAM disks can be formatted as HFS+ or APFS. While APFS is the default, formatting as HFS+ might slightly reduce lock contention (though benchmarks vary). Either way, the speed of RAM mitigates lock-related bottlenecks.
@boxabirds
boxabirds / gist:2892a2bc4aa3c087b8e8d31564572073
Created December 29, 2024 22:04
Coding Agent prompt for review & retrospective documentation
At this point I want you to create a design doc that describes the following things. The things below are to be made into separate .md files in a doc/ directory.
mermaid diagrams showing the key objects and their relationships
mermaid sequence diagram showing key interactions for the main use cases
summarise the agent journey so far: review the entire chat history and highlight the things that were easy to implement (one prompt => feature) and things that were very hard to implement
following this, create a maintenance guide whose sole objective is to help the next contributors to the code base. It should explain the frameworks and services used, the components, and notes on anything about the implementation that may not be obvious to someone even if they have experience with the framework used.
finally summarise areas that need to be developed to turn this into a proper product that can be supported, maintained and expanded.E.g. logging, telemetry, security considerations etc.
@boxabirds
boxabirds / sample.txt
Created December 15, 2024 12:13
sqlc column name mapping question
SQL:
-- name: GetRecentPostsByTags :many
-- $1: TagNames
SELECT DISTINCT p.id, p.created_at, t.name AS tag_name
FROM posts p
JOIN post_tags pt ON p.id = pt.post_id
JOIN tags t ON pt.tag_id = t.id
WHERE t.name = ANY($1::text[]) AND p.created_at < $2
ORDER BY p.created_at DESC
@boxabirds
boxabirds / increment-version-patch.js
Created November 22, 2024 13:49
Autobump version patch (node script for bumping the version patch)
// track every build with a unique number
// e.g. in package.json … "build": "node scripts/increment-version-patch.js && <your normal build script>"
const fs = require('fs');
const path = require('path');
const packageJsonPath = path.join(__dirname, '..', 'package.json');
const packageJson = require(packageJsonPath);
// Split version into major, minor, and patch
const [major, minor, patch] = packageJson.version.split('.').map(Number);
@boxabirds
boxabirds / estimator.js
Created October 22, 2024 20:50
Google Gemini cost estimator (node)
const {GoogleGenerativeAI} = require('@google/generative-ai');
/**
* Estimates the cost of a Gemini API invocation based on token usage.
*
* @param {Object} usageMetadata - The usage metadata from the API response.
* @param {number} usageMetadata.promptTokenCount - The number of tokens in the input prompt.
* @param {number} usageMetadata.candidatesTokenCount - The number of tokens in the output.
* @returns {number} The estimated cost of the invocation in USD.
*
* Pricing information:
@boxabirds
boxabirds / img2alt.py
Created August 6, 2024 12:15
Generate alt tags for images (using llava)
import os
import requests
from bs4 import BeautifulSoup
import argparse
import base64
import json
def download_image(url, save_path):
response = requests.get(url)
if response.status_code == 200: