Skip to content

Instantly share code, notes, and snippets.

wmhilton /
Last active Aug 22, 2017
Embedding data in HTTP messages - an exhaustive analysis

Embedding data in HTTP messages - an exhaustive analysis

Hypertext Transport Protocol (HTTP) is the de facto protocol for sending data over the Internet. Today in addition to transporting hypertext documents, it is used to transport images, stylesheets, JavaScript, fonts - nearly everything in a web page. Rarely do developers pause to question why this is. Lately, I've been thinking a lot about HTTP and its relation to APIs and web apps. This document contains my thoughts on the usefulness of HTTP requests as envelopes for sending data.

HTTP requests consist of at least 7 pieces: the path, the query string, the method, the status, the headers, the body, and cookies. (Technically cookies are a subcategory of headers but they have additional behaviors that make them worth examining separately.) This article examines each of them from the perspective of their utility for carrying arbitrary data. Note: This article only looks at HTTP/1.

Least general

REST APIs often make use of HTTP methods and respo

wmhilton / index.js
Created Aug 20, 2017
requirebin sketch
View index.js
var signalhub = require('signalhub')
var hub = signalhub('my-app', [
.on('data', function (message) {
console.log('new message received', message)
wmhilton /
Created Dec 9, 2015 — forked from seanh/
A custom merge driver for git, for automatically merging my 'log.txt' file in a simplistic way.
#!/bin/env python
This is a custom merge driver for git. It should be called from git
with a stanza in .git.config like this:
[merge "mergelog"]
name = A custom merge driver for my log.txt file.
driver = ~/scripts/mergelog %O %A %B %L
recursive = binary
wmhilton / app.html
Created Jan 20, 2017
Replace internal links with history.pushState based navigation but leave external links unmodified
View app.html
<!DOCTYPE html>
<meta name="viewport" content="width=device-width, initial-scale=1">
<a href="/app.html">app.html</a>
wmhilton /
Last active Nov 14, 2016
Verifying that "" is my Blockstack ID.
Verifying that "" is my Blockstack ID.
wmhilton /
Created May 6, 2016
Mocha users need to watch out for this surprising behavior

Mocha does not reload modules when running multiple tests. This can lead to some curious errors that are difficult to understand at first, but have to do with modules that have an internal state of their own. If you have a folder with two files, test1.js and test2.js (shown in gist below), you will find you get different test results even though they are identical except in name. The first one fails, but the second succeeds.

So some state from previous tests can "pollute" later tests. This makes it difficult to write unit tests in isolation with Mocha, because suddenly when you put both tests together in the same directoy, mocha's behavior can break the tests.

wmhilton / random_thoughts.txt
Last active Feb 25, 2016
Thoughts on a Universal Data schema
View random_thoughts.txt
// TODO: Clean up thoughts into a nice document.
// Thoughts on Universal Data language / description
// See:
/* Preface:
Why do Thrift, Protobuf, and Avro each define their own IDL?
I would think that there could be an implementation-independent "master" IDL
to standardize the syntax (the semantics depends on the feature set of the implementation).
It makes it hard to try out these different libraries when they require rewriting
the message schema each time.
wmhilton / util.bash
Created Jan 14, 2016
A huge collection of Bash utility functions. Could come in handy!
View util.bash
#!/bin/bash -e
# Author: gdbtek (Nam Nguyen)
# Repo:
# License: MIT
function arrayToString()
View comma-first-var.js
// See comments below.
// This code sample and justification brought to you by
// Isaac Z. Schlueter, aka isaacs
// standard style
var a = "ape",
b = "bat",
c = "cat",
d = "dog",
wmhilton / Dict.js
Last active Dec 18, 2015
Dict Object for JavaScript
View Dict.js
* Dict Object for JavaScript (
* Author: William Hilton (
* License:
* Say you want something like a Python "dictionary" or a Java "map" where you
* are storing (String key, Object value) pairs. It's tempting to do it using
* object properties in JavaScript, since
* obj['key'] = value
* works so conveniently. However, say you want to be able to have some properties