Annotated/commented code for the dialog example shown here: https://www.w3.org/WAI/ARIA/apg/patterns/dialog-modal/examples/dialog/
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import { | |
EntitiesDef, | |
i, | |
LinksDef, | |
type AttrsDefs, | |
} from "@instantdb/react"; | |
function addEssentialAttrs<Attrs extends AttrsDefs>(attrs: Attrs) { | |
return { | |
...attrs, |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import { | |
i, | |
LinksDef, | |
type AttrsDefs, | |
} from "@instantdb/react"; | |
function addEssentialAttrs<Attrs extends AttrsDefs>(attrs: Attrs) { | |
return { | |
...attrs, | |
id: i.string(), |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
class LinkedList<T> { | |
value: T; | |
rest: LinkedList<T> | null; | |
constructor(value: T, rest: LinkedList<T> | null) { | |
this.value = value; | |
this.rest = rest; | |
} | |
get length(): number { |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// https://replit.com/@arihantverma1/JSON-stringify-deeply-nested-node-value-change?v=1 | |
const util = require('util') | |
const data = { | |
widgets: [ | |
{ | |
type: "performance", | |
data: { | |
progress_bars: [ |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// https://leerob.io/blog/spotify-api-nextjs | |
const url = 'https://accounts.spotify.com/authorize' | |
function getAuthorizationCodeURL() { | |
const u = new URL(url); | |
u.searchParams.append('client_id', ''); | |
u.searchParams.append('response_type', 'code'); | |
u.searchParams.append('redirect_uri', 'http://127.0.0.1:8080/callback'); | |
u.searchParams.append('scope', 'user-read-currently-playing'); | |
u.searchParams.append('state', ''); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/* Problem Name is &&& Run Length Encoding &&& PLEASE DO NOT REMOVE THIS LINE. */ | |
/** | |
* Instructions to candidate. | |
* 1) Run this code in the REPL to observe its behaviour. | |
* 2) Consider adding some additional tests in doTestsPass(). | |
* 3) Implement rle() correctly. | |
* 4) If time permits, try to improve your implementation. | |
*/ |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/* Problem Name is &&& JS Object to String &&& PLEASE DO NOT REMOVE THIS LINE. */ | |
/** | |
* Instructions to candidate: | |
* | |
* 1) Given the below code. Write a function (ES6 recommended) that loops through all the properties of the Employee and create a comma-seperated string with the values | |
* For e.g. | |
* { | |
* firstName: "X", | |
* lastName: "Y", |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import React, { useState, useEffect, useRef } from "react"; | |
import ReactDOM from "react-dom"; | |
function Counter() { | |
const [count, setCount] = useState(0); | |
const [delay, setDelay] = useState(1000); | |
const [isRunning, setIsRunning] = useState(true); | |
useInterval(() => { | |
setCount(count + 1); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/** | |
* 🦢🦢🦢 | |
* 1. Read the comments and render the required component | |
* 2. You are allowed to browse react docs if you need be | |
*/ | |
const Parent = () => { | |
// 🦢 write code here | |
return null; | |
}; |