Skip to content

Instantly share code, notes, and snippets.

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

Gaurav Kumar Gaurav8757

🏠
Working from home
View GitHub Profile
@Gaurav8757
Gaurav8757 / prisma.md
Last active April 5, 2026 05:51
All Installations setup here..

See Examples: -url: https://www.prisma.io/docs/prisma-orm/quickstart/postgresql

DIRECT_URL to create table (Migration)

DIRECT_URL="postgres://USER:PASSWORD@db.prisma.io:5432/postgres?sslmode=require" 

DATABASE_URL to query with db (Queries)!

DATABASE_URL="postgres://USER:PASSWORD@pooled.db.prisma.io:5432/postgres?sslmode=require"
@Gaurav8757
Gaurav8757 / mysql.sql
Created March 29, 2026 07:55
If you forgot root password of mysql workbench
1. Open CMD as administrator
2. taskkill /F /IM mysqld.exe >> ERROR: The process "mysqld.exe" not found.
Step_1 >> cd "C:\Program Files\MySQL\MySQL Server 8.0\bin"
Step_2 >> mysqld --initialize-insecure // Initialize(fresh setup)
Step_3 >> mysqld --install MySQL80 // service installed
Step_4 >> net start MySQL80 // start services
Step_5 >> mysql -u root // login to mysql
Step_6 >> ALTER USER 'root'@'localhost' IDENTIFIED BY 'root123'; // Password set karo
Step_7 >>
@Gaurav8757
Gaurav8757 / urlencoded.js
Last active March 28, 2026 12:13
How express.urlencoded || express.raw() Works?
// 1. converts the incoming data into a JavaScript object and makes it accessible through req.body
// 2. { extended: true } is set, it supports >> nested objects and arrays << using the qs library.
// 3. It only parses requests with Content-Type: application/x-www-form-urlencoded, ignoring other data formats.
app.use(express.urlencoded({ extended: true }))
app.get('/login', (req, res) => {
res.send('<form method=POST action=/login><input type=text name=username><input type=number name=age><input type=submit></form>')
})
express.raw() function: It parses incoming request payloads into a >> Buffer << and is based on body-parser.
@Gaurav8757
Gaurav8757 / carousel.html
Created March 26, 2026 10:35
Auto Carousel
@Gaurav8757
Gaurav8757 / dom_randomColor.js
Created March 24, 2026 18:34
Random Color generate
<html>
<head></head>
<body></body>
</html>
// js file
function getColors(){
//rgb 0 - 255;
let R = Math.floor(Math.random() * 255);
let G = Math.floor(Math.random() * 255);
@Gaurav8757
Gaurav8757 / callback_promise_asyncAwait.js
Last active March 23, 2026 11:04
Callback, Promise and Async / Await
// Callbacks
function user(callback1){
let name = 'Gaurav';
setTimeout(()=> {
callback1(name); // if callback not take argument give undefined
}, 2000);
}
function userAge(name, callback2){
let age = name + ' age is 24.';
@Gaurav8757
Gaurav8757 / forwardRef.js
Created February 12, 2026 06:15
forwardRef allows a parent component to send a ref to a child so the parent can directly access: a child DOM element or a child’s imperative methods.
// Child Component (Custom Input + Auto Focus)
// “forwardRef lets a parent component directly access a child’s DOM element or method through a ref,
// which is not possible with normal props.”
import React, { forwardRef } from "react";
const TextInput = forwardRef((props, ref) => {
return <input ref={ref} {...props} />;
});
@Gaurav8757
Gaurav8757 / RegexValidation.js
Created January 8, 2026 07:02
Regex Validation (Strong Patterns)
export const regexValidators = {
fullName: z
.string()
.regex(/^[a-zA-Z0-9_]{3,16}$/, "Only letters, numbers & underscore"),
phone: z
.string()
.regex(/^\+91\d{10}$/, "Phone must be +91XXXXXXXXXX"),
strongPassword: z
@Gaurav8757
Gaurav8757 / asyncValidation.js
Created January 8, 2026 06:59
ASYNC VALIDATION — Email Existence Check or other field you can add
import api from "./api"; // your axios instance
export const checkEmailExists = async (email) => {
try {
const res = await api.post("/auth/check-email", { email });
return res.data.exists; // true / false
} catch (e) {
return false;
}
};