Skip to content

Instantly share code, notes, and snippets.

View nandordudas's full-sized avatar

Nándor Dudás nandordudas

View GitHub Profile
@nandordudas
nandordudas / 00-setup.md
Last active November 4, 2024 20:51
Setup WSL 2 on Windows 11

Windows Development Environment Setup Guide

Warning

This is a work in progress.

TODO: fzf, nvm, delta, exiftool

This guide provides step-by-step instructions for setting up a complete development environment on Windows, including WSL, package managers, and essential tools.

Table of Contents

import type { Dispatch, PropsWithChildren, SetStateAction } from 'react'
import { createContext, useContext, useState } from 'react'
type Prettify<T> = {
[K in keyof T]: T[K]
} & NonNullable<unknown>
type Nullable<T> = T | null
type Theme = 'dark' | 'light'
@layer root, hacked;
@property --horizontal-spacing {
syntax: '<length>';
initial-value: 0;
}
@layer root {
:root {
--highlight-bg-color: rgba(101, 117, 133, .16);
@nandordudas
nandordudas / vector-2d.ts
Last active August 9, 2024 13:13
Vector 2D
type Constructor<T> = new (...args: any[]) => T
type Intersection<T extends any[]> = T extends [infer First, ...infer Rest]
? First & Intersection<Rest>
: unknown
type Brand<T, B> = T & { __brand: B }
type Scalar = Brand<number, 'scalar'>
type Radians = Brand<number, 'radians'>
export type Constructor<T> = new (...args: any[]) => T
export type Brand<T, B> = T & { __brand: B }
export type Scalar = number
export type Radian = number
export interface Coordinates2D {
x: number
y: number
import { bench, describe } from 'vitest'
describe.each([
{ time: 0, iterations: 100_000, warmupTime: 100, warmupIterations: 1_000 },
{ time: 0, iterations: 100_000, warmupTime: 100, warmupIterations: 0 },
])('vector2D operations with various inputs $warmupIterations', (benchOptions) => {
describe.each([
{ name: 'Small integers', value: { x: 1, y: 2 } },
{ name: 'Large integers', value: { x: 1000000, y: 2000000 } },
{ name: 'Floating point', value: { x: 3.14159, y: 2.71828 } },
#!/usr/bin/env zsh
alias rebasa="git rebase --interactive HEAD~$(git rev-list --count $(git branch --show-current) ^main)"
update_deps() {
# Stash changes including untracked files
if ! git stash push -u -m "Temporary stash before updating dependencies"; then
echo "Error: Failed to stash changes. Aborting update process."
return 1
fi
type Constructor<T = void> = new (...args: any[]) => T
type RenderCallback = (deltaTime: number) => void
type FPSUpdateCallback = (fps: number) => void
declare namespace Rendering {
type Context2D = OffscreenCanvasRenderingContext2D | CanvasRenderingContext2D
}
interface RendererContract<T extends Rendering.Context2D> {
context: T
export class Vector2D implements Math.Vector2D {
static readonly #constructorSymbol = Symbol('Math.Vector2D')
static get zero(): Vector2D {
const zeroVector = Vector2D.create(0, 0)
return zeroVector
}
static create(
graph TD
    subgraph Client
        direction TB
        eventListener(Event: User Input) -->|SharedArrayBuffer| WebWorker
        WebWorker -->|SharedArrayBuffer: User Input| WebSocketClient
        WebWorker -->|Render Shapes| OffscreenCanvas
        WebSocketClient -->|User Input| WebSocketServer
        WebSocketServer -->|Calculated Game State| WebSocketClient
 WebSocketClient --&gt;|SharedArrayBuffer: Ball &amp; Paddles| WebWorker