Skip to content

Instantly share code, notes, and snippets.

@sorcerykid
sorcerykid / mario.lua
Created January 12, 2025 16:42
Super Mario demo for BearLibTerminal 2.0 + HexLib API
require "hexlib"
------------------------------------
local Mushroom, Fireflower, Superstar, Goomba, KoopaTroopa
local enemies = { }
local def = { }
local ref = { }
local core = { }
local game = { }
@sorcerykid
sorcerykid / sprintf.js
Created December 11, 2024 00:45
ANSI C-like sprintf() helper for Javascript, with support for alignment and field widths
function sprintf( )
{
let regex = /%([-0])?([0-9]+)?(\.[0-9]+)?([sdf%])/g;
let args = arguments;
let tmpl = args[ 0 ];
let idx = 1;
return tmpl.replace( regex, function ( exp, p0, p1, p2, p3 )
{
if( exp == '%%' )
@sorcerykid
sorcerykid / strftime.js
Created November 27, 2024 03:25
Awk-compatible implementation of strftime() function in JavaScript
function strftime( tmpl, timestamp )
{
let regex = /%([admbyYzZHMS])/g;
let date = new Date( ( timestamp + 60 * getTimezone( ) ) * 1000 );
let utc_format = date.toUTCString( ); // Tue, 12 May 2020 23:50:21 GMT
let iso_format = date.toISOString( ); // 2020-05-12T23:50:21.817Z
return tmpl.replace( regex, function ( exp, type )
{
if( exp == '%%' )
@sorcerykid
sorcerykid / stream.html
Created October 28, 2020 14:29
Apply effects to a live audio feed in JS
<audio crossorigin="anonymous" id="audio_source" controls preload="none" style="width:16em;padding:0;">
<source src="http://www.example.com:8000/sample?type=http&amp;nocache=4" type='audio/mpeg'>
</audio>
<script>
const AudioContext = window.AudioContext || window.webkitAudioContext;
const audio = document.querySelector( "audio" );
var convolverBuffer;
var convolverNode;
@sorcerykid
sorcerykid / init.lua
Last active June 19, 2018 14:22
Filter Mod
--------------------------------------------------------
-- Minetest :: Auth Redux Mod v2.1 (auth_rx)
--
-- See README.txt for licensing and release notes.
-- Copyright (c) 2017-2018, Leslie E. Krause
--
-- ./games/minetest_game/mods/auth_rx/filter.lua
--------------------------------------------------------
FILTER_TYPE_STRING = 11
--------------------------------------------------------
-- Minetest :: Auth Redux Mod v2.1 (auth_rx)
--
-- See README.txt for licensing and release notes.
-- Copyright (c) 2017-2018, Leslie E. Krause
--
-- ./games/just_test_tribute/mods/auth_rx/init.lua
--------------------------------------------------------
----------------------------
I have been contributing code to Minetest for months, not just sitting on code.