Skip to content

Instantly share code, notes, and snippets.

@treytomes
treytomes / stringFormat.ms
Last active March 30, 2023 12:14
Simple string interpolation in MiniScript.
string.format = function(text, values)
if values isa map then
for kv in values
text = text.replace("${" + kv.key + "}", kv.value)
end for
else if values isa list then
if values.len > 0 then
for n in range(0, values.len - 1)
text = text.replace("${" + n + "}", values[n])
end for
@treytomes
treytomes / colorUtil.ms
Last active March 29, 2023 11:52
Fluent color interface.
builtinColor = globals.color
Color = {}
Color.r = 0
Color.g = 0
Color.b = 0
Color.a = 0
Color.init = function(r, g, b, a = 255)
self.r = r
@treytomes
treytomes / Color.cs
Created March 28, 2023 21:48
Color selection with all the fixings.
using roguecore.Math;
using System;
using System.Linq;
using System.Reflection;
namespace roguecore.Rendering
{
[Serializable]
public struct Color
{
@treytomes
treytomes / times.ms
Created March 9, 2023 14:20
Generate a times table based animation in Mini Script.
import "tc"
tau=pi*2
r=gfx.height/2.1
cx=gfx.width/2
cy=gfx.height/2
n=180
s=tau/n
t=1
@treytomes
treytomes / voices.cpp
Created July 14, 2022 12:40
Generate some audio with SDL2.
#include <stdio.h>
#include <stdlib.h>
#include <math.h>
#include <SDL2/SDL.h>
const double ChromaticRatio = 1.059463094359295264562;
const double Tao = 6.283185307179586476925;
Uint32 sampleRate = 48000;
Uint32 frameRate = 60;
@treytomes
treytomes / sound.asm
Created July 7, 2022 13:49
Play a 440Hz square wave through the PC speaker.
[org 0x0100]
jmp start
PIT_CHANNEL0 equ 0x40
PIT_CHANNEL1 equ 0x41
PIT_CHANNEL2 equ 0x42
PIT_COMMAND equ 0x43
PIT_HZ equ 1193180
@treytomes
treytomes / print.asm
Created July 6, 2022 20:12
Write strings and integers to text memory.
[org 0x0100]
jmp start
videoRAMSeg equ 0xb800
textAttr db 0x07
text:
db 'Hello, world!', 0
@treytomes
treytomes / timer.asm
Created July 6, 2022 17:26
Hooking the timer interrupt in x86 assembly.
[org 0x0100]
jmp start
ms_per_cycle equ 55
hrs: dw 0
min: dw 0
s: dw 0
ms: dw 0
@treytomes
treytomes / temperature.sh
Created February 14, 2022 21:44
Get your local temperature from the Linux terminal.
curl -s -L "$(curl -s -L "https://api.weather.gov/points/$(curl -s -L "https://nominatim.openstreetmap.org/search.php?q=$(curl -s -L ipinfo.io | jq -r '"\(.city),\(.region)"')&polygon_geojson=1&format=jsonv2" | jq -r '"\(.[0].lat),\(.[0].lon)"')" | jq -r '.properties.forecastHourly')" | jq -r '.properties.periods[0].temperature'
@treytomes
treytomes / ROGLITE2.BAS
Last active January 18, 2022 20:58
ROGLITE2.1 for QB64
' M(,) CONTAINS THE MAP DATA
' V(,) ARRAY CONTAINS THE VISIBILITY DATA
' MAP DATA: 1=FLOOR, 2=WALL
'''
' Feature toggles.
'''
' Set this to 1 to cause the entire playfield to be visible.
Const SHOW_PLAYFIELD = 0