Skip to content

Instantly share code, notes, and snippets.

Avatar
💭
Tired

Jake Archibald jakearchibald

💭
Tired
View GitHub Profile
@slightlyoff
slightlyoff / push_payloads_userland.md
Last active Oct 10, 2020
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-

@phamann
phamann / worker.js
Last active Aug 29, 2015
Simple ServiceWorker for Guardian hackday
View worker.js
console.log("Worker startup");
this.oninstall = function(event) {
console.log('Worker install');
event.waitUntil(
caches.create('static').then(function(cache) {
return cache.add(
//Templates
@latentflip
latentflip / accessiblity.md
Created Nov 22, 2013
300ms, Fast Click & Accessibility
View accessiblity.md

Thoughts

Caveats: I suck at accessibility, so I am probably wrong on a lot of things.

The debate

Chrome 32 on Android removes the 300ms delay on touch events for responsive sites. This disables double-tap zoom, leaving pinch to zoom the only way to zoom content. This is an accessibility concern, as for some users double tap zoom may have been the only way they were able to zoom web pages.

Why did they do it?

@jakearchibald
jakearchibald / gist:4489851
Last active Dec 10, 2015
Setting innerHTML and IE
View gist:4489851

What do you think this will output?

var div = document.createElement('div');
div.innerHTML = '<span>Hello world!</span>';
var span = div.firstChild;
div.innerHTML = '<span>Uh oh!</span>';
console.log(span.innerHTML);
@bradleypriest
bradleypriest / convert_hex_to_rgb.py
Created Apr 4, 2012
Convert Hex To RGB Sublime Plugin
View convert_hex_to_rgb.py
# Add a key binding to your User Key Bindings and you're all good to go
# { "keys": ["super+shift+h"], "command": "convert_hex_to_rgb" }
#
import sublime, sublime_plugin
class ConvertHexToRgb(sublime_plugin.TextCommand):
def run(self, edit):
for region in self.view.sel():
if not region.empty():
@gre
gre / easing.js
Last active Oct 20, 2020
Simple Easing Functions in Javascript - see https://github.com/gre/bezier-easing
View easing.js
/*
* Easing Functions - inspired from http://gizma.com/easing/
* only considering the t value for the range [0, 1] => [0, 1]
*/
EasingFunctions = {
// no easing, no acceleration
linear: t => t,
// accelerating from zero velocity
easeInQuad: t => t*t,
// decelerating to zero velocity
You can’t perform that action at this time.