Skip to content

Instantly share code, notes, and snippets.

View Frando's full-sized avatar
🐢
on parental leave, slow to respond

Franz Heinzmann Frando

🐢
on parental leave, slow to respond
View GitHub Profile
@Frando
Frando / index.js
Created March 23, 2018 18:46
hyperdrive & hypergraph in same hyperdb
var hyperdb = require('hyperdb')
var sub = require('subhyperdb')
var hyperdrive = require('hyperdrive')
var hypergraph = require('hyper-graph-db')
var hyperdriveMessages = require('hyperdrive/lib/messages')
var dbName = process.argv[2]
var op = process.argv[3]
if (op !== 'read' && op !== 'write') {
@Frando
Frando / example.js
Last active March 24, 2018 12:43
smoosh-stream
var flatten = require('.')
var bulk = require('bulk-write-stream')
var stream = bulk.obj(flatten(write))
function write(batch, cb) {
batch.forEach(function(obj) {
console.log(obj)
})
cb(null)
@Frando
Frando / schema.proto
Last active February 8, 2019 00:26
"hyperclock" schema proposal
message Entry {
message Feed {
required bytes key = 1;
}
message Feeds {
repeated Feed feeds = 1;
optional Feed contentFeed = 2;
}
@Frando
Frando / battery-warn.service
Last active February 19, 2019 17:17
Warn & hibernate on low battery
# put this in ~/.config/systemd/user/battery-warn.service
# and adjust the line in exec-start
[Unit]
Description=Battery warning
[Service]
Type=oneshot
Environment="DISPLAY=:0" "XAUTHORITY=/home/bit/.Xauthority"
ExecStart=/home/.../battery.sh
NANOBENCH version 2
> /usr/bin/node bench.js
# write fs 5000 * 4K sequentially
ok ~262 ms (0 s + 261710236 ns)
# write hyperdrive 5000 * 4K sequentially
ok ~3.65 s (3 s + 653388561 ns)
# write client 5000 * 4K sequentially
@Frando
Frando / package.json
Last active August 9, 2019 09:31
hyperswarm local replication test
{
"name": "hyperswarm-replication-test",
"version": "1.0.0",
"description": "",
"main": "index.js",
"keywords": [],
"author": "",
"license": "MIT",
"dependencies": {
"@hyperswarm/replicator": "^1.1.0",

Keybase proof

I hereby claim:

  • I am Frando on github.
  • I am Frando (https://keybase.io/frando) on keybase.
  • I have a public key whose fingerprint is 6672 052F 6DF2 AC7E 2948 CB40 5CDC 80F9 A1AF ED95

To claim this, I am signing this object:

const tape = require('tape')
const hypercore = require('hypercore')
const ram = require('random-access-memory')
const { runAll, replicate } = require('./lib/util')
const { Kappa } = require('..')
const createIndexer = require('../sources/hypercore-sparse')
const topics = ['red', 'blue', 'green', 'yellow']
// This is an example for a sparse source for kappa5 pubsub
const Bitfield = require('bitfield-db')
const nanoiterator = require('nanoiterator')
const ram = require('random-access-memory')
module.exports = function createIndexer (handlers, opts) {
return new SparseIndexer(handlers, opts)
}
const tape = require('tape')
const { Kappa } = require('..')
const { runAll } = require('./lib/util')
tape.only('simple source', t => {
const kappa = new Kappa()
kappa.use('view1', makeSimpleSource(), makeSimpleView())
kappa.use('view2', makeSimpleSource(), makeSimpleView())
kappa.api.view1.source.push(1)