Skip to content

Instantly share code, notes, and snippets.

View buzzdecafe's full-sized avatar
💭
quaquaquaqua

buzzdecafe

💭
quaquaquaqua
View GitHub Profile
@ghl3
ghl3 / _ImmutableDatabase
Last active October 24, 2024 13:50
Implementation of an immutable database in postgres
We couldn’t find that file to show.
-- 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.
@tel
tel / ProfunctorLens.js
Last active October 23, 2023 20:32
Pure Profunctor Lenses in Javascript (redux)
/* 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)
@tel
tel / Profunctor.js
Last active January 6, 2025 09:37
"Pure-profunctor" lenses in Javascript (!)
/// 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.
*/
@jethrolarson
jethrolarson / future_example.js
Last active August 29, 2015 14:23
Playing with Future
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);
@joneshf
joneshf / moore.js
Last active August 29, 2015 14:22
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.
@raine
raine / ramda
Last active May 4, 2020 12:14
Browse Ramda documentation in Terminal
#!/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')
/*
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
@tildedave
tildedave / createFacebookTestUser.js
Last active May 25, 2016 22:29
Nightwatch Command for Creating Facebook Test User
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);
@kedashoe
kedashoe / gist:e0184a5b91e63084299b
Last active August 29, 2015 14:15
curry with placeholders curry2 and curry3
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) {