Skip to content

Instantly share code, notes, and snippets.

View unbracketed's full-sized avatar

Brian Luft unbracketed

View GitHub Profile
@unbracketed
unbracketed / branch-fu.md
Created April 7, 2015 17:49
Moving commits between branches

Example: Moving up to a few commits to another branch

Branch A has commits (X,Y) that also need to be in Branch B. The cherry-pick operations should be done in the same chronological order that the commits appear in Branch A.

cherry-pick does support a range of commits, but if you have merge commits in that range, it gets really complicated

git checkout branch-B
git cherry-pick X
git cherry-pick Y
@unbracketed
unbracketed / ccmanager-status-hook.sh
Created June 20, 2025 17:19
A script called when CCManager detects Claude Code state changes - logs status data and session info to skate
#!/bin/bash
# Set defaults if environment variables are not defined
if [ -z "$CCMANAGER_WORKTREE" ]; then
CCMANAGER_WORKTREE=$(pwd)
fi
if [ -z "$CCMANAGER_WORKTREE_BRANCH" ]; then
# Check if we're in a git repository and get the branch name
if git rev-parse --git-dir > /dev/null 2>&1; then
@unbracketed
unbracketed / code.py
Last active March 9, 2025 04:27
Single-file nanodjango llm chat which can render highlighted code blocks for nice display and easy copy
# /// script
# requires-python = ">=3.12"
# dependencies = [
# "nanodjango",
# "channels",
# "daphne",
# "htpy",
# "markdown",
# "markupsafe",
# "llm"
@unbracketed
unbracketed / chat.py
Last active March 7, 2025 04:50
Single-file nanodjango & llm powered chat app using HTMX and websockets
# /// script
# requires-python = ">=3.12"
# dependencies = [
# "nanodjango",
# "channels",
# "daphne",
# "htpy",
# "markdown",
# "markupsafe",
# "llm"
# /// script
# requires-python = ">=3.12"
# dependencies = [
# "nanodjango",
# "channels",
# "daphne",
# "htpy",
# "markdown",
# "markupsafe",
# "llm"
@unbracketed
unbracketed / nanodjango_htmx_websocket_example.py
Last active March 6, 2025 05:08
Example single-file Python Nanodjango app using HTMX websockets over ASGI
# /// script
# requires-python = ">=3.12"
# dependencies = [
# "nanodjango",
# "channels",
# "daphne",
# "htpy"
# ]
# ///
@unbracketed
unbracketed / image-to-text-model-comparison.py
Created February 4, 2025 19:32
Processes a directory of images using a few image-to-text models and outputs tables for comparing the processing times and generated captions
# /// script
# requires-python = ">=3.12"
# dependencies = [
# "click",
# "torch",
# "transformers",
# "Pillow",
# "rich",
# "pandas",
# ]
@unbracketed
unbracketed / image-caption-demo.py
Created February 3, 2025 23:31
A Python script that will apply image-to-text transformations for any images found in the directory it runs in using a few different models for comparison.
# /// script
# requires-python = ">=3.12"
# dependencies = [
# "torch",
# "transformers",
# "Pillow",
# ]
# ///
from pathlib import Path
# /// script
# requires-python = ">=3.12"
# dependencies = [
# "starlette",
# "uvicorn",
# "beautifulsoup4",
# "httpx",
# "html5lib"
# ]
# ///
@unbracketed
unbracketed / Repeater-FastTag-for-FastHTML.md
Last active August 3, 2024 08:13
Docs about how to make a Repeater FastTag for easily rendering lists or tables of data

Repeater FastTag

This intended as a utility component for rendering lists, iterables, or sequence-type objects, with a goal of providing useful results with minimal configuration, while allowing all aspects of rendering to be easily overridden.

Source

class Repeater:
    """