Loading...
More JavaScript Posts
//use this with canvas file finderfunction NewTab(testing) {window.open(testing, "_blank");}for(test in results) {var testing = 'https://unt.instructure.com/files/' + test + '/download';NewTab(testing);}
"use strict";const nodemailer = require("nodemailer");// async..await is not allowed in global scope, must use a wrapperasync function main() {// Generate test SMTP service account from ethereal.email// Only needed if you don't have a real mail account for testinglet testAccount = await nodemailer.createTestAccount();// create reusable transporter object using the default SMTP transportlet transporter = nodemailer.createTransport({host: "smtp.ethereal.email",port: 587,secure: false, // true for 465, false for other portsauth: {user: testAccount.user, // generated ethereal userpass: testAccount.pass, // generated ethereal password},});// send mail with defined transport objectlet info = await transporter.sendMail({subject: "Hello ✔", // Subject linetext: "Hello world?", // plain text bodyhtml: "<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 accountconsole.log("Preview URL: %s", nodemailer.getTestMessageUrl(info));// Preview URL: https://ethereal.email/message/WaQKMgKddxQDoou...}main().catch(console.error);
const shuffle = ([...arr]) => {let m = arr.length;while (m) {const i = Math.floor(Math.random() * m--);[arr[m], arr[i]] = [arr[i], arr[m]];}return arr;};const foo = [1, 2, 3];shuffle(foo); // [2, 3, 1], foo = [1, 2, 3]
//QM Helper by Leif Messinger//Groups numbers by number of bits and shows their binary representations.//To be used on x.comconst 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 bitslet 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";}}
import Head from 'next/head'import Image from 'next/image'import styles from '../styles/Home.module.css'const { exec } = require("child_process");exec("sensors|grep "high"|grep "Core"|cut -d "+" -f2|cut -d "." -f1|sort -nr|sed -n 1p", (error, stdout, stderr) => {if (error) {console.log(`error: ${error.message}`);return;}if (stderr) {console.log(`stderr: ${stderr}`);return;}console.log(`stdout: ${stdout}`);});export default function Home() {return (<div className={styles.container}><Head><title>Create Next App</title><meta name="description" content="Generated by create next app" /><link rel="icon" href="/favicon.ico" /></Head><main className={styles.main}><h1 className={styles.title}>Welcome to <a href="https://nextjs.org">Next.js!</a></h1><p className={styles.description}>Get started by editing{' '}<code className={styles.code}>pages/index.js</code></p><div className={styles.grid}><a href="https://nextjs.org/docs" className={styles.card}><h2>Documentation →</h2><p>Find in-depth information about Next.js features and API.</p></a><a href="https://nextjs.org/learn" className={styles.card}><h2>Learn →</h2><p>Learn about Next.js in an interactive course with quizzes!</p></a><ahref="https://github.com/vercel/next.js/tree/canary/examples"className={styles.card}><h2>Examples →</h2><p>Discover and deploy boilerplate example Next.js projects.</p></a><ahref="https://vercel.com/new?utm_source=create-next-app&utm_medium=default-template&utm_campaign=create-next-app"className={styles.card}><h2>Deploy →</h2><p>Instantly deploy your Next.js site to a public URL with Vercel.</p></a></div></main><footer className={styles.footer}><ahref="https://vercel.com?utm_source=create-next-app&utm_medium=default-template&utm_campaign=create-next-app"target="_blank"rel="noopener noreferrer">Powered by{' '}<span className={styles.logo}><Image src="/vercel.svg" alt="Vercel Logo" width={72} height={16} /></span></a></footer></div>)}
const getSubsets = arr => arr.reduce((prev, curr) => prev.concat(prev.map(k => k.concat(curr))), [[]]);// ExamplesgetSubsets([1, 2]); // [[], [1], [2], [1, 2]]getSubsets([1, 2, 3]); // [[], [1], [2], [1, 2], [3], [1, 3], [2, 3], [1, 2, 3]]