Skip to content

Instantly share code, notes, and snippets.

View kainino0x's full-sized avatar
🐠

Kai Ninomiya kainino0x

🐠
View GitHub Profile
@kainino0x
kainino0x / macadamia.md
Last active October 1, 2025 23:46
How do you spell "Fuchsia"?

How do you (remember how to) spell Fuchsia?

tl;dr: Its etymology goes back to a German botanist named Leonhart Fuchs, plus an -ia suffix.

Fuchsia (OS) is named after a color which is named after a (genus of) plant. Like many plants and flowers, the plant's scientific name was given by some European guy after some other European guy, with an -ia suffix to make it a plant name. (Presumably in many cases because they couldn't fathom that indigenous people already had names for things, and so didn't bother to find out; there are plenty of plant names that are derived from indigenous names.)

Plant Named after Named by Native to
Fuchsia Leonhart Fuchs Charles Plumier Americas, Oceania
Begonia Michel Bégon Charles Plumier Asia, Americas
@kainino0x
kainino0x / second_userdata.cpp
Last active April 26, 2024 21:46
webgpu.h second userdata / C++ API proof of concept
// -std=c++11
// -Weverything -Wno-unused-variable -Wno-unused-parameter -Wno-c++98-compat -Wno-c++98-compat-pedantic
#include <cstdio>
#include <cstring>
#include <functional>
#include <memory>
#include <string>
#include <vector>
#include <cstddef>
@kainino0x
kainino0x / git-lg.sh
Last active October 31, 2025 21:01
my personal `git lg` and friends
# Aliases
git config --global alias.lg "log --pretty=tformat:'%Cred%h%Creset %Cgreen%cd%Creset%C(yellow)%d%Creset %s %Cgreen(%cr) %C(bold blue)<%an>%Creset' --abbrev-commit --date=short-local"
git config --global alias.gr "log --graph --pretty=tformat:'%Cred%h%Creset %Cgreen%cd%Creset%C(yellow)%d%Creset %s %Cgreen(%cr) %C(bold blue)<%an>%Creset' --abbrev-commit --date=short-local"
git config --global alias.l '!git --no-pager lg main~.. && echo && git status --show-stash'
git config --global alias.br "branch --sort=-committerdate --format='%(HEAD) %(if)%(HEAD)%(then)%(color:green)%(end)%(committerdate:short) %(align:32)%(refname:short)%(end) %(contents:subject)'"
# Configs
# Automatically turn `--fixup` commits into fixups when running `git rebase -i`
@kainino0x
kainino0x / CompilerColumnNumbers.md
Last active February 17, 2022 01:54
compiler "column" numbers

Clang - UTF-8 code units (bytes)

int main() {
/*xxx*/int x=xx; // codepoints=11+3=14, utf8units=11+3=14, utf16units=11+3=14, clusters=11+3=14
/*日本語*/int x=xx; // codepoints=11+3=14, utf8units=11+9=20, utf16units=11+3=14, clusters=11+3=14
/*👩‍💻*/int x=xx; // codepoints=11+3=14, utf8units=11+11=22, utf16units=11+5=16, clusters=11+1=12
}
@kainino0x
kainino0x / StructuredAccessor.ts
Last active December 9, 2025 08:26
Structured struct/array access into ArrayBuffer with JS properties+Proxies (in TypeScript)
// Utilities
function align(n: number, alignment: number): number {
return Math.ceil(n / alignment) * alignment;
}
function assert(condition: boolean, msg: () => string): asserts condition {
if (!condition) throw new Error(msg());
}
partial interface GPUDevice {
    GPUSurface createSurface(GPUSurfaceDescriptor descriptor);
};

interface GPUSurface : GPUTexture {
    ImageBitmap transferToImageBitmap();
};

dictionary GPUSurfaceDescriptor : GPUObjectDescriptorBase {
@kainino0x
kainino0x / spirv-1.1-1.2.diff
Created January 2, 2018 00:20
diff -U0 SPIRV1.1.html SPIRV1.2.html
--- SPIRV1.1.html 2018-01-01 16:07:16.000000000 -0800
+++ SPIRV1.2.html 2018-01-01 16:07:14.000000000 -0800
@@ -6 +6 @@
-<title>SPIR-V Specification Provisional</title>
+<title>SPIR-V Specification</title>
@@ -1729 +1729 @@
-<h1>SPIR-V Specification Provisional</h1>
+<h1>SPIR-V Specification</h1>
@@ -1731 +1731 @@
-<span id="revnumber">version 1.1, Revision 8</span>
@kainino0x
kainino0x / offscreencanvas-devtools-crash.html
Created December 25, 2017 09:39
OffscreenCanvas DevTools crash
<script type="text/plain" id="worker">
onmessage = function(e) {
let ctx = e.data.getContext('2d');
function loop() {
debugger; // When you hit this breakpoint, inspect any variable.
ctx.commit().then(loop);
}
ctx.commit().then(loop);
};
</script>
@kainino0x
kainino0x / shadertoy-Xds3zN.opt.html
Last active October 26, 2017 19:00
shadertoy-Xds3zN glslc->spirv-opt->spirv-cross
<style>
td pre {
overflow-x: scroll;
width: 31vw;
}
td {
border: 1px solid black;
vertical-align: top;
}
@kainino0x
kainino0x / boids.comp.opt.spv.html
Last active October 26, 2017 19:03
boids glslc->spirv-opt->spirv-cross
<style>
td pre {
overflow-x: scroll;
width: 31vw;
}
td {
border: 1px solid black;
vertical-align: top;
}