• Mar 11, 2021 •C S
0 likes • 2 views
import { configureStore } from "@reduxjs/toolkit"; import { combineReducers } from "redux"; import profile from "./profile"; import auth from "./auth"; import alert from "./alert"; const reducer = combineReducers({ profile, auth, alert, }); const store = configureStore({ reducer }); export default store;
0 likes • 1 view
const jwt = require("jsonwebtoken"); const authToken = (req, res, next) => { const token = req.headers["x-auth-token"]; try { req.user = jwt.verify(token, process.env.ACCESS_TOKEN_SECRET); next(); } catch (err) { console.log(err.message); res.status(401).json({ msg: "Error authenticating token" }); } }; module.exports = authToken;
• Mar 10, 2022 •LeifMessinger
//Use at https://mee6.xyz/leaderboard/732262089447702588 //Higher the spammy stat, the more spammy that person is. //This is because mee doesn't give experience to people who post more comments in a minute. function statBlock(title, value){ let elm = document.createElement("div"); elm.className = "leaderboardPlayerStatBlock"; let titleElm = document.createElement("div"); titleElm.className = "leaderboardPlayerStatName"; titleElm.textContent = title; let valueElm = document.createElement("div"); valueElm.className = "leaderboardPlayerStatValue"; valueElm.textContent = value; elm.appendChild(titleElm); elm.appendChild(valueElm); elm.remove = function(){ this.parentElement.removeChild(this); } return elm; } for(let player of Array.from(document.getElementsByClassName("leaderboardPlayer"))){ if(player.spamminess) player.spamminess.remove(); let messages = null; let experience = null; const statBlockArray = Array.from(player.querySelectorAll(".leaderboardPlayerStatBlock")); for(let statBlock of statBlockArray){ const statName = statBlock.querySelector(".leaderboardPlayerStatName").textContent; const text = statBlock.querySelector(".leaderboardPlayerStatValue").textContent; const number = ((text.includes("k"))? (text.replace("k","") * 1000.0) : +(text)); if(statName.includes("MESSAGES")){ messages = number; }else if(statName.includes("EXPERIENCE")){ experience = number; } } const stats = player.querySelector(".leaderboardPlayerStats"); const messagesElement = stats.firstChild; const spamminess = ((messages/experience)*2000.0).toFixed(2); player.spamminess = stats.insertBefore(statBlock("SPAMMINESS", spamminess), messagesElement); }
• Nov 18, 2022 •AustinLeath
0 likes • 5 views
"use strict"; const nodemailer = require("nodemailer"); // async..await is not allowed in global scope, must use a wrapper async function main() { // Generate test SMTP service account from ethereal.email // Only needed if you don't have a real mail account for testing let testAccount = await nodemailer.createTestAccount(); // create reusable transporter object using the default SMTP transport let transporter = nodemailer.createTransport({ host: "smtp.ethereal.email", port: 587, secure: false, // true for 465, false for other ports auth: { user: testAccount.user, // generated ethereal user pass: testAccount.pass, // generated ethereal password }, }); // send mail with defined transport object let info = await transporter.sendMail({ from: '"Fred Foo 👻" <[email protected]>', // sender address to: "[email protected], [email protected]", // list of receivers subject: "Hello ✔", // Subject line text: "Hello world?", // plain text body html: "<b>Hello world?</b>", // html body }); console.log("Message sent: %s", info.messageId); // Message sent: <[email protected]> // Preview only available when sending through an Ethereal account console.log("Preview URL: %s", nodemailer.getTestMessageUrl(info)); // Preview URL: https://ethereal.email/message/WaQKMgKddxQDoou... } main().catch(console.error);
• 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); };
• Nov 19, 2022 •CodeCatch
0 likes • 0 views
const geometricProgression = (end, start = 1, step = 2) => Array.from({ length: Math.floor(Math.log(end / start) / Math.log(step)) + 1, }).map((_, i) => start * step ** i); geometricProgression(256); // [1, 2, 4, 8, 16, 32, 64, 128, 256] geometricProgression(256, 3); // [3, 6, 12, 24, 48, 96, 192] geometricProgression(256, 1, 4); // [1, 4, 16, 64, 256]