This file contains hidden or 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 hidden or 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 hidden or 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 hidden or 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> |
This file contains hidden or 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 app = express(); | |
| const mogoose = require('mongoose'); | |
| const categories = require('./Routes/categories'); // import router with route name | |
| mogoose.connect('mongodb://127.0.0.1/eapp').then(()=>console.log("Connection successful")).catch(err=>console.error("Couldn't connect to monogodb",err)); | |
This file contains hidden or 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
| let isAuth = cookies.get('auth-token') ? true : false; | |
| const fullMain = document.querySelector(".full-main"); | |
| setAuth(isAuth); | |
| // when auth got changed make the main clickable and non clickble | |
| function handler(e) { | |
| e.stopPropagation(); | |
| e.preventDefault(); | |
| } |
This file contains hidden or 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 editIcon from "./imgs/edit.png"; | |
| import projDeleteIconSrc from "./imgs/proDelete.png"; | |
| import { format } from "date-fns"; | |
| import { Project } from "./project"; | |
| import { activateCheckboxes, activateEditBtns, allTasks } from "./index"; | |
| import { changeContent } from './projectsDOM' | |
| const allProjects = document.querySelector(".all-projects"); // refer to that of tasks | |
| const projectAddForm = document.querySelector(".project-add-form"); |
This file contains hidden or 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 { useState, useEffect } from "react"; | |
| import ReactDOM from "react-dom/client"; | |
| const useFetch = (url) => { | |
| const [data, setData] = useState(null); | |
| useEffect(() => { | |
| fetch(url) | |
| .then((res) => res.json()) | |
| .then((data) => setData(data)); | |
| }, [url]); |
This file contains hidden or 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 { Route, Routes } from "react-router-dom"; | |
| import Navbar from "./components/Navbar"; | |
| import Home from "./components/Home"; | |
| import Shop from "./components/Shop"; | |
| import Cart from "./components/Cart"; | |
| import itemData from "./ItemData"; | |
| import { useState, useEffect } from "react"; | |
| export default function App() { | |
| const [shopItems, setShopItems] = useState(itemData); |
This file contains hidden or 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
| function shuffleArray(arr){ | |
| for(let i=arr.length-1 ; i>0; i--){ | |
| let j = Math.floor(Math.random()*(i+1)) | |
| [arr[i],arr[j]] = [arr[j] ,arr[i]] | |
| return arr | |
| } | |
| // https://en.wikipedia.org/wiki/Fisher-Yates_shuffle#The_modern_algorithm |