Skip to content

Instantly share code, notes, and snippets.

bellbind / clock.html
Last active Aug 17, 2022
[SVG][JavaScript] SVG Analog Clock
View clock.html
<!doctype html>
<meta charset="utf-8" />
<meta name="viewport" content="user-scalable=no" />
<link rel="icon" href="././clock.svg" />
<link rel="manifest" href="./manifest.json" />
<title>SVG Clock</title>
html {height: 100%;}
bellbind / index.html
Created Jul 29, 2022
[JavaScript][HTML] run es modules in iframe context
View index.html
<!doctype html>
<script type="module">
document.querySelector("#run").addEventListener("click", async ev => {
const modUrl = new URL("./module.js", location.href).href;
const iframe = document.createElement("iframe"); = "none";
bellbind / index.html
Last active Jun 8, 2022
[css] shadow button example
View index.html
<!doctype html>
<meta charset="utf-8">
/* shadow button */
button {
border-style: none;
border-radius: 0.5em;
color: inherit;
bellbind / server.js
Last active May 27, 2022
[browser][deno] Example registration page and its server of API: navigator.registerProtocolHandler()
View server.js
#!/usr/bin/env -S deno run --allow-net
// Example registration page and its server of API: navigator.registerProtocolHandler()
import {serve} from "";
// A pattern of protocol scheme name is limited with prefix "web+" as web+lowerletters ,
// or whitelisted names in
const protocol = "web+local";
// navigator.registerProtocolHandler() should be called in user inputs (e.g. button click)
// - forwarded url must be same origin of the location.href
bellbind / movconcat.js
Last active May 21, 2022
[deno]10M bps video files concation with x4 speed and x2 volume with ffmpeg command
View movconcat.js
#!/usr/bin/env -S deno run --allow-read --allow-run
// usage: deno run --allow-read --allow-run movconcat.js /Volumes/UNTITLED/Normal/F/ result.mp4
import * as path from "";
const sources =;
const output =;
const inputs = [];
for await (const {name} of Deno.readDir(sources)) inputs.push(name);
const list = => `file ${path.toFileUrl(path.join(sources, f))}\n`).join(``);
bellbind / concat.mjs
Last active May 21, 2022
[nodejs][macos] 10M bps video files concation with x4 speed and x2 volume with ffmpeg command
View concat.mjs
#!/usr/bin/env node
// usage: node concat.mjs /Volumes/UNTITLED/Normal/F/ result.mp4
import * as cp from "node:child_process";
import * as fs from "node:fs/promises";
import * as path from "node:path";
import * as process from "node:process";
import * as stream from "node:stream";
import * as url from "node:url";
bellbind / example.js
Created Apr 26, 2022
[javascript] geodesic direct/inverse by Vincenty formulae
View example.js
import {inverse, direct} from "./vincenty.js";
// example from
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));
bellbind / index.html
Created Apr 22, 2022
[browser] custmizing input range sliders
View index.html
<!doctype html>
<meta charset="utf-8" />
.container {
position: relative;
display: flex;
flex-direction: column;
align-items: center;
bellbind / example-ipfs.html
Last active Apr 23, 2022
[leaflet] Web Component for display GPX
View example-ipfs.html
<!doctype html>
<meta charset="utf-8" />
<link rel="icon" href="data:img/x-icon," />
<script type="module" src="./leaflet-gpx.js"></script>
<body style="height: 100vh; display: flex; align-items: center; justify-content: center;">
style="width: 80vmin; height: 80vmin;"
bellbind / byob-transform.js
Last active Apr 10, 2022
[browser] Display MNIST images with Web API DecompressionStream
View byob-transform.js
// 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}};