View index.html
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<!doctype html> | |
<html> | |
<head> | |
<meta charset="utf-8" /> | |
<script src="https://unpkg.com/three"></script> | |
<script | |
src="https://unpkg.com/three/examples/js/loaders/GLTF2Loader.js" | |
></script> | |
<script src="script.js" defer="defer"></script> | |
</head> |
View complex.py
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# complex arith for programming with other languages | |
# - required functions: exp(f), log(f), sin(f), cos(f), atan2(f), pow(f1, f2) | |
import math | |
# [equality for complex] | |
def ceq(a, b): | |
return a.real == b.real and a.imag == b.imag | |
# [add, sub, mul for complex] |
View less.py
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# example of curses: less command | |
import locale | |
import sys | |
import curses | |
def load(): | |
filename = sys.argv[1] | |
with open(filename) as f: | |
return f.readlines(), filename | |
return [], "" |
View DisplayMode.swift
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/env swift | |
// swiftc displaymode1.swift | |
import Foundation | |
import CoreGraphics | |
let display = CGMainDisplayID() | |
guard let dmodes = CGDisplayCopyAllDisplayModes(display, nil) as? [CGDisplayMode] else {exit(1)} | |
let argv = CommandLine.arguments | |
if argv.count == 2 { |
View capture.c
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/* | |
* capturing from UVC cam | |
* requires: libjpeg-dev | |
* build: gcc -std=c99 capture.c -ljpeg -o capture | |
*/ | |
#include <stdint.h> | |
#include <stdlib.h> | |
#include <stdio.h> | |
#include <string.h> |
View pem.js
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// RSA with node-forge | |
"use strict"; | |
// npm install node-forge | |
const forge = require("node-forge"); | |
new Promise((f, r) => forge.pki.rsa.generateKeyPair( | |
2048, (err, pair) => err ? r(err) : f(pair))) | |
.then(keypair => { | |
const priv = keypair.privateKey; |
View closable-stream.js
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// wrapping libp2p stream (mplex/stream) | |
// - stream.source: AsyncIterable<Uint8Array> | |
// - stream.sink: (Iterable<Uint8Array> | AsyncIterable<Uint8Array>) => Promise<undefined> | |
// - stream.close, stream.closeRead, stream.closeWrite, stream.abort, stream.reset | |
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)); |
View cache-method.js
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
await caches.delete("tmp"); | |
const cache = await caches.open("tmp"); | |
const req1 = new Request("http://example.com/"); | |
const req2 = new Request("http://example.com/", {method: "head"}); | |
const req3 = new Request("http://example.com/", {method: "post"}); | |
const res1 = new Response("hello en-US", {headers: {"Content-Type": "text/plain;charset=utf-8"}}); | |
const res2 = new Response("", {headers: {}}); | |
await cache.put(req1, res1); // cache "http://example.com/ with res1 |
View example-relay-http2p.mjs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/env node | |
import * as fs from "node:fs"; | |
// IPFS | |
import * as IPFS from "ipfs-core"; | |
// WebRTCStar | |
import wrtc from "@koush/wrtc"; | |
import {sigServer} from "@libp2p/webrtc-star-signalling-server"; | |
import {webRTCStar} from "@libp2p/webrtc-star"; | |
// pubsub peerDiscovery | |
//import {floodsub} from "@libp2p/floodsub"; |
View index.html
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<!doctype html> | |
<html> | |
<head> | |
<meta charset="utf-8" /> | |
<script src="script.js" defer="defer"></script> | |
</head> | |
<body> | |
</body> | |
</html> |