Skip to content

Instantly share code, notes, and snippets.

View chriscarrollsmith's full-sized avatar

Christopher Carroll Smith chriscarrollsmith

View GitHub Profile
@chriscarrollsmith
chriscarrollsmith / embed_tweets_with_llm.md
Last active August 10, 2025 22:35
Workflows for using Simon Willson's 'llm' CLI tool to embed your downloadable Twitter archive for semantic search and RAG

Embedding your downloaded Twitter archive data for semantic search and RAG with llm

Getting your tweets

Twitter allows you to download your archive of tweets. You can do this by going to your account settings and requesting your archive. Once you receive the email with the download link, you can download the zip file.

Exploring the data

Top-level keys of Twitter/twitter_archive.json (via jq 'keys' Twitter/twitter_archive.json):

@chriscarrollsmith
chriscarrollsmith / scrape_tweet.js
Last active August 10, 2025 14:46
Scrape the text of a tweet by URL with Puppeteer. Self-installs dependencies when run with bun. Add arbitrary metadata with --metadata-json flag.
#!/usr/bin/env bun
// @bun-dependencies: puppeteer@latest puppeteer-extra@latest puppeteer-extra-plugin-stealth@latest
import puppeteer from 'puppeteer';
async function scrapeXTweet(url, metadata) {
// Launch browser with stealth options
const browser = await puppeteer.launch({
headless: true, // or 'new' for new headless mode
executablePath: '/usr/bin/google-chrome',
@chriscarrollsmith
chriscarrollsmith / create-nl-tool.sh
Created July 9, 2025 00:05
Create a natural-language version of any command-line tool, powered by `llm`
#!/bin/bash
# create-nl-tool.sh - Programmatically create natural language interfaces
# for CLI tools
# Usage: ./create-nl-tool.sh <tool-name>
# Example: ./create-nl-tool.sh repomix
set -e
if [ $# -eq 0 ]; then
@chriscarrollsmith
chriscarrollsmith / llm-hackathon-submissions.md
Last active July 18, 2025 08:29
Writeup of submissions to the Coders' Colaboratory `llm` hackathon in Latham, New York

Projects

Runner-Up: Doctor of Credit

Prerequisites

Google Chrome CLI entrypoint

@chriscarrollsmith
chriscarrollsmith / llm-hackathon.md
Created July 5, 2025 13:56
Coders' Colaboratory mini-hackathon on `llm` by simonw

Let's hack on llm!

If you have uv installed (and you should!), you can install llm globally in a uv-managed tool environment with:

uv tool install llm

If you want to use models other than OpenAI models, you'll need some extensions:

@chriscarrollsmith
chriscarrollsmith / pre-push
Created July 1, 2025 20:19
pre-push git hook to only allow pulling from, not pushing to, a template remote
#!/bin/bash
# Pre-push hook to prevent pushing from the template branch
# This allows pulling from template remote but prevents accidental pushes
current_branch=$(git symbolic-ref --short HEAD)
if [ "$current_branch" = "template" ]; then
echo "ERROR: Pushing from the 'template' branch is not allowed."
echo "This branch is reserved for pulling updates from the template repository."
@chriscarrollsmith
chriscarrollsmith / Zotero_schema.md
Created June 2, 2025 01:35
Zotero Local Database Schema Documentation

Exploring the Zotero Local Database Schema

On my (Windows) machine, Zotero's local database was located at C:\Users\chris\Zotero\zotero.sqlite. I was able to dump the schema using the sqlite3 command line tool:

sqlite3 zotero.sqlite ".schema" > zotero_schema.sql

Here is the SQL schema dump:

@chriscarrollsmith
chriscarrollsmith / setup_digital_ocean_db.sh
Created March 26, 2025 19:52
End-to-end setup script for deploying a PostgreSQL database and optional droplet (for API layer) to Digital Ocean using `doctl` in Bash
#!/bin/bash
# Exit on error
set -e
# Load environment variables if .env exists
if [ -f .env ]; then
export $(cat .env | grep -v '^#' | xargs)
fi
@chriscarrollsmith
chriscarrollsmith / create-gif.py
Created March 2, 2025 19:50
Python script to create an animated gif
from PIL import Image
import os
def create_gif(image_folder, gif_name, frame_duration=200):
"""
Creates an animated GIF from images in a folder.
Args:
image_folder (str): Path to the folder containing the images.
gif_name (str): Name of the output GIF file.
@chriscarrollsmith
chriscarrollsmith / sse-demo.py
Last active February 10, 2025 00:58
Demo showing how to use HTMX to split an SSE event stream
from fastapi import FastAPI, Request
from fastapi.responses import HTMLResponse, StreamingResponse
import time
app = FastAPI()
index_html = """
<html>
<head>
<!-- Include htmx -->