Skip to content

Instantly share code, notes, and snippets.

View jasonsperske's full-sized avatar

Jason Sperske jasonsperske

View GitHub Profile
@jasonsperske
jasonsperske / Chart-README.md
Created February 21, 2026 20:29
AI-Tag Example - generated by first creating index.html and example.css, then running generate:spec, then updating some of the README and SPEC files to add more information, and running generate:code and using Claude to improve the generated code and README files.

Chart Component

Description

Documentation for the ai-Chart component. Renders a chart as an SVG using the data that is produced from the data-function or downloaded from the data-src URL. Data arrives as an array of objects that have keys that match the parsed series attribute and values to chart. Each index of the array is a series that is plotted on it's own.

Attributes

  • type: 'bar' describes a bar chart, 'line' describes a line chart.
  • data-function: a globally defined function that when called produces data that this element will render. If the function starts with a * then the funciton is a generator function and will need to have .next() called until it ends. The data format
@jasonsperske
jasonsperske / take.cs
Last active June 6, 2025 17:49
take function in c#
using System;
using System.Collections.Generic;
using System.Linq;
public class Program
{
public static IEnumerable<T> take<T>(IEnumerable<T> things, int size)
{
using (var iter = things.GetEnumerator())
{
@jasonsperske
jasonsperske / debounceDistinctUntilKeyChanged.spec.ts
Last active April 14, 2025 16:42
A function that takes a stream of events and only emits distinct ones after a debounce timer.
import { asyncScheduler, scheduled } from 'rxjs'
import { debounceDistinctUntilKeyChanged } from '.'
describe('debounceDistinctUntilKeyChanged', () => {
it('should emit as soon as a distinct key appears', () => {
type TestEvent = { fieldName?: string; fieldValue?: string }
const source = scheduled<TestEvent>(
[
@jasonsperske
jasonsperske / cn.js
Created April 2, 2025 00:01
className helper
/**
* Function that takes any number of strings or records of booleans or functions that return booleans
* and returns a string of class names that are true.
* @param classes
* @returns
*/
export function cn(...classes) {
return classes
.flatMap(c =>
typeof c === 'string'
@jasonsperske
jasonsperske / WITCH.CPP
Last active December 2, 2024 17:05
Witcheroo
#include <stdio.h>
#include <dos.h>
#include <conio.h>
typedef int bool;
#define TRUE 1
#define FALSE 0
#define PCI_CONFIG_ADDRESS 0xCF8
#define PCI_CONFIG_DATA 0xCFC
@jasonsperske
jasonsperske / claude-dl.py
Created November 11, 2024 10:38
A simple command line utility that takes one or more published Claude artifacts URLs and creates the files described in their code blocks automatically
# Adapted from https://claude.site/artifacts/adb7d26c-d81e-4df8-a8ba-d33ae4747a16
# very slight changes to some regexes
import argparse
import os
import re
from typing import List, Dict, Optional, Tuple
import requests
from bs4 import BeautifulSoup
@jasonsperske
jasonsperske / merge.js
Last active October 16, 2024 01:35
Array Merge Util (takes an ordered array and creates a new array with the value that overlap included while the values outside are left alone)
const src = [3, 4, 8, 9]
/**
* @param {number[]} input
* @param {number[]} source
* @returns
*/
function update(input, source) {
if (input.length === 0) return [...source]
if (source.length === 0) return [...input]
@jasonsperske
jasonsperske / mcp.sh
Created October 13, 2024 23:37
Minecraft MCP commands
# Remove the "downloads" object from 1.20.2_mcp.json
jq ".downloads = {}" 1.20.2_mcp.json | sponge 1.20.2_mcp.json
# update the "id" to match folder name
jq ".id = '1.20.2_mcp'" 1.20.2_mcp.json | sponge 1.20.2_mcp.json
# With the base files extrcted into a folder called `base` run the follwing command:
@jasonsperske
jasonsperske / dumb.js
Last active October 11, 2024 17:56
Dumb Number prototype overloading
Number.prototype.milliseconds = function() { return this }
Number.prototype.seconds = function() { return Number.prototype.milliseconds.call(this * 1000) }
Number.prototype.minutes = function() { return Number.prototype.seconds.call(this * 60) }
Number.prototype.hours = function() { return Number.prototype.minutes.call(this * 60) }
Number.prototype.days = function() { return Number.prototype.hours.call(this * 24) }
Number.prototype.weeks = function() { return Number.prototype.days.call(this * 7) }
Number.prototype.fortnights = function() { return Number.prototype.weeks.call(this * 2) }
Number.prototype.in = function() {
const that = this;
@jasonsperske
jasonsperske / cookies.js
Last active May 20, 2022 17:49
A super tiny function that converts the document.cookie to an object
function cookieMap() {
return document.cookie
.split('; ')
.map((c) => Object.fromEntries([c.split(/=(.*)/s).slice(0, 2)]))
.reduce((a, v) => ({ ...a, ...v }), {});
}