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 dynamic from 'next/dynamic' | |
import React from 'react' | |
const NoSsr = props => ( | |
<React.Fragment>{props.children}</React.Fragment> | |
) | |
export default dynamic(() => Promise.resolve(NoSsr), { | |
ssr: false | |
}) |
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
"use strict"; | |
const { readdir } = require("fs"); | |
const { promisify } = require("util"); | |
const readdirP = promisify(readdir); | |
async function getAllFilesRecursively(folder) { | |
return await ( |
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
function randomTime() { | |
const min = 0, max = 6; | |
return (Math.floor(Math.random() * (max - min + 1)) + min) * 1000;; | |
} | |
Array.from({length:10}, (_, k) => k+1).reduce(async (prev, curr) => { | |
await prev; | |
return new Promise((resolve) => { | |
setTimeout(resolve,randomTime(), console.log(curr)) | |
}); |
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 { useEffect, useState } from 'react'; | |
import debounce from 'lodash.debounce'; | |
interface ViewportSize { | |
width: number; | |
height: number; | |
} | |
function useViewportSize() { | |
const [viewportSize, setViewportSize] = useState<ViewportSize>({ |
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 { | |
COLORS, | |
COLOR_MODE_KEY, | |
INITIAL_COLOR_MODE_CSS_PROPERTY, | |
} from '@/styles/themeConfig'; | |
import { createContext, useEffect, useMemo, useState } from 'react'; | |
import { ChildrenOnlyProps, ColorMode } from '@/types/index'; | |
export const ThemeContext = createContext<{ |
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 { useState, useEffect } from "react"; | |
const useLocalStorage = (initialState, key) => { | |
const [value, setValue] = useState(() => { | |
const keyValue = localStorage.getItem(key); | |
if(keyValue) return JSON.parse(keyValue)[value]; | |
return initialState; | |
}); | |
useEffect(() => { |
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 { useEffect, useState } from "react"; | |
export default function scrollToTop(){ | |
const [isBtnVisible, setIsBtnVisible] = useState(false); | |
const [pageYOffset, setPageYOffset] = useState(0); | |
useEffect(()=>{ | |
const checkVisiblity = () => { | |
setPageYOffset(window.pageYOffset); | |
if(pageYOffset > window.innerHeight){ |
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
{ | |
"final_space": false, | |
"osc99": false, | |
"console_title": false, | |
"console_title_style": "", | |
"console_title_template": "", | |
"blocks": [ | |
{ | |
"type": "prompt", | |
"alignment": "left", |
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
function seive(n){ | |
const arr = Array.from({length: n}, (_,i) => i > 1 ? i : false), | |
limit = Math.sqrt(n); | |
for(let i = 0; i < limit; i++){ | |
let j = i*i; | |
while (j <= n) { | |
arr[j] = false; | |
j = j+i; | |
} |
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 from 'react'; | |
export default function mergeRefs(...refs){ | |
const filteredRefs = refs.filter(Boolean); | |
return React.useMemo(() => { | |
if(!filteredRefs.length) return null; | |
return (node) => { | |
filteredRefs.forEach(ref => { | |
if(ref) assignRef(ref, node); | |
}); |