Skip to content

Instantly share code, notes, and snippets.

@kconner
kconner / macOS Internals.md
Last active April 15, 2024 10:14
macOS Internals

macOS Internals

Understand your Mac and iPhone more deeply by tracing the evolution of Mac OS X from prelease to Swift. John Siracusa delivers the details.

Starting Points

How to use this gist

You've got two main options:

addEventListener("fetch", e => {
if (e.request.destination !== "image" || // Only do this when requesting an image
request.mode === "no-cors") // We don't know the status of no-cors images
return;
e.respondWith((async () => {
try {
const response = await fetch(e.request);
if (response.ok)
return response;
@ttesmer
ttesmer / AD.hs
Last active March 19, 2024 03:04
Automatic Differentiation in 38 lines of Haskell using Operator Overloading and Dual Numbers. Inspired by conal.net/papers/beautiful-differentiation
{-# LANGUAGE TypeSynonymInstances #-}
data Dual d = D Float d deriving Show
type Float' = Float
diff :: (Dual Float' -> Dual Float') -> Float -> Float'
diff f x = y'
where D y y' = f (D x 1)
class VectorSpace v where
zero :: v
@giacomozecchini
giacomozecchini / bfcachetest.js
Last active April 21, 2022 06:55
This script checks if a page is bfcache eligible and prints reasons if it isn't. It can be easily modified to check multiple pages.
// This script checks if a page is bfcache eligible and prints reasons if it isn't.
// It can be easily modified to check multiple pages.
// Chrome crbug: https://bugs.chromium.org/p/chromium/issues/detail?id=1312486
// Puppeteer issue: https://github.com/puppeteer/puppeteer/issues/8182
const puppeteer = require('puppeteer');
(async () => {
// Configuring and launching the browser
@nucliweb
nucliweb / list-link-rels.js
Created August 31, 2021 08:30
Snippet to list the link elements with some web performance "rel" attribute
@wanderview
wanderview / sw.js
Last active January 29, 2021 08:16
Example "no-op" navigation preload service worker
self.addEventListener('fetch', evt => {
// Fallback for subresource requests or in browsers that do not
// support navigation preload.
if (evt.request.mode !== "navigate" || !evt.preloadResponse)
return;
evt.respondWith(async _ => {
// Try to get the navigation preload response.
let r = await evt.preloadResponse;
// Modified from @mutsuda's https://medium.com/@mutsuda/create-an-ios-widget-showing-google-spreadsheets-data-856767a9447e
// by @levelsio
// HOW TO
// 1) Make a Google Sheet, we'll pull the first cell e.g. A1
// 2) Publish your Google Sheet, File -> Publish To Web
// 3) Copy the SHEET_ID in the URL, put it in here below:
const endpoint = "https://spreadsheets.google.com/feeds/cells/SHEET_ID/1/public/full?alt=json"
// 4) Install Scriptable @ https://apps.apple.com/us/app/scriptable/id1405459188
// 5) Copy this entire script in to Scriptable (tip: you can send it to your iPhone via Whatsapp/Messenger/Telegram etc)

See current development here.

This document proposes a new resource batch file format, together with a concept of preloading resource batches on the Web. This proposal is derived from Web Bundles by Jeffrey Yasskin and dynamic bundle serving by Yoav Weiss, with significant input from Pete Snyder, who raised concerns about Web Bundles.

Resource Batch Preloading

When loading subresources on the Web, developers currently have an unfortunate choice between serving resources individually, or using bundlers, both of which have disadvantages which hurt loading performance. This document proposes a new mechanism, "resource batch preloading", which allows subresources to be loaded

@threepointone
threepointone / durable-objects-001-fundamentals.md
Last active September 29, 2023 12:14
Notes on Durable Objects. Part 1 - Migrations.

Note: Since writing this, I've been pointed to some exciting new research/tooling called Project Cambria https://www.inkandswitch.com/cambria.html I'll likely have to rewrite this article taking that into account. Leaving this up for posterity's sake.


(This series isn't meant to be a primer/tutorial, though we might do something regarding it in the future. For official documentation and starters, see https://developers.cloudflare.com/workers/learning/using-durable-objects.

Further - these are my personal views; I expect to be wrong about a lot of them. Indeed, I'm not paying much attention to presenting these well at the moment, simply writing down thoughts. As such, expect these writeups to change often, particularly as the platform takes shape. I'm also mostly a front end guy, so don't get mad if I get it very wrong. Give me feedback! Always happy to learn and make changes.)

Durable Objects are a fascinating new storage primitive from cloudflare for their workers platform. There's a lot of 'cool'

@charlespwd
charlespwd / make-mp4-from-profile
Last active November 1, 2020 09:19
Make a mp4 from a Chrome DevTools Performance Profile
#!/usr/bin/env bash
set -eou pipefail
profile=$1
frameRate=${2:-10}
timeline='timeline.json'
cat $profile \
| jq '.[] | select(.args.snapshot | . and (type == "string") and contains("/9j"))' \
| jq -s . \
> $timeline