Skip to content

Instantly share code, notes, and snippets.

@jamesu
jamesu / imgui_impl.cpp
Created March 31, 2026 13:58
ImGUI Impl for Torque3D GFX
/*
Copyright 2026 James S Urquhart
Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the “Software”),
to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense,
and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:
The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED “AS IS”, WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
#!/usr/bin/env python3
#
# DevonThink database decoder
#
# Stuck on a desert island with no internet, unable to load your meticulously categorized DevonThink database?
# This could be come in handy!
#
# This code should probably be considered in the public domain since it is basically just vibe coded with a load of prompts,
# though feel free to fork and vibe code your own enhancements!
# Lovingly vibe coded 100% in ChatGPT.
@jamesu
jamesu / tgemit_sdl2.md
Last active December 29, 2025 22:40
Building tgemit on OSX using SDL2

Building tgemit on OSX using SDL2

  • Checkout the relevant branch (currently pbfix_mango)
  • Make sure you have xcode, dev tools, and metal tools installed (i.e. xcodebuild -downloadComponent MetalToolchain)

Currently only dawn is known to work with this setup, so you need to build and install it somewhere. A script in lib can do this:

./build_dawn.sh getdeps ~/dawnbuild
./build_dawn.sh build ~/dawnbuild Release
@jamesu
jamesu / packet_dump.cpp
Created September 26, 2025 15:02
Code to dump packet info from onverse connections
//#pragma GCC visibility push(hidden)
#include <stdio.h>
#include <string.h>
#include <stdlib.h>
#include <stdint.h>
#include <math.h>
#include <sys/types.h>
#include <sys/socket.h>
(module
;; --- Import from host: print(offset: i32) -> void
(import "env" "print" (func $print (param i32)))
;; --- Linear memory: fixed at 2 pages (128 KiB) ---
(memory (export "memory") 2 2)
;; --- Data segment: static string ---
(data (i32.const 16) "Hello World\00")
#include <stdio.h>
#include <sys/wait.h>
#include <sys/mman.h>
#include <unistd.h>
#include <semaphore.h>
#include <string.h>
#include <pthread.h>
typedef struct {
int value;
# HexFiend script to parse ThinkTanks .ter files
section "Header" {
# Read the version (int32)
set version [int8 version]
set gridShift 8
set lmShift 9
# If version > 3, parse additional fields
if {$version > 3} {
template <typename V, int S, int T>
class TableLookup {
public:
TableLookup(DataChunker* chunker) : mTables((S+(T-1)) / T, nullptr), mChunker(chunker), mNumEntries(0) {}
bool insert(U32 address, const V& value);
bool lookup(U32 address, V& value) const;
struct CommonUniforms {
projMat: mat4x4<f32>,
viewMat: mat4x4<f32>,
modelMat: mat4x4<f32>,
params1: vec4<f32>, // viewportScale.xy, lineWidth
params2: vec4<f32>, // alphaTestF, squareSize, hmX, hmY
lightPos: vec4<f32>,
lightColor: vec4<f32>,
sq01Tex : array<vec4<f32>, 16> // texcoord split over 2 vec4's
# tribes_extract_grid.rb
#
# Extracts tribes terrain data from ted volumes.
# Metadata will be outputted in JSON format.
#
# Copyright (C) 2024 James S Urquhart.
# Also makes use of LZH huffman decode tables and general decode logic.
#
require 'optparse'