Skip to content

Instantly share code, notes, and snippets.

View idris95's full-sized avatar
🏠
Working from home

Md Mir Idris Ali idris95

🏠
Working from home
View GitHub Profile
@idris95
idris95 / generate-components-data.js
Last active September 22, 2023 13:08
Generate array of object data for components
const fs = require('fs-extra');
const glob = require('glob');
// Define the directory where your React component files are located
const componentsDir = './src/components/icons'; // Change this to your directory path
// Use glob to find all JavaScript/TypeScript files in the directory
const componentFiles = glob.sync(`${componentsDir}/**/*.ts?(x)`);
// Function to extract component name from a file
@idris95
idris95 / convert-to-webp.js
Created September 9, 2023 06:48
A node js script to convert jpg, jpeg, and png format images to webp
const sharp = require('sharp');
const fs = require('fs');
const path = require('path');
// Define the input and output directories
const inputDir = './input';
const outputDir = './output';
// Create the output directory if it doesn't exist
if (!fs.existsSync(outputDir)) {
@idris95
idris95 / convert-to-blur-image.js
Last active September 9, 2023 06:46
A node js script to convert jpg, jpeg, png, webp format images to blur image, you need to install sharp package.
const sharp = require('sharp');
const fs = require('fs');
const path = require('path');
// Define the input and output directories
const inputDir = './input';
const outputDir = './output';
// Create the output directory if it doesn't exist
if (!fs.existsSync(outputDir)) {
@idris95
idris95 / react-lazy-laod-image.tsx
Last active December 3, 2020 15:26
Custom react lazy load image component with typescript
import React, { FC, useRef, useState, useEffect } from 'react';
import styled from 'styled-components';
const placeHolder =
'data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAAEAAAABCAQAAAC1HAwCAAAAC0lEQVR42mNkqAcAAIUAgUW0RjgAAAAASUVORK5CYII=';
const Image = styled.img`
display: block;
@keyframes loaded {
0% {