Skip to content

Instantly share code, notes, and snippets.

View magicoal-nerb's full-sized avatar
💭
leelee,e

magical magicoal-nerb

💭
leelee,e
  • UC Davis
View GitHub Profile
@magicoal-nerb
magicoal-nerb / script_lex.gd
Last active October 21, 2026 02:36
cool party trick
class_name script_lex
# magicoal_nerb :3
func _init(data: String) -> void:
self._str = data
self._cursor = 0
self._lexemes = []
self._lines = []
_lex()
@magicoal-nerb
magicoal-nerb / Animate.lua
Last active October 27, 2026 11:11
retro animator
local ReplicatedStorage = game:GetService("ReplicatedStorage")
local RunService = game:GetService("RunService")
local Animator = require(ReplicatedStorage:WaitForChild("Animator"))
local Figure = script.Parent
local Humanoid = Figure:WaitForChild("Humanoid")
local Rig = Animator.new(Figure)
local Walk = Animator.loadAnimation(require(ReplicatedStorage.animations.Walk))
@magicoal-nerb
magicoal-nerb / cfg.luau
Last active October 6, 2026 12:46
cfg (based off of david doty's CFG syntax at davis)
--!strict
export type Lexer = {
expect: (what: string) -> boolean,
eof: () -> boolean,
requires: (what: string) -> (),
peek: (offset: number?) -> string,
consume: () -> string,
}
local CurrentCamera = assert(workspace.CurrentCamera)
local ContextActionService = game:GetService("ContextActionService")
local UserInputService = game:GetService("UserInputService")
local RunService = game:GetService("RunService")
local Players = game:GetService("Players")
local beginDragging = require("./beginDragging")
@magicoal-nerb
magicoal-nerb / priority_queue.h
Created June 16, 2026 08:40
priority_queue.h
#ifndef PRIORITY_QUEUE_H
#define PRIORITY_QUEUE_H
#define swap(a, b) do { \
uint32_t temp = (a); \
(a) = (b); \
(b) = temp; \
} while (0)
#include <stdint.h>
@magicoal-nerb
magicoal-nerb / dict.h
Created June 16, 2026 08:37
dictionary
#ifndef HASHTABLE_H
#define HASHTABLE_H
#include <stdlib.h>
#include <stdint.h>
#define swap(a, b) do { \
uint32_t temp = (a); \
(a) = (b); \
(b) = temp; \
--!strict
-- Matrices are in row-major order
-- magicoal_nerb :3
local function entry(a: number, b: number, n: number): number
return (a-1)*n + b
end
local function forwardSubstitution(L: { number }, b: { number }): { number }
-- Let A = LU. Ax = b <=> LUx = b
--!strict
-- deque; could be used as an object pool
-- magicoal_nerb :3
local Deque = {}
export type Deque<T> = {
elements: { T },
capacity: number,
@magicoal-nerb
magicoal-nerb / trvth.luau
Last active April 11, 2026 12:00
trvth.... example bytecode system for a friend
--!strict
local kOp = { ['v'] = 1, ['^'] = 2, ['>'] = 3, ['x'] = 4, ['='] = 5 }
export type OpCode = { ret: number, a: number, b: number, op: number }
export type State = {
var: (string) -> number,
reg: () -> number,
emit: (ret: number, a: number, b: number, op: number) -> (),
@magicoal-nerb
magicoal-nerb / RetroBvh.lua
Last active February 23, 2026 00:49
old roblox bvh for a friend
--!nolint
local FLAG_BRANCH = 1
local FLAG_LEAF = 0
local Bvh = {}
Bvh.__index = Bvh
local function safe(x)
-- safe epsilon