Skip to content

Instantly share code, notes, and snippets.

💭
Setting my status.

Alex Russell slightlyoff

💭
Setting my status.
Block or report user

Report or block slightlyoff

Hide content and notifications from this user.

Learn more about blocking users

Contact Support about this user’s behavior.

Learn more about reporting abuse

Report abuse
View GitHub Profile
@slightlyoff
slightlyoff / push_payloads_userland.md
Last active Apr 17, 2019
Delivering H/2 Push Payloads To Userland
View push_payloads_userland.md

Background

One of the biggest missed opportunities thus far with HTTP/2 ("H/2") is that we are not yet able to sunset WebSockets in favor of H/2. Web Sockets and H/2 both support multiplexing messages bi-directionally and can send both textual and binary data.

Server Sent Events ("SSE"), by contrast, are not bi-directional (they're a "server-push-only" channel) and binary data cannot be sent easily. They are, however, very simple to implement. Adding to the menagerie of options, RTCPeerConnection can also be used to signal data to applications in a low-latency (but potentially lossy) way.

Because H/2 [does not support the handshake (upgrade) that WebSockets use to negotiate a connection](https://daniel.haxx.se/blog/2016/06/15/no-websockets-

@slightlyoff
slightlyoff / push_api_sketch.md
Last active Jun 7, 2018
Service Worker + Push API
View push_api_sketch.md

Motivation

The current Push API Draft specifies a system that has no notion of push channel persistence. Further, it does not include push message payloads, a feature that many developers want.

This gist outlines an API which:

  • integrates with the Service Worker to enable delivery of push messages to applications which do not have visible tabs
  • enables a JSON-formatted body of content
  • guards access to registration for pushes on potential user consent
@slightlyoff
slightlyoff / error-first-futures-examples.js
Created May 1, 2013
Error-first callback style Futures.
View error-first-futures-examples.js
var log = console.log.bind(console);
// Like .then(), except we move to a single callback
asyncAPI().when(function(err, value) {
if (err) {
// error handling/recovery
// ...
// If return is instanceof Error, continues error chain
return new Error(err.toString());
}
@slightlyoff
slightlyoff / connectionchange.js
Last active Dec 12, 2015
connectionchange event properties
View connectionchange.js
class ConnectionInfo {
constructor(media="unknown",
className="unknown",
classId=0) {
this.media = media;
this.className = className;
this.classId = classId;
}
}
View ctrl.js
// ctrl.js
// origin: http://example.com
// scope: "/*"
"use strict";
// Called when this controller is installed as the newest version
// for a scope. Perhaps a clearer name for what is now sketched
// as "onupdate". Note that this is called BEFORE "onupgrade" is
// sent to a previous version's controller.
You can’t perform that action at this time.