Skip to content

Instantly share code, notes, and snippets.

View kanzwataru's full-sized avatar

kanzwataru kanzwataru

View GitHub Profile
@kanzwataru
kanzwataru / undo.h
Created November 10, 2025 03:57
A generic C undo system, with a chunked ring-buffer that just memcpy's undoable chunks. Based on rxi's simple undo blog post.
// Push a maybe-change backup to the undo system
// Commit-or-discard a set of changes
//
// * Push to end (with wraparound)
// * Reclaim free blocks by pushing the head
// * Discard from middle
// * Move cursor around
// * Keep a separate set of pending items to then include into the structure as above
// * Always keeping the chronological order
@kanzwataru
kanzwataru / raylib_visualize_nodes.c
Created January 31, 2025 04:58
Very small <100LOC Raylib program to visualize a node tree
#include <stdbool.h>
#include <raylib.h>
struct Node {
const char *name;
int prev;
Vector2 ui_pos;
};
typedef struct Node Node;
# Based on https://krita-artists.org/t/checkerbord-seexpr-pattern/13900
$color1 = [0,0,0];
$color2 = [1,1,1];
$scale_horizontal = 3 ; # 1,500
$scale_vertical = 3; # 1,500
$offset_horizontal = 5; # 1,500
$offset_vertical = 5; # 1,500
$rotation = 0; # 0,360
"""
Super bare-bones mesh exporter script.
Exports into a minimal data format ready to upload to the GPU.
Vertices are deduplicated, and using index buffer.
Mesh is triangulated. Hard edges are preserved.
Coordinates are mesh-local, converted to Y-up.
--- Data Format ---
VERTEX_COUNT: u32
INDEX_COUNT: u32
VERTEX_BUFFER: float[VERTEX_COUNT][8]
#include "LegConstraintComponent.h"
ULegConstraintComponent::ULegConstraintComponent() {
PrimaryComponentTick.bCanEverTick = true;
}
void ULegConstraintComponent::TickComponent(float DeltaTime, ELevelTick TickType, FActorComponentTickFunction * ThisTickFunction)
{
Super::TickComponent(DeltaTime, TickType, ThisTickFunction);
if (!Pelvis || !LeftLeg || !RightLeg || !LeftKnee || !RightKnee)
@kanzwataru
kanzwataru / 32dos.c
Created April 29, 2019 02:27
MS-DOS Protected Mode (DOS/4GW) Test
#include <stdio.h>
#include <dos.h>
#include <conio.h>
#include <string.h>
#include <stdlib.h>
#define STAR_MAX 128
#define STAR_DARK 16
#define STAR_BRIGHT 31
#define STAR_SHIFT 4
@kanzwataru
kanzwataru / test.ui
Created February 3, 2019 16:26
Load Qt .ui file and add methods・uiファイルを読み込んでメソッドを追加
<?xml version="1.0" encoding="UTF-8"?>
<ui version="4.0">
<class>Form</class>
<widget class="QWidget" name="Form">
<property name="geometry">
<rect>
<x>0</x>
<y>0</y>
<width>350</width>
<height>301</height>
import unittest
class TestOrder(unittest.TestCase):
def setUp(self):
self.stuff = []
def test_01_create_stuff(self):
for n in xrange(20):
self.stuff.append(n)