Skip to content

Instantly share code, notes, and snippets.

View mdtanvirahamedshanto's full-sized avatar
💻
Ready For New Project 👽

Md Tanvir Ahamed Shanto mdtanvirahamedshanto

💻
Ready For New Project 👽
View GitHub Profile
const mysql = require('mysql2/promise');
// Create a connection pool
const pool = mysql.createPool({
host: process.env.DB_HOST || 'localhost',
user: process.env.DB_USER || 'root',
password: process.env.DB_PASSWORD || '',
database: process.env.DB_NAME || 'team_management',
waitForConnections: true,
connectionLimit: 10,
@mdtanvirahamedshanto
mdtanvirahamedshanto / not-found.js
Created May 12, 2024 14:01
Next js Not-Found Component
"use client"; // Error components must be Client Components
import { useRouter } from "next/navigation";
export default function NotFound({ error, reset }) {
const router = useRouter();
return (
<div className="flex flex-col justify-center items-center text-center w-full h-svh">
<h2 className="mb-10 text-red-500 text-6xl">Page Not-Found !</h2>
<button
className="mb-24 w-auto bg-green-500 text-white rounded-md py-2 px-4 hover:bg-green-600"
@mdtanvirahamedshanto
mdtanvirahamedshanto / error.js
Last active May 12, 2024 14:02
Nextjs Error component
"use client"; // Error components must be Client Components
import { useRouter } from "next/navigation";
import { useEffect } from "react";
export default function Error({ error, reset }) {
const router = useRouter();
useEffect(() => {
// Log the error to an error reporting service
console.error(error);
@mdtanvirahamedshanto
mdtanvirahamedshanto / date.js
Created February 11, 2024 10:34
get carrent date time
export default function getDate(value, type, inMS) {
if (!type) {
return value;
}
if (!inMS) {
value = value * 1000;
}
const date = new Date(value);
let didInit = false;
function App() {
useEffect(() => {
if (!didInit) {
didInit = true;
// ✅ Only runs once per app load
loadDataFromLocalStorage();
checkAuthToken();
}
@mdtanvirahamedshanto
mdtanvirahamedshanto / clineupFetchEffect.js
Created January 31, 2024 17:45
dev mode clear data fetch
useEffect(() => {
let ignore = false;
async function startFetching() {
const json = await fetchTodos(userId);
if (!ignore) {
setTodos(json);
}
}
@mdtanvirahamedshanto
mdtanvirahamedshanto / snnipet.json
Created January 19, 2024 17:38
React Next.js normal funtion and array funtion
"Create arrow function with arguments": {
"prefix": "fa",
"body": [
"const $1 = ($2) => {",
" $3",
"}"
],
"description": "Create a arrow function with cursor on arguments/params"
},
"Create inline arrow function": {
@mdtanvirahamedshanto
mdtanvirahamedshanto / starCanva.tsx
Created January 8, 2024 08:16
create start canva animation
/**
* React Or Nextjs Install All Pakagese ,
* npm install or yarn add @react-three/drei @react-three/fiber
* copy all of file [ .jsx / .tsx ]
* then use this component main layout / main file top...
*/
"use client";
import { PointMaterial, Points } from "@react-three/drei";
import { Canvas, useFrame } from "@react-three/fiber";