Skip to content

Instantly share code, notes, and snippets.

@orodio
orodio / es.md
Last active May 28, 2021 06:30
Event Sourcing

Wat

  1. Commands vs Events
  2. Complex Addition

Commands.

Something that CAN happen.

IT'S A COMMAND

#!/usr/bin/env node
const fcl = require("@onflow/fcl")
console.log("hello")
fcl.account(process.argv[3]).then(fcl.decode).then(d => console.log(d))
{
"name": "lolololololol",
"version": "999.99.99",
"bin": "./rawr.js",
"dependencies": {
"@onflow/fcl": "0.0.67-alpha.43"
}
}
@orodio
orodio / prng.js
Created March 3, 2020 19:08 — forked from blixt/prng.js
A very simple, seedable JavaScript PRNG.
/**
* Creates a pseudo-random value generator. The seed must be an integer.
*
* Uses an optimized version of the Park-Miller PRNG.
* http://www.firstpr.com.au/dsp/rand31/
*/
function Random(seed) {
this._seed = seed % 2147483647;
if (this._seed <= 0) this._seed += 2147483646;
}
@orodio
orodio / perf.js
Last active February 1, 2020 02:19
choose
// PTS | 1 2 3 4 5 6 7 8 9 10 11 12 13 14
// ----+----------------------------------------------------
// R1 | t6 t12 t4 t8 t5 t14 t11 t10 t13 t1 t2 t9 t3 t7
// R2 | t6 t4 t14 t13 t11 t10 t12 t1 t8 t5 t2 t9 t3 t7
// R3 | t6 t5 t11 t4 t14 t8 t10 t2 t1 t13 t12 t9 t3 t7
// R4 | t6 t5 t4 t10 t12 t11 t13 t8 t14 t2 t1 t9 t3 t7
// R5 | t6 t13 t11 t2 t10 t5 t12 t14 t8 t1 t4 t9 t3 t7
// R6 | t6 t5 t4 t13 t12 t8 t14 t11 t10 t1 t2 t9 t3 t7
// R7 | t6 t5 t13 t8 t4 t10 t1 t2 t14 t11 t12 t3 t9 t7
// R8 | t6 t5 t11 t14 t8 t4 t13 t10 t12 t1 t2 t3 t9 t7
@orodio
orodio / dirtyInject.js
Last active January 9, 2020 23:40
dirtyInject
const root =
(typeof self === 'object' && self.self === self && self) ||
(typeof global === 'object' && global.global === global && global) ||
(typeof window === 'object' && window.window === window && window) ||
this
root.__RAWR__ = {
onMount: (domNode, props) => {
// ReactDOM.render(<Counter {...props} />, domNode)
domNode.innerHTML = `<div>
const { GenServer, Ok, Reply, NoReply, Continue } = require("./gen-server")
var counts = {}
function UpdateCount(event) {
if (!(this instanceof UpdateCount)) return new UpdateCount(event)
this.count = event.count
}
const Counter = GenServer({
@orodio
orodio / keybase.md
Created March 5, 2019 23:32
keybase.md

Keybase proof

I hereby claim:

  • I am orodio on github.
  • I am qvvg (https://keybase.io/qvvg) on keybase.
  • I have a public key ASBf-wXJ3JAfM4GCCg9M96ZHtraCOzUneZkS_T40Tw2ziAo

To claim this, I am signing this object:

@orodio
orodio / simon_counter2.js
Created July 17, 2018 19:59
simon_counter2.js
const foo1 = () => { this.rawr = "rawr" }
function foo2 () { this.rawr = "rawr" }
function moo2 () { this.rawr = "moo" }
function resetRawr () { this.rawr = "rawr" }
function setRawr (value) { this.rawr = value }
const rawrStuff = { moo2: moo2, resetRawr: resetRawr, setRawr: setRawr }
foo1()
button.addEventListener('click', () => {
Promise.resolve().then(() => console.log('P1'))
console.log('L1')
})
button.addEventListener('click', () => {
Promise.resolve().then(() => console.log('P2'))
console.log('L2')
})