Skip to content

Instantly share code, notes, and snippets.

@MineRobber9000
MineRobber9000 / mdfpwm.py
Created March 4, 2024 06:51
MDFPWM converter in Python. Assumes you have up-to-date ffmpeg in PATH.
# MDFPWM encoder
# Uses ffmpeg to encode a WAV file as dfpwm
# Assumes ffmpeg is on PATH
# CC0, whatever
# credit Drucifer@SwitchCraft.kst for the format
import subprocess, tempfile, os, os.path, struct, json
def I(n):
return struct.pack("<I",n)
@MineRobber9000
MineRobber9000 / base64.ms
Created February 25, 2024 19:16
base64 encode/decode in MiniScript (Mini Micro exclusive)
// base64 in MiniScript
// by minerobber
// Mini Micro-exclusive (uses RawData)
// use base64.encode/decode for standard base64
// also supports variants (use .encode/decode on variants):
// - standard (A-Za-z0-9+/; base64.standard)
// - URL (A-Za-z0-9-_; base64.url)
// - B64 (crypt/GEDCOM; ./0-9A-Za-z; base64.b64/crypt/gedcom)
// - bcrypt (./A-Za-z0-9; base64.bcrypt)
// - bash base64 literals (0-9A-Za-z@_; base64.bash)
@MineRobber9000
MineRobber9000 / basic.lua
Last active August 11, 2023 02:09
Dartmouth BASIC interpreter
local functions = {}
for v in ("ABS ATN COS EXP INT LOG RND SIN SQR TAN "):gmatch("(.-) ") do
functions[v]=true
end
for c in ("ABCDEFGHIJKLMNOPQRSTUVWXYZ"):gmatch("(.)") do
functions["FN"..c]=true
end
local statements = {}
for v in ("LET PRINT END READ DATA GOTO IF FOR NEXT GOSUB RETURN DEF DIM REM STOP INPUT "):gmatch("(.-) ") do
statements[v]=true
@MineRobber9000
MineRobber9000 / switchcase.lua
Created July 22, 2023 04:59
syntax sugary switch case in lua
local _nil = setmetatable({},{__newindex=function() end}) -- sentinel
local function switch(val)
if val==nil then val=_nil end
return function(cases)
return (cases[val] or cases.default or function() end)()
end
end
return setmetatable({["_nil"]=_nil,switch=switch},{__call=function(t,...) return switch(...) end})
@MineRobber9000
MineRobber9000 / tic80gfx.py
Created June 24, 2023 02:36
TIC-80 graphics converter. Requires pillow.
"""TIC-80 graphics converter. Requires pillow.
usage: tic80gfx.py [-b BACKGROUND_COLOR] [-c COMMENT] [-p PALETTE] image index output
positional arguments:
image The image to convert.
index The index number for the top-left sprite.
output Where the converted image data will be saved.
options:
@MineRobber9000
MineRobber9000 / README.md
Created December 10, 2022 07:47
multiMon

multiMon

An update of the original by Shazz. Adds all term functions that have been added since 2014, and changes the architecture a bit.

To use

Unfortunately, due to the nature of this library, you still need to use os.loadAPI to use it (yuck, I know).

os.loadAPI("multiMon")
@MineRobber9000
MineRobber9000 / fr.lua
Created November 19, 2022 06:19
Floppy Rockers! A system for ComputerCraft drag-and-drop audio playing
-- Floppy Rocker
-- by MineRobber___T
-- Requires aukit and an attached speaker
if not package.path:find("lib/?") then package.path=package.path..";lib/?;lib/?.lua;lib/?/init.lua" end
if not pcall(require,"aukit") then error"Requires aukit" end
local aukit=package.loaded.aukit
local fs=fs
@MineRobber9000
MineRobber9000 / toml.lua
Created November 1, 2022 13:08
TOML library, written in pure Lua (should work 5.1+)
-- TOML parser
-- by MineRobber___T/khuxkm
-- no guarantee it'll pass every test but it should absolutely be capable
-- of reading valid TOML passed to it
--
-- returns a parse function; TOML goes in, table comes out
--
-- MIT licensed
local function lookupify(a,b)
@MineRobber9000
MineRobber9000 / LibDeflate.lua
Created February 23, 2022 13:16
LibDeflate (by Haoqian He/SafeteeWoW), pared down for ComputerCraft usage. Use `LibDeflate_min.lua` as LibDeflate to save space.
--[[--
LibDeflate 1.0.2-release <br>
Pure Lua compressor and decompressor with high compression ratio using
DEFLATE/zlib format.
Based on the original by Haoqian He, pared down for ComputerCraft usage
by Robert "khuxkm/minerobber" Miles
]] --[[
zlib License
@MineRobber9000
MineRobber9000 / gemtext.nanorc
Last active November 6, 2020 03:22
Gemtext nano formatting
syntax gemtext "\.(gmi|gemini)$"
color brightred "^#.*$"
color brightgreen "^##.*$"
color brightmagenta "^###.*$"
color yellow "\* .+"
color green ">.+"
color blue "=>\s+\S+\s+.+"