Skip to content

Instantly share code, notes, and snippets.

@givensuman
givensuman / main.go
Last active October 14, 2025 17:12
Quirked up matrix multiplication
// Quirked up matrix multiplication
// This is stupid and suboptimal but appeared to me
// in a dream and I wanted to code it out
//
// Matrices in all functions of this
// package are assumed to be square
package main
import (
"math"
@givensuman
givensuman / main.go
Last active October 14, 2025 16:21
Implementation of the Observer design pattern
package main
import "fmt"
// UpdateLogger is a concrete type which can observe
// Observable and log their updates
type UpdateLogger struct {
message string
}
@givensuman
givensuman / App.tsx
Created December 17, 2024 05:01
Type-safe useCanvas hook for React canvas animations
import React from "react";
import useCanvas from "./useCanvas";
import { useWindowSize } from "@uidotdev/usehooks";
const App = () => {
const { width, height } = useWindowSize();
const canvasRef = useCanvas(
(ctx, frame) => {
ctx.fillRect(100, 100 + frame, 100, 100);
},