Skip to content

Instantly share code, notes, and snippets.

View CGamesPlay's full-sized avatar
:bowtie:

Ryan Patterson CGamesPlay

:bowtie:
View GitHub Profile
@CGamesPlay
CGamesPlay / README.md
Created June 25, 2026 05:32
Tree Sitter WASM benchmarking

It works, but wasm isn't free. I noticed that zed has some funny-looking code to carefully reuse TS objects, so I did some benchmarks to make sure that this API design doesn't put us into a corner. Benchmarks were run on my Macbook only. It turns out that what Zed is doing saves ~20% of the wasm language load time (25ms->20ms), entirely because instantiating a TSWasmStore takes ~5ms.

Loading a language

grammar native ms wasm ms native RAM MB wasm RAM MB
javascript 0.1 24.0 0.2 0.9
rust 0.1 20.7 0.0 2.2
python 0.1 20.6 0.0 1.0
typescript 0.1 23.4 0.0 2.0
@CGamesPlay
CGamesPlay / eml.py
Last active April 13, 2026 20:59
Marimo notebook: All elementary functions from a single binary operator
# Run this notebook with:
# marimo edit --sandbox eml.py
#
# /// script
# dependencies = [
# "marimo",
# "sympy",
# ]
# requires-python = ">=3.12"
# ///
//! Proof of concept of a tokio::sync::watch-style channel with WeakSender support
//! Copyright Ryan Patterson - MIT license
use std::sync::{
atomic::{AtomicUsize, Ordering},
Arc, RwLock, RwLockReadGuard, TryLockError, Weak,
};
use tokio::sync::Notify;
/// Thread-safe reference-counted reader-writer lock with change notification.
///
@CGamesPlay
CGamesPlay / repro.html
Created July 23, 2025 03:29
Safari Animation.commitStyles() CSP Bug
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>Safari Animation.commitStyles() CSP Bug</title>
<!-- CSP that triggers the bug - style-src-attr 'self' only -->
<meta http-equiv="Content-Security-Policy" content="style-src-attr 'self'">
@CGamesPlay
CGamesPlay / import.py
Created December 14, 2024 00:58
Migrate Obsidian (or markdown directory) to Anytype markdown import
#!/usr/bin/env python3
# /// script
# dependencies = [
# "mistune==3.0.2",
# ]
# ///
import os
import sys
import hashlib
@CGamesPlay
CGamesPlay / dynamicComponent.test.tsx
Last active August 22, 2024 14:22
Component factory that enables "as" props.
import * as React from "react";
import { expect, test } from "vitest";
import { makeDynamicComponent } from "./dynamicComponent";
type NoProps = object;
const ComponentA1 = (_: { req: "a"; opt?: "a" }) => null;
const ComponentA2 = (_: { req: "a"; opt?: "a" }) => null;
const ComponentB = (_: { req: "b"; opt?: "a" }) => null;
const ComponentC = (_: { opt?: "a" }) => null;
@CGamesPlay
CGamesPlay / cva.tsx
Last active August 22, 2024 17:10
CVA prop splitting
import { cva } from "cva";
export * from "cva";
type Base = Parameters<typeof cva<unknown>>[0];
type Config<T> = Parameters<typeof cva<T>>[1];
type Simplify<T> = { [KeyType in keyof T]: T[KeyType] } & {};
type Props<T> = Simplify<
Omit<
Exclude<Parameters<ReturnType<typeof cva<T>>>[0], undefined>,
@CGamesPlay
CGamesPlay / decorator.py
Last active July 17, 2024 07:25
Fully-typed Python decorator for functions, methods, staticmethods, and classmethods.
"""
Showcase a fully-typed decorator that can be applied to functions, methods,
staticmethods, and classmethods.
This example has some limitations due to the limited expressiveness of the
Python type system:
1. When applying the decorator to a function whose first argument is an
optional type object, the returned function's first argument is shown as
required.
@CGamesPlay
CGamesPlay / bench.py
Created July 1, 2024 02:17
MappingProxyType performance
import timeit
import types
def create_benchmark(test_dict):
def benchmark():
for key in range(100):
if key in test_dict:
value = test_dict[key]
return benchmark
@CGamesPlay
CGamesPlay / ARCHITECTURE.md
Created April 4, 2024 10:31
Plandex LLM Usage

Based on analyzing the code, here is a high-level overview of the main prompts used in this project and how they fit into the overall flow:

The core prompts are defined in the model/prompts package:

  1. SysCreate (create.go) - This is the main system prompt that defines the AI's identity as Plandex, an AI programming assistant. It provides detailed instructions on how to collaboratively create a 'plan' with the user to complete a programming task. The prompt covers things like assessing if there is a clear task, breaking down large tasks into subtasks, generating code blocks, using open source libraries, and ending responses.

  2. ListReplacementsFn (build.go) - Used when building code files from a plan. It analyzes proposed code updates and produces a structured list of changes to make.

  3. SysDescribe (describe.go) - Used to generate a commit message summarizing the changes made in a plan.