Skip to content

Instantly share code, notes, and snippets.

View mohitxskull's full-sized avatar

Mohit Meena mohitxskull

View GitHub Profile
@mohitxskull
mohitxskull / searchReact.jsx
Last active January 10, 2023 04:53
This code is for a React component that allows users to filter a list of items by searching for specific keywords
import { useEffect, useState } from "react";
// It uses the useState hook to manage the state of the filtered data,
// and an input field with an onKeyUp event listener to trigger the filtering function.
// When the function is called, it filters the list of items based on
// whether the item's name includes the search query, and updates the state of the filtered data.
// The component then renders the list of items or a message indicating that no data was found,
// depending on whether there are any items in the filtered data array.
const App = () => {
@mohitxskull
mohitxskull / Notification.js
Created January 8, 2023 10:01
This function will send a notification to the user.
// This function will send a notification to the user.
// If the user has not granted permission to show notifications
// it will ask for permission.
function sendNotification() {
// Check if the browser supports notifications
if (!("Notification" in window)) {
console.log("This browser does not support notifications.");
}
// Check if the user has granted permission to show notifications
else if (Notification.permission === "granted") {
@mohitxskull
mohitxskull / passGen.js
Created January 5, 2023 06:33
Generate strong and unique passwords with customizable options.
const passwordGen = (
length = 8,
{
includeLowercase: inLc = true,
includeUppercase: inUc = true,
includeNumbers: inN = true,
includeSymbols: inS = true,
numberOfSymbols: nOfS = 1,
numberOfNumbers: nOfN = 1,
numberOfUppercase: nOfUc = 1,