Skip to content

Instantly share code, notes, and snippets.

View rohitsSpace's full-sized avatar

Rohit Yadav rohitsSpace

View GitHub Profile
@rohitsSpace
rohitsSpace / PrintLogMessage.ts
Last active September 21, 2023 08:18
This versatile method enables you to print messages in vivid colours and customize the text to your liking. With printLineBreak, you can easily log messages, simplifying the debugging purposes. Customize your messages to your exact specifications and choose between displaying long, sorted.
interface TNeedNameChangeProps {
bgColor?: string;
fontStyle?: string;
fontWeight?: string;
[key: string]: any;
}
interface TCustomStyle extends TNeedNameChangeProps {
color?: string;
padding?: string;
@rohitsSpace
rohitsSpace / useCacheAbleFetch.js
Last active October 26, 2021 21:12
In memory Cacheable Fetch API react hook
import { useEffect, useRef, useReducer } from 'react';
export const useCacheAbleFetch = (url) => {
const cache = useRef({});
const initialState = {
status: 'idle',
error: null,
data: [],
loading: false, // helper to get loading state of the request
@rohitsSpace
rohitsSpace / utiliies.css
Created September 4, 2021 11:47
CSS Utilities Classes
.m0 {
margin: 0;
}
.mt0 {
margin-top: 0;
}
.mr0 {
margin-right: 0;
@rohitsSpace
rohitsSpace / IntersectionOfArrays.js
Created April 14, 2021 06:13
Get intersection of arrays using recursion
// Example Arrays
const arr1 = [1,2,3]
const arr2 = [10,1,2]
const arr3 = [1, 12,13, 2]
const getIntersection = (arr1, arr2, ...rest) => {
const interSection = arr1.filter(x => arr2.includes(x))
// if we got more than two arrays then we will check rest length
// it its more than 0 then we will call that function again.
if (rest.length === 0) { return interSection; }