Skip to content

Instantly share code, notes, and snippets.

View kumavis's full-sized avatar
🐉
!

kumavis kumavis

🐉
!
View GitHub Profile
@kumavis
kumavis / gist:220699f0fc5d52e2cfc4
Last active August 29, 2015 14:13
Example of es6 transpile
var koa = require('koa');
var app = koa();
// logger
app.use(function *(next){
var start = new Date;
yield next;
var ms = new Date - start;
console.log('%s %s - %s', this.method, this.url, ms);
function* addGenerator() {
var i = 0;
while (true) {
i += yield i;
}
}
var adder = addGenerator();
adder.next().value; // 0
adder.next(5).value; // 5
std=["top", "window", "location", "external", "chrome", "document", "define", "global", "cr", "ntp", "templateData", "Handler", "i18nTemplate"];Object.keys(window).filter(function(item){return std.indexOf(item)===-1})
@kumavis
kumavis / gist:c654143c4bcdea21e618
Last active August 29, 2015 14:14
How to Mercury (kumavis style)

First define your component:

  • value types and defaults for each key
  • 'channels', actions that potentially modify state or perform i/o. triggered by button presses, mouse movements, etc
var Value = require('observ')
var Component = require('../lib/component.js')
var Wallet = require('../wallet/index.js')
var Identity = require('../identity/index.js')
var render = require('./render.js')
nm = NumberMachine()
nm.multiply(2)
nm.add(6)
nm.subtract(3)
nm.multiply(2)
nm(10) //=> 46
nm(0) //=> 6
nm(20) //=> 86
10:46 <kumavis> maybe components could have some generic channel-generating hooks ?
10:46 <kumavis> render() { return inputBox( state.label, state.channels.bindValue('label') ) }
10:47 <kumavis> which could simplify to inputBox( state, 'label' )
10:47 <kumavis> so i dont have to create a channel that only updates a value directly passed in
10:48 <kumavis> right now i have to do inputBox(state.newIdentityAddress, state.channels.updateNewIdentityAddress)
10:48 <kumavis> function updateNewIdentityAddress(state, data) {
10:48 <kumavis> state.newIdentityAddress.set(data.text)
10:48 <kumavis> }
10:48 <kumavis> its just a lot of code to do one simple thing i feel
10:56 ⇐ alexandergugel quit (~alexander@208.66.27.18) Remote host closed the connection
╭─{👘 } kumavis in ~/Development/Node/ethereum-address-generator
╰─± node example.js
Looking for an address starting with "abc".
tried 1000 identities.
tried 2000 identities.
tried 3000 identities.
tried 4000 identities.
tried 5000 identities.
tried 6000 identities.
Found after 6110 attempts!
;(function () {
function c() {
var e = document.createElement("link");
e.setAttribute("type", "text/css");
e.setAttribute("rel", "stylesheet");
e.setAttribute("href", f);
e.setAttribute("class", l);
document.body.appendChild(e)
}
function h() {
start (secret) -> return apiObject with [encrypt, decrypt] with plaintext secret stored in closure
encrypt (input) -> generate salt, iv, additionalData, -> generate hash from salt and secret -> generate key from hash -> encrypt with key -> return json string with salt, iv, additionalData, and encrypted data (edited)
decrypt(input) -> read salt, iv, additionalData -> generate hash from salt and secret -> generate key from hash -> decrypt with key -> return unecrypted data
and the 'encrypted text' includes plaintext metadata about the encryption settings (salt, iv, additionalData)

Keybase proof

I hereby claim:

  • I am kumavis on github.
  • I am kumavis (https://keybase.io/kumavis) on keybase.
  • I have a public key whose fingerprint is 6750 E5FB B48E 01F1 D3AB 6BEE 9AC5 DEA8 D6AD D69B

To claim this, I am signing this object: