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 / 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
@magicoal-nerb
magicoal-nerb / Xml.lua
Last active February 8, 2026 05:16
xml parser in luajit
-- Xml.lua
-- Parses xml files
-- poopbarrel/magicoal_nerb :^)
-- This parser makes a few assumptions about our data:
-- * element tags are not separated by whitespace
-- * no comments
local Stack = require("Stack")
local ffi = require("ffi")
@magicoal-nerb
magicoal-nerb / mergesort.luau
Last active January 18, 2026 23:39
stack based merge sort
--!strict
local function decodePair(pair: number): (number, number)
-- Get the vertex A and B
return bit32.rshift(pair, 16), bit32.band(pair, 0xFFFF)
end
local function encodePair(a: number, b: number): number
-- Encode A and B
return bit32.bor(bit32.lshift(a, 16), b)
end
using System;
using System.Collections.Generic;
public class JsonVariant {
// Referent
public JsonObject referent = null;
// Floating point number
public float number;
@magicoal-nerb
magicoal-nerb / Xml.cs
Created January 12, 2026 01:08
xml in C#
using System;
using System.Collections.Generic;
// Xml element
public class XmlElement {
// Current XML tag
public string tag;
// Current XML body
public string body;
@magicoal-nerb
magicoal-nerb / Animate.luau
Created December 13, 2025 03:20
roblox animate script 2.0
--!strict
-- Animate.lua
-- magicoal_nerb/poopbarrel :3
local AnimateScriptKeymap: {[string]: string} = {
Climbing = "climb",
Freefall = "fall",
Running = "run",
Jumping = "jump",
--!strict
local Queue = require("./Queue")
local Octree = {}
Octree.__index = Octree
export type OctreeNode = {
-- nodes expect 8 children if childIndex != 0
min: vector,
max: vector,
@magicoal-nerb
magicoal-nerb / buffer.luau
Created November 23, 2025 06:35
luau buffer
--!strict
-- Buffer
-- magicoal_nerb :P
local Buffer = {}
Buffer.__index = Buffer
export type Buffer = typeof(setmetatable({} :: {
data: buffer,
@magicoal-nerb
magicoal-nerb / Avl.luau
Last active November 13, 2025 00:39
avl tree
--!strict
-- AVL Tree implementations based on the mit ocw lecture videos
-- poopbarrel/magicoal_nerb :^)
local Queue = require("./Queue")
local Avl = {}
Avl.__index = Avl