The following compares the output of several creative hash functions designed for human readability.
sha1's are merely used as arbitrary, longer, distributed input values.
input | 1 word output | 2 word output | 3 word output |
---|
// Streams all values from a public contract array. Callback is a function that takes a single | |
// argument, one item from the array. Returns a promise that rejects if there is any error or | |
// resolves if all items have been retrieved. | |
function getAll(contract, sizeGetter, array, cb) { | |
// get the size of the array | |
return contract[sizeGetter]().then(n => { | |
// generate an array of contract calls | |
return Promise.all(Array(n.toNumber()).fill().map(i => { | |
// invoke the callback with the item | |
return contract[array](i).then(cb) |
const waterfall = require('promise.waterfall') | |
const Bluebird = require('bluebird') | |
const _ = require('lodash') | |
// an array of 10ms functions with different return values | |
const functions = [ | |
() => Bluebird.delay(10, 'a'), | |
() => Bluebird.delay(10, 'b'), | |
() => Bluebird.delay(10, 'c') | |
] |
The following compares the output of several creative hash functions designed for human readability.
sha1's are merely used as arbitrary, longer, distributed input values.
input | 1 word output | 2 word output | 3 word output |
---|
web3.currentProvider.sendAsync({ | |
jsonrpc: “2.0”, | |
method: “evm_increaseTime”, | |
params: [60], // 60 seconds, may need to be hex, I forget | |
id: new Date().getTime() // Id of the request; anything works, really | |
}, function(err) { | |
// ... | |
}); |
const reducers = {} | |
// these could be easily split up across different files | |
reducers.FETCH_RESULT = (state, result) => Object.assign({}, { myData: result.myData }, state } | |
reducers.ADD_ITEM = (state, item) => Object.assign({}, { items: state.items.concat(item) }, state } | |
reducers.REMOVE_ITEM = (state, item) => Object.assign({}, { items: ... }, state } | |
// the main reducer | |
reducer = (state, action) => { | |
return reducers[action.type](state, action.data) |
https://github.com/ziman/lightyear | |
idris JsonTest.idr -p lightyear -p contrib | |
parse jsonToplevelValue "{ \"a\": 1, \"b\": 2 }" |
git config user.email "Full Name" | |
git config user.email "[email protected]" |
it('should throw an error', cb => { | |
const result = aMethodThatRejects() | |
result.then(x => { cb('Expected error. Instead got ' + x) })) | |
result.catch(() => cb()) | |
}) |
_ |