Skip to content

Instantly share code, notes, and snippets.

@JakeChampion
JakeChampion / logger.js
Last active January 25, 2024 19:14
Hono logger for use on Fastly Compute
// @ts-check
/* eslint-env serviceworker */
/// <reference types="@fastly/js-compute" />
// You can use this logger like so:
// import { Hono } from 'hono'
// import { logger } from "./logger.js";
// const app = new Hono()
// app.use('*', logger());

Kirsten’s favourite cake: 6 Oz stork 6 Oz caster sugar -x 4.5 Oz dove gf flour -x 1.5 Oz bourneville cocoa -x 1/8 teaspoon xanthan

3 eggs If the flour was plain (not self raising) add 2 tsps baking powder After mixing it all up I have started adding some cold water. 1 or 2 teaspoons? That makes the cake rise evenly

/^[0-9]+$/
/[^%.[\]]+|\[(?:(\x2D?\d+(?:\.\d+)?)|(["'])((?:(?!\2)[^\\]|\\.)*?)\2)\]|(?=(?:\.|\[\])(?:\.|\[\]|%$))/g
/\\(\\)?/g
/^%?[^%]*%?$/
/^\s*(?:function)?\*/
/^\s*class\b/
/^\[object HTML/
/%[sdj%]/g
/^$/
/[|\\{}()[\]^$+?.]/g
146.690053ms
141.394012ms
144.742848ms
138.472319ms
139.853484ms
146.318905ms
139.12777ms
307.430594ms
139.070671ms
144.592693ms
202.818279ms
195.242371ms
215.554224ms
203.658686ms
190.605445ms
190.057869ms
206.058932ms
191.880047ms
185.420293ms
200.222338ms
0
1
2
3
4
5
6
7
8
9
@JakeChampion
JakeChampion / results.md
Last active April 27, 2022 16:07
c@e js perf

Here are some results on the bench-v8 version 7 benchmark.

We did not run Splay as that uses more memory than c@e permits.

The programs were executed using Viceroy. They were run on a MacBook Pro 13inch, 2019, Core i7 @ 2.8GHz, 16 GB 2133 MHz LPDDR3.

Engine QuickJS C@E SpiderMonkey C@E
Executable size 3.9M 9.4M
Richards 112 36.8
@JakeChampion
JakeChampion / machine.js
Created October 26, 2021 21:34
Generated by XState Viz: https://xstate.js.org/viz
// Available variables:
// - Machine
// - interpret
// - assign
// - send
// - sendParent
// - spawn
// - raise
// - actions
@JakeChampion
JakeChampion / main.js
Last active September 6, 2021 13:48
Install javascript by chee (https://addons.mozilla.org/en-US/firefox/addon/javascript/) and then visit ft.com and paste the below code into the extension -- do the same for local.ft.com and that is it. When you press `t` it will toggle the domain from ft.com to local.ft.com and vice versa
document.addEventListener(
"keydown",
(event) => {
var name = event.key;
if (
window.location.hostname.endsWith("ft.com") &&
name.toLowerCase() === "t"
) {
window.location = toggleOrigin(window.location);
}
@JakeChampion
JakeChampion / json-stringify-circular-replacer.js
Created July 15, 2020 10:57
replacer function for json.stringify to change circular references
function circularReferenceReplacer () {
const seen = new WeakMap();
return (key, value) => {
if (typeof value === "object" && value !== null) {
if (seen.has(value)) {
let path = seen.get(value);
if (path === "") {
path = "the root object";
}
return 'circular reference which points to ' + path + '.';