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
#!/bin/bash | |
if [ "$#" -ne 3 ]; then | |
echo "usage:" | |
echo " ipfs-publish-remote.sh <keyname> <dir> <host>" | |
echo " example: ipfs-publish-remote.sh keyname output/rootdir user@ipfs.company.net" | |
exit 1 | |
fi | |
KEYNAME=$1 | |
DIR=$2 | |
HOST=$3 |
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
type Protocol = { | |
foo: { x: string }; | |
bar: { y: number }; | |
} | |
type Fold<T, U> = { | |
readonly [P in keyof T]: (value: T[P]) => U | |
} | |
type WithTag<T> = { | |
[TKey in keyof T]: { type: TKey } & T[TKey] | |
} |
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 enum Test { a = 'a' } | |
type Protocol = { | |
foo: { x: string }; | |
bar: { y: number }; | |
} | |
type WithTag<T> = { | |
[TKey in keyof T]: { type: TKey } & T[TKey] | |
} | |
type ToDiscriminatedUnion<P> = WithTag<P>[keyof P] | |
type Constructor<T> = { |
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
$ node benchmark2.js | |
= Encoding Time (ms) = | |
msgp.encode 9172.339491000399 | |
borc.encode 20400.477496000007 | |
json.stringify 9445.365290999413 | |
= Decoding Time (ms) = | |
msgp.decode 121.99922000057995 | |
borc.decodeFirst 383.22095499932766 | |
json.parse 48.20755399949849 |
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
let msgpackLite = require('msgpack-lite'); | |
let borc = require('borc'); | |
let _ = require('lodash'); | |
let { performance } = require('perf_hooks') | |
let arrays = _.times(100, (n) => { | |
return _.times(n, i => ({ i, a: [String(i * 1234), String(i * 1234), String(i * 1234), String(i * 1234)] })) | |
}); | |
let encodedBORC = arrays.map(array => borc.encode(array)); |
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
use std::iter::{Iterator, Peekable}; | |
pub struct MergeSorted<A: Iterator, B: Iterator> { | |
a: Peekable<A>, | |
b: Peekable<B>, | |
} | |
impl<A: Iterator, B: Iterator> MergeSorted<A, B> { | |
fn new(a: A, b: B) -> MergeSorted<A, B> { | |
MergeSorted { |
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
use futures::{future::FutureExt, select}; | |
async fn a() {} | |
async fn b() {} | |
async fn test() { | |
select! { | |
a = a().fuse() => println!("a"), | |
b = b().fuse() => println!("b"), |
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
use futures::prelude::*; | |
use std::{rc::Rc, task::{Context, Poll}, cell::RefCell, pin::Pin}; | |
fn foo<'a>(c: &'a mut u64) -> impl Stream<Item = u64> + 'a { | |
stream::unfold(10u64, move |max| { | |
future::ready(if *c < max { | |
*c += 1; | |
Some((*c, max)) | |
} else { | |
None |
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
Jul 24 13:25:22.534 DEBUG libp2p_gossipsub::behaviour: Subscribing to topic: discovery | |
Jul 24 13:25:22.534 DEBUG libp2p_gossipsub::behaviour: Running JOIN for topic: TopicHash { hash: "discovery" } | |
Jul 24 13:25:22.534 DEBUG libp2p_gossipsub::behaviour: RANDOM PEERS: Got 0 peers | |
Jul 24 13:25:22.534 DEBUG libp2p_gossipsub::behaviour: JOIN: Inserting 0 random peers into the mesh | |
Jul 24 13:25:22.535 DEBUG libp2p_gossipsub::behaviour: Completed JOIN for topic: TopicHash { hash: "discovery" } | |
Jul 24 13:25:22.535 INFO libp2p_gossipsub::behaviour: Subscribed to topic: discovery | |
Jul 24 13:25:22.537 DEBUG libp2p_gossipsub::behaviour: Subscribing to topic: /klk/prod/2020-01-09 | |
Jul 24 13:25:22.537 DEBUG libp2p_gossipsub::behaviour: Running JOIN for topic: TopicHash { hash: "/klk/prod/2020-01-09" } | |
Jul 24 13:25:22.537 DEBUG libp2p_gossipsub::behaviour: RANDOM PEERS: Got 0 peers | |
Jul 24 13:25:22.537 DEBUG libp2p_gossipsub::behaviour: JOIN: Inserting 0 random peers into the mesh |
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
/// This abomination only works if the underlying bytes are known in number (Sized), | |
/// can be moved around in memory (Unpin) and do no hold on to other things than the | |
/// underlying bytes ('static). | |
#[cfg(feature = "dataflow")] | |
impl<T: Abomonation + 'static + Sized + Unpin> Abomonation for ArcVal<T> { | |
unsafe fn entomb<W: std::io::Write>(&self, write: &mut W) -> std::io::Result<()> { | |
/* Since the value T has not yet been seen by abomonate (it is behind a pointer) | |
* we need to fully encode it. | |
*/ | |
abomonation::encode(self.deref(), write) |