Skip to content

Instantly share code, notes, and snippets.

View mstade's full-sized avatar

Marcus Stade mstade

View GitHub Profile
body {
background: rgb(239, 239, 244);
}
.toggle {
position: relative;
display: inline-block;
font-family: "Helvetica Neue";
font-size: 10pt;
border: 1px solid lightgrey;
@mstade
mstade / bridging-the-gap.md
Last active December 30, 2015 17:59
Programmable Hypermedia Client Blues

Programmable Hypermedia Client Blues (Part I)

In Restful Web APIs it is argued that one of the major problems with APIs (arguably regardless of whether they are RESTful) is that they don't convey enough semantics so a client unfamiliar with implementation details (media type, URL structures, HTTP methods etc.) could still make use of it. On the "human web" this isn't really a problem, as the book rightly points out, because humans are much better at making decisions despite considerable semantic gaps. For example, if a site contains a link with the text:

Click here to buy our most popular product!

It's easy for us to understand that we can click on it to purchase an item; a computer however would just see some additional markup and realize it's a link, but not where it points to, why or what it is:

@mstade
mstade / view.md
Last active January 4, 2016 23:12
Some thoughts on application/view

Application views using HTTP trickery

If the client makes a request, let's say this is an initial request to a resource that the client knows nothing about. It goes along and does a little something like this:

GET /foo HTTP/1.1
Accept: text/html
@mstade
mstade / test.md
Last active January 3, 2016 22:39
Testing GFM syntax

Syntax:

Works
  = Swimmingly
  / Beautiful

List with headings:

  • Well this is fun
@mstade
mstade / behavior.js
Last active August 29, 2015 13:55
Tiny app to visualize linear equations for my sister in-law.
var cm = document.getElementById('#unit').width.baseVal.value
d3.selectAll('.interactive.point')
.data([[-2, -2], [2, 2]])
.each(_(recalc, place, type()))
.call(
d3.behavior.drag()
.on('dragstart', drag(true))
.on('drag', _(move(), d(recalc, place, type())))
.on('dragend', _(drag(false), snap, d(recalc, place, type())))
@mstade
mstade / fib.js
Last active August 29, 2015 13:57
Fibonacci
// 0 and below will yield 0, everything else follows the sequence.
function fib(n) {
const sq = Math.sqrt(5)
, gr = (1 + sq) / 2
return Math.floor(Math.pow(gr, n) / sq + 0.5)
}
@mstade
mstade / rewindable-it.js
Last active August 29, 2015 13:58
ES6 rewindable iterators
function range(n) {
var i = 0
return { next: step, rewind: rewind }
function step() {
return i++ < n? { value: i } : { done: '110%' }
}
function rewind() { i = 0 }
@mstade
mstade / auto-rewind-it.js
Last active August 29, 2015 13:58
ES6 auto-rewinding iterators
function range(n) {
var i = 0
return { next: step }
function step() {
if (i++ < n) return { value: i }
return i = 0, { done: '110%' }
}
@mstade
mstade / index.js
Created November 26, 2014 17:54
emails index
// Documents look like:
{ profile:
{ emails:
[ { type: "account", "foo@bar.com" }
, { type: "work", "bar@foo.com" }
]
}
}
(automaton init
(init : (c → more))
(more : (a → more)
(d → more)
(r → end))
(end : ))