Skip to content

Instantly share code, notes, and snippets.

View srflp's full-sized avatar

Filip Sauer srflp

View GitHub Profile
@srflp
srflp / pushLiveListItems.ts
Last active August 13, 2025 12:37
Liveblocks: A script that pushes 150 list items simultaneously using 150 simultaneous mutateStorage calls. The expected result is 150 items being pushed to the array, since we don't override the LiveList, we only mutate it by pushing items. The real result is not all items being pushed.
import { Liveblocks, LiveList } from "@liveblocks/node";
/**
* This script is used to push a list of items to a Liveblocks room.
* We're mutating the list, by pushing 150 items, so the final list should have 150 items,
* but we never get 150 items back, it's always less.
*
* For running the script use Node 24 (it allows to run .ts directly using node only):
*
* ```node
import {
useCallback,
useState,
} from "react"
/**
* Allows to use a Set as a state more conveniently.
*/
export function useSet<T>(initialValues?: Iterable<T> | null) {
const [set, setSet] = useState<Set<T>>(new Set(initialValues))
@srflp
srflp / zip-top-level-directories.yml
Last active October 17, 2021 15:26
GitHub Action that checkouts the repository, gets a list of recently changed files, creates Zip archives of top-level directories and commits them back to the repo.
# source: https://gist.github.com/srflp/2da77871ed5e41edab913b3aaac85ba9
# put this file in <your-repo>/.github/workflows/zip-top-level-directories.yml
name: Zip top-level directories
on:
push:
branches:
- main
jobs:
@srflp
srflp / BarcodeDetectorTypes.ts
Last active August 7, 2021 12:53
Barcode Detector API Types, not yet implemented in libdom.d.ts in TypeScript, because the browser support is two low. Docs: https://developer.mozilla.org/en-US/docs/Web/API/Barcode_Detection_API
// Barcode Detector API Types
// remove these types after they get implemented in TypeScript
type BarcodeFormat =
| 'aztec'
| 'code_128'
| 'code_39'
| 'code_93'
| 'codabar'
| 'data_matrix'