Skip to content

Instantly share code, notes, and snippets.

View theMackabu's full-sized avatar
😹
meow

Mack theMackabu

😹
meow
View GitHub Profile
@theMackabu
theMackabu / fun.c
Created April 29, 2026 07:55
“fun”.c
/*
* 1. Have fun.
* 2. Always clean up after yourself.
* optional: bring a priest
*/
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <time.h>
$ python3 tools/gc_log_report.py /tmp/ant.gc.log
logfile: /tmp/ant.gc.log
log rows: 602
major collections: 22
minor collections: 176
Collection Timing
major total count= 22 avg= 21.57ms p50= 28.90ms p95= 36.31ms max= 65.49ms
major objects count= 22 avg= 20.23ms p50= 27.32ms p95= 34.71ms max= 61.83ms
const std = @import("std");
const Managed = std.math.big.int.Managed;
pub fn main() !void {
var gpa = std.heap.GeneralPurposeAllocator(.{}){};
defer _ = gpa.deinit();
const allocator = gpa.allocator();
const n = 1_000_000;
var a = try Managed.initSet(allocator, 0);
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <ctype.h>
#include <stdint.h>
#include <math.h>
#define PREFIX 0xFFF0000000000000ULL
#define DATA_MASK 0x00007FFFFFFFFFFFULL
enum Type { T_NUM, T_STR, T_BOOL, T_NIL };
static inline uint64_t mknum(double d) { uint64_t v; memcpy(&v, &d, 8); return v; }
@theMackabu
theMackabu / print.c
Created March 15, 2026 21:14
undefined behavior land
#include <stdio.h>
#define fmt(x) _Generic((x), \
int: "%d", \
long: "%ld", \
float: "%f", \
double: "%lf", \
char: "%c", \
char*: "%s", \
const char*: "%s", \

it first generates the bytecode from the parsed ast, then runs them through a type feedback checker, which runs the bytecode a few times unoptimized, the type feedback is used to analyze data and control flow simultaneously, like if we can skip the fallbacks to prototype chain walking. then it strips away dead code. if there is less than a detected threshold, it skips to emitting the actual operations and runs. If the threshold is hit, the non-optimizing "baseline" compiler is used that quickly turns bytecode into simple machine code to bridge the gap between interpretation and full optimization, this does not use type feedback. at the third stage, > 1000 iterations, we hit a graph that converts code into a graph representation that ignores the original order of lines to find the most efficient execution path, using the data from stage 2, it "bets" that the data types won't change, this removes expensive safety checks to create highly efficient machine code. if those "bets" fail, for example, if you sudden

@theMackabu
theMackabu / bunny.c
Created February 10, 2026 23:07
bnuy
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <ctype.h>
typedef enum {
OP_CONST, // push constant
OP_LOAD, // load local variable
OP_ADD, // add top two values
OP_CALL, // call function
@theMackabu
theMackabu / starfield.glsl
Created November 23, 2025 00:29
// divisions of grid
const float repeats = 30.;
// number of layers
const float layers = 21.;
// star colours
const vec3 blue = vec3(51.,64.,195.)/255.;
const vec3 cyan = vec3(117.,250.,254.)/255.;
const vec3 white = vec3(255.,255.,255.)/255.;
float ease(float x) {
return pow(1.0 - x, 10.0);
}
float sdBox(in vec2 p, in vec2 xy, in vec2 b)
{
vec2 d = abs(p - xy) - b;
return length(max(d, 0.0)) + min(max(d.x, d.y), 0.0);
}
# goto directory by name
setopt autocd
# zsh plugins
source $HOME/.config/plugins/completion/completion.zsh
source $HOME/.config/plugins/fsh/fast-syntax-highlighting.plugin.zsh
source $HOME/.config/plugins/autosuggestions/zsh-autosuggestions.plugin.zsh
# enable built in scripts
source $HOME/.local/scripts/entry.sh