• Mar 9, 2021 •LeifMessinger
0 likes • 1 view
alert("bruh")
• Mar 22, 2022 •LeifMessinger
//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);
0 likes • 2 views
var d = new Date(); var d = new Date(milliseconds); var d = new Date(dateString); var d = new Date(year, month, day, hours, minutes, seconds, milliseconds);
• Feb 11, 2021 •LeifMessinger
function spam(times = 1,log = true){ for(let i = 0; i < times; i++){ $.get("backend-search.php", {term: (" "+Date.now())}).done(function(data){ if(log) console.log(data); }); } } spam(100000);
• Nov 19, 2022 •CodeCatch
let nums = [1,2,3,1] var containsDuplicate = function(nums) { let obj = {}; for(let i =0; i< nums.length; i++){ if(obj[nums[i]]){ obj[nums[i]] += 1; return true; }else{ obj[nums[i]] = 1; } } return false; }; console.log(containsDuplicate(nums));