Skip to content

Instantly share code, notes, and snippets.

View kainino0x's full-sized avatar
🦙

Kai Ninomiya kainino0x

🦙
View GitHub Profile
@kainino0x
kainino0x / second_userdata.cpp
Last active July 20, 2023 19:40
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 August 29, 2023 19:28
my personal `git lg` and friends
git config --global alias.lg "log --pretty=format:'%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=format:'%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.rl "reflog --format='%C(auto)%h %<|(17)%gd %C(blue)%cr%C(reset) %s'"
git config --global alias.st '!git --no-pager log -1 --oneline && git status -sb'
git config --global alias.l '!git status -s; git --no-pager lg -n8;echo'
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)'"
git config gerrit.squash-uploads false
@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 April 7, 2021 01:55
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;
}
@kainino0x
kainino0x / gist:271702608e4a1f8560d1
Created March 3, 2016 21:44
coqtop -ideslave --help-XML-protocol
=== Available calls ===
"Add" : ((string * int) * (Stateid.t * bool))
-> (Stateid.t * (((unit, Stateid.t) CSig.union) * string))
"Edit_at" : Stateid.t
-> ((unit, (Stateid.t * (Stateid.t * Stateid.t))) CSig.union)
"Query" : (string * Stateid.t)
-> string
"Goal" : unit
-> (Interface.goals option)