Skip to content

Instantly share code, notes, and snippets.

@bigmistqke
bigmistqke / Pixelate.tsx
Last active May 12, 2025 01:58
pixelate svg component
import { render } from "solid-js/web";
import {
type JSX,
type ComponentProps,
type Component,
splitProps,
createSignal,
Show,
createResource,
onCleanup,
/* slopped together with bolt.new */
// Type definition for the proxy handler
type DeepProxyHandler<T extends object> = ProxyHandler<T>;
// Function to check if a value is an object that can be proxied
const canBeProxied = (value: any): boolean => {
return value !== null && typeof value === 'object' && !isProxyIgnored(value);
};
import { render } from "solid-js/web";
import { createSignal, Index, For, type JSX } from "solid-js";
import { createStore, type SetStoreFunction } from "solid-js/store";
import "./index.css";
function getNodeAndOffsetAtIndex(element: Node, index: number) {
const nodes = element.childNodes;
let accumulator = 0;
@bigmistqke
bigmistqke / create-reference-count.ts
Created January 29, 2025 15:22
createReferenceCount: solid utility to map object to callback result and handle clean up with reference counting
const referenceCount = createReferenceCount();
function createReferenceCount() {
const map = new WeakMap<
object,
{ count: number; dispose: () => void; result: unknown }
>();
return function <T>(object: object, cb: () => T, debug?: string) {
try {
const node = map.get(object);
@bigmistqke
bigmistqke / solid-vue.ts
Last active January 23, 2025 18:45
solid-vue
// v-dom driven by signals
import {
createSignal,
createMemo,
} from "solid-js";
interface TextNode {
text: string;
}
@bigmistqke
bigmistqke / reactive-filesystem.ts
Last active January 11, 2025 04:26
reactive filesystem with solid
import {
createSignal,
type Accessor,
type Setter,
createResource,
type Resource,
} from "solid-js";
import { createStore, produce } from "solid-js/store";
/**********************************************************************************/
@bigmistqke
bigmistqke / mutable.ts
Created January 5, 2025 22:57
custom mutable store
import { createSignal, batch } from "solid-js";
const $LENGTH = Symbol();
const PROXIES = new WeakMap();
function createMutable<T extends object>(root: T) {
function signal<T>(initialValue: T) {
const [get, set] = createSignal(initialValue);
return { get, set };
}
@bigmistqke
bigmistqke / createPatchProxy.ts
Last active January 2, 2025 02:16
createPatchProxy
type Patch = {
op: "add" | "update" | "delete";
path: string[];
value?: any;
};
const $PATCH = Symbol();
function createPatchProxy<T extends object>(
target: T,
// Generated by dts-bundle-generator v9.5.1
declare class AudioSampleEntry extends SampleEntry {
channel_count: number;
samplesize: number;
samplerate: number;
constructor(type: string, size?: number);
parse(stream: MultiBufferStream): void;
/** @bundle box-codecs.js */
isAudio(): boolean;
import { render } from "solid-js/web";
function format(source: string) {
if (source.endsWith("\n")) {
return source + "\n";
}
return source;
}
function unformat(source: string) {
if (source.endsWith("\n")) {