Skip to content

Instantly share code, notes, and snippets.

Setting my status.

Alex Russell slightlyoff

Setting my status.
View GitHub Profile
View shortcodes_snippet.js
// Phil Hawksworth's Netlify LMS <picture> img generator
let getPicture = (url, alt="Missing alt text", width, height, style) => {
let w = width ? width : "500";
let w_attr = width ? `width="${width}"` : "";
let h_attr = height ? `height="${height}"` : "";
let s_attr = style ? `style="${style}"` : "";
return `<picture>
media="(min-width: 1200px)"
slightlyoff / .eleventy.js
Created Aug 20, 2020
image/picture/figure sizing shortcode
View .eleventy.js
// Here's how I use this shortcode in my .md files:
// {% picture
// "/2020/06/platform-adjacency-theory/relevance_gap_opt.png",
// "Mind the gap."
// %}
// And for the <figure> version that puts the alt text visibly below the image:
// {% figure
View index.html
<!DOCTYPE html>
<meta charset="utf-8">
<meta name="viewport" content="width=device-width">
<title>TikTok spinner</title>
:root {
--base: 4px;
slightlyoff /
Last active Oct 10, 2020
Delivering H/2 Push Payloads To Userland


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](

slightlyoff /
Last active Jun 7, 2018
Service Worker + Push API


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 / 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 / connectionchange.js
Last active Dec 12, 2015
connectionchange event properties
View connectionchange.js
class ConnectionInfo {
classId=0) { = media;
this.className = className;
this.classId = classId;
View ctrl.js
// ctrl.js
// origin:
// 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.