Skip to content

Instantly share code, notes, and snippets.

View slightlyoff's full-sized avatar
💭
Setting my status.

Alex Russell slightlyoff

💭
Setting my status.
View GitHub Profile
@rviscomi
rviscomi / gatsby-cwv.sql
Created September 3, 2020 17:11
Calculating the % of Gatsby websites with "good" Core Web Vitals performance
#standardSQL
# Gatsby Core Web Vitals performance
CREATE TEMP FUNCTION IS_GOOD (good FLOAT64, needs_improvement FLOAT64, poor FLOAT64) RETURNS BOOL AS (
good / (good + needs_improvement + poor) >= 0.75
);
CREATE TEMP FUNCTION IS_NON_ZERO (good FLOAT64, needs_improvement FLOAT64, poor FLOAT64) RETURNS BOOL AS (
good + needs_improvement + poor > 0
);
@inexorabletash
inexorabletash / @ Indexed DB Promises.md
Last active September 25, 2015 15:51
Indexed DB + Promises #3
@josephg
josephg / react.html
Created July 28, 2014 20:48
ShareJS react demo
<!DOCTYPE html>
<html>
<head>
<title>Hello React</title>
<link rel="stylesheet" href="base.css" />
<script src="http://fb.me/react-0.11.0.js"></script>
<script src="http://fb.me/JSXTransformer-0.11.0.js"></script>
<script src="channel/bcsocket.js"></script>
<script src="share.uncompressed.js"></script>
<script src="http://cdnjs.cloudflare.com/ajax/libs/showdown/0.3.1/showdown.min.js"></script>
@domenic
domenic / removing-module-x-from-y.md
Last active August 29, 2015 14:02
Practical implications of removing `module x from "y"`

Practical Implications of Removing module x from "y"

Background

According to this gist, the modules break-out session at TC39 (a subset of the larger committee) decided to remove the

module x from "y";
@dglazkov
dglazkov / gist:716913d889c38e42d55c
Last active March 19, 2020 16:14
Composition is the Goal

#Composition is the Goal

I see several discussions now that vacillate around on encapsulation qualities of Shadow DOM and the flavors thereof. It's all my fault. I stuck encapsulation into the problem statement of the spec. I even glued the somewhat irrelevant term functional encapsulation on top of it. What a dork.

It was a couple of years ago, when one of my colleagues read the spec and noted: "Dude, it's like your story and whatever, but the way you tell it, Shadow DOM is not about encapsulation. It's about composition". The world went blank around me. I was blinded by insight.

My hipster colleague was right, of course. Encapsulation is just a tool. Composition is the goal.

This is why the people who'd never used Shadow DOM in real life get really hung up on the details of encapsulation, while those who actually use Shadow DOM stare at them quizzically.

@arv
arv / Document.registor.md
Last active December 30, 2015 19:38
document.register with a functionThe main difference between this and the current LC is that it takes a Function object instead of an Object. The Function's @@create method is updated to create instances that are real elements.

Register

When called, the register method must run these steps:

Input

  • ENVIRONMENT, the unit of related similar-origin browsing contexts
  • DOCUMENT, the context object of the method
  • NAME, the custom element name of the element being registered
  • FUNCTION, the custom element constructor function, optional
@mcasperson
mcasperson / gist:5820329
Last active December 23, 2018 16:56
emscripten libxml
Install python-all-dev
emscripten/system/include/net/netinet/in.h
Add the following lines (see http://pubs.opengroup.org/onlinepubs/009695399/basedefs/arpa/inet.h.html)
#define INET_ADDRSTRLEN (16)
#define INET6_ADDRSTRLEN (48)
nanohttp.c
@shinypb
shinypb / controller.js
Last active December 12, 2015 07:49 — forked from darobin/controller.js
var fallbacks = {}
, networks = {}
, cacheName = "OldSchoolAppCache"
, settings = {}
;
this.onmessage = function (e) {
var msg = e.data;
if (msg.type && msg.type === "manifest") {
var lines = msg.manifest.split(/\n+/)

Fun with Mutation Observers

I’ve been having a play around with Mutation Observers this morning, trying to work out when notifications happen and what happens when removing a node that was just added.

If you’re unfamiliar with Mutation Observers, they let you receive notifications when an element, or elements, have been modified in a particular way (here's an intro to Mutation Observers from Mozilla).

Observing mid-parsing

Consider this: