This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
-- So as an example of using a log orientated approach in PostgreSQL, | |
-- let's write a simple blog application. We will want to be able to: | |
-- * Write and edit blog posts | |
-- * Publish revisions of posts for public viewing | |
-- * Delete posts | |
-- * Add or remove tags to posts | |
-- Let's start by creating a schema. |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/* eslint-disable new-cap */ | |
/** | |
* Lens types. | |
* =========== | |
* | |
* a * b = {fst: a, snd: b} | |
* a + b = {index: Boolean, value: a | b} | |
* | |
* Iso s t a b = forall (~>) . Profunctor (~>) => (a ~> b) -> (s ~> t) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/// PRELIMINARIES | |
/** | |
* Generalized "products" of any size. For gluing things together. A tuple is a | |
* "2"-meet. | |
* | |
* The type `Meet a b c d ...` indicates a `Meet` of the given size with values | |
* at each type in the sequence. | |
*/ |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
var R = require('ramda'); | |
var Future = require('ramda-fantasy').Future; | |
//Wrap ajax in a future | |
//:: String -> Future String | |
var fetch = function(url) { | |
return new Future(function(rej, res){ | |
var oReq = new XMLHttpRequest(); | |
oReq.addEventListener("load", res, false); | |
oReq.addEventListener("error", rej, false); | |
oReq.addEventListener("abort", rej, false); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
var R = require('ramda'); | |
var Type = require('union-type-js'); | |
// We need a base set of states: {`Q0`, `Q1`, `Q2`}. | |
var State = Type({Q0: [], Q1: [], Q2: []}); | |
// We need an input alphabet: {`A`, `B`}. | |
var Sigma = Type({A: [], B: []}); | |
// We need a transition function | |
// that takes a state and an element of the alphabet, and gives a new state. |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/env bash | |
# Browse Ramda documentation in Terminal | |
# Requires jq and a tool such as fzf or peco for interactive filtering | |
LATEST="http://raine.github.io/ramda-json-docs/latest.json" | |
DOCS_URL="http://ramdajs.com/docs/" | |
json=$(curl -s $LATEST) | |
functions=$(echo "$json" | jq -r '.[] | if .sig and (.sig | length > 0) then .name + " :: " + .sig else .name end') |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/* | |
The MIT License (MIT) | |
Copyright (c) 2014 | |
Permission is hereby granted, free of charge, to any person obtaining a copy | |
of this software and associated documentation files (the "Software"), to deal | |
in the Software without restriction, including without limitation the rights | |
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell | |
copies of the Software, and to permit persons to whom the Software is |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
var util = require('util'); | |
var events = require('events'); | |
var Promise = require('bluebird'); | |
var request = Promise.promisify(require('request')); | |
var CreateFacebookTestUser = function() { | |
events.EventEmitter.call(this); | |
}; | |
util.inherits(CreateFacebookTestUser, events.EventEmitter); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
function curry2(fn) { | |
return function(a, b) { | |
switch (arguments.length) { | |
case 1: | |
return function(B) { | |
return fn(a, B); | |
}; | |
default: | |
if (a === __) { | |
return function(A) { |