Skip to content

Instantly share code, notes, and snippets.

View clinuxrulz's full-sized avatar

Clinton Selke clinuxrulz

View GitHub Profile
@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) {
export function projectMutableOverAutomergeDocV2<T extends object>(
json: any,
updateJson: (cb: (json: any) => any) => void,
typeSchema: TypeSchema<T>
): T {
if (typeof typeSchema != "object" || typeSchema.type != "Object") {
throw new Error("Expected object.");
}
let properties = typeSchema.properties;
let result = new Proxy<T>(
@clinuxrulz
clinuxrulz / index.ts
Created May 23, 2025 00:32
`Cont` monad being used for code generation (used as a Reified Monad)
import { Cont, do_, exec, execR, } from "prelude";
let freeVar = 0;
let code = "";
function main(): Cont<void> {
return do_(() => {
let name = ask(_("What is your name?"));
print(append(_("Hello "), name));
});
@clinuxrulz
clinuxrulz / index.ts
Created May 22, 2025 08:59
Monadic handles for return values in do-notation for Cont
import { Cont } from "prelude";
let div = document.createElement("div");
div.style.setProperty("position", "absolute");
div.style.setProperty("left", "20px");
div.style.setProperty("top", "20px");
div.style.setProperty("width", "300px");
div.style.setProperty("z-index", "100");
div.style.setProperty("background-color", "rgba(0,0,0,0.7)");
setTimeout(() => {
type Extract<Type, Union> = Type extends Union ? Type : never;
export type TypeSchema<A> =
TypeSchemaInvariantMap<unknown, A> |
TypeSchemaRecursive<A> |
{ type: "MaybeUndefined", elemTypeSchema: TypeSchema<NonNullable<A>>, } | (
A extends ({ has: true, value: unknown, } | { has: false, }) ? { type: "Optional", elemTypeSchema: TypeSchema<Extract<A, { value: unknown, }>["value"]>, } :
A extends boolean ? { type: "Boolean", } :
A extends number ? { type: "Number", } :
A extends string ? { type: "String", possibleValues?: string[], } :
import { SetStoreFunction, Store, createStore, reconcile, unwrap } from "solid-js/store";
import { parseJsonViaPropertiesSchema, writeJsonViaPropertiesSchema } from "../model/PropertiesSchema";
import { Result, err, ok } from "../model/Result";
import { Component, ComponentType, IsComponent, IsComponentType } from "./Component";
import { Registry } from "./Registry";
import { generateUUID } from "three/src/math/MathUtils";
import { parentComponentType } from "./components/ParentComponent";
import { childrenComponentType, ChildrenState } from "./components/ChildrenComponent";
import { Accessor, batch, createMemo, createSignal, onCleanup, untrack } from "solid-js";
@clinuxrulz
clinuxrulz / csv_into_excel_dump_2.ps1
Created March 22, 2024 11:45
csv into excel dump via powershell written by ChatGPT
function ProcessFile {
param(
[string]$inputFilename,
[string]$outputFilename
)
$csv = @()
$sr = New-Object System.IO.StreamReader($inputFilename)
try {
while ($true) {
@clinuxrulz
clinuxrulz / csv_into_excel_dump.ps1
Created March 22, 2024 08:20
Dump CSV into Excel via powerscript.
Add-Type -ReferencedAssemblies ("Microsoft.Office.Interop.Excel") -TypeDefinition @"
using System;
using System.Collections.Generic;
using Excel = Microsoft.Office.Interop.Excel;
public static class Program {
public static void Main(string[] args) {
if (args.Length != 2) {
Console.WriteLine("Please pass input file name and output file name as arguments.");
return;