Skip to content

Instantly share code, notes, and snippets.

View geotrev's full-sized avatar
🏠
Working from home

George Treviranus geotrev

🏠
Working from home
View GitHub Profile
@geotrev
geotrev / tic-tac-toe.js
Last active March 3, 2020 01:26
Tic Tac Toe
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()
}
@geotrev
geotrev / live-exp-active-element.js
Last active February 1, 2024 15:23
Active Element Live Expression
/**
* 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:
@geotrev
geotrev / tcg-player-add-card-script.js
Last active May 31, 2020 02:03
Add missing cards to collection
;(() => {
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()
@geotrev
geotrev / fail.js
Created November 6, 2020 20:29
it's a fail
console.log(
(![] + [])[+[]] +
(![] + [])[+!+[]] +
([![]] + [][[]])[+!+[] + [+[]]] +
(![] + [])[!+[] + !+[]]
);
@geotrev
geotrev / try-catch.ts
Created March 20, 2025 14:59 — forked from t3dotgg/try-catch.ts
Theo's preferred way of handling try/catch in TypeScript
// Types for the result object with discriminated union
type Success<T> = {
data: T;
error: null;
};
type Failure<E> = {
data: null;
error: E;
};