Skip to content

Instantly share code, notes, and snippets.

@reyronald
reyronald / startDurationMeasurement.ts
Last active December 4, 2023 13:47
Measures timing using the NodeJS performance API "perf_hooks"
import { PerformanceObserver, performance } from "node:perf_hooks";
import type { PerformanceEntry } from "node:perf_hooks";
export function startDurationMeasurement(name: string) {
const id = crypto.randomUUID();
const measurementName = `${name}-measurementName-${id}`;
const startMark = `${name}-startMark-${id}`;
const endMark = `${name}-endMark-${id}`;
import React from 'react'
export type Props = {
show: boolean
children: React.ReactNode
animate(args: { el: HTMLDivElement; show: boolean }): Animation
}
export const AnimateMounting: React.FunctionComponent<Props> = ({ show, children, animate }) => {
const elRef = React.useRef<HTMLDivElement>(null)
import React from 'react'
declare var $: any
export type Select2Ref = {
getValue(): string | string[] | null
setValue(val: string | string[]): void
clear(): void
}
import { useEffect } from 'react'
import { useLocation } from 'react-router-dom'
import { usePrevious } from './use-previous'
import { useStopWatch } from './use-stop-watch'
export const usePageTracker = () => {
const location = useLocation()
const pathname = usePrevious(location.pathname)
const sw = useStopWatch()
@reyronald
reyronald / partymode.css
Created March 18, 2021 00:19
Party mode!
.partymode--container {
position: fixed;
z-index: 10000;
left: 0;
top: 0;
right: 0;
bottom: 0;
overflow: hidden;
pointer-events: none;
import React from 'react'
import ReactDOM from 'react-dom'
export function useTooltip<Props>(): {
openPopover(component: React.FunctionComponentElement<Props>): void
closePopover(): void
} {
const mountNodeRef = React.useRef<HTMLDivElement>()
const openPopover = (component: React.FunctionComponentElement<Props>) => {
@reyronald
reyronald / pure_html_css_modal.css
Created October 26, 2020 23:41 — forked from calebporzio/pure_html_css_modal.css
The CSS for the pure HTML/CSS modal I tweeted about.
details summary {
cursor: pointer;
outline: none !important;
display: inline-block;
padding: 8px 12px;
padding-top: 10px;
border-radius: 4px;
overflow: hidden;
background: #F09825;
color: white;
// ==UserScript==//
// @name Wanikani Final Fantasy victory fanfare
// @namespace https://gist.github.com/reyronald/e3c1d27872d2d500335ddf01f560c5e5
// @version 0.4
// @description Plays the Final Fantasy Victory Fanfare on Wanikani level up
// @author Ronald Rey @reyronald (reyronald@gmail.com)
// @match *://www.wanikani.com/*
// @grant none
// @downloadURL https://gist.githubusercontent.com/reyronald/e3c1d27872d2d500335ddf01f560c5e5/raw/wanikaniVictoryFanfare.user.js
// @updateURL https://gist.githubusercontent.com/reyronald/e3c1d27872d2d500335ddf01f560c5e5/raw/wanikaniVictoryFanfare.user.js
import React from 'react'
import { Overlay, Popover } from 'react-bootstrap'
function useTooltip() {
const mountNodeRef = React.useRef<HTMLDivElement>()
React.useEffect(() => {
const mountNode = document.createElement('div')
mountNodeRef.current = mountNode
// From https://apex.sh/
:root {
--ease: cubic-bezier(0.075,0.82,0.165,1.15);
}