Skip to content

Instantly share code, notes, and snippets.

View timshadel's full-sized avatar

Tim Shadel timshadel

View GitHub Profile
@timshadel
timshadel / api-stack.js
Last active December 16, 2015 09:59
Middleware stack config ideas.
/**
* Module dependencies.
*/
var stack = require("simple-stack-common")
, cors = require("connect-xcors");
/**
* Expose the stack
*/
module.exports = exports = function(config) {
DEBUG=connect:something,fn=requestLogger

So the brilliance of hypermedia is that it's a protocol programming language: the client is the generic execution environment, and the server is the "programmer" which sends tiny little chunks of programs down to the client to dictate what actions may be taken next, given its context.

The fact that the client also builds a UI is irrelevant to this power. The power is in creating a dynamic, custom protocol by choosing for the client which message structures that will be sent from the client, which is done using merely the tools of hypermedia. The protocol between a client and server is then codified in the hypermedia (e.g. HTML) part of the code which uses links and forms to document the various messages which may pass between client and server, and the client states in which either may be used.

Armstrong's formula for a good protocol:

Client-State, Client-Message => Server-State, Server-Response-Message

But in hypermedia, the server's response dictate's the client state:

@timshadel
timshadel / .gitignore
Last active December 22, 2015 09:29 — forked from mbostock/.block
node_modules
@timshadel
timshadel / .gitignore
Last active December 22, 2015 09:49 — forked from mbostock/.block
node_modules
@timshadel
timshadel / Internal stunnel S3 proxy.md
Last active February 13, 2021 22:12
Create a URL that can be used to issue a plain HTTP request to an internal stunnel proxy that will wrap it in HTTPS and send it on to S3.

S3 proxy

If you've got tools that don't speak HTTPS, then using stunnel in client mode you can wrap those requests in SSL on their way to S3. If you don't hijack the S3 DNS with iptables, then you'll need to send those URLs using the domain name of your internal stunnel proxy. This utility gives you one way to create those URLs. It's incomplete, and just to give you some ideas.

{
"photos": {
"href": "/photos",
"count": 154,
"collection": [
{
"href": "...",
"type": "image/jpeg",
"name": "beach.jpg"
}
@timshadel
timshadel / 0-instructions.md
Last active August 25, 2019 20:15
A Facebook post in HTML and hyper+json.

Compare & Contrast

HTML, Hyper+JSON, and Data as JSON

OK. Everyone's got LOTS of questions and emotions around how to use hyper. I want to answer them, but first I want to walk you through a comparison exercise.

  1. Take a look at the screenshot below of a typical Facebook post.

    Think about the ways you could navigate or interact with this FB post, based only on what you see. Any kind of interaction you take either moves the view to another object, or it alters the data of this object.

@timshadel
timshadel / EmptyPodForWatchExtension.h
Last active August 29, 2015 14:18
Empty Pod For Watch Extension
/**
* If your watch extension doesn't need any of it's own exclusive pods,
* it won't have its header search path set to see any of the dependencies
* of embedded frameworks it relies on. This fixes that without duplication.
*/
@interface EmptyPodForWatchExtension
@end
@timshadel
timshadel / 0_reuse_code.js
Last active August 29, 2015 14:20
Here are some things you can do with Gists in GistBox.
// Use Gists to store code you would like to remember later on
console.log(window); // log the "window" object to the console