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
S | |
/ \ | |
B - A | |
A requests 0 when there only one piece of data | |
A (0) | |
A goes offline |
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
console.log(Math.clz32(42424), clz(42424)) | |
function clz(x) { | |
// Let n be ToUint32(x). | |
// Let p be the number of leading zero bits in | |
// the 32-bit binary representation of n. | |
// Return p. | |
if (x == null || x === 0) { | |
return 32; | |
} |
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
npm-clone () { | |
if echo $1 | grep '/' >/dev/null; then | |
git clone git@github.com:$1.git | |
else | |
git clone git@github.com:mafintosh/$1.git | |
fi | |
cd $(echo $1 | sed 's|.*/||') | |
[ -f "package.json" ] && npm install | |
cd .. | |
} |
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
const noise = require('noise-peer') | |
const network = require('@hyperswarm/network') | |
const jsonStream = require('duplex-json-stream') | |
const hypercore = require('hypercore') | |
const pump = require('pump') | |
const swarm = network() | |
const hyperswarm = network() | |
const publicKey = Buffer.from(process.argv[2], 'hex') |
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
{ | |
"name": "kappa-workshop", | |
"description": "P2P collaboration workshop", | |
"license": "MIT", | |
"dependencies": { | |
"chalk": "^2.4.1", | |
"discovery-swarm": "^5.1.2", | |
"hypercore": "^6.20.2", | |
"kappa-core": "^2.3.2", | |
"kappa-view-kv": "^2.0.1", |
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
dat://a50ec5d10f61c2e6e4f7d8cd67324603052b0450dc187a86b1134c662a52599c |
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
const zlib = require('zlib'); | |
const { Writable } = require('stream'); | |
const ts = zlib.createGzip(); | |
const buf = Buffer.allocUnsafe(1024 * 1024 * 20); | |
ts.on('data', common.mustCall(() => ts.close())); | |
ts.end(buf); |
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
const zlib = require('zlib') | |
const { Writable } = require('stream') | |
const ts = zlib.createGzip() | |
const ws = new Writable({ | |
write (chunk, enc, cb) { | |
setImmediate(cb) | |
ts.close() | |
} |
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
const hooks = require('async_hooks') | |
const promises = new Set() | |
const hook = hooks.createHook({ | |
init (asyncId, type) { | |
if (type === 'PROMISE') { | |
promises.add(asyncId) | |
} | |
}, |
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
lookup static route x 52,214,074 ops/sec ±0.49% (94 runs sampled) | |
lookup dynamic route x 11,251,578 ops/sec ±1.89% (89 runs sampled) | |
lookup dynamic multi-parametric route x 7,225,928 ops/sec ±2.04% (91 runs sampled) | |
find dynamic multi-parametric route with regex (NOT FULLY IMPLEMENTED, BUT FOLLOWING TREND SOFAR) | |
lookup long static route x 7,017,902 ops/sec ±0.75% (87 runs sampled) | |
lookup long dynamic route x 5,324,800 ops/sec ±1.48% (89 runs sampled) | |
find static route x 53,943,393 ops/sec ±1.72% (88 runs sampled) | |
find dynamic route x 15,433,000 ops/sec ±1.87% (89 runs sampled) | |
find dynamic multi-parametric route x 14,652,641 ops/sec ±1.00% (93 runs sampled) | |
find dynamic multi-parametric route with regex (NOT FULLY IMPLEMENTED, BUT FOLLOWING TREND SOFAR) |