const mockTimers = () => {
const globalTimerFn = window.setTimeout;
const runAllTimers = () => (window.setTimeout = (fn) => fn());
const restoreAllTimers = () => (window.setTimeout = globalTimerFn);
return {runAllTimers, restoreAllTimers};
};
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
| // Types for the result object with discriminated union | |
| type Success<T> = { | |
| data: T; | |
| error: null; | |
| }; | |
| type Failure<E> = { | |
| data: null; | |
| error: E; | |
| }; |
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
| console.log( | |
| (![] + [])[+[]] + | |
| (![] + [])[+!+[]] + | |
| ([![]] + [][[]])[+!+[] + [+[]]] + | |
| (![] + [])[!+[] + !+[]] | |
| ); |
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 productRows = document.querySelectorAll('tr[id^="StoreProductId_"]') | |
| productRows.forEach((row) => { | |
| const quantity = row.querySelector(".CollectionText").innerText | |
| const value = row.querySelector('.minPrice').innerText | |
| if (parseInt(quantity) > 0 || value === "$0.00") return | |
| row.querySelector(".CollectionUpArrow").click() |
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
| /** | |
| * This script recursively checks `shadowRoot`s and `contentDocument`s until the true `activeElement` is found. | |
| * | |
| * HOW TO USE: Copy and paste this into your Chrome dev tools in the `Create live expression` input. | |
| */ | |
| (function(){function d(){var u=arguments[0]||document.activeElement;if(u.shadowRoot&&u.shadowRoot.activeElement){return d(u.shadowRoot.activeElement)}if(u.contentDocument&&u.contentDocument.activeElement){return d(u.contentDocument.activeElement)}return u}return d()})(); | |
| /** | |
| Unminified version: |
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 TicTacToe { | |
| constructor() { | |
| this.handleMouseEnter = this.handleMouseEnter.bind(this) | |
| this.handleMouseLeave = this.handleMouseLeave.bind(this) | |
| this.handleClick = this.handleClick.bind(this) | |
| this.handleResetClick = this.handleResetClick.bind(this) | |
| this.tiles = [] | |
| this.start() | |
| } |
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
| #!/usr/bin/env bash | |
| set -o nounset | |
| set -o errexit | |
| set -o pipefail | |
| git config user.name "$USER_NAME" | |
| git config user.email "$USER_EMAIL" | |
| # Add github to known_hosts to enable push from CI |
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
| version: 2 | |
| jobs: | |
| build: | |
| working_directory: ~/repo-working-dir | |
| docker: | |
| - image: circleci/ruby:2.6.5-node-browsers | |
| steps: | |
| - checkout | |
| - save_cache: |
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 { terser } from "rollup-plugin-terser" | |
| import path from "path" | |
| import resolve from "rollup-plugin-node-resolve" | |
| import babel from "rollup-plugin-babel" | |
| import glob from "glob" | |
| const scriptPattern = path.resolve(__dirname, "_scripts/**/!(_)*.js") | |
| const inputs = glob.sync(scriptPattern).reduce((files, input) => { | |
| const parts = input.split("/") |
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
| export const dom = { | |
| // Attribute manipulation | |
| getAttr: (element, attr) => element.getAttribute(attr), | |
| setAttr: (element, attr, value) => element.setAttribute(attr, value), | |
| removeAttr: (element, attr) => element.removeAttribute(attr), | |
| toggleAttr: (element, attr, forceCondition) => element.toggleAttribute(attr, forceCondition), | |
| hasAttr: (element, attr) => element.hasAttribute(attr), | |
| // Element selection | |
| find: (selector, parent = document) => parent.querySelector(selector), |
NewerOlder