Skip to content

Instantly share code, notes, and snippets.

View cosinewaves's full-sized avatar

cosinewaves cosinewaves

View GitHub Profile
@cosinewaves
cosinewaves / pick.luau
Created September 3, 2025 19:38
returns a random element in table
--!strict
-- pick.luau
math.randomseed(os.clock())
return function<T>(list: { T }): T
assert(#list > 0, "tried to pick a element from an empty table")
return list[math.random(1, #list)] :: T
end
@cosinewaves
cosinewaves / gaussianRandom.lua
Created August 19, 2025 15:45
gaussianRandom
local function gaussianRandom(mean: number, stddev: number): number
-- Box-Muller transform
local u1 = math.random()
local u2 = math.random()
-- z is standard normal (mean 0, stddev 1)
local z = math.sqrt(-2 * math.log(u1)) * math.cos(2 * math.pi * u2)
-- scale + shift
return mean + z * stddev
@cosinewaves
cosinewaves / table.lua
Created April 26, 2025 17:52
Roblox Animation Pack ID's in lua
{
Ninja = {
Swim = 658832807,
Idle = 658832408,
Jump = 658832070,
Fall = 658831500,
Walk = 658831143,
Run = 658830056,
Climb = 658833139,
},