Loading...
More JavaScript Posts
"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);
//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);}
const reverse = str => str.split('').reverse().join('');reverse('hello world');// Result: 'dlrow olleh'
function filePath(file){let folders = file.getParents();const parents = [];function makePathString(folderArray){let path = "";folderArray.forEach((folder)=>{path += "/" + folder.getName();});return path;}while (folders.hasNext()) {const folder = folders.next(); //This should hopefully remove that folder from the iteratorparents.unshift(folder);}return makePathString(parents);}function myFunction() {const myEmail = Session.getEffectiveUser().getEmail();Logger.log("My email is " + myEmail);// Log the name of every file in the user's Drive.var fileIterator = DriveApp.getFiles();const files = []; //List of [File, size] entriesconst filesMaxSize = 10;while (fileIterator.hasNext()) {var file = fileIterator.next();const owner = file.getOwner();//Only files I ownif((!(owner)) || (!(owner.getEmail)) || owner.getEmail() != myEmail){continue;}const entry = [file, file.getSize()];function slideUp(arr, index){//Let's keep sliding it up so we don't have to sort it at the end.for(let i = index; i > 0; --i){ //Stops at 1const nextFile = arr[i-1];if(nextFile[1] > entry[1]){break;}else{//Swap with the next file to slide the file upconst temp = arr[i];arr[i] = arr[i - 1];arr[i - 1] = temp;}}}if(files.length < filesMaxSize){files.push(entry);slideUp(files, files.length - 1);}else{if(entry[1] > files[files.length - 1][1]){ //If it's bigger than the smallest file in the list.files[files.length - 1] = entry; //Replace the smallest fileslideUp(files, files.length - 1); //Slide it up}}}for(let i = 0; i < filesMaxSize; ++i){const file = files[i][0];const size = files[i][1];Logger.log(size + "\t" + filePath(file) + "/" + file.getName() + "\t" + file.getOwner().getName());}}
if (process.env.NODE_ENV === "production") {app.use(express.static("client/build"));app.get("*", (req, res) => {res.sendFile(path.resolve(__dirname, "client", "build", "index.html"));});}
function sortNumbers(arr) {return arr.slice().sort((a, b) => a - b);}const unsortedArray = [4, 1, 9, 6, 3, 5];const sortedArray = sortNumbers(unsortedArray);console.log("Unsorted Numbers:", unsortedArray);console.log("\n");console.log("Sorted Numbers:", sortedArray);