This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| -- jonbyte, 2026 | |
| local queue = {} :: array<{ | |
| fn: callback, | |
| args: argpack | |
| }> | |
| local active = false | |
| local index = 1 | |
| local epoch = 0 | |
| local thread: thread? |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| -- jonbyte, 2026 | |
| local function split( | |
| input: string, -- string to be split | |
| sep: { string }, -- array of separator strings | |
| include: true? -- if separators should be included in result | |
| ) | |
| if #sep == 0 then | |
| -- early exit: there is nothing to split the string | |
| return { input } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| -- queue: (assumed to not add anymore items mid-dequeue) | |
| -- length: the initial length of the queue | |
| local function fastDequeue(queue, length) | |
| local k = #queue | |
| local i = math.min(k, length - k + 1) | |
| queue[i], queue[k] = queue[k], queue[i] | |
| local v = queue[k] | |
| queue[k] = nil | |
| return v | |
| end |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| --!strict | |
| -- jonbyte, 2025 | |
| -- types | |
| type Int = number | |
| type i53 = Int | |
| type Type = Int | |
| type Index = Int | |
| type Map<K, V> = { [K]: V } | |
| type Array<V> = Map<Int, V> |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| -- jonbyte, 2024 | |
| -- approximate a kelvin temperature as RGB | |
| -- the result of messing around with equations and seeing the results | |
| local R, G, B = 560, 530, 420 -- sample wavelengths | |
| local c = 299792458 -- speed of light (m/s) | |
| local h = 6.62607015e-34 -- planck constant | |
| local k = 1.380649e-23 -- boltzmann constant | |
| local vec0 = vector.create(0, 0, 0) |