Skip to content

Instantly share code, notes, and snippets.

button.addEventListener('click', () => {
Promise.resolve().then(() => console.log('P1'))
console.log('L1')
})
button.addEventListener('click', () => {
Promise.resolve().then(() => console.log('P2'))
console.log('L2')
})
@orodio
orodio / redux.js
Created May 31, 2017 21:28
redux with a generator
export const createStore = (reducer, state = {}) => {
let subs = []
const store = (function * () {
while (true) {
const event = yield null
state = reducer(state, event)
subs.forEach(fn => fn(state))
}
})
@orodio
orodio / flux.js
Created May 29, 2017 20:07
redux'ish thing with generators and adhoc handlers
const createStore = (state) => {
const noop_handler = state => state
state = state || {}
var handlers = {}
var subs = []
const store = (function * () {
while (true) {
const { type, payload } = yield null
state = (handlers[type] || noop_handler)(state, ...payload)
@orodio
orodio / cmds.md
Created April 11, 2017 23:53
elixir phoenix mac postgres
$ mix phoenix.new <NAME>
$ cd <NAME>
$ mix ecto.create

// if postgres errors
  $ brew install postgresql
  $ psql postgres
  postgres=# CREATE ROLE postgres;
 postgres=# ALTER ROLE postgres LOGIN;
@orodio
orodio / Lambda Calc
Created September 23, 2016 02:30
Lambda Calc
λf.(λx.f(xx))(λx.f(xx))
ZERO = λfx.x | f -> x -> x
ONE = λfx.fx | f -> x -> f(x)
TWO = λfx.f(fx) | f -> x -> f(f(x))
THREE = λfx.f(f(fx)) | f -> x -> f(f(f(x)))
SUCC = λnfx.nfx | n -> f -> x -> n(f)(x)
ADD = λmnfx.mf(nfx) || λmn.n succ m | m -> n -> f -> x -> m(n(f))(x)
import css from "./styles.css"
import React from "react"
import Counter from "../Counter"
import Form from "../Form"
import update from "../__lib__/update"
import unset from "../__lib__/unset"
import set from "../__lib__/set"
import xhr from 'superagent'
import { Observable } from 'rx'
/** body
* @description returns the body of a supplied response
* @param {Object} response the response from the xhr request
* @return {Any} what ever the body is
*/
function body (response) {
return response.body
@orodio
orodio / .eslintrc
Created January 15, 2016 03:46
Drawboard ESlintFile
env:
browser: true
node: true
es6: true
mocha: true
protractor: true
ecmaFeatures:
modules: true
jsx: true
import xhr from "superagent"
import { Observable } from "rx"
var id = v => v
var body = r => r.body
var r = (resolve, reject, fn=id) =>
(err, res) =>
!!err
@orodio
orodio / index.html
Last active December 29, 2015 17:18
d3 - blocks test
<!DOCTYPE html>
<meta charset="utf-8">
<style>
* { margin:0; padding:0; }
body { background:aliceblue; }
</style>
<script src="http://cdnjs.cloudflare.com/ajax/libs/d3/3.3.10/d3.min.js"></script>
<script>
d3.select('body').append('h1').text('hello world')
</script>