This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| function jsonp(url, callback = "callback") { | |
| return new Promise((ok, fail) => { | |
| let iframe = document.createElement("iframe"); | |
| let onmessage = function(e) { | |
| if (e.source == iframe.contentWindow) { | |
| iframe.remove(); | |
| window.removeEventListener("message", onmessage); | |
| ok(e.data.response); | |
| } | |
| }; |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| class Cluster { | |
| start = 0; | |
| end = 0; | |
| min = 0; | |
| max = 0; | |
| items = []; | |
| constructor(items, start, end, min, max) { | |
| this.items = items; | |
| this.start = start; |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| var stack = []; | |
| var verbose = false; | |
| // make our own undefined sentinel value | |
| var undefined = Symbol("undefined signal"); | |
| class Signal extends EventTarget { | |
| #value = undefined; | |
| #computation = null; | |
| #lifetime = new AbortController(); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| var links = document.querySelectorAll(`link[rel="stylesheet"][media="async"], link[rel="async-styles"]`); | |
| for (var link of links) { | |
| var resolved = new URL(link.href, window.location); | |
| var processed = await getSheet(resolved.toString()); | |
| var style = document.createElement("style"); | |
| var constructed = new CSSStyleSheet(); | |
| var output = serializeCSS(processed); | |
| constructed.replaceSync(output); | |
| // console.log(output); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| <!doctype html> | |
| <style> | |
| .card { | |
| display: grid; | |
| grid-template-columns: 1fr 2fr; | |
| & img { | |
| max-height: 200px; | |
| } | |
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| const TARGET = Symbol("proxy target"); | |
| function defaultdict(missing) { | |
| var dict = {}; | |
| var instantiate = missing; | |
| if (missing instanceof Function) { | |
| if (missing.constructor) { | |
| instantiate = () => new missing(); | |
| } | |
| } else if (missing instanceof Object) { |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| var proxyRegistry = new WeakMap(); | |
| function observe(root, callback) { | |
| var handler = { | |
| get(target, property, rec) { | |
| var value = target[property]; | |
| if (value instanceof Object && !(value instanceof Function)) { | |
| if (proxyRegistry.has(value)) { | |
| return proxyRegistry.get(value); | |
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| var tracking = []; | |
| var pending = new Set(); | |
| function anticipate(fn) { | |
| pending.add(fn); | |
| requestAnimationFrame(() => { | |
| for (var p of pending) p(); | |
| pending.clear(); | |
| }); | |
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| <!doctype html> | |
| <ul id="ul"></ul> | |
| <script type="module"> | |
| import { html, render } from "https://unpkg.com/lit-html"; | |
| import { repeat } from "https://unpkg.com/lit-html/directives/repeat.js"; | |
| import { map } from "https://unpkg.com/lit-html/directives/map.js"; | |
| function replacer(container, data, factory, update = () => {}) { |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| // run with deno run --allow-all datapatcher.js {SHEET_ID} {SHEET_TAB (optional)} | |
| import { login, google } from "https://raw.githubusercontent.com/Chalkbeat/deno-google-login/main/index.js"; | |
| import * as flags from "https://deno.land/[email protected]/flags/mod.ts"; | |
| var args = flags.parse(Deno.args); | |
| var spreadsheetId = args.sheet || args._[0]; |
NewerOlder