Skip to content

Instantly share code, notes, and snippets.

View mattrossman's full-sized avatar
🐐
Vaxxed and relaxed

Matt Rossman mattrossman

🐐
Vaxxed and relaxed
View GitHub Profile
import { useEffect, useRef } from "react"
type UseIntervalOptions = {
callback: () => void
/** milliseconds */
delay: number
enabled?: boolean
@mattrossman
mattrossman / use-random-interval.ts
Created April 12, 2024 21:09
useRandomInterval
import { useCallback, useEffect, useRef } from "react";
const random = (min: number, max: number) =>
Math.floor(Math.random() * (max - min)) + min;
/**
* https://www.joshwcomeau.com/snippets/react-hooks/use-random-interval/
*/
type UseRandomIntervalOptions = {
callback: () => void | Promise<void>;
import { useCallback, useEffect, useRef, useState } from "react";
export function useFuse<T>(initialValue: T) {
const [value, setValue] = useState<T>(initialValue);
const timeoutId = useRef<number>();
const onComplete = useCallback(() => {
setValue(initialValue);
}, [initialValue]);
@mattrossman
mattrossman / remove-emoji.ts
Created April 12, 2024 18:39
Remove Emoji
export function removeEmoji(text: string) {
return text.replaceAll(/\p{Emoji_Presentation}/gu, "");
}
@mattrossman
mattrossman / face_mesh.js
Last active July 6, 2022 19:05
MediaPipe Face Mesh web worker patch
/**
* Original file: https://cdn.jsdelivr.net/npm/@mediapipe/face_mesh@0.4.1633559619/face_mesh.js
*/
(function() {
/*
Copyright The Closure Library Authors.
SPDX-License-Identifier: Apache-2.0
*/
'use strict';
@mattrossman
mattrossman / ael-hubs-upgrade-process.md
Last active May 12, 2022 18:43
AEL Hubs Upgrade Process

This document explains my environment and workflow for handling upgrades to AEL's Hubs Cloud instance.

Overview

hubs.aelatgt.net includes source modifications to support script injection and a handful of project-specific tweaks. This allows developers to add new behaviors on a room-by-room basis without having to rebuild the client. Some projects require access to internal client logic, which we expose on a global APP.utils object.

Environment

I have multiple Git remotes configured so I can maneuver between the Mozilla and AEL repos:

@mattrossman
mattrossman / hubs-stash.js
Last active November 23, 2020 22:12
Hubs stash and unstash
/* Usage:
let data = stash()
// Or in the (Firefox) console, right click on the output array -> "Copy Object" to move data across scenes.
let elements = unstash(data)
*/
function getAllMedia() {
return document.querySelectorAll("[media-loader][networked]")
}