This file contains 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
function wait(ms) { | |
console.log(`waiting for ${ms}`); | |
const past = Date.now(); | |
const future = past + ms; | |
let current = past; | |
while (current < future) { | |
current = Date.now(); | |
} | |
This file contains 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
const MyVideoComponent = () => { | |
const [state, setPlayerState] = Video.usePlayerState(); | |
const handleOnStateChange = state => { | |
if (state === 'playing') { | |
trackEvent('playing video'); | |
} | |
setPlayerState(state); | |
} |
This file contains 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
export interface Welcome { | |
sys: SysElement; | |
total: number; | |
skip: number; | |
limit: number; | |
items: Item[]; | |
includes: Includes; | |
} | |
export interface Includes { |
This file contains 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, useRef, useEffect } from "react"; | |
import "./index.css"; | |
const states = { | |
LOADING: "loading", | |
READY: "ready", | |
PLAYING: "playing", | |
PAUSED: "paused" | |
}; |
This file contains 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
use clock::Clock; | |
// | |
// Clock Creation | |
// | |
#[test] | |
fn test_on_the_hour() { | |
assert_eq!(Clock::new(8, 0).to_string(), "08:00"); | |
} |
This file contains 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
// Available variables: | |
// - Machine | |
// - interpret | |
// - assign | |
// - send | |
// - sendParent | |
// - spawn | |
// - raise | |
// - actions |
This file contains 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
// Available variables: | |
// - Machine | |
// - interpret | |
// - assign | |
// - send | |
// - sendParent | |
// - spawn | |
// - raise | |
// - actions |
This file contains 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
const FOCUSABLE_QUERY = | |
'button, [href], input, select, textarea, [tabindex]:not([tabindex="-1"])'; | |
const dialogMachine = Machine( | |
{ | |
id: 'dialog (modal)', | |
initial: 'closed', | |
context: { | |
// to be passed in as a ref to the dom node with is the modal container | |
// used for focus trapping |
This file contains 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
const dialogMachine = Machine( | |
{ | |
id: "dialog (modal)", | |
initial: "unmounted", | |
context: { | |
retries: 0 | |
}, | |
states: { | |
unmounted: { | |
on: { |
This file contains 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
605. Can Place Flowers | |
Suppose you have a long flowerbed in which some of the plots are planted and some are not. | |
However, flowers cannot be planted in adjacent plots - they would compete for water and both would die. | |
Given a flowerbed (represented as an array containing 0 and 1, where 0 means empty and 1 means not empty), | |
and a number n, return if n new flowers can be planted in it without violating the no-adjacent-flowers rule. | |
Example 1: |
NewerOlder