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
@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]")
}
@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 / face_mesh.js
Last active July 6, 2022 19:05
MediaPipe Face Mesh web worker patch
/**
* Original file: https://cdn.jsdelivr.net/npm/@mediapipe/[email protected]/face_mesh.js
*/
(function() {
/*
Copyright The Closure Library Authors.
SPDX-License-Identifier: Apache-2.0
*/
'use strict';
@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, "");
}
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 / 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 { useEffect, useRef } from "react"
type UseIntervalOptions = {
callback: () => void
/** milliseconds */
delay: number
enabled?: boolean
export async function generateRandomSHA1Hash() {
const data = crypto.getRandomValues(new Uint8Array(16))
const hashBuffer = await crypto.subtle.digest("SHA-1", data)
const hashArray = Array.from(new Uint8Array(hashBuffer))
const hashHex = hashArray
.map((byte) => byte.toString(16).padStart(2, "0"))
.join("")
return hashHex