Skip to content

Instantly share code, notes, and snippets.

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

magical_noob magicoal-nerb

💭
leelee,e
View GitHub Profile
@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 / bktree.luau
Last active November 12, 2025 09:02
burkhard keller tree
--!strict
-- BK trees are used for fast string lookup queries
-- And yea u have to use levenshtein
-- Basically, I just knocked down a few constants
-- so it is marginally faster than most implementations.
-- But, asymptotic performance is basically the same so yeah
-- https://gist.github.com/magicoal-nerb/6c91120e671d557de59e6d87e6617868
--!strict
-- yet another queue implementation :P
-- magicoal_nerb
local Queue = {}
Queue.__index = Queue
export type Queue<T> = typeof(setmetatable({} :: {
data: { T },
--!strict
local Set = {}
Set.__index = Set
export type Set<T> = typeof(setmetatable({} :: {
data: { [T]: boolean },
}, Set))
function Set.new()
@magicoal-nerb
magicoal-nerb / Bvh.luau
Created October 15, 2025 05:45
very basic bvh
--!strict
-- yet another bvh implementation :P
-- magicoal_nerb
local Queue = require("./Queue")
local Bvh = {}
Bvh.__index = Bvh