Skip to content

Instantly share code, notes, and snippets.

View srflp's full-sized avatar
🎯

Filip Sauer srflp

🎯
  • Prismic
  • Poznań, Poland
  • 21:36 (UTC +01:00)
  • LinkedIn in/srflp
View GitHub Profile
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'