Skip to content

Instantly share code, notes, and snippets.

View nandordudas's full-sized avatar

Nándor Dudás nandordudas

View GitHub Profile
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(
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
#!/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
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 } },
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
@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'>
@layer root, hacked;
@property --horizontal-spacing {
syntax: '<length>';
initial-value: 0;
}
@layer root {
:root {
--highlight-bg-color: rgba(101, 117, 133, .16);
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'
@nandordudas
nandordudas / 00-setup.md
Last active September 21, 2024 08:52
Setup WSL 2 on Windows 11

Install [Scoop]: A Command-Line Installer for Windows

Set-ExecutionPolicy -ExecutionPolicy RemoteSigned -Scope CurrentUser
iex "& {$(irm get.scoop.sh)} -ScoopDir ${Env:USERPROFILE}/Scoop"
scoop install git
scoop bucket add extras

[Scoop] is a command-line installer for Windows that makes it easy to install and manage software.