Skip to content

Instantly share code, notes, and snippets.

@bellbind
bellbind / example.js
Created April 26, 2022 07:21
[javascript] geodesic direct/inverse by Vincenty formulae
import {inverse, direct} from "./vincenty.js";
{
// example from https://vldb.gsi.go.jp/sokuchi/surveycalc/surveycalc/bl2stf.html
const latlon1 = [36.10377477777778, 140.08785502777778], latlon2 = [35.65502847222223, 139.74475044444443];
console.log(inverse(latlon1, latlon2));
const s =58643.80450350114, a1to2 = 211.99252761069826;
console.log(direct(latlon1, a1to2, s));
console.log(latlon2);
}
@bellbind
bellbind / index.html
Created April 22, 2022 15:35
[browser] custmizing input range sliders
<!doctype html>
<html>
<head>
<meta charset="utf-8" />
<style>
.container {
position: relative;
display: flex;
flex-direction: column;
align-items: center;
@bellbind
bellbind / example-ipfs.html
Last active April 23, 2022 08:11
[leaflet] Web Component for display GPX
<!doctype html>
<html>
<head>
<meta charset="utf-8" />
<link rel="icon" href="data:img/x-icon," />
<script type="module" src="./leaflet-gpx.js"></script>
</head>
<body style="height: 100vh; display: flex; align-items: center; justify-content: center;">
<leaflet-gpx
style="width: 80vmin; height: 80vmin;"
@bellbind
bellbind / byob-transform.js
Last active April 10, 2022 10:16
[browser] Display MNIST images with Web API DecompressionStream
// BYOB emulation as TransformStream for `u8readable.pipeThrough(new BYOBTransform())`
const newQueue = () => {
const [gets, polls] = [[], []];
const next = () => new Promise(get => polls.length > 0 ? polls.shift()(get) : gets.push(get));
const poll = () => new Promise(poll => gets.length > 0 ? poll(gets.shift()) : polls.push(poll));
const push = async value => (await poll())({value, done: false});
const close = async () => (await poll())({done: true});
return {next, push, close, [Symbol.asyncIterator]() {return this}};
};
@bellbind
bellbind / example.js
Last active March 18, 2022 13:48
[javascript] math functions for regular matrix as flat array
import {det, adjugate as adj, inv, mulmm} from "./mat.js";
{
const a = [1, 2, 3, 4];
console.log(det(2, a));
console.log(adj(2, a));
console.log(inv(2, a));
console.log(mulmm(2, inv(2, a), a));
const b = [0, 1, 2, 7, 8, 3, 6, 5, 4];
@bellbind
bellbind / index.html
Last active April 3, 2022 13:08
[WebGPU] sampling from bitmap image by compute shaders (for Chrome-100)
<!doctype html>
<html>
<head>
<!-- IMPORTANT: The current Chrome requires some origin-trial token in <meta>.
To register origins at the last "WebGPU REGISTER" in https://developer.chrome.com/origintrials/
This token is for a Web Origin "http://localhost:8000" (maybe expired at Mar 31, 2022)
-->
<meta http-equiv="origin-trial"
content="AkIL+/THBoi1QEsWbX5SOuMpL6+KGAXKrZE5Bz6yHTuijzvKz2MznuLqE+MH4YSqRi/v1fDK/6JyFzgibTTeNAsAAABJeyJvcmlnaW4iOiJodHRwOi8vbG9jYWxob3N0OjgwMDAiLCJmZWF0dXJlIjoiV2ViR1BVIiwiZXhwaXJ5IjoxNjUyODMxOTk5fQ==" />
<meta http-equiv="origin-trial"
@bellbind
bellbind / index.html
Last active October 1, 2023 10:33
[WebGPU] Tiny example for WebGPU API
<!doctype html>
<html>
<head>
<!-- IMPORTANT: The current Chrome requires some origin-trial token in <meta>.
To register origins at the last "WebGPU REGISTER" in https://developer.chrome.com/origintrials/
This token is for a Web Origin "http://localhost:8000" (maybe expired at Mar 31, 2022)
-->
<meta http-equiv="origin-trial"
content="AkIL+/THBoi1QEsWbX5SOuMpL6+KGAXKrZE5Bz6yHTuijzvKz2MznuLqE+MH4YSqRi/v1fDK/6JyFzgibTTeNAsAAABJeyJvcmlnaW4iOiJodHRwOi8vbG9jYWxob3N0OjgwMDAiLCJmZWF0dXJlIjoiV2ViR1BVIiwiZXhwaXJ5IjoxNjUyODMxOTk5fQ==" />
<meta http-equiv="origin-trial"
@bellbind
bellbind / index.html
Last active April 3, 2022 13:06
[WebGPU] render with no vertex buffer
<!doctype html>
<html>
<head>
<!-- IMPORTANT: The current Chrome requires some origin-trial token in <meta>.
To register origins at the last "WebGPU REGISTER" in https://developer.chrome.com/origintrials/
This token is for a Web Origin "http://localhost:8000" (maybe expired at Mar 31, 2022)
-->
<meta http-equiv="origin-trial"
content="AkIL+/THBoi1QEsWbX5SOuMpL6+KGAXKrZE5Bz6yHTuijzvKz2MznuLqE+MH4YSqRi/v1fDK/6JyFzgibTTeNAsAAABJeyJvcmlnaW4iOiJodHRwOi8vbG9jYWxob3N0OjgwMDAiLCJmZWF0dXJlIjoiV2ViR1BVIiwiZXhwaXJ5IjoxNjUyODMxOTk5fQ==" />
<meta http-equiv="origin-trial"
@bellbind
bellbind / index.html
Last active May 7, 2022 05:53
[WebGPU] Image texture example for WebGPU API for Chrome-100
<!doctype html>
<html>
<head>
<!-- IMPORTANT: The current Chrome requires some origin-trial token in <meta>.
To register origins at the last "WebGPU REGISTER" in https://developer.chrome.com/origintrials/
This token is for a Web Origin "http://localhost:8000" (maybe expired at Mar 31, 2022)
-->
<meta http-equiv="origin-trial"
content="AkIL+/THBoi1QEsWbX5SOuMpL6+KGAXKrZE5Bz6yHTuijzvKz2MznuLqE+MH4YSqRi/v1fDK/6JyFzgibTTeNAsAAABJeyJvcmlnaW4iOiJodHRwOi8vbG9jYWxob3N0OjgwMDAiLCJmZWF0dXJlIjoiV2ViR1BVIiwiZXhwaXJ5IjoxNjUyODMxOTk5fQ==" />
<meta http-equiv="origin-trial"
@bellbind
bellbind / index.html
Last active November 23, 2023 13:54
[WebGPU] Rendering animated 3D object for Chrome-100
<!doctype html>
<html>
<head>
<!-- IMPORTANT: The current Chrome requires some origin-trial token in <meta>.
To register origins at the last "WebGPU REGISTER" in https://developer.chrome.com/origintrials/
This token is for a Web Origin "http://localhost:8000" (maybe expired at Mar 31, 2022)
-->
<meta http-equiv="origin-trial"
content="AkIL+/THBoi1QEsWbX5SOuMpL6+KGAXKrZE5Bz6yHTuijzvKz2MznuLqE+MH4YSqRi/v1fDK/6JyFzgibTTeNAsAAABJeyJvcmlnaW4iOiJodHRwOi8vbG9jYWxob3N0OjgwMDAiLCJmZWF0dXJlIjoiV2ViR1BVIiwiZXhwaXJ5IjoxNjUyODMxOTk5fQ==" />
<meta http-equiv="origin-trial"