Skip to content

Instantly share code, notes, and snippets.

@JamesMessinger
JamesMessinger / IndexedDB101.js
Last active April 14, 2025 16:34
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"});
@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:

@andywer
andywer / _readme.md
Last active January 8, 2025 04:42
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

@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,

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
@xi
xi / dbusmenu.py
Last active December 13, 2024 01:12
dmenu wrapper around dbus menues
# dmenu wrapper around dbus menues
#
# Example Usage:
# python3 dbusmenu.py org.freedesktop.network-manager-applet /org/ayatana/NotificationItem/nm_applet/Menu
#
# https://github.com/tetzank/qmenu_hud/blob/master/com.canonical.dbusmenu.xml
import subprocess
import sys
import time
@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
@ronnyroeller
ronnyroeller / signaling-server.ts
Last active January 2, 2025 00:30
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,
});
@pesterhazy
pesterhazy / building-sync-systems.md
Last active April 16, 2025 11:29
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

@ssrihari
ssrihari / clojure-learning-list.md
Last active April 17, 2025 15:56
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