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
| ;(async () => { | |
| const TIMEOUT_MS = 700 | |
| const delay = () => new Promise((resolve) => setTimeout(resolve, TIMEOUT_MS)) | |
| const revealButtons = document.querySelectorAll('button[aria-label="Click to reveal"]') | |
| for (revealButton of revealButtons) { | |
| revealButton.click() | |
| await delay() | |
| } |
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
| function pixelToRem(...values: number[]) { | |
| return values | |
| .reduce((acc, current) => (acc += current / 16 + `rem `), "") | |
| .trim(); | |
| } | |
| pixelToRem(13, 20) // 0.8125rem 1.25rem |
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
| // target can ben an array of targets like ['#element', '.element'] | |
| function waitFor(target, callback, timeout = 1000) { | |
| return new Promise((resolve) => { | |
| const interval = window.setInterval(() => { | |
| let isTargetOnDOM | |
| isTargetOnDOM = Array.isArray(target) | |
| ? target.every((element) => document.querySelector(element)) | |
| : (isTargetOnDOM = document.querySelector(target)) |
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 dayjs from "dayjs"; | |
| import { CarsRepositoryInMemory } from "@modules/cars/repositories/in-memory/CarsRepositoryInMemory"; | |
| import { RentalsRepositoryInMemory } from "@modules/rentals/repositories/RentalsRepositoryInMemory"; | |
| import { DayjsDateProvider } from "@shared/container/providers/DateProvider/implementations/DayjsDateProvider"; | |
| import { AppError } from "@shared/errors/AppError"; | |
| import { CreateRentalUseCase } from "./CreateRentalUseCase"; | |
| let createRentalUseCase: CreateRentalUseCase; |
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
| "editor.tokenColorCustomizations": { | |
| "textMateRules": [ | |
| { | |
| "name": "Meta", | |
| "scope": [ | |
| "meta.object-literal.key", | |
| "variable.object.property", | |
| "variable.other.property", | |
| "keyword.operator", |
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
| const objectList = [ | |
| { id: 1, console: 'playstation 4' }, | |
| { id: 2, console: 'xbox one s' }, | |
| { id: 2, console: 'xbox one s' }, | |
| { id: 1, console: 'playstation 4' }, | |
| { id: 1, console: 'playstation 4' }, | |
| { id: 1, console: 'playstation 2' }, | |
| { id: 3, console: 'playstation 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
| fetch('https://www.githubstatus.com/') | |
| .then(res => res.text()) | |
| .then(text => { | |
| const parser = new DOMParser() | |
| const dom = parser.parseFromString(text, 'text/html') | |
| const status = Array.from( | |
| dom.querySelectorAll("div.component-inner-container.showcased span.component-status"), | |
| el => { | |
| const alias = { | |
| 'status-green': 'normal', |
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
| const numbers = [4, 2, 5, 1, 3] | |
| const orderBy = ([...arr], type = 'ASC') => { | |
| const order = { | |
| ASC: (a, b) => a - b, | |
| DESC: (a, b) => b - a | |
| } | |
| return arr.sort(order[type]) | |
| } |
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
| function delay(time) { | |
| return new Promise(resolve => | |
| setTimeout(resolve, time) | |
| ) | |
| } | |
| (async () => { | |
| await delay(1000) | |
| console.log('It takes 1 second to be executed.') |
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
| const pixel = ((init = 0) => { | |
| let pixelValue = init | |
| function increment(value) { | |
| pixelValue += value | |
| } | |
| return { | |
| getByIncrement: value => { | |
| increment(value) |
NewerOlder