Skip to content

Instantly share code, notes, and snippets.

View Frando's full-sized avatar
🏠

Franz Heinzmann Frando

🏠
View GitHub Profile
syntax = "proto2";
package hrpc;
import "google/protobuf/descriptor.proto";
extend google.protobuf.ServiceOptions {
optional uint32 service = 50000;
}
extend google.protobuf.MethodOptions {

Rust is server

Listening on 127.0.0.1:8000
new connection from 127.0.0.1:52456
start handshaking
initiator: false
keypair public [160, 40, 198, 116, 22, 83, 78, 176, 233, 211, 154, 123, 37, 225, 135, 217, 143, 57, 220, 36, 141, 64, 202, 205, 154, 40, 249, 126, 1, 171, 64, 65] private [70, 92, 38, 45, 171, 60, 30, 169, 236, 96, 53, 30, 116, 242, 201, 22, 175, 223, 80, 0, 165, 119, 101, 25, 94, 101, 160, 229, 78, 174, 14, 64]
local pubkey: [a0, 28, c6, 74, 16, 53, 4e, b0, e9, d3, 9a, 7b, 25, e1, 87, d9, 8f, 39, dc, 24, 8d, 40, ca, cd, 9a, 28, f9, 7e, 1, ab, 40, 41]
local nonce: [0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0]
@Frando
Frando / hypercore-protocol in rust - demo.txt
Last active January 26, 2020 16:58
hypercore-protocol in rust - first steps
# in one terminal:
node hypercore-demo.js server 8080
# in another
git clone https://github.com/Frando/hypercore-protocol-rust-experiments
cargo run --example basic -- client 8080
# this will print:
recv: Open(Open { discovery_key: [184, 247, 61, 143, 233, 194, 150, 241, 106, 107, 132, 78, 106, 85, 102, 241, 250, 223, 3, 228, 39, 56, 171, 83, 111, 70, 25, 193, 212, 113, 39, 143], capability: None })
send 1 Open(Open { discovery_key: [184, 247, 61, 143, 233, 194, 150, 241, 106, 107, 132, 78, 106, 85, 102, 241, 250, 223, 3, 228, 39, 56, 171, 83, 111, 70, 25, 193, 212, 113, 39, 143], capability: None })
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)
// 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 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']

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:

@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",
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 / 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