Skip to content

Instantly share code, notes, and snippets.

View NGR-NP's full-sized avatar
🤔
Lost in coding

NGR NGR-NP

🤔
Lost in coding
View GitHub Profile
@NGR-NP
NGR-NP / guide.md
Created March 19, 2024 07:01
solve youtube github not working problem

Given your situation and the details you've provided, it seems like you're experiencing issues with accessing most websites on your Linux system, while certain sites like Gmail and Facebook work. The inability to ping 8.8.8.8 suggests a DNS resolution issue, which is likely the root cause of your problem. Here's a step-by-step guide to help you troubleshoot and potentially resolve the issue:

1. Check Your DNS Settings

First, let's ensure your DNS settings are correctly configured. You can check your current DNS settings by looking at the /etc/resolv.conf file. Open a terminal and type:

cat /etc/resolv.conf
@NGR-NP
NGR-NP / updateFavicon.js
Created January 11, 2024 18:46
dynamic favicon icon similar to WhatsApp's notification badge
function updateFavicon(notificationsCount) {
if (notificationsCount === 0) {
// No notifications, so just exit and don't update the favicon
return;
}
const canvas = document.createElement('canvas');
canvas.width = 16;
canvas.height = 16;
const ctx = canvas.getContext('2d');
@NGR-NP
NGR-NP / gist:ff5464d4f60d5adb19df073f924fb8ae
Created October 3, 2023 06:36
in mui make respondive component using useMediaquery theme break points
const theme = useTheme();
const isXsScreen = useMediaQuery(theme.breakpoints.only("xs")); // return boolean
@NGR-NP
NGR-NP / interviews questions.READ.md
Created May 27, 2023 10:56
10 most asked React JS developer questions:

1. Can you explain the concept of virtual DOM in React and how it improves performance?

  • Answer: Imagine you're playing a game of "Spot the Differences" between two similar pictures. The virtual DOM is like a cheat sheet that tells you exactly which parts have changed, so you don't have to search the entire pictures. React uses this cheat sheet to update only the necessary elements in the real DOM, making the game (and your app) much faster!

2. How do you handle state management in React? Explain the difference between local state and global state.

  • Answer: Think of state as a backpack. Local state is like keeping your personal belongings in your own backpack, easily accessible and private. Global state is like a community backpack shared by everyone, where you put items that need to be accessed and modified by different components. It's like a team effort to keep things organized and synchronized!
@NGR-NP
NGR-NP / index.jsx
Created May 26, 2023 13:46
access and extract the specific query parameters from url in react js
const extractquery = ()=>{
const { search } = useLocation(); /// ?page=1&limit=10
const params = new URLSearchParams(search);
const limit = params.get("limit"); // 10
return{
<div>{limit}</div>
}
}
@NGR-NP
NGR-NP / index.html
Last active May 26, 2023 13:49
show text animation when website is loading
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8" />
<link rel="icon" type="image/svg+xml" href="/vite.svg" />
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
<link rel="preconnect" href="https://fonts.googleapis.com">
<link rel="preconnect" href="https://fonts.gstatic.com" crossorigin>
<link
@NGR-NP
NGR-NP / loading.jsx
Last active May 26, 2023 13:51
show loading message while page resources is loading
const Loading = () =>{
const [loading, setLoading] = useState(true);
useEffect(() => {
const handleLoad = () => setLoading(false);
if (document.readyState === 'complete') {
setLoading(false);
} else {
window.addEventListener('load', handleLoad);
@NGR-NP
NGR-NP / database.js
Last active January 27, 2023 07:57
connect to mongodb with mongoose
const mongoose = require("mongoose");
const MONGO_URI = mongodb+srv://<username>:<password>@projectname.dmcuzcx.mongodb.net/collectionname
const connectMongoDB = () => {
try {
mongoose.connect(MONGO_URI);
console.log("\n Waiting ⏰ MongoDB Connections 😴 😴");
} catch (error) {
throw error;
@NGR-NP
NGR-NP / server.js
Last active January 27, 2023 08:12
node console log message
console.log("\nstarting node server\n");
const PORT = 8080
const API_URL = "http://localhost"
app.listen(PORT, () => {
console.log(
"🚀🚀 express app is Running 🏃 at 🌐 " +
API_URL +
" & 👂 listening on PORT " +
PORT +
" "
class Person {
hair_color;
blood_group;
gender;
constructor(hair_color, blood_group, gender) {
this.hair_color = hair_color;
this.blood_group = blood_group;
this.gender = gender;
};