Skip to content

Instantly share code, notes, and snippets.

@alavkx
alavkx / machine.js
Created January 19, 2021 17:25
Generated by XState Viz: https://xstate.js.org/viz
// XState Brain Teaser 2 - Async Validation
// https://www.youtube.com/watch?v=nUKA0xhkZc8
const fetchValidateUserCanSendAmount = () => fetch("/validate-user-can-send-amount")
const fetchValidateBankDetails = () => fetch("/validate-bank-details")
const validationMachine = Machine({
id: 'validation',
initial: 'idle',
context: {},
@alavkx
alavkx / Banner.tsx
Last active January 27, 2021 17:57
A11y: Which labeling method is more semantically "correct"?
// Option A: associate the label directly and hide the redundant DOM node
<div role="status" aria-label={title}>
<div aria-hidden>{title}</div>
</div>
// Option B: associate the label with an id
<div role="status" aria-labelledby="banner-title">
<div id="banner-title">{title}</div>
</div>
@alavkx
alavkx / package.json
Created January 8, 2024 22:36
Simple Puppeteer Web Scraper
{
"name": "some-project",
"version": "1.0.0",
"description": "",
"main": "index.js",
"scripts": {
"scrape": "npx tsx ./src/scrape.ts"
},
"author": "",
"license": "ISC",