This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import React, { useState, useCallback, useMemo, ReactNode } from 'react'; | |
interface Step { | |
component: ReactNode; | |
name: string; | |
} | |
interface StepWizardHook { | |
currentStep: Step; | |
next: () => void; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import { useMemo } from 'react' | |
type ClassValue = string | { [key: string]: boolean } | undefined | null | false | |
const useClassNames = (...classes: ClassValue[]): string => { | |
const className = useMemo( | |
() => | |
classes | |
.filter(Boolean) | |
.map((classValue) => { |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
const useScrollToElementOnMount = (loading: boolean) => { | |
useLayoutEffect(() => { | |
const isDirectLink = !document.referrer | |
const hash = window.location.hash | |
if (isDirectLink && hash) { | |
const elementId = hash.substring(1) | |
const element = document.getElementById(elementId) | |
if (element && !loading) { | |
element.scrollIntoView({ behavior: 'smooth' }) | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// ==UserScript== | |
// @name Add Button Before Element - ChatGPT | |
// @namespace http://tampermonkey.net/ | |
// @version 1.0 | |
// @description Add HTML button before an element on the page. | |
// @author Chase Harrison | |
// @match https://chat.openai.com/* | |
// @grant none | |
// ==/UserScript== |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// https://sunrise-sunset.org/api | |
let url = `https://api.sunrise-sunset.org/json?lat=${30.6502082}&lng=${-87.9074242}date=today`; | |
let response = await fetch(url); | |
let { results } = await response.json(); | |
let final = Object.entries(results).map(([key, val]) => { | |
let date = new Date(); | |
let time = new Date(new Date(`${date.getFullYear()}-${date.getMonth()+1}-${date.getDate()}-${val}`)); | |
time.setHours(time.getHours() - date.getTimezoneOffset()/60); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import { useSelector } from 'react-redux'; | |
import { RootState } from '../state'; | |
type States = keyof RootState; | |
/** | |
* This hook will get you the global app state | |
* @returns App State | |
* @param stateName | |
*/ |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/** | |
* Fade out elements as they're deleted | |
* @param el - the element to focus | |
* @param speed - the speed of the focus | |
* @example | |
const ref = useRef<HTMLDivElement>(null); | |
... | |
fadeOut(ref.current, 500) | |
*/ | |
const fadeOut = (el: HTMLDivElement, speed: number) => { |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import dotenv from 'dotenv'; | |
dotenv.config(); | |
import type { NextApiRequest, NextApiResponse } from 'next'; | |
import { getSignedUrl } from "@aws-sdk/s3-request-presigner"; | |
import { S3Client, PutObjectCommand } from "@aws-sdk/client-s3"; | |
interface PresignedURLResponse { | |
success: boolean, | |
data: string | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// Main Component | |
let myRef = useRef<HTMLDivElement>(null); | |
// Child Component | |
interface MYINTERFACE { | |
// ...props | |
} | |
const Notifications = React.forwardRef<HTMLDivElement, MYINTERFACE>(({ MYPROPS }, ref) => { | |
return <div>My Component</div> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import { useRef, useCallback, useEffect, MutableRefObject } from 'react'; | |
/** | |
* Hook to check if an element is clicked or not clicked. | |
* When the element isn't clicked, a callback function is fired. | |
* | |
* @param ref Ref element to listen to | |
* @param handler Call function that fires when element is outside click area | |
*/ | |
const useClickOutside = (ref: MutableRefObject<HTMLElement | null>, handler: (e: MouseEvent) => any): void => { |
NewerOlder