• Nov 18, 2022 •AustinLeath
0 likes • 2 views
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> <a href="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> <a href="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}> <a href="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> ) }
0 likes • 0 views
const dragAndDropDiv = editor.container; dragAndDropDiv.addEventListener('dragover', function(e) { e.stopPropagation(); e.preventDefault(); e.dataTransfer.dropEffect = 'copy'; }); dragAndDropDiv.addEventListener("drop",function(e){ // Prevent default behavior (Prevent file from being opened) e.stopPropagation(); e.preventDefault(); const files = e.dataTransfer.items; // Array of all files console.assert(files.length >= 1); if (files[0].kind === 'file') { var file = e.dataTransfer.items[0].getAsFile(); const fileSize = file.size; const fileName = file.name; const fileMimeType = file.type; reader = new FileReader(); reader.onloadend = function(){ editor.setValue(reader.result); } reader.readAsText(file); }else{ //Maybe handle if text is dropped console.log(files[0].kind); } });
• Nov 20, 2022 •Helper
new StringBuilder(hi).reverse().toString()
• Nov 19, 2022 •CodeCatch
const union = (...arr) => [...new Set(arr.flat())]; // Example union([1, 2], [2, 3], [3]); // [1, 2, 3]
• Nov 16, 2023 •LeifMessinger
0 likes • 7 views
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 iterator parents.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] entries const filesMaxSize = 10; while (fileIterator.hasNext()) { var file = fileIterator.next(); const owner = file.getOwner(); //Only files I own if((!(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 1 const nextFile = arr[i-1]; if(nextFile[1] > entry[1]){ break; }else{ //Swap with the next file to slide the file up const 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 file slideUp(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()); } }
const powerset = arr => arr.reduce((a, v) => a.concat(a.map(r => r.concat(v))), [[]]); powerset([1, 2]); // [[], [1], [2], [1, 2]]