View ecc.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
# Basics of Elliptic Curve Cryptography implementation on Python | |
import collections | |
def inv(n, q): | |
"""div on PN modulo a/b mod q as a * inv(b, q) mod q | |
>>> assert n * inv(n, q) % q == 1 | |
""" | |
for i in range(q): | |
if (n * i) % q == 1: |
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> | |
<script type="module"> | |
// WICG Shape Detection API | |
// - https://wicg.github.io/shape-detection-api/ | |
try { | |
const start = document.getElementById("start"); | |
const video = document.getElementById("video"); | |
const result = document.getElementById("result"); |
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> |
View tetris-svg.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" /> | |
<meta http-equiv="X-UA-Compatible" content="IE=edge;chrome=1" /> | |
<script src="tetris.js"></script> | |
<script src="tetris-svg.js"></script> | |
</head> | |
<body> | |
<div><svg id="stage"></svg></div> |
NewerOlder