• Mar 22, 2022 •LeifMessinger
0 likes • 1 view
//QM Helper by Leif Messinger //Groups numbers by number of bits and shows their binary representations. //To be used on x.com const minterms = prompt("Enter your minterms separated by commas").split(",").map(x => parseInt(x.trim())); const maxNumBits = minterms.reduce(function(a, b) { return Math.max(a, Math.log2(b)); }); const bitGroups = []; for(let i = 0; i < maxNumBits; ++i){ bitGroups.push([]); } for(const minterm of minterms){ let outputString = (minterm+" "); //Count the bits let count = 0; for (var i = maxNumBits; i >= 0; --i) { if((minterm >> i) & 1){ ++count; outputString += "1"; }else{ outputString += "0"; } } bitGroups[count].push(outputString); } document.body.textContent = ""; document.body.style.setProperty("white-space", "pre"); for(const group of bitGroups){ for(const outputString of group){ document.body.textContent += outputString + "\r\n"; } }
• Nov 18, 2022 •AustinLeath
// Or const randomColor = () => `#${(~~(Math.random()*(1<<24))).toString(16)}`; console.log(randomColor);
• Nov 19, 2022 •CodeCatch
0 likes • 0 views
const getTimezone = () => Intl.DateTimeFormat().resolvedOptions().timeZone; // Example getTimezone();
• 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) })
• 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); }
• Jan 17, 2021 •C S
const getSearchTerm = delimiter => { let searchTerm = ""; for (let i = 1; i < commands.length - 1; i++) searchTerm = searchTerm + commands[i] + delimiter; searchTerm += commands[commands.length - 1]; return searchTerm; };