• Mar 11, 2021 •C S
0 likes • 1 view
const mongoose = require('mongoose') const UserSchema = new mongoose.Schema({ username: { type: String, required: true }, email: { type: String, unique: true, required: true }, password: { type: String, required: true }, date: { type: Date, default: Date.now } }) module.exports = User = mongoose.model('user', UserSchema)
• Apr 10, 2025 •hasnaoui1
0 likes • 11 views
const express = require('express') const mongoose = require('mongoose') const cors = require('cors') const dotenv = require('dotenv') const server = express() dotenv.config() server.use(express.json()) server.get('/' , (req , res)=>{ res.send('Hello') }) //4.lancement du serveur server.listen(process.env.PORT , ()=>{ console.log('server run on http://localhost:'+process.env.PORT) })
• Nov 19, 2022 •CodeCatch
0 likes • 0 views
const insertionSort = arr => arr.reduce((acc, x) => { if (!acc.length) return [x]; acc.some((y, j) => { if (x <= y) { acc.splice(j, 0, x); return true; } if (x > y && j === acc.length - 1) { acc.splice(j + 1, 0, x); return true; } return false; }); return acc; }, []); insertionSort([6, 3, 4, 1]); // [1, 3, 4, 6]
• Oct 15, 2022 •CodeCatch
2 likes • 9 views
var invertTree = function(root) { const reverseNode = node => { if (node == null) { return null } reverseNode(node.left); reverseNode(node.right); let holdLeft = node.left; node.left = node.right; node.right = holdLeft; return node; } return reverseNode(root); };
0 likes • 3 views
const linearSearch = (arr, item) => { for (const i in arr) { if (arr[i] === item) return +i; } return -1; }; linearSearch([2, 9, 9], 9); // 1 linearSearch([2, 9, 9], 7); // -1
• Oct 29, 2020 •LeifMessinger
0 likes • 2 views
questions = Array.from(document.querySelectorAll(".multiple-choice-question")); async function hackRadio(question){ if(question.querySelector(".question-chevron").getAttribute("aria-label") == "Question completed") return; let answerChoices = question.querySelectorAll(".zb-radio-button"); async function guess(answerChoice){ answerChoice.querySelector("label").click(); } let pause = 0; for(let answerChoice of answerChoices){ setTimeout(()=>{guess(answerChoice)},pause); //No need to check given that it will record the correct answer anyways. pause += 1000; } } for(let question of questions){ hackRadio(question); } questions = Array.from(document.querySelectorAll(".short-answer-question")); async function hackShortAnswer(question){ if(question.querySelector(".question-chevron").getAttribute("aria-label") == "Question completed") return; question.querySelector("textarea").value = question.querySelector(".forfeit-answer").textContent; //question.querySelector(".check-button").click(); They are smart bastards } for(let question of questions){ const showAnswerButton = question.querySelector(".show-answer-button"); showAnswerButton.click(); showAnswerButton.click(); hackShortAnswer(question); }