Skip to content

Instantly share code, notes, and snippets.

View rushkeldon's full-sized avatar

Keldon Rush rushkeldon

View GitHub Profile
@rushkeldon
rushkeldon / propMapper.js
Last active June 4, 2025 21:38
When prop spreading has left you with doubt as to the shape of the props...
const propMapper = {
typeMap: {},
trueTypeOf(obj) {
const match = {}.toString.call(obj).match(/\s([a-zA-Z]+)/);
const trueType = match?.[1]?.toLowerCase?.() ?? 'unknown';
return trueType === 'asyncgeneratorfunction' ? 'function' : trueType;
},
inferType(value) {
const type = propMapper.trueTypeOf(value);
switch (type) {
/**
* Ephemeral Element Capture & Injection
*
* Usage:
* ephemera.startObserving();
* ephemera.trace(); // to see the captured HTML in the console
* ephemera.injectElement();
*/
const ephemera = {
@rushkeldon
rushkeldon / _useA11yKeysClick.ts
Last active May 6, 2025 21:43
A hook to enable keyboard handling on non-interactive elements that are made interactive.
import { useCallback } from 'react';
function isElementDisabled(el: HTMLElement): boolean {
return (
el.hasAttribute('disabled') ||
el.getAttribute('aria-disabled') === 'true' ||
el.getAttribute('data-disabled') === 'true'
);
}
@rushkeldon
rushkeldon / useElementRect.ts
Created October 23, 2024 08:07
useElementRect - a react hook that keeps the current rectangle inhabited by an element up-to-date
import { RefObject, useEffect, useState, useRef } from 'react';
const useElementRect = <T extends HTMLElement>(): [RefObject<T>, DOMRect] => {
const [rect, setRect] = useState<DOMRect>(new DOMRect());
const ref = useRef<T>(null);
useEffect(() => {
const updateRect = () => setRect(ref?.current?.getBoundingClientRect() || new DOMRect());
@rushkeldon
rushkeldon / jira_addon.css
Last active April 18, 2024 21:40
Jira Addon : adds a standup button and gamifies Jira a bit with FX
a.btn-standup:hover {
color: black !important;
}
.popup-standup {
font-family: -apple-system, "system-ui", "Segoe UI", Roboto, Oxygen, Ubuntu, "Fira Sans", "Droid Sans", "Helvetica Neue", sans-serif;
position: fixed;
z-index: 5000;
padding: 0px 10px;
border: 1px solid black;
@rushkeldon
rushkeldon / gamify.css
Last active April 17, 2024 04:54
gamify Jira with sound effects and fireworks when moving tickets by dragging
canvas {
position: absolute;
left: 0;
right: 0;
top: 0;
bottom: 0;
width: 100vw;
height: 100vh;
z-index: 1000;
@rushkeldon
rushkeldon / bash_functions.sh
Last active April 15, 2024 06:30
useful bash functions for your .bash_profile or similar
# region : timers
# example usage :
# npm run clean && startTimer && npm run build && endTimer
function startTimer() {
START_TIME=$(date +%s.%N)
}
function endTimer() {
@rushkeldon
rushkeldon / JIRA_STANDUP_GENERATOR.MD
Last active April 17, 2024 05:22
jira random standup order generator

WHAT

This inserts a "Standup" button into the Jira interface. When clicked, it will display a list of all the people who have filters created for them - in a random order.

Caveats - Only Works :

  • in the Chrome browser
  • when filters created for each team member
  • with the Chrome extension below installed (and configured with the code below)

HOW

@rushkeldon
rushkeldon / nextSlide.js
Created July 8, 2023 14:26
next slide please - now
// pick an easy element from the dom
const bar = document.querySelector( '.nav-primary' );
// listen for the click event and nextSlide
bar.addEventListener( 'click', nextSlide );
/*
* Sample URL :
* https://definition.org/meghan-markle-facts/40/
*/