Skip to content

Instantly share code, notes, and snippets.

View JamieMason's full-sized avatar

Jamie Mason JamieMason

View GitHub Profile
@JamieMason
JamieMason / on-active-service-worker.md
Created December 16, 2024 13:53
on active service worker

onActiveServiceWorker

Abandoned this as being over the top, but saving it as this Gist.

import { isDev } from '@builder.io/qwik/build';

let memo: Promise<ServiceWorker> | null;

export async function getActiveServiceWorker(): Promise<ServiceWorker> {
@JamieMason
JamieMason / unfollow-everyone-on-bsky-app.md
Last active December 4, 2024 09:04
Unfollow everyone on bsky.app
@JamieMason
JamieMason / copy-versions.js
Created November 26, 2024 09:47
Use same versions as another local package.json
const from = require('/Users/foldleft/Dev/foo/bar/package.json');
const to = require('./package.json');
Object.entries(from.dependencies).forEach(([name, version]) => {
if (to.dependencies[name]) {
to.dependencies[name] = version;
}
});
Object.entries(from.devDependencies).forEach(([name, version]) => {
@JamieMason
JamieMason / create-syncpack-issue-reproduction.md
Created October 30, 2024 13:04
Create Syncpack Issue Reproduction

Create Syncpack Issue Reproduction

Delete all files in the current directory except for this script, lerna.json, package.json, pnpm-workspace.yaml, and syncpack.config.cjs. Also delete all empty directories except for the .git directory.

Put this script at create-syncpack-issue-reproduction.js in the root of the repo.

const child_process = require("child_process");
const fs = require("fs");
{
"$schema": "https://raw.githubusercontent.com/jsonresume/resume-schema/v1.0.0/schema.json",
"meta": {
"theme": "elegant",
"version": "v1.0.0",
"canonical": "https://github.com/jsonresume/resume-schema/blob/v1.0.0/schema.json"
},
"basics": {
"name": "Jamie Mason",
"label": "Principal Frontend Developer",
@JamieMason
JamieMason / keymap.json
Last active December 16, 2024 12:33
Zed Settings
[
{
"context": "Editor",
"bindings": {
"alt-q": "editor::Rewrap",
"alt-shift-down": "editor::DuplicateLineDown",
"alt-shift-f": "editor::Format",
"alt-shift-i": "editor::SplitSelectionIntoLines",
"alt-shift-up": "editor::DuplicateLineUp",
"cmd cmd": "editor::ShowCompletions",
@JamieMason
JamieMason / pipe.ts
Created May 9, 2024 14:08
TypeScript pipe function
/**
* Takes a value and passes it through a sequence of functions in left-to-right order.
*
* A Function that takes an initial value of any type (`unknown`), followed by any number of functions as arguments. It
* returns the result of passing the initial value through each of the functions, one by one, in the order that they
* were passed in. It provides a way to easily chain together multiple functions in a pipeline, where the output of each
* function becomes the input for the next one.
*
* ## Example
*
@JamieMason
JamieMason / randomise-package-json.js
Last active May 4, 2024 10:58
add random numbers to semver versions in package.json files to create mismatches in fixtures.
const root = "/Users/foldleft/Dev/rust-syncpack/fixtures/fluid-framework";
[
`${root}/experimental/framework/data-objects/package.json`,
`${root}/experimental/framework/last-edited/package.json`,
`${root}/experimental/PropertyDDS/examples/property-inspector/package.json`,
`${root}/experimental/PropertyDDS/examples/schemas/package.json`,
`${root}/experimental/PropertyDDS/packages/property-shared-tree-interop/package.json`,
`${root}/experimental/PropertyDDS/packages/property-common/platform-dependent/package.json`,
`${root}/experimental/PropertyDDS/packages/property-common/package.json`,
@JamieMason
JamieMason / try-rescript.res
Created December 18, 2023 22:04
Try ReScript
// looking at an alternative to ReScript's Option
// which exists at runtime when compiled to JS
type maybe<'a> = {
_tag: [#Some],
value: 'a,
}
let createMaybe = (value: 'a): maybe<'a> => {
{