https://github.com/filecoin-project/lassie
Lassie is:
| // spec: https://github.com/tc39/proposal-weakrefs | |
| // the spec contains an [iterable WeakMap implementation](https://github.com/tc39/proposal-weakrefs#iterable-weakmaps) | |
| // NOTE: this WeakSet implementation is incomplete, only does what I needed | |
| // In Firefox Nightly, visit about:config and enable javascript.options.experimental.weakrefs | |
| class IterableWeakSet extends Set { | |
| add(el) { | |
| super.add(new WeakRef(el)) | |
| } | |
| forEach(fn) { |
| /** | |
| * The function you pass to `asyncPoll` should return a promise | |
| * that resolves with object that satisfies this interface. | |
| * | |
| * The `done` property indicates to the async poller whether to | |
| * continue polling or not. | |
| * | |
| * When done is `true` that means you've got what you need | |
| * and the poller will resolve with `data`. | |
| * |
| // Model to represent an account in the distributed database | |
| // Accounts are mainly a place users can store information like their private keys, in a password protected | |
| // vault, so they can login conveniently from other devices and keep hold of their private keys and record | |
| // what blogs they are authors of. It's also a way for other users to lookup an authors public keys to validate | |
| // their other objects when determining if a new version of some data really belongs to the blog it claims to be | |
| // related to. | |
| const nacl = require('tweetnacl') | |
| const cbor = require('borc') | |
| class HSAccount { |
| // We model the call stack using a linked list of Generators | |
| // Each Generator has a _return field pointing back to its parent | |
| function stepGen(gen, arg) { | |
| const {done, value} = gen.next(arg) | |
| if(done) { | |
| if(gen._return) { | |
| stepGen(gen._return, value) | |
| } |
| import ( | |
| "context" | |
| "fmt" | |
| "os" | |
| "time" | |
| "github.com/dgraph-io/badger" | |
| ) | |
| const ( |
| package main | |
| import ( | |
| "fmt" | |
| "github.com/ethereum/go-ethereum/accounts" | |
| "github.com/ethereum/go-ethereum/common/hexutil" | |
| "github.com/ethereum/go-ethereum/crypto" | |
| ) |
| // Simple example of how to display an image from IPFS on your html web page | |
| // Using ipfs/js-ipfs : https://github.com/ipfs/js-ipfs#use-in-the-browser | |
| // Don't forget to include the scripts into your html page: | |
| // <script src="https://unpkg.com/ipfs/dist/index.min.js"></script> | |
| // <script src="https://cdn.jsdelivr.net/npm/ipfs/dist/index.min.js"></script> | |
| function showIPFSImage () { | |
| // Create the IPFS node instance | |
| const node = new Ipfs() |
| /* | |
| Author: Jonathan Lurie - http://me.jonathanlurie.fr | |
| License: MIT | |
| The point of this little gist is to fix the issue of losing | |
| typed arrays when calling the default JSON serilization. | |
| The default mode has for effect to convert typed arrays into | |
| object like that: {0: 0.1, 1: 0.2, 2: 0.3} what used to be | |
| Float32Array([0.1, 0.2, 0.3]) and once it takes the shape of an | |
| object, there is no way to get it back in an automated way! |
Good documentation should include two distinct elements - a Guide and an API:
GitBook is well suited to