Skip to content

Instantly share code, notes, and snippets.

View raineorshine's full-sized avatar

Raine Revere raineorshine

  • New York, NY
View GitHub Profile
raineorshine /
Created January 15, 2024 16:37

Frequently asked questions on

How to set initial data without duplication?

The recommended approach is to have the client (or server) who creates the Doc populate it with initial data. All other clients should sync before editing.

Full discussion:

As far as I know it's not possible to selectively apply or broadcast some updates and not others. As soon as you skip an update, that Doc has a "hole" in it. No other updates will work as YJS will wait for the missing update, ensuring that updates are not applied out-of-order.

raineorshine / inject.js
Last active October 21, 2023 22:15
Simple script to inject a file into a README idempotently.
1. Add <!-- TEMPLATE: myfile.txt --> to your
2. Run `node inject.js`.
import fs from 'fs'
raineorshine / staticRegistry.json
Created August 17, 2023 13:09
Static registry for npm-check-updates test
"ncu-test-v2": "99.9.9"
raineorshine / promiseOnDemand.ts
Last active June 26, 2023 22:59
A promise that can be resolved on demand.
import Emitter from 'emitter20'
/** Returns a [promise, resolve] pair. The promise is resolved when resolve(value) is called. */
const promiseOnDemand = <T>(): [Promise<T>, (value: T) => void] => {
const emitter = new Emitter()
const promise = new Promise<T>((resolve, reject) => {
emitter.on('resolve', resolve)
/** Triggers the emitter to resolve the promise. */
raineorshine / keybindings.json
Created June 20, 2023 21:42
Four handy VS Code keyboard shortcuts
"key": "alt+cmd+d",
"command": "editor.action.revealDefinition",
"when": "editorHasDefinitionProvider && editorTextFocus && !isInEmbeddedEditor"
"key": "cmd+r",
"command": "editor.action.rename",
"when": "editorHasRenameProvider && editorTextFocus && !editorReadonly"
raineorshine / Vanilla IndexedDB Recipes
Last active June 12, 2023 14:02
Vanilla IndexedDB Recipes... because IndexedDB was designed by Java developers 🙄🙄🙄
i ♡ indexeddb
raineorshine / readLines.ts
Created March 22, 2023 14:31
Stream a file by chunk size and return whole lines. Based on:
/** Stream a file by chunk size and return whole lines. */
// See:
function readLines(
file: Blob,
}: { chunkSizeBytes?: number; data?: (lines: string) => void; complete?: (err: DOMException | null) => void },
) {
raineorshine / tsconfig.json
Created February 21, 2023 21:01
Minimum typescript configuration needed to use ESM modules and top-level await
"includes": ["*.ts"],
"compilerOptions": {
// es modules
"module": "es2022",
"moduleResolution": "node",
// top-level await
"target": "es2022"
raineorshine / firebase.js
Created July 21, 2022 11:16
Firebase v4.12.1
* @license Firebase v4.12.1
* Build: rev-5cfbafd
* Terms:
var firebase=function(){var e=void 0===e?self:e;return function(t){function r(e){if(o[e])return o[e].exports;var n=o[e]={i:e,l:!1,exports:{}};return t[e].call(n.exports,n,n.exports,r),n.l=!0,n.exports}var n=e.webpackJsonpFirebase;e.webpackJsonpFirebase=function(e,o,a){for(var c,s,u,f=0,l=[];f<e.length;f++)s=e[f],i[s]&&l.push(i[s][0]),i[s]=0;for(c in o),c)&&(t[c]=o[c]);for(n&&n(e,o,a);l.length;)l.shift()();if(a)for(f=0;f<a.length;f++)u=r(r.s=a[f]);return u};var o={},i={6:0};return r.m=t,r.c=o,r.d=function(e,t,n){r.o(e,t)||Object.defineProperty(e,t,{configurable:!1,enumerable:!0,get:n})},r.n=function(e){var t=e&&e.__esModule?function(){return e.default}:function(){return e};return r.d(t,"a",t),t},r.o=function(e,t){return,t)},r.p="",r.oe=function(e){throw console.error(e),e}
raineorshine /
Last active November 12, 2021 17:22
Installing MySQL is the worst

Installing MySQL is the worst


Use MariaDB.

MySQL community edition had permissons issued with mysqld.

brew update