Skip to content

Instantly share code, notes, and snippets.

View machellerogden's full-sized avatar
💭
riding the inspiration train

Mac Heller-Ogden machellerogden

💭
riding the inspiration train
View GitHub Profile
@machellerogden
machellerogden / keyboardShortcut.js
Created January 29, 2026 15:39
Svelte Multi-Character Keyboard Shortcuts with Chord Support
import { writable } from 'svelte/store';
const activeShortcut = writable(null);
function hasModifiers(event) {
return event.ctrlKey || event.shiftKey || event.altKey || event.metaKey;
}
const ignoreRoleValues = new Set(['textarea']);
const ignoreNodeNames = new Set(['INPUT', 'TEXTAREA', 'SELECT']);
@machellerogden
machellerogden / strip-ansi.js
Created November 10, 2025 18:12
strip-ansi script
#!/usr/bin/env node
import { Transform, pipeline } from 'node:stream';
import { stripVTControlCharacters } from 'node:util';
const stripAnsi = new Transform({
transform(chunk, encoding, callback) {
try {
const stripped = stripVTControlCharacters(chunk.toString());
callback(null, stripped);
@machellerogden
machellerogden / llm-file-context
Last active May 8, 2025 19:02
A simple script for grabbing input-ready, markdown fenced code to share with an LLM.
#!/usr/bin/env bash
# The purpose of this script is to output text which can be used with an LLM which contains all of the code for the files matching a given glob pattern.
# For each file matching the given glob pattern the script will output the file path as a markdown heading and then the contents of the file within a properly syntax annotated code fence.
# Usage:
#
# llm-file-context file1 file2 file3 ...
#
# Example:
@machellerogden
machellerogden / HashRouter.md
Last active May 7, 2026 18:10
HashRouter.svelte - Svelte 5 Optimized Hash Router

Svelte 5 Hash Router

A lightweight, production-ready hash-based router for Svelte 5, built on SvelteURL. It supports:

  • Route guards (sync or async)
  • Param extraction with optional async resolvers
  • Reactive location and state exports
  • Minimal, idiomatic integration with Svelte's reactivity model

Inspired by the principle of reactive first, framework last—this router leans on standards and composition, not magic.

@machellerogden
machellerogden / SemanticKeys.md
Last active December 21, 2024 03:31
Svelte 5 - SemanticKeys.svelte - map semantics over typed input

SemanticKeys

Simple Svelte event-provider making it easy to map sequences of typed keys to semantic events.

Playground

@machellerogden
machellerogden / atomics.js
Created February 23, 2023 16:30
node atomics
const { Worker, SHARE_ENV } = require('node:worker_threads')
const { serialize, deserialize } = require('node:v8');
const HEADER_LENGTH = 16;
const LENGTH_MULTIPLE = 8;
function set_atom_header(a, l) {
const header = numToUint8Array(l);
const header_offset = HEADER_LENGTH - header.length;
if (header_offset <= 0) throw new Error('insufficient header space');
const invert = (e = document.documentElement, g = window, s = Symbol.for('invert')) => {
const [ i, d ] = (g[s] = !g[s]) ? [ 1, '180deg' ] : [ 0, 0 ];
e.style.backgroundColor = 'white';
e.style.filter = `invert(${i}) hue-rotate(${d})`;
};
export const omit = (o, ks) =>
!ks?.length ? o : Object.entries(o).reduce((acc, [ k, v ]) =>
ks.includes(k) ? acc : { ...acc, [k]: v }, {});
export const pick = (o, ks) =>
!ks?.length ? o : Object.entries(o).reduce((acc, [ k, v ]) =>
ks.includes(k) ? { ...acc, [k]: v } : acc, {});
export const partial = (fn, ...args) =>
(...rest) => fn(...args, ...rest);
function accessor(get, set) {
const g = [ get, set ];
g.get = get;
g.set = set;
return g;
}
function useSignal(context = []) {
function signal(value) {
#!/usr/bin/env sh
":" //; exec /usr/bin/env node --input-type=module - "$@" < "$0"