Skip to content

Instantly share code, notes, and snippets.

@ericgj
ericgj / README.md
Last active December 24, 2015 20:16
Costs of task switching analysis

Costs of task switching

An exploratory data analysis using d3

# More or less direct translation of folktale.js data.task + control.async.parallel
# https://github.com/folktale/data.task/blob/master/lib/task.js
# https://github.com/folktale/control.async/blob/master/lib/core.js
module Monads
class Task
def self.of(x)
new {|_,res| res[x] }
@ericgj
ericgj / startapp.js
Last active October 28, 2015 15:13
// A translation of Elm's StartApp to js + ramda + flyd
// for comparison see https://github.com/evancz/start-app/blob/2.0.1/src/StartApp.elm
// Comments welcome
var curry = require('ramda/src/curry');
var map = require('ramda/src/map');
var concat = require('ramda/src/concat');
var reduce = require('ramda/src/reduce');
var commute = require('ramda/src/commute');
@ericgj
ericgj / gist:1c091837431c7f0ec230
Created February 22, 2015 04:11
npm install error
This file has been truncated, but you can view the full file.
8004 http fetch 200 https://registry.npmjs.org/growl/-/growl-1.8.1.tgz
8005 silly fetchAndShaCheck shasum 4b2dec8d907e93db336624dcec0183502f8c9428
8006 verbose addTmpTarball /tmp/npm-949-95ba9a63/registry.npmjs.org/growl/-/growl-1.8.1.tgz not in flight; adding
8007 verbose addTmpTarball already have metadata; skipping unpack for growl@1.8.1
8008 silly cache afterAdd growl@1.8.1
8009 verbose afterAdd /home/egjertsen/.npm/growl/1.8.1/package/package.json not in flight; writing
8010 silly gunzTarPerm extractEntry lib/babel/build-helpers.js
8011 verbose afterAdd /home/egjertsen/.npm/growl/1.8.1/package/package.json written
8012 info preinstall source-map@0.1.34
8013 http 200 https://registry.npmjs.org/jade
@ericgj
ericgj / 0-description.md
Last active April 5, 2020 22:50
Implementing a REST workflow using JSON Schema, an example

Implementing a REST workflow using JSON Schema, an example

The problem domain

You are designing a document-control system. Users create and edit documents for publication. Documents can be draft, in review, on hold, in process, or published. Users have specific roles which determine which documents they have access to, and what they are permitted to do to the documents, as the documents move through the workflow. Some users are writers, others are editors.

Expressed in plain language, the rules are:

  • Writers can view their own documents regardless of status.
  • Writers can create new documents.
  • Writers can save new documents as draft, or to in review if certain information is included.
@ericgj
ericgj / 0-INDEX.md
Last active December 17, 2015 12:09
DEFER LIST

2 Oct

  • update metalsmith plugins for metalsmith 1.x

30 Jan

  • json-schema-*: consider a different implementation strategy that makes "core" less core:
  • does not require pre-parsing the schema in order to dereference and validate
  • allows pluggable validators through a common interface, with a default validator
  • parses the schema only when building a correlation, which is where it is actually used
  • correlation prototype is extendable, as now, through a plugin interface
  • "model" functionality is implemented as a correlation plugin
@ericgj
ericgj / sequel_dot.rb
Created September 30, 2012 02:59
ER diagrams with Sequel and Graphviz
# Usage:
# ruby sequel_dot.rb [SEQUEL-DATABASE-URI] > output.dot
# Or pipe directly to Graphviz:
# ruby sequel_dot.rb [SEQUEL-DATABASE-URI] | dot -Tgif > output.gif
#
# Note adapted from Jeremy Evans' and Rohit Namjoshi's son's code at
# http://sequel.heroku.com/2010/05/29/fun-with-graphviz-and-associations/
#
# However, instead of basing graph on model associations, this uses foreign key constraints of the db tables
# Thus, this relies on the database adapter supporting #foreign_key_list.
@ericgj
ericgj / gsubs.rb
Created September 14, 2012 00:25
rspec to minitest
# Usage
# ruby gsubs.rb './tests/**/*.rb'
ARGF.replace Dir[ARGV[0]] unless ARGV.empty?
require 'fileutils'
$GSUBS = \
[
[ /^(\s*)(.+)\.should\s+be_true/ , '\1assert \2' ],
@ericgj
ericgj / 0-INDEX.txt
Created February 27, 2012 16:04
Several things I learned this week: 27 Feb
1. Two different uses for DelegateClass [newman-scheduler]
2. Array() top-level function works on any Enumerable
@ericgj
ericgj / 0-INDEX.txt
Created February 14, 2012 18:15
Several things I learned this week: 13 Feb
1. Building a chainable lazy-iterator interface
2.