Skip to content

Instantly share code, notes, and snippets.

View bennobuilder's full-sized avatar
👋
hello there

Benno bennobuilder

👋
hello there
View GitHub Profile
@bennobuilder
bennobuilder / use-css-variable.ts
Created March 27, 2025 15:16
use-css-variable
'use client';
import React, { useId } from 'react';
export function useCssVariable<GValue extends string | number>(
elementRef: React.RefObject<HTMLElement | null>,
config: TCssVariableConfig<GValue> | (() => TCssVariableConfig<GValue>),
deps: React.DependencyList = []
) {
const id = useId();
@bennobuilder
bennobuilder / gist:6781a3c5b21d2a24621fb3d9f64c2e8f
Created October 23, 2024 05:09
Why Math.atan2(0, -1) Returns -90 Degrees Instead of 0 for a Falling Object
The reason it's -90 degrees rather than 0 is because atan2 uses the standard mathematical coordinate system where:
The x-axis runs horizontally (right is positive)
The y-axis runs vertically (up is positive)
Angles are measured counterclockwise from the positive x-axis
In this system:
0 degrees points to the right (positive x-axis)
90 degrees points up (positive y-axis)