Skip to content

Instantly share code, notes, and snippets.

View illourr's full-sized avatar

Dillon Curry illourr

  • Wayfair
  • Boston, MA
View GitHub Profile
@illourr
illourr / wait.js
Created February 4, 2024 23:59
Wait function
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();
}
const MyVideoComponent = () => {
const [state, setPlayerState] = Video.usePlayerState();
const handleOnStateChange = state => {
if (state === 'playing') {
trackEvent('playing video');
}
setPlayerState(state);
}
export interface Welcome {
sys: SysElement;
total: number;
skip: number;
limit: number;
items: Item[];
includes: Includes;
}
export interface Includes {
import React, { useState, useRef, useEffect } from "react";
import "./index.css";
const states = {
LOADING: "loading",
READY: "ready",
PLAYING: "playing",
PAUSED: "paused"
};
@illourr
illourr / clock.rs
Created February 24, 2020 04:10
Clock Test Cases
use clock::Clock;
//
// Clock Creation
//
#[test]
fn test_on_the_hour() {
assert_eq!(Clock::new(8, 0).to_string(), "08:00");
}
@illourr
illourr / machine.js
Created November 19, 2019 21:23
Generated by XState Viz: https://xstate.js.org/viz
// Available variables:
// - Machine
// - interpret
// - assign
// - send
// - sendParent
// - spawn
// - raise
// - actions
@illourr
illourr / machine.js
Created November 14, 2019 23:31
Generated by XState Viz: https://xstate.js.org/viz
// Available variables:
// - Machine
// - interpret
// - assign
// - send
// - sendParent
// - spawn
// - raise
// - actions
@illourr
illourr / machine.js
Created November 11, 2019 20:38
Generated by XState Viz: https://xstate.js.org/viz
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
@illourr
illourr / machine.js
Created November 8, 2019 22:26
Generated by XState Viz: https://xstate.js.org/viz
const dialogMachine = Machine(
{
id: "dialog (modal)",
initial: "unmounted",
context: {
retries: 0
},
states: {
unmounted: {
on: {
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: