Navigation Menu

Skip to content

Instantly share code, notes, and snippets.

View davidchambers's full-sized avatar

David Chambers davidchambers

View GitHub Profile
@davidchambers
davidchambers / io.js
Last active September 26, 2015 01:17
Sketch of possible (synchronous) IO and AsyncIO types in JavaScript
'use strict';
const fs = require('fs');
const R = require('ramda');
const S = require('sanctuary');
// unit :: ()
const unit = void 0;
@davidchambers
davidchambers / standard-super-league-s1.md
Last active August 29, 2015 14:22
Standard Super League

Standings

Player Points
David 9
Darryn 6
Matt 3
Koray 3

Round 1

Function composition has one huge benefit over chaining APIs: it allows any combination of JavaScript functions to be stuck together to form a pipeline. One could create a pipeline involving a function from library A, a function from library B, a function from library C, and a built-in function. With a chaining API one is restricted to the set of functions available on the object facilitating the chaining.

I found this to be a problem when using Underscore. This would be fine for a pipeline comprised solely of Underscore functions (represented here by lower-case identifiers):

_(x)
.a(...)
.b(...)
.c(...)
.value()
findX :: (MatchObj -> Maybe MatchObj) -> [String] -> Maybe MatchObj
findX matcher words = head xs
where
xs = do len <- length words .. 1
idx <- 0 .. length words - len
let m = matcher { before: take idx words
, group: (drop idx >>> take len) words
, after: drop (idx + len) words
, matches: defaultTransaction
, context: []
@davidchambers
davidchambers / zip-many.js
Created October 17, 2014 18:07
zipMany implementation with Ramda, created with @benperez
var R = require('ramda');
var zipMany =
R.cond(R.isEmpty,
R.always([]),
R.converge(R.map,
R.flip(R.pluck),
R.pipe(R.head, R.length, R.range(0))));
var zipMany2 = function(lists) {
@davidchambers
davidchambers / DETAILS
Last active August 29, 2015 14:00
Single-Set Constructed (Teams)
DATE
9am, Sunday 15 June 2014 (NZ time)
VENUE
Level 2
5 High Street
Auckland 1010
@davidchambers
davidchambers / Makefile
Created March 8, 2014 00:32
Exclude files with "doctest ignore" in first line when running doctests
DOCTEST = node_modules/.bin/doctest --module commonjs
.PHONY: test
test: JS_FILES = $(shell find . -name '*.js' -not -path './node_modules/*' -not -path './test/*')
test:
@$(foreach file,$(JS_FILES),head -n 1 -- $(file) | grep --silent 'doctest ignore' - || $(DOCTEST) $(file) || exit 1;)

Keybase proof

I hereby claim:

  • I am davidchambers on github.
  • I am davidchambers (https://keybase.io/davidchambers) on keybase.
  • I have the public key with fingerprint CC3A 9C98 F8FA 1729 D1ED  C345 1625 E2CF 0BD0 FE42

To claim this, I am signing this object:

var alib = require('alib');
var blib = require('blib');
var clib = require('clib');
+var zlib = require('zlib');
var fruits = [
'apples',
'bananas',
'cherries',