Skip to content

Instantly share code, notes, and snippets.

import { mediaQueryListSet } from "client/src/hooks/useMediaQuery";
import { useEffect } from "react";
const modifiedCSSRules: Map<CSSMediaRule, string> = new Map();
export function useEmulateMediaPrint() {
useEffect(() => {
for (const styleSheet of document.styleSheets) {
for (const cssRule of styleSheet.cssRules) {
if (cssRule instanceof CSSStyleRule) {
@echo off
setlocal enabledelayedexpansion
echo Starting git pull for all directories...
echo.
for /d %%i in (*) do (
if exist "%%i\.git" (
echo Pulling updates for: %%i
cd "%%i"
import type { NextFunction, Request, Response } from "express"
import { ctx } from "~/app/.server/async-context"
export interface TimingOptions {
header?: string
decimals?: number
log?: (ms: number, req: Request, res: Response) => void
}
// Uses 'prefinish' (emitted by Express) to set header just before flush and 'finish' to optionally log.
@reyronald
reyronald / prefetch-all-routes.tsx
Created September 8, 2025 01:02
Utility for React Router Framework Mode
import { useEffect } from "react"
/**
* Opportunistically preloads all route modules after initial render.
* Simplified to satisfy strict lint rules (no type assertions / conditionally skipped hooks).
*/
export function PreloadAllRoutes() {
useEffect(() => {
if (import.meta.env.SSR) return
function useCloserOffcanvasOnNavigation(show: boolean, toggleShow: () => void) {
const location = useLocation()
const prevPathnameRef = useRef(location.pathname)
useEffect(() => {
if (prevPathnameRef.current !== location.pathname && show) {
toggleShow()
}
prevPathnameRef.current = location.pathname
}, [location.pathname, show, toggleShow])
import { setTimeout } from "node:timers/promises";
import { parse } from "node:url";
import { ctx } from "server/infra/asyncContext";
import { logErrorMessage, logger } from "server/infra/logger";
import * as redis from "server/infra/redis/redis";
import { backgroundWork } from "server/utils/backgroundWork";
import type { AsyncHandler } from "server/http/functions/utils";
const EX = 20; // seconds
import "./styles.css";
import { useState } from "react";
export default function Toaster() {
const [toasts, setToasts] = useState(0);
return (
<div className="wrapper">
<div className="toaster">
{Array.from({ length: toasts }).map((_, i, arr) => (
export const hasCoverageChanged = (previousClient: Client, nextClient: Client) => {
const previousPolicies = new Map(
previousClient.policies.map((p) => [p.id, new Set(p.slfCoverages)]),
);
const nextPolicies = new Map(nextClient.policies.map((p) => [p.id, new Set(p.slfCoverages)]));
for (const [policyId, prevCoverages] of previousPolicies) {
const nextCoverages = nextPolicies.get(policyId);
if (!nextCoverages)
@reyronald
reyronald / http-proxy-server.ts
Created January 24, 2025 19:08
Intercepts requests and forwards them to another service.
import * as http from "node:http";
/**
*
npm run play server/playgrounds/load-balancer.ts
*/
const PORT = 3333;
const TARGET_PORT = 3335;
@reyronald
reyronald / gsap-eases.css
Created January 13, 2025 22:59 — forked from jh3y/gsap-eases.css
GreenSock eases with CSS linear()
:root {
--none: linear(0, 1);
--power1-in: linear( 0, 0.0039, 0.0156, 0.0352, 0.0625, 0.0977, 0.1407, 0.1914, 0.2499, 0.3164, 0.3906 62.5%, 0.5625, 0.7656, 1 );
--power1-out: linear( 0, 0.2342, 0.4374, 0.6093 37.49%, 0.6835, 0.7499, 0.8086, 0.8593, 0.9023, 0.9375, 0.9648, 0.9844, 0.9961, 1 );
--power1-in-out: linear( 0, 0.0027, 0.0106 7.29%, 0.0425, 0.0957, 0.1701 29.16%, 0.2477, 0.3401 41.23%, 0.5982 55.18%, 0.7044 61.56%, 0.7987, 0.875 75%, 0.9297, 0.9687, 0.9922, 1 );
--power2-in: linear( 0, 0.0014 11.11%, 0.0071 19.24%, 0.0188 26.6%, 0.037 33.33%, 0.0634 39.87%, 0.0978 46.07%, 0.1407 52.02%, 0.1925 57.74%, 0.2559 63.49%, 0.3295 69.07%, 0.4135 74.5%, 0.5083 79.81%, 0.6141 85%, 0.7312 90.09%, 1 );
--power2-out: linear( 0, 0.2688 9.91%, 0.3859 15%, 0.4917 20.19%, 0.5865 25.5%, 0.6705 30.93%, 0.7441 36.51%, 0.8075 42.26%, 0.8593 47.98%, 0.9022 53.93%, 0.9366 60.13%, 0.963 66.67%, 0.9812 73.4%, 0.9929 80.76%, 0.9986 88.89%, 1 );
--power2-in-out: linear( 0, 0.0036 9.62%, 0.0185 16.66