Skip to content

Instantly share code, notes, and snippets.

@orodio
orodio / left.md
Created November 11, 2015 06:09
MelbJS - Nov 11th 2015

Intro

Event Sourcing

James Hunter

  • Twitter: @cccc00
  • GitHub: orodio
@orodio
orodio / tmp.js
Created November 5, 2015 09:45
map filter reduce
var arr1 = [1, 2, 3, 4, 5];
var arr2 = ["one", "two", "three", "four", "five"];
map
[a] -> (a -> b) -> [b]
function double (v) { return v + v }
var a = arr1.map(double)
// a === [2, 4, 6, 8, 10]
__git_ps1 () {
local b="$(git symbolic-ref HEAD 2>/dev/null)";
if [ -n "$b" ]; then
printf " (%s)" "${b##refs/heads/}";
fi
}
PS1="\[\033[0;35m\]\$(__git_ps1)\[\033[0m\] \[\033[0;33m\]\W\[\033[0m\] \$ "
@orodio
orodio / bank_account.ex
Last active September 4, 2018 16:10
Actor Model Pattern in elixir
defmodule BankAccount do
def start do
await
end
def await, do: await([])
def await events do
receive do
event = { :deposit, _amount } -> events = [ event | events ]
event = { :withdraw, _amount } -> events = [ event | events ]
@orodio
orodio / Robot.md
Created September 22, 2015 04:00

Beep Boop

$ npm install # install dependencies
$ npm test    # run tests
$ npm start   # run commands in commands.txt

Toy Robot Simulator

function digitalRoot (n) {
return n === 0 ? 0 : 1 + ((n - 1) % 9)
}
function sum (a,b) { return a + b }
function luhn (x) {
return String(x)
.trim()
.split("")
function tokenize(input) {
return input
.replace(/[\(]/g, ' ( ')
.replace(/[\)]/g, ' ) ')
.trim()
.split(/\s+/);
}
function nest(input=[], list=[]) {
let token = input.shift()
function value (line) {
const [, t, c, v] = line.split(" ")
return {t, p: {cursor: c.split("::"), value: v}}
}
function header (line) {
const [,...rest] = line.split(" ")
const c = rest.join(" ")
return {t: "header", c}
}
import { shape, str, num, bool } from "facts"
shape(thingToCheck, {
foo: str,
bar: num,
rawr: {
name: str,
age: num,
alive: bool
}
app_1 | [ 'save',
app_1 | 'lrem',
app_1 | 'auth',
app_1 | 'append',
app_1 | 'psetex',
app_1 | 'shutdown',
app_1 | 'sync',
app_1 | 'blpop',
app_1 | 'dbsize',
app_1 | 'rpop',