Skip to content

Instantly share code, notes, and snippets.

View fullstackzach's full-sized avatar
🎯
Focusing

Zach Willard fullstackzach

🎯
Focusing
View GitHub Profile
@fullstackzach
fullstackzach / file_generator.js
Created January 15, 2024 16:07
Create an arbitrary file of any size, useful for testing
// this can be thrown into chrome dev tools to create a dummy file for testing
function createLargeFile(fileName, fileSizeInGB) {
const chunkSize = 1024 * 1024 * 10; // 10MB chunk size
let fileSize = fileSizeInGB * 1024 * 1024 * 1024; // Convert GB to bytes
let parts = [];
while (fileSize > 0) {
let size = Math.min(chunkSize, fileSize);
let part = new Uint8Array(size);
parts.push(part);
/**
* @param {string[]} words
* @param {number} maxWidth
* @return {string[]}
*/
var fullJustify = function(words, maxWidth) {
let wordIndex = 0
let justified = []
let wordLengths = []
while (wordIndex < words.length) {