Skip to content

Instantly share code, notes, and snippets.

View HerbCaudill's full-sized avatar

Herb Caudill HerbCaudill

View GitHub Profile
@HerbCaudill
HerbCaudill / local-first-resources.md
Last active February 2, 2024 16:57
Resources for getting started with local-first software development

Local-first resources

Background

Getting started

@HerbCaudill
HerbCaudill / localfirst-auth-provider.md
Last active December 26, 2023 12:24
automerge-repo auth spec

localfirst/auth provider for Automerge Repo

This is pseudo-documentation for a hypothetical auth provider for Automerge Repo built around @localfirst/auth.

Configuration

A LocalFirstAuthProvider is configured with information about the local user and device.

import { LocalFirstAuthProvider, createUser, createDevice } from 'automerge-repo-auth-localfirstauth'
@HerbCaudill
HerbCaudill / flaky.js
Last active December 21, 2023 20:13
Flaky test tooling
import { exec as _exec } from 'child_process'
import fs from 'fs'
import path from 'path'
import { fileURLToPath } from 'url'
import { promisify } from 'util'
const exec = promisify(_exec)
// ensure outputDir exists
const __dirname = fileURLToPath(new URL('.', import.meta.url))
@HerbCaudill
HerbCaudill / machine.js
Created October 4, 2023 12:31
Generated by XState Viz: https://xstate.js.org/viz
// Available variables:
// - Machine
// - interpret
// - assign
// - send
// - sendParent
// - spawn
// - raise
// - actions
@HerbCaudill
HerbCaudill / automerge-repo message types.md
Last active June 10, 2023 11:32
automerge-repo message types

Proposed message types

type SyncMessage = {
  type: 'SYNC_MESSAGE'
  senderId: PeerId
  recipientId: PeerId
  documentId: DocumentId
  payload: Uint8Array // Automerge binary sync message
}
@HerbCaudill
HerbCaudill / transcript.md
Last active January 17, 2023 05:13
Cleaned-up transcript of Rich Hickey's talk "Deconstructing the Database"

This is a talk I keep referring back to, and I wanted to have it in text form. I grabbed the raw machine-generated transcript from YouTube and used GPT-3 to help me turn it into well-punctuated sentences and paragraphs. I had to do some additional cleanup, but it got me most of the way there - my first experience getting AI to help me out with a real task!


Deconstructing the Database

Rich Hickey, author of Clojure, and designer of Datomic presents a new way to look at database architectures in this talk from JaxConf 2012. https://www.youtube.com/watch?v=Cym4TZwTCNU

The title of this talk is "Deconstructing the Database".

@HerbCaudill
HerbCaudill / automerge-repo-readme.md
Last active May 1, 2022 09:21
draft readme for automerge repo

Automerge repository API

A replicated key-value store that magically synchronizes with peers in the background.

Why

Automerge is a CRDT that ...

The original Automerge API leaves a number of difficult problems to be solved in userland: Storage, network communication, and synchronization are all left as an exercise for the developer.

@HerbCaudill
HerbCaudill / dynalist.css
Created June 3, 2019 11:01
Custom CSS for Dynalist
/* dynalist.css */
/* tags */
.node-tag {
background: rgba(255, 165, 0, 0.8);
font-size: 0.8em;
border-radius: 0.3em;
font-weight: bold;
padding: 2px 5px;
@HerbCaudill
HerbCaudill / rename.bat
Last active May 20, 2021 10:25
rename master to main
git branch -m master main
git push -u origin main
git push origin --delete master
@REM will probably get an error on the last line
@REM go to https://github.com/XXXXX/XXXXX/settings/branches and change default branch
@REM then retry the last line
@HerbCaudill
HerbCaudill / optimalBloomFilter
Created November 18, 2020 13:38
Self-optimizing Bloom filter
import { BloomFilter } from 'bloomfilter' // https://github.com/jasondavies/bloomfilter.js
/**
* Returns an optimally configured Bloom filter for the given number of elements, using the
* calculations from https://www.di-mgt.com.au/bloom-filter.html .
* @param n The number of elements to be added to the Bloom filter
* @param p The target false positive rate
*/
const optimalBloomFilter = (n: number, p: number = 0.01) => {
const LOG2 = Math.log(2)