Skip to content

Instantly share code, notes, and snippets.

View jwdeane's full-sized avatar

James Deane jwdeane

View GitHub Profile
@jwdeane
jwdeane / IMPLEMENTATIONS.md
Last active June 19, 2026 01:00
Cloudflare Workers stale-while-revalidate implementations

Stale-While-Revalidate Implementations

This project can demonstrate stale-while-revalidate (SWR) in two different ways:

  1. Native Cloudflare CDN cache behavior.
  2. A custom Worker implementation using the Workers Cache API.

They look similar from the client side, but the cache layer doing the work is different.

1. Native CDN SWR

@jwdeane
jwdeane / llm-wiki.md
Created April 4, 2026 23:16 — forked from karpathy/llm-wiki.md
llm-wiki

LLM Wiki

A pattern for building personal knowledge bases using LLMs.

This is an idea file, it is designed to be copy pasted to your own LLM Agent (e.g. OpenAI Codex, Claude Code, OpenCode / Pi, or etc.). Its goal is to communicate the high level idea, but your agent will build out the specifics in collaboration with you.

The core idea

Most people's experience with LLMs and documents looks like RAG: you upload a collection of files, the LLM retrieves relevant chunks at query time, and generates an answer. This works, but the LLM is rediscovering knowledge from scratch on every question. There's no accumulation. Ask a subtle question that requires synthesizing five documents, and the LLM has to find and piece together the relevant fragments every time. Nothing is built up. NotebookLM, ChatGPT file uploads, and most RAG systems work this way.

@jwdeane
jwdeane / title-from-url.ts
Created September 14, 2025 10:55 — forked from steven-tey/title-from-url.ts
Get Title from URL
// Note: this gist is a part of this OSS project that I'm currently working on: https://github.com/steven-tey/dub
export default async function getTitleFromUrl (url: string) {
const controller = new AbortController();
const timeoutId = setTimeout(() => controller.abort(), 2000); // timeout if it takes longer than 2 seconds
const title = await fetch(url, { signal: controller.signal })
.then((res) => {
clearTimeout(timeoutId);
return res.text();
})
@jwdeane
jwdeane / gist:568989fc93a95aa8eb48e6b1bd2b19c7
Created March 27, 2019 22:24
Import SQL dump into Docker container
# Grab and run MariaDB image
docker run --name mariadb -p 3306:3306 -e MYSQL_ROOT_PASSWORD=secret -e MYSQL_DATABASE=db -d mariadb:latest
# Restore a dump into the DB
docker exec -i mariadb mysql -uroot -psecret --database=db < dump.sql
@jwdeane
jwdeane / get_latest_ami.sh
Created May 22, 2018 02:48
Get latest AWS EC2 Linux AMI
#!/bin/bash
# Assumes AWS CLI installed and configured with default region.
# To query an alternate region add the --region parameter, e.g.
# --region us-west-2
aws ec2 describe-images \
--owners amazon \
--filters "Name=name,Values=amzn-ami-hvm*ebs" \
--query 'sort_by(Images,&CreationDate)[-1].ImageId' \
@jwdeane
jwdeane / brew-perms.sh
Last active March 13, 2017 02:22 — forked from jaibeee/brew-perms.sh
Configure homebrew permissions to allow multiple users on MAC OSX. Any user from the admin group will be able to manage the homebrew and cask installation on the machine.
#!/bin/sh
# Configure homebrew permissions to allow multiple users on MAC OSX.
# Any user from the admin group will be able to manage the homebrew and cask installation on the machine.
# allow admins to manage homebrew's local install directory
chgrp -R admin /usr/local
chmod -R g+w /usr/local
# allow admins to homebrew's local cache of formulae and source files
chgrp -R admin /Library/Caches/Homebrew
define (['knockout', 'jquery', 'prettyDate', 'metrojs'], function ( ko, $ ) {
"use strict";
// See https://github.com/SteveSanderson/knockout/wiki/Bindings---class
ko.bindingHandlers['class'] = {
'update' : function ( element, valueAccessor ) {
if ( element['__ko__previousClassValue__'] ) {
ko.utils.toggleDomNodeCssClass (element, element['__ko__previousClassValue__'], false);
}
var value = ko.utils.unwrapObservable (valueAccessor ());
define (['knockout', 'jquery', 'prettyDate', 'metrojs'], function ( ko, $ ) {
"use strict";
// See https://github.com/SteveSanderson/knockout/wiki/Bindings---class
ko.bindingHandlers['class'] = {
'update' : function ( element, valueAccessor ) {
if ( element['__ko__previousClassValue__'] ) {
ko.utils.toggleDomNodeCssClass (element, element['__ko__previousClassValue__'], false);
}
var value = ko.utils.unwrapObservable (valueAccessor ());
@jwdeane
jwdeane / Change WP domain
Created August 9, 2010 14:20
Changed your Wordpress domain?
// Edit themes functions.php. Right after initial <?php line place the following:
update_option('siteurl','http://example.com/blog');
update_option('home','http://example.com/blog');
@jwdeane
jwdeane / randomImage.js
Created January 21, 2010 10:32
display random image with jQuery
// Basic Random Image Rotator
// jQuery required http://jquery.com
// Easy option
// img is an array of images
var img = ['img1.jpg','img2.jpg','img3.jpg','img4.jpg'];
// src="images/rotator/ is path to your files contained in above array
$('<img src="images/rotator/' + images[Math.floor(Math.random() * images.length)] + '">').appendTo('#imageContainer');
////////////////////////////