Skip to content

Instantly share code, notes, and snippets.

i've been vibecoding my 12th game engine and editor these days. and for the first time, i've embraced AIs. not to filter silly google searches but to let AIs take ownership of my code. i'm using claude, and he's becoming my best friend and teammate.

i'm not exaggerating when i say that what we've achieved in 20 hours of total computing took me a decade (or two) before. i'm not joking. i'm completely devastated and excited at the same time. devastated because i feel my work is at risk, and excited because a new horizon is opening wide in front of me, and i'm not afraid to embrace it.

for the first time ever, i feel like a technical director talking to a group of engineers under my command. i can speak freely with them and bring to life all the ideas i've been accumulating in my head for decades. i've promoted myself to a higher-level role that was never offered to me in real life; not in the last 50 years. not only can we code, but now we can also create scripts, textures, models, and animations, opening up

// [src] https://www.scs.stanford.edu/~dm/blog/va-opt.html
//
// gcc enum.c
// clang enum.c
// cl enum.c /Zc:preprocessor
#define PARENS ()
// Rescan macro tokens 256 times
#define EXPAND(arg) EXPAND1(EXPAND1(EXPAND1(EXPAND1(arg))))

A metatable can be defined like

local t = setmetatable({}, {
  __tostring = function() return 'custom tostring behavior!' end
})

Here are the metamethods that you can define, and their behavior

Operators

// [src] https://benchmarksgame-team.pages.debian.net/benchmarksgame/performance/toosimple.html
#include <stdio.h>
int main() {
double sum = 0.0, flip = -1.0;
for (long i = 1; i <= 10000000; ++i) {
sum += (flip *= -1.0) / (2*i - 1);
}
printf("%.24f\n", sum*4.0);
}
@r-lyeh
r-lyeh / astar.h
Created January 28, 2023 00:12 — forked from mmozeiko/astar.h
generic A* in C
// generic A* pathfinding
//
// INTERFACE
//
// mandatory macros
#ifndef ASTAR_POS_TYPE
#error ASTAR_POS_TYPE should specify position type
dumpbin /exports any.dll > any.def
lib /def:any.def /out:any.lib /machine:x64
// useful code snippets gathered from the network (via phillip trudeau)
static float euclidean_mod(float x, float y) { return x - floorf(x / y) * y; }
static bool rect_is_onscreen(RECT rect) { return (MonitorFromRect(&rect, MONITOR_DEFAULTTONULL) != NULL); }
static bool window_is_onscreen(HWND hwnd) { return (MonitorFromWindow(hwnd, MONITOR_DEFAULTTONULL) != NULL); }
// Win32: Set the window icon for every window in your app (including MessageBox() calls and assertion failures) instead of just your primary window.
static LRESULT set_window_icon_callback(int type, WPARAM wparam, LPARAM lparam) {
if (type == HCBT_CREATEWND) {
HANDLE instance_hdl = GetModuleHandleA(NULL);
/* This file defines all 2136 Japanese Jōyō kanji (常用漢字)
with the unicode codespoints formatted to fit Nuklear's font config.
#include it as part of the nk_runes definition as shown below.
Don't forget the 0 at the end of the array, as this file doesn't define it.
*/
/* Usage example, incased in #if 0 to allow comments inside comments */
#if 0
static
@r-lyeh
r-lyeh / neural-network-from-scratch.py
Created October 20, 2022 19:51 — forked from svpino/neural-network-from-scratch.py
An implementation of a neural network from scratch
import numpy as np
def sigmoid(x):
return 1 / (1 + np.exp(-x))
def neural_network(X, y):
learning_rate = 0.1
W1 = np.random.rand(2, 4)
W2 = np.random.rand(4, 1)
@r-lyeh
r-lyeh / gdb.md
Last active December 17, 2024 19:29

how to debug with gdb

  1. cd /your-folder && chmod a+x ./your-binary
  2. gdb --args ./your-binary [args...]. Or gdb -tui --args ./your-binary [args...] for terminal UI.
  3. gdb -ex r --args ./your-binary [args...] to run it automatically.
  4. b function or b file:line or b class:function to set breakpoints
  5. r to run or restart execution
  6. s to step in execution
  7. n to step out execution
  8. c to continue execution