Skip to content

Instantly share code, notes, and snippets.

James Halliday substack

Block or report user

Report or block substack

Hide content and notifications from this user.

Learn more about blocking users

Contact Support about this user’s behavior.

Learn more about reporting abuse

Report abuse
View GitHub Profile
@substack
substack / peermaps-roadmap.md
Created Feb 13, 2020
peermaps february 2020 roadmap
View peermaps-roadmap.md

peermaps roadmap

planet.osm

The goal of the planet.osm iteration will be to get peermaps into a usable state, cutting the release from a single machine for now.

  • eyros deletes
  • wasm version of eyros hooked up to browser storage
  • rust version of random-access-osm-pbf
@substack
substack / flow.js
Created Dec 14, 2019
kappa-flow hypothetical sparse key/value store
View flow.js
var flow = require('kappa-flow')()
var umkvl = require('unordered-materialized-kv-live')
var memdb = require('memdb')
var { EventEmitter } = require('events')
flow.use('kv', function () {
var kv = umkvl(memdb())
var refs = {}, queries = {}
kv.on('value', function (k, ids) {
ids.forEach(function (id) {
View replicate.js
var Protocol = require('hypercore-protocol')
module.exports = function (corestore, handlers) {
var p = new Protocol(Object.assign(handlers || {}, {
ondiscoverykey: function (dkey) {
corestore.keyFromDiscoveryKey(dkey, function (err, key) {
if (err) return error(err)
if (!key) return
corestore.get(key, function (err, feed) {
if (err) return error(err)
@substack
substack / kv.js
Created Nov 18, 2019
key/value pubsub with multiple feeds over sparse hypercore data
View kv.js
var minimist = require('minimist')
var argv = minimist(process.argv.slice(2), {
alias: { d: 'datadir' }
})
var path = require('path')
var pump = require('pump')
var feeds = {}
var Protocol = require('hypercore-protocol')
var swarm = require('discovery-swarm')
@substack
substack / pubsub.js
Created Oct 21, 2019
chat example with hypercores using a hypothetical pubsub api
View pubsub.js
var pubsub = require('../')
var path = require('path')
var { Transform } = require('readable-stream')
var live = require('level-live')
var diff = require('ansi-diff')({ width: process.stdout.columns })
process.stdout.on('resize', function () {
diff.resize({ width: process.stdout.columns })
render()
})
@substack
substack / perf.js
Created Jul 17, 2019
dataview vs typed array performance
View perf.js
let abuf = (function () {
let ua = new Uint32Array(1000*1000)
let max = 2**32
for (let i = 0; i < ua.length; i++) {
ua[i] = i%5
}
return ua.buffer // assume we got this from a network connection
})()
;(function () {
@substack
substack / kv.js
Created Jun 27, 2019
sharding hypertrie kv prototype api
View kv.js
var argv = require('minimist')(process.argv.slice(2), {
alias: { d: 'datadir', s: 'swarm', n: 'node' },
string: [ '_' ]
})
if (argv._[0] === 'listen') {
var prefix = argv._[1]
var listen = require('../listen.js')({
prefix,
swarm: require('discovery-swarm')
@substack
substack / core.js
Created Jun 21, 2019
hooking into have/want events in hypercore replication
View core.js
var hypercore = require('hypercore')
if (process.argv[2] === 'init') {
var feed = hypercore(process.argv[3])
feed.ready(function () {
console.log(feed.key.toString('hex'))
})
} else if (process.argv[2] === 'populate') {
var feed = hypercore(process.argv[3])
var r = feed.replicate({ live: true })
@substack
substack / bytes.js
Last active May 17, 2019
split a u64 into two u32s and verify that the combination works
View bytes.js
var n = 123456789012345
var u32a = Uint32Array.from([n,n/2**32])
var u8a = new Uint8Array(u32a.buffer)
console.log(u8a)
// Uint8Array [ 121, 223, 13, 134, 72, 112, 0, 0 ]
View hawaii-police-shootings.md
You can’t perform that action at this time.