Skip to content

Instantly share code, notes, and snippets.

View ZacharyBear's full-sized avatar
📖
Learning ThreeJS

Zachary Bear ZacharyBear

📖
Learning ThreeJS
View GitHub Profile
@ZacharyBear
ZacharyBear / useDark.ts
Last active May 28, 2025 07:10
React dark mode hook
import { useMemo, useSyncExternalStore } from 'React'
const useDark = () => {
const match = useMemo(() => window.matchMedia('(prefers-color-scheme: dark)'), [])
// Handlers
const subscribe = (cb: () => void) => {
match.addEventListener('change', cb)
return () => match.removeEventListener('change', cb)
@ZacharyBear
ZacharyBear / learn.swift
Last active November 13, 2023 08:51
learn-swift
print("Hello, world")
// Prints "Hello, world
// Simple Values
var myVariable = 18
myVariable = 33
let myConstant = 18
//print(myVariable, myConstant)
@ZacharyBear
ZacharyBear / tree.js
Created November 4, 2023 05:08
Print tree node list, generate structure string and find childrens
const nodes = [
{ id: 1 },
{ id: 2, pid: 1 },
{ id: 3, pid: 1 },
{ id: 4, pid: 2 },
{ id: 5, pid: 2 },
{ id: 6, pid: 3 },
{ id: 7, pid: 3 },
{ id: 8, pid: 3 },
]