Skip to content

Instantly share code, notes, and snippets.

@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))
@ssrihari
ssrihari / clojure-learning-list.md
Last active November 4, 2024 14:03
An opinionated list of excellent Clojure learning materials

An opinionated list of excellent Clojure learning materials

These resources (articles, books, and videos) are useful when you're starting to learn the language, or when you're learning a specific part of the language. This an opinionated list, no doubt. I've compiled this list from writing and teaching Clojure over the last 10 years.

  • 🔴 Mandatory (for both beginners and intermediates)
  • 🟩 For beginners
  • 🟨 For intermediates

Table of contents

  1. Getting into the language
@pesterhazy
pesterhazy / building-sync-systems.md
Last active November 15, 2024 10:17
Building an offline realtime sync engine

So you want to write a sync system for a web app with offline and realtime support? Good luck. You might find the following resources useful.

Overview articles

@ronnyroeller
ronnyroeller / signaling-server.ts
Last active April 1, 2024 14:13
Lambda function to provide webrtc signaling server
import { ApiGatewayManagementApi, DynamoDB } from 'aws-sdk';
import { scanItems } from './dynamodb';
const { AWS_REGION, TOPICS_TABLE } = process.env;
const dynamoDb = new DynamoDB({
apiVersion: '2012-08-10',
region: AWS_REGION,
});
@unframework
unframework / XtermCanvas.tsx
Last active February 22, 2024 21:14
Snapshot of a Xterm.js + Ink component in React and cross-compilation settings to bundle Ink for the browser environment
import React, { useEffect, useRef } from 'react';
import ReactDOM from 'react-dom';
import { EventEmitter } from 'events';
import { Terminal } from 'xterm';
import { render } from 'ink';
/// <reference types="node" />
import 'xterm/css/xterm.css';
// this spins up Xterm.js, initializes Ink inside it and sets up

Multiplayer online board game sandbox

There are a few existing ones, with each their own characteristics. Which means of course I want to make my own.

Some design principles:

  • keep it simple but versatile
  • in browser, no install needed
  • click and drag 2D interface, compatible with mobile
  • no account needed: join rooms by URL or room code
@0x6273
0x6273 / booster.js
Created May 19, 2020 14:49
TP Booster Pack
function boosterJson(cards) {
let firstCard = cards.pop();
let cardStack = {
"objectType": "Card",
"transform": {
"rotation":
{
"x": 0,
"y": 0,
@andywer
andywer / _readme.md
Last active October 18, 2024 18:19
React - Functional error boundaries

React - Functional error boundaries

Thanks to React hooks you have now happily turned all your classes into functional components.

Wait, all your components? Not quite. There is one thing that can still only be implemented using classes: Error boundaries.

There is just no functional equivalent for componentDidCatch and deriveStateFromError yet.

Proposed solution

@justinwoo
justinwoo / using-rxjs-instead-of-flux-with-react.md
Last active October 21, 2023 10:16
Using RxJS instead of Flux with React to organize data flow

Reposted from Qiita

For almost a year now, I've been using this "flux" architecture to organize my React applications and to work on other people's projects, and its popularity has grown quite a lot, to the point where it shows up on job listings for React and a lot of people get confused about what it is.

Why I'm tired of using and teaching flux

There are a billion explainations on the internet, so I'll skip explaining the parts. Instead, let's cut to the chase -- the main parts I hate about flux are the Dispatcher and the Store's own updating mechanism.

If you use a setup similar to the examples in facebook/flux, and you use flux.Dispatcher, you probably have this kind of flow:

@JamesMessinger
JamesMessinger / IndexedDB101.js
Last active October 16, 2024 09:40
Very Simple IndexedDB Example
// This works on all devices/browsers, and uses IndexedDBShim as a final fallback
var indexedDB = window.indexedDB || window.mozIndexedDB || window.webkitIndexedDB || window.msIndexedDB || window.shimIndexedDB;
// Open (or create) the database
var open = indexedDB.open("MyDatabase", 1);
// Create the schema
open.onupgradeneeded = function() {
var db = open.result;
var store = db.createObjectStore("MyObjectStore", {keyPath: "id"});