Skip to content

Instantly share code, notes, and snippets.

View raineorshine's full-sized avatar

Raine Revere raineorshine

  • New York, NY
View GitHub Profile
@raineorshine
raineorshine / promiseReduce.js
Last active April 6, 2017 02:35
Executes an array of promises or promise-returning functions serially and reduces the results with the given accumulator.
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')
]
@raineorshine
raineorshine / human-readable-hash-comparisons.md
Last active April 26, 2024 13:52
An aesthetic comparison of a few human-readable hashing functions.

An Aesthetic Comparison of Human-Readable
Hashing Functions

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
@raineorshine
raineorshine / raw-rpc-request.js
Created February 11, 2017 15:02
Send a raw RPC request with web3
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) {
// ...
});
@raineorshine
raineorshine / evm-lang-design-notes.md
Last active February 10, 2017 17:07
My personal notes trying to wrap my head around all the amazing ideas from evm-lang-design.
@raineorshine
raineorshine / auto-reducers.js
Last active February 5, 2017 16:32
React reducers keyed by action type
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)
@raineorshine
raineorshine / idris-lightyear-notes.c
Created February 2, 2017 04:15
Notes from experimenting with Idris Lightyear
https://github.com/ziman/lightyear
idris JsonTest.idr -p lightyear -p contrib
parse jsonToplevelValue "{ \"a\": 1, \"b\": 2 }"
@raineorshine
raineorshine / custom-git-committer.sh
Created January 26, 2017 15:59
Set different committer on a specific repo.
git config user.email "Full Name"
git config user.email "example@gmail.com"
@raineorshine
raineorshine / assert-throw.js
Last active March 16, 2019 18:37
Asserting solidity throws in truffle tests.
it('should throw an error', cb => {
const result = aMethodThatRejects()
result.then(x => { cb('Expected error. Instead got ' + x) }))
result.catch(() => cb())
})
@raineorshine
raineorshine / test-solidity-error-in-truffle.js
Last active January 3, 2017 12:58
Test that a contract method throws in a truffle unit test.
_
@raineorshine
raineorshine / memrise-export.js
Last active December 1, 2021 17:02
Export Memrise course words to CSV. There is also a Chrome Extension: https://chrome.google.com/webstore/detail/memrise-export/hcllgkpmoiolndnhmbdceffaidjmkoam
/*
UPDATE: This is now a Chrome Extension: https://chrome.google.com/webstore/detail/memrise-export/hcllgkpmoiolndnhmbdceffaidjmkoam
Source Code: https://github.com/raineorshine/memrise-export
Export Memrise course words to CSV (technically TSV, or "tab separated file", but it is effectively the same).
1. Log into Memrise.
2. Navigate to the course page you would like to export (e.g. https://app.memrise.com/course/2156672/german-random-01/).
3. Open the browser's Developer Console (https://support.airtable.com/hc/en-us/articles/232313848-How-to-open-the-developer-console)