Skip to content

Instantly share code, notes, and snippets.

@wmhilton
wmhilton / mergelog.py
Created Dec 9, 2015 — forked from seanh/mergelog.py
A custom merge driver for git, for automatically merging my 'log.txt' file in a simplistic way.
View mergelog.py
#!/bin/env python
"""mergelog
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
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: https://github.com/gdbtek/ubuntu-cookbooks
# License: MIT
###################
# ARRAY UTILITIES #
###################
function arrayToString()
@wmhilton
wmhilton / data-over-http.md
Last active Aug 22, 2017
Embedding data in HTTP messages - an exhaustive analysis
View data-over-http.md

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
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: https://martin.kleppmann.com/2012/12/05/schema-evolution-in-avro-protocol-buffers-thrift.html#comment-2534873305
/* 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
wmhilton / README.md
Created May 6, 2016
Mocha users need to watch out for this surprising behavior
View README.md

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
wmhilton / wmhilton.id
Last active Nov 14, 2016
Verifying that "wmhilton.id" is my Blockstack ID. https://onename.com/wmhilton
View wmhilton.id
Verifying that "wmhilton.id" is my Blockstack ID. https://onename.com/wmhilton
@wmhilton
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>
<html>
<head>
<meta name="viewport" content="width=device-width, initial-scale=1">
<title></title>
</head>
<body>
<a href="/app.html">app.html</a>
<br>
@wmhilton
wmhilton / storageQuota.js
Created Mar 13, 2017
StorageQuota polyfill
View storageQuota.js
// MIT License, Copyright William Hilton <wmhilton@gmail.com>
// Implement the proposed W3C Quota Management API (circa 2017)
navigator.storageQuota = {
get supportedTypes () {
let types = []
if (navigator.webkitTemporaryStorage) types.push('temporary')
if (navigator.webkitPersistentStorage) types.push('persistent')
return types
},
queryInfo (type) {
@wmhilton
wmhilton / index.js
Created Aug 20, 2017
requirebin sketch
View index.js
var signalhub = require('signalhub')
var hub = signalhub('my-app', [
'https://signalhub-jccqtwhdwc.now.sh/'
])
hub.subscribe('my-channel')
.on('data', function (message) {
console.log('new message received', message)
})
@wmhilton
wmhilton / DatArchive.md
Last active Oct 26, 2017
Musings on BeakerBrowser compatibility
View DatArchive.md

Browser must have a global DatArchive object. https://beakerbrowser.com/docs/apis/dat.html

I think these ones could be supported in a client-side script using BrowserFS

  • new DatArchive(url)
  • DatArchive.create(opts?)
  • DatArchive.fork(url, opts?)
  • DatArchive.selectArchive(opts?)
  • DatArchive.resolveName(url)
  • url