Skip to content

Instantly share code, notes, and snippets.

View clinuxrulz's full-sized avatar

Clinton Selke clinuxrulz

View GitHub Profile
@clinuxrulz
clinuxrulz / generic-retained-collection.tsx
Created November 11, 2026 09:42
Generic Retained Collections
import { createSignal, onCleanup } from "solid-js";
// 1. Define the contract for what a row instance must return
export interface RowHandle<T> {
element: HTMLElement;
update?: (item: T) => void; // Optional: for surgical in-place property updates
}
// 2. The Generic Retained Binder
export class RetainedBinder<T> {
@clinuxrulz
clinuxrulz / todo-retained.tsx
Last active November 11, 2026 08:29
Solid.js TODO retained style
import { createSignal, onCleanup } from "solid-js";
// ============================================================================
// 1. DECLARATIVE REACTIVE ROW COMPONENT
// ============================================================================
export interface TodoRowProps {
id: string;
text: string;
initialCompleted: boolean;
onToggle: (id: string) => void;
@clinuxrulz
clinuxrulz / todo-mvc-hybrid.ts
Created November 11, 2026 03:43
TODO MVC Hybrid
import { createSignal, onMount } from "solid-js";
import { createEmitter } from "@solid-primitives/event-bus";
// ==========================================
// 1. TYPES & DELTA DEFINITIONS
// ==========================================
export type TodoDelta =
| { type: 'addTodo'; id: string; text: string; completed: boolean; index: number }
| { type: 'removeTodo'; id: string }
| { type: 'swapTodos'; indexA: number; indexB: number }
@clinuxrulz
clinuxrulz / incremental-dom-typescript.ts
Created November 11, 2026 03:05
incremental-dom-typescript.ts
// 1. Define Delta Action Types
export type ListDelta =
| { type: 'insert'; id: string; index: number; text: string }
| { type: 'remove'; id: string }
| { type: 'swap'; indexA: number; indexB: number }
| { type: 'updateText'; id: string; text: string };
// 2. Batched Delta Event Bus / Queue
export class DeltaBus {
@clinuxrulz
clinuxrulz / map.ts
Created June 4, 2026 22:03
Multikey zero gc Map TypeScript
export class LowLevelCoordinateMap<V> {
private capacity: number;
private mask: number;
private size: number = 0;
private maxLoadFactor = 0.7;
// Stores structural composite keys flat in memory: [x0, y0, z0, x1, y1, z1, ...]
private keys: Int32Array;
// Standard array storing the mapped values, aligning perfectly with the key slots
private values: Array<V | undefined>;
@clinuxrulz
clinuxrulz / init.lua
Created February 21, 2026 17:30
Neovim config ~/.config/nvim/init.lua
-- 1. Bootstrap Lazy.nvim
local lazypath = vim.fn.stdpath("data") .. "/lazy/lazy.nvim"
if not vim.loop.fs_stat(lazypath) then
vim.fn.system({
"git", "clone", "--filter=blob:none",
"https://github.com/folke/lazy.nvim.git", "--branch=stable", lazypath,
})
end
vim.opt.rtp:prepend(lazypath)
@clinuxrulz
clinuxrulz / IntrusiveIndexedPriorityQueue.ts
Last active November 5, 2025 03:54
Intrusive Indexed Priority Queue
import { Vertex } from "./Vertex";
const SANITY_CHECKS = false;
export class IntrusiveIndexedPriorityQueue<
A extends {
pqRank: number,
inPq: boolean,
pqPrev: A | null,
pqNext: A | null,
@clinuxrulz
clinuxrulz / knob.html
Created September 21, 2025 02:40
Knob svg/html
<svg version="1.1" viewBox="-16 -16 32 32" style="width: 192px; height: 192px; user-select: none; outline: none; --rot: 20deg;">
<defs>
<linearGradient id="shape-fill" x1="0" x2="0" y1="0" y2="1">
<stop offset="0%" stop-color="rgb(80, 80, 81)"/>
<stop offset="100%" stop-color="rgb(30, 30, 31)"/>
</linearGradient>
<path id="shape" d="
M14.876 -5.890A-16 -16 0 0 0 14.876 5.890A16 16 0 0 112.539 9.938A-16 -16 0 0 0 2.337 15.828
A16 16 0 0 1-2.337 15.828A-16 -16 0 0 0 -12.539 9.938A16 16 0 0 1-14.876 5.890A-16 -16 0 0 0 -14.876 -5.890
A16 16 0 0 1-12.539 -9.938A-16 -16 0 0 0 -2.337 -15.828A16 16 0 0 12.337 -15.828A-16 -16 0 0 0 12.539 -9.938
@clinuxrulz
clinuxrulz / selector.ts
Last active July 27, 2025 10:15
O(1) glitch free createSelector in solidjs user space
// https://playground.solidjs.com/anonymous/7ccf3971-2a47-45d5-82ed-1bc3a0481637
import { render } from "solid-js/web";
import { type Accessor, createSignal, createMemo, type Signal, onCleanup, untrack, For } from "solid-js";
function createSelector(a: Accessor<string | undefined>): (k: string) => boolean {
let map = new Map<string,{
s: Signal<boolean>,
refCount: number,
}>();
@clinuxrulz
clinuxrulz / add_no_add.js
Created July 4, 2025 23:36
Adding without adding
/**
* Performs 4-bit integer addition using direct, unrolled carry-lookahead logic.
* This function serves as a building block for the 32-bit adder.
*
* @param {number} nibbleA The first 4-bit input (0-15).
* @param {number} nibbleB The second 4-bit input (0-15).
* @param {number} carryIn The carry-in from the previous 4-bit block (0 or 1).
* @returns {{sum: number, carryOut: number}} An object containing the 4-bit sum and the carry-out.
*/
function add4BitCarryLookahead(nibbleA, nibbleB, carryIn) {