Skip to content

Instantly share code, notes, and snippets.

View jdmichaud's full-sized avatar

jdmichaud

View GitHub Profile
@jdmichaud
jdmichaud / chat.md
Created December 13, 2025 10:58
Vectors/Matrices in Zig

This is a very strong objection — and you’re right to push on it. Let me respond directly to your claim, not by retreating to “nested vectors”, and not by hand-waving about math libraries.

I’ll try to be precise about where matrices really do differ from vectors at the “core representation” level, and where they don’t. The key is that the difference is narrower than people often imply — but it’s still real.


1. You’re right about one big thing

“All this applied to vectors too.”

@jdmichaud
jdmichaud / notes.md
Created December 11, 2025 19:49
Video edit

Metadata

See metadata (and other data about the file):

ffmpeg -i input.mp4

Add metadata to video:

ffmpeg -i input.mp4 -metadata title="My Video Title" \
@jdmichaud
jdmichaud / main.js
Created December 4, 2025 16:23
Retrieve pixels of an image
const data = await (await fetch('Tv-test-pattern-146649_640.png')).bytes();
const decoder = new ImageDecoder({ type: "image/png", data });
const frame = await decoder.decode();
const bytes = new Uint8Array(frame.image.allocationSize());
await frame.image.copyTo(bytes.buffer);
@jdmichaud
jdmichaud / jit.c
Created November 26, 2025 18:07
jit
#include <sys/mman.h>
#include <string.h>
#include <stdio.h>
int main() {
/*
This is raw x86-64 machine code for a TINY *leaf function*:
lea eax, [rdi + 1] ; compute (arg + 1)
@jdmichaud
jdmichaud / dicom.md
Created October 30, 2025 16:28
ImageMagick

This does not currently work.

  • Render an image from a Dicom file (the last one in case the DICOM file contain an icon)
  • resize the image using the Bicubic interpolation method
  • apply the VOI Lut
convert isome.file[-1] -resize 50% -interpolate Bicubic -level 495,210 isome.file.png
@jdmichaud
jdmichaud / make_polygon.py
Last active September 15, 2025 19:32
2D drawing algorithm
# python3 -mvenv venv && source venv/bin/activate && pip install matplotlib
# python3 make_polygon.py
import matplotlib.pyplot as plt
import math
def make_polygon(vertices):
# compute centroid
average_x = sum([vertex[0] for vertex in vertices]) / len(vertices)
average_y = sum([vertex[1] for vertex in vertices]) / len(vertices)
centroid = [average_x, average_y]

-a archives recursively
-P shows progress and enables resuming interrupted download
-a compresses

rsync -azP -e 'ssh -p PORT' <user>@<IP>:/path/to/folder .
<!DOCTYPE html>
<html>
<head>
<title>Sand</title>
<meta charset="utf-8">
<link rel="icon" href="data:;base64,iVBORw0KGgo=">
<script type="text/javascript">
const SAND = 0xEF | 0xDD << 8 | 0x6F << 16 | 0xFF << 24;
const WATER = 0x1C | 0xA3 << 8 | 0xEC << 16 | 0xFF << 24;
let run = true;
@jdmichaud
jdmichaud / notes.md
Last active August 10, 2025 14:46
Javascript specification notes

Definitions

A Value is synonymous with ECMAScript Language Types, a fundamental data atom of javascript. A value can be primitive:

  • Undefined
  • Null
  • Boolean
  • String
  • Symbol
  • Number
@jdmichaud
jdmichaud / how-to.md
Last active July 30, 2025 10:38
Core dump gdb debug crash

Write a buggy program:

int main() {
    int *p = 0;
    *p = 42;
    return 0;
}

Compile it with debug options: