Skip to content

Instantly share code, notes, and snippets.

@threepointone
threepointone / FiduciaryContributorLicenseAgreement.md
Created April 17, 2023 11:40
Fiduciary Contributor License Agreement

Fiduciary License Agreement 2.0

based on the

Individual Contributor Exclusive License Agreement

(including the Traditional Patent License OPTION)

Thank you for your interest in contributing to PartyKit, Inc.'s PartyKit ("We" or "Us").

@threepointone
threepointone / eggs.md
Last active July 16, 2023 15:54
Sunil's Gochujang eggs

Sunil's Eggs.

These are my eggs. I like this recipe because it's delicious, doesn't take too much time to make, and goes well with other meals in my life.

All instructions are negotiable, adjust based on vibes.

Start by slicing up an onion. I like using a milder tasting onion, or a banana shallot. I like slices so I can taste it in the final product, but feel free to chop it finer if you'd like.

In a bowl, make the 'sauce'. A teaspoon each of gochugang paste, soy sauce, sesame oil, a couple of pinches of brown sugar, mirin or rice vinegar (I prefer mirin because it doesn't smell as strong, but the vinegar is more 'traditional'). Also add a teaspoon of garlic paste, and a teaspoon of ginger paste.

@threepointone
threepointone / chatgpt-god.md
Created December 6, 2022 23:09
ChatGPT's answers to Battleground god

The Questions (and answers) Technically, these are statements, not questions, but... what the hell!

Question 1 God exists.

  • true

Question 2 God is a logical possibility (i.e., there is nothing contradictory about the very idea of God).

  • true
@threepointone
threepointone / after.js
Last active February 4, 2021 09:30
converted a function to a generator; simpler, more efficient, cooler.
// recursively get all files in a folder
function* getAllFiles(dirPath: string): Iterable<string> {
for (const file of fs.readdirSync(dirPath)) {
const pathToCheck = path.join(dirPath, file);
if (fs.statSync(pathToCheck).isDirectory()) {
if (file !== 'node_modules') {
yield* getAllFiles(pathToCheck);
}
} else {
yield pathToCheck;
@threepointone
threepointone / feature-flags-client-implementation.md
Last active June 1, 2023 18:35
Implementing a client for feature flags

On implementing a client for feature flags in your UI codebase

This document isn't an explainer on Feature Flags, you can find that with my amateur writeup, or literally hundreds of better writeups out there.

This document is also agnostic to the choice of service you'd use: LaunchDarkly or split.io or optimizely or whatever; that's orthogonal to this conversation.

Instead, this document is a list of considerations for implementing a client for using Feature Flags for User Interface development. Service providers usually give a simple fetch and use client and that's it; I contend that there's a lot more to care about. Let's dive in.

To encourage usage, we'd like for the developer experience to be as brutally simple as possible. So, this should be valid usage:

@threepointone
threepointone / iframe.tsx
Created December 8, 2020 00:16
An iframe loader powered by Suspense
import { Suspense, useLayoutEffect, useRef, useState } from 'react';
type IFrameProps = React.ComponentPropsWithRef<'iframe'> & {
fallback?: JSX.Element;
};
export function IFrame(props: IFrameProps) {
const { fallback, ...rest } = props;
return (
@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'

import tree from "./tree";
test("it should serialise the tree", () => {
expect(tree("path/to/folder")).toMatchInlineSnapshot(); // jest will fill this in automatically
});
@threepointone
threepointone / feature-flags.md
Last active May 24, 2023 11:03
Feature flags: why, how, all that

(I'm enjoying doing these raw, barely edited writeups; I hope they're useful to you too)

Feature flags

This is my own writeup on feature flags; for a deep dive I'd recommend something like Martin Fowler's article (https://martinfowler.com/articles/feature-toggles.html).

So. Feature flags. The basic idea that you'll store configuration/values on a database/service somewhere, and by changing those values, you can change the user experience/features for a user on the fly.

Let's say that you're building a new feature, called 'new-button' which changes the color of buttons, which is currently red, to blue. Then you'd change code that looks like this -

(This is a draft for something I'm writing internally but figured it would be useful for everyone.)

tl;dr -

  • make sure git --version returns 2.27.0 or higher.
  • git clone --filter=blob:none --sparse <repo> --depth=1
  • cd <repo>
  • git sparse-checkout set <path> <path> <...path>