Skip to content

Instantly share code, notes, and snippets.

@floooh
floooh / Makefile
Created September 18, 2026 12:15
Opus 4.7 "write a sokol app in C with a rotating cube"
CC = clang
CFLAGS = -Wall -Wextra -O2 -x objective-c -fobjc-arc
LDFLAGS = -framework Cocoa -framework QuartzCore -framework Metal -framework MetalKit -framework AudioToolbox
cube: main.c
$(CC) $(CFLAGS) main.c -o cube $(LDFLAGS)
run: cube
./cube
@floooh
floooh / tif_to_png.py
Created August 8, 2026 13:10
tif_to_png.py
# DGM TIFF to various PNGs (heightmap, hillshade, and shaded heightmap)
#
# disclaimer: vibecoded!
#
import rasterio
import numpy as np
from PIL import Image
SRC = "dgm1_33340_5596_2_sn.tif"
@floooh
floooh / AppLauncher.cc
Created January 27, 2026 08:20
Nebula3 AppLauncher class
//------------------------------------------------------------------------------
// applauncher.cc
// (C) 2008 Radon Labs GmbH
//------------------------------------------------------------------------------
#include "stdneb.h"
#include "applauncher.h"
namespace ToolkitUtil
{
using namespace Util;
@floooh
floooh / gfx.json
Created November 7, 2023 10:10
sokol_gfx.h auto-generated API JSON
{
"module": "gfx",
"prefix": "sg_",
"dep_prefixes": [],
"decls": [
{
"kind": "struct",
"name": "sg_buffer",
"fields": [
{
@floooh
floooh / CMakeUserPresets.json
Created January 6, 2023 19:48
my generated cmake presets file
{
"version": 3,
"cmakeMinimumRequired": {
"major": 3,
"minor": 21,
"patch": 0
},
"configurePresets": [
{
"name": "default",
@floooh
floooh / project.pbxproj
Created February 27, 2022 11:46
Fixed Xcode project file for DeferredLighting sample
// !$*UTF8*$!
{
archiveVersion = 1;
classes = {
};
objectVersion = 46;
objects = {
/* Begin PBXBuildFile section */
3A2F3F23226FE35A000FACA9 /* AAPLRenderer_TraditionalDeferred.m in Sources */ = {isa = PBXBuildFile; fileRef = 3AE0241720584D0F00D9006B /* AAPLRenderer_TraditionalDeferred.m */; };
@floooh
floooh / vscode_wasm_async.ts
Last active November 16, 2021 16:30
WASM in VSCode Extension
import * as vscode from 'vscode';
import {promises as fs} from 'fs';
import * as path from 'path';
export function activate(context: vscode.ExtensionContext) {
context.subscriptions.push(vscode.commands.registerCommand('wasmtest.helloWorld', async () => {
const wasm = await load_wasm(path.join(context.extensionPath, 'media', 'bla.wasm'));
const exports: any = wasm.exports; // not sure how static typing is supposed to work here
const c_str = exports.greeting();
const js_str = c_to_js_string(c_str, exports.memory.buffer);
// PSEUDOCODE!
fn imm8(pins: u64, ticks: u64, pc: u16, tick_func: TickFunc) pins: u64, ticks: usize, pc: u16, data: u8 {
pins, ticks, data = memRead(pins, ticks, pc, tick_func);
return pins, ticks, pc +% 1, data;
}
fn memRead(pins: u64, ticks: u64, addr: u16, tick_func: TickFunc) pins: u64, ticks: usize, data: u8 {
pins, ticks = tick(setAddr(pins, addr), ticks, 3, MREQ|RD, tick_func);
return pins, ticks, getData(pins);
@floooh
floooh / zig_test_debugging_vscode.md
Last active December 20, 2025 18:50
How to debug Zig tests in VSCode

Tested on macOS:

  1. Install the CodeLLDB VSCode extension. Unlike the debugger in the C/C++ extension, this allows to set breakpoints inside Zig "test" blocks (in the MS C/C++ extension debugger, breakpoints inside test blocks will be disabled once the debugger starts for unknown reasons.
  2. When compiling the test, tell it to also emit a binary: zig test -femit-bin=zig-out/bin/my-test src/bla.zig, otherwise there will be no executable to debug.
  3. The compiled test executable expects the path to the Zig executable as first command line argument, the launch.json file needs to be setup accordingly (note the args item):
@floooh
floooh / hello.c
Created March 7, 2021 17:56
C-on-ObjC experiments...
// which is then used like this
// (helper functions like oc_alloc() and oc_alloc_init() will move into a header later)
#include <stdio.h>
#include <assert.h>
#include "hello_macos.h"
Class app_delegate_class;
id app_delegate;