Skip to content

Instantly share code, notes, and snippets.

View Iamsheye's full-sized avatar
💭
Interested in Open Source

Majekodunmi Oluwaseye Iamsheye

💭
Interested in Open Source
View GitHub Profile
@Iamsheye
Iamsheye / prettify-type.ts
Created May 19, 2025 23:42
Prettify Typescript Type
type Prettify<T> = {
[K in keyof T]: T[K];
} & {}
@Iamsheye
Iamsheye / useSearchParamState.tsx
Created June 24, 2024 01:35
managing state in url
import { useRouter, useSearchParams, usePathname } from 'next/navigation';
import { useEffect, useState } from 'react';
type UseSearchParamStateReturn<T> = [T, (newValue: T) => void];
const useSearchParamState = <T>(param: string, defaultValue: T): UseSearchParamStateReturn<T> => {
const router = useRouter();
const pathname = usePathname();
const searchParams = useSearchParams();
const [value, setValue] = useState<T>(defaultValue);
@Iamsheye
Iamsheye / Fitty.tsx
Created May 29, 2024 10:37
Fit Text to width
"use client";
import React, { useEffect, useRef, useCallback } from "react";
type IFittyProps = {
children: React.ReactNode;
minSize?: number;
maxSize?: number;
multiLine?: boolean;
};
@Iamsheye
Iamsheye / ImageMagnifier.tsx
Created May 6, 2024 12:57
Image Magnifier
import { useState } from 'react';
const ImageMagnifier = ({
src,
className,
width,
height,
alt,
magnifierHeight = 150,
magnifierWidth = 150,
@Iamsheye
Iamsheye / luxonGenerateConfig.ts
Created August 19, 2023 15:14
Luxon Generate Config for Antd
// from https://github.com/react-component/picker/pull/230
import { DateTime, Info } from 'luxon';
import type { GenerateConfig } from 'rc-picker/lib/generate';
/**
* Normalizes part of a moment format string that should
* not be escaped to a luxon compatible format string.
*
* @param part string
@Iamsheye
Iamsheye / deploy.yaml
Created August 1, 2023 15:02
Vercel CI/CD Deployment
name: Vercel Deployment
env:
VERCEL_ORG_ID: ${{ secrets.VERCEL_ORG_ID }}
VERCEL_PROJECT_ID: ${{ secrets.VERCEL_PROJECT_ID }}
on:
push:
branches:
- develop
jobs:
Deploy-Production:
@Iamsheye
Iamsheye / vite.config.js
Created July 23, 2023 17:34
Vite Config Multiple Pages
import { resolve } from "path";
export default {
build: {
rollupOptions: {
input: {
indexPage: resolve(__dirname, "index.html"),
},
},
},
@Iamsheye
Iamsheye / yt-playlist.sh
Created July 11, 2023 20:33
yt dlp download playlist, 720p and with auto subtitle
yt-dlp "playlist-url" -f "bestvideo[height<=720]+bestaudio/best[height<=720]" --yes-playlist --write-auto-subs --embed-subs --merge-output-format mp4
@Iamsheye
Iamsheye / regex.js
Created July 3, 2023 13:54
Below is the regex used in type=”email” from W3C
const EMAIL_REGEX = /^[a-zA-Z0-9.!#$%&*+/=?^_`{|}~-]+@[a-zA-Z0-9-]+(?:\.[a-zA-Z0-9-]+)*$/
@Iamsheye
Iamsheye / outside-click-handler.ts
Created December 1, 2022 13:40
Outside Click Handler
const emojiRef = useRef<HTMLDivElement>(null);
useEffect(() => {
const handleClickOutside = (event: MouseEvent) => {
if (emojiRef.current && !emojiRef.current.contains(event.target as Node)) {
// write your outside click function
}
};
document.addEventListener('click', handleClickOutside, true);
return () => {