Loading...
More JavaScript Posts
export const Main = () => {const [title, setTitle] = useState('');return (<ChildComponenttitle={title}onChange={e => setTitle(e.target.value)}/>);};export const ChildComponent = ({ title, onChange }) => {return (<Box component="form" onSubmit={() => {}} noValidate mt={5}><TextFieldfullWidthid="title"label="Title"name="title"autoComplete="title"autoFocuscolor="primary"variant="filled"InputLabelProps={{ shrink: true }}value={title}onChange={onChange}/></Box>);};
const getTimezone = () => Intl.DateTimeFormat().resolvedOptions().timeZone;// ExamplegetTimezone();
const euclideanDistance = (a, b) =>Math.hypot(...Object.keys(a).map(k => b[k] - a[k]));euclideanDistance([1, 1], [2, 3]); // ~2.2361euclideanDistance([1, 1, 1], [2, 3, 2]); // ~2.4495
const heapsort = arr => {const a = [...arr];let l = a.length;const heapify = (a, i) => {const left = 2 * i + 1;const right = 2 * i + 2;let max = i;if (left < l && a[left] > a[max]) max = left;if (right < l && a[right] > a[max]) max = right;if (max !== i) {[a[max], a[i]] = [a[i], a[max]];heapify(a, max);}};for (let i = Math.floor(l / 2); i >= 0; i -= 1) heapify(a, i);for (i = a.length - 1; i > 0; i--) {[a[0], a[i]] = [a[i], a[0]];l--;heapify(a, 0);}return a;};heapsort([6, 3, 4, 1]); // [1, 3, 4, 6]
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);}
router.post("/", async (req, res) => {const { email, password } = req.body;try {if (!email) return res.status(400).json({ msg: "An email is required" });if (!password)return res.status(400).json({ msg: "A password is required" });const user = await User.findOne({ email }).select("_id password");if (!user) return res.status(400).json({ msg: "Invalid credentials" });const match = await bcrypt.compare(password, user.password);if (!match) return res.status(400).json({ msg: "Invalid credentials" });const accessToken = genAccessToken({ id: user._id });const refreshToken = genRefreshToken({ id: user._id });res.cookie("token", refreshToken, {expires: new Date(Date.now() + 604800),httpOnly: true,});res.json({ accessToken });} catch (err) {console.log(err.message);res.status(500).json({ msg: "Error logging in user" });}});