Skip to content

Instantly share code, notes, and snippets.

View kainino0x's full-sized avatar
🐹

Kai Ninomiya kainino0x

🐹
View GitHub Profile
@kainino0x
kainino0x / hijack.js
Created November 23, 2015 03:00
hijack.js
var hijack = function(that, name, wrap) {
var f0 = that[name];
that[name] = function() {
var f = function() {
f0.apply(that, arguments);
};
var args = Array.prototype.slice.call(arguments);
args.unshift(f);
return wrap.apply(null, args);
};
@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)
@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 / 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 / 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 / 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>
partial interface GPUDevice {
    GPUSurface createSurface(GPUSurfaceDescriptor descriptor);
};

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

dictionary GPUSurfaceDescriptor : GPUObjectDescriptorBase {
@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());
}
@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 / git-lg.sh
Last active April 3, 2024 23:56
my personal `git lg` and friends
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)'"
git config --bool gerrit.override-squash-uploads false # probably won't be overwritten but haven't verified
# old unused
#git config --global alias.rl "reflog --format='%C(auto)%h %<|(17)%gd %C(blue)%cr%C(reset) %s'" # drops branch info