Skip to content

Instantly share code, notes, and snippets.

View katsaii's full-sized avatar
🟣
Icon by NightMargin

Katt katsaii

🟣
Icon by NightMargin
View GitHub Profile
@katsaii
katsaii / array_clone.gml
Last active July 26, 2026 18:06
Misc GML snippets from the olden times (pre-2.3 update)
/// @desc Returns a clone of an array.
/// @param variable {Array} The array to clone.
/// @author Kat @katsaii
if (array_length_1d(argument0) < 1) then return [];
argument0[0] = argument0[0];
return argument0;
@katsaii
katsaii / gyazo-thumb-dl.js
Created January 8, 2026 23:44
JS console command to download upscaled thumbnails of Gyazo images, bypasses the pay wall at the cost of loss of image quality.
(async () => {
const require_ = async (jsURL) => {
// we can have a little security vulnerability, as a treat!
return await fetch(jsURL).then(data => data.text()).then(eval);
};
if (!this.includedJSZip) {
this.includedJSZip = true;
await require_("https://raw.githubusercontent.com/Stuk/jszip/refs/heads/main/dist/jszip.min.js");
await require_("https://raw.githubusercontent.com/eligrey/FileSaver.js/refs/heads/master/src/FileSaver.js");
}
@katsaii
katsaii / pool.gml
Last active September 3, 2022 22:34
A simple "ds_map" pooling example using probability to avoid constantly polling whether references are still alive. Technically unbound space complexity, but it is extremely unlikely to occur unless you're creating many new instances per frame without letting the garbage collector catch up.
/// @ignore
function __pool() {
static pool = [];
return pool;
}
function pool_get(container) {
var pool = __pool();
var poolMax = array_length(pool) - 1;
@katsaii
katsaii / factorial.rs
Last active March 7, 2022 11:07
A simple factorial function written in Rust
#![feature(generic_const_exprs)]
#![allow(incomplete_features)]
trait Factorialable<const N : usize> {
fn value() -> usize;
}
impl Factorialable<0> for () {
fn value() -> usize { 1 }
}
@katsaii
katsaii / split_name.pl
Created March 15, 2021 04:12
Splits a name and displays all possible splits, prefixes and suffixes.
fst((A, _), A).
snd((_, B), B).
name("katsaii").
?-
name(Name),
findall((Prefix, Suffix), string_concat(Prefix, Suffix, Name), Pairs),
maplist(fst, Pairs, Prefixes),
maplist(snd, Pairs, Suffixes),
@katsaii
katsaii / main.pl
Created December 5, 2020 03:21
My first prolog program!
distance(A, B, Dist) :-
A = (X1, Y1),
B = (X2, Y2),
Dx is X2 - X1,
Dy is Y2 - Y1,
Dist is sqrt(Dx * Dx + Dy * Dy).
closest([X | Xs], Target, Min) :-
distance(X, Target, Dist),
closest_ext(Xs, Target, (X, Dist), Min).
@katsaii
katsaii / scr_defer.gml
Created August 19, 2020 13:04
Defer execution of a block until another block is complete.
/* Deferred Exeuction of Code
* --------------------------
* Kat @Katsaii
*/
#macro DEFER for (;; {
#macro UNTIL ; break; })
@katsaii
katsaii / scr_controllers.gml
Created July 1, 2020 13:43
Handles the creation of controller objects and parents, offering runtime errors in situations where there could be strange behaviour.
/* Singleton object utilities
* --------------------------
* Kat @Katsaii
*/
#macro __instance_create_layer_internal instance_create_layer
#macro __instance_create_depth_internal instance_create_depth
#macro instance_create_layer instance_create_checked_layer
#macro instance_create_depth instance_create_checked_depth
#macro PREFIX_SINGLETON "the"
@katsaii
katsaii / quicksort.c
Created October 15, 2019 22:20
Sorts an array and removes any duplicate elements.
#include <stdio.h>
#include <stdlib.h>
void swap(int* a, int i, int j) {
int temp = a[i];
a[i] = a[j];
a[j] = temp;
return;
}
@katsaii
katsaii / download.bat
Last active August 14, 2019 14:22
A wrapper to shorten the youtube-dl command 'youtube-dl --extract-audio --audio-format (fmt) (url)' to simply 'download (fmt) (url)'.
@echo off
set fmt=%1
set url=%*
:: Strip fmt from url
set s=%fmt%
:loop
if [%s%] NEQ [] (
set s=%s:~1%
set url=%url:~1%
goto loop