This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import NextAuth from "next-auth"; | |
import GithubProvider from "next-auth/providers/github"; | |
export const authOptions = { | |
providers: [ | |
GithubProvider({ | |
clientId: process.env.GITHUB_ID ?? "", | |
clientSecret: process.env.GITHUB_SECRET ?? "", | |
}), | |
], |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
const express = require("express"); | |
const jwt = require("jsonwebtoken"); | |
const app = express(); | |
app.get("/api", (req, res) => { | |
res.json({ | |
message: "Welcome to the API", | |
}); | |
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
const express = require("express"); | |
const path = require("path"); | |
const session = require("express-session"); | |
const passport = require("passport"); | |
const LocalStrategy = require("passport-local").Strategy; | |
const mongoose = require("mongoose"); | |
const User = require("./models/user"); | |
const { | |
getUser, |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/* | |
A throttled function is first called without delay and then, for a time interval of t milliseconds, can't be executed but should store the latest function arguments provided to call fn with them after the end of the delay. | |
*/ | |
const throttle = function (fn , t){ | |
let intervalInProgress = null; | |
let argsToProcess = null; | |
const intervalFunction = () =>{ | |
if(argsToProcess == null){ |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
const promisePool = async function(functions, n) { | |
async function evaluateNext(){ | |
if(functions.length == 0 ) return ; | |
const fn = functions.shift(); | |
await fn(); | |
await evaluateNext(); // call the function recursively until the function ends | |
} | |
const nPromises = Array(n).fill().map(evaluateNext); // create array of size n to call the evalute next fn. | |
await Promise.all(nPromises); // wait for all promise to resolve | |
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/** | |
* @param {Function} fn | |
* @param {number} t | |
* @return {Function} | |
*/ | |
var timeLimit = function(fn, t) { | |
return async function(...args) { | |
return Promise.race([new Promise((res,rej)=>setTimeout(()=>rej("Time Limit Exceeded"),t)) , fn(...args) ]) | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
async function sleep(millis){ | |
return new Promise(res => setTimeout(res,millis) ) // return a promise that will resolve after millis milliseconds | |
} | |
const t = Date.now(); | |
sleep(100).then(()=>console.log(Date.now() - t )); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
const curry = function (fn){ | |
return function currying(...args){ | |
if(args.length >= fn.length ){ | |
return fn(...args); | |
} | |
else { | |
return function(...args2){ | |
return currying.apply(...args.concat(args2)) | |
} | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import { useEffect, useRef, useState } from "react"; | |
import { | |
BrowserRouter as Router, | |
Routes, | |
Route, | |
Navigate, | |
} from "react-router-dom"; | |
import "./index.css"; | |
import { projectId, account } from "./appwrite/appwriteConfig"; | |
import Signup from "./components/Signup"; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import React from "react"; | |
function Main() { | |
return ( | |
<div className="flex-1 overflow-auto scroll-smooth "> | |
<section id="about" className="h-[100%] bg-pink-200"></section> | |
<section id="skills" className="h-[100%] bg-pink-400"></section> | |
<section id="projects" className="h-[100%] bg-pink-800"></section> | |
<section id="interests" className="h-[100%] bg-gray-400"></section> | |
<section id="certifications" className="h-[100%] bg-red-200"></section> |
NewerOlder