Skip to content

Instantly share code, notes, and snippets.

View broskisworld's full-sized avatar

Josh Bosley broskisworld

View GitHub Profile
@broskisworld
broskisworld / waitFor.js
Created March 4, 2024 21:34
Wait for certain conditions to arise before calling callback function, with wait interval and optional timeout
function waitFor(condition, callback, waitMs = 100, timeoutMs = -1) {
if (condition()) {
callback();
} else {
let interval = setInterval(() => {
if (condition()) {
clearInterval(interval);
callback();
}
}, waitMs);
/** @OnlyCurrentDoc */
/* Globals */
let sheetDataRanges = {};
let sheetVals = {};
let skuParentInfo = {};
/* This is the launch point! */
function buildNewList() {
Logger.log('Building parent SKU info...');
@broskisworld
broskisworld / logger.js
Last active November 16, 2023 20:03
Winston quickstart file with a daily rotating log file, colorization, timestamp prefix, and log level prefix
// PACKAGES
const winston = require('winston');
const { format } = require('logform');
require('winston-daily-rotate-file');
const simpleTimestampAndLevel = format.printf(({ level, message, timestamp }) => {
return `${timestamp} ${level}: ${message}`;
});
const simpleLevel = format.printf(({ level, message }) => {
@broskisworld
broskisworld / killscreens.sh
Created October 20, 2022 15:13
A quick function you can add to your .zshrc or .bashrc to close all screens with a certain name, even if multiple screens exist with the same name
# killscreens()
# close alls screens with name
# based on answer by joschi from question here https://unix.stackexchange.com/questions/20435/killing-multiple-gnu-screen-sessions-with-the-same-name
#
# [ USAGE ]
# killscreens <screen-name> Kill all screens with name
# killscreens -h Displays help menu
killscreens() {
if [[ "$1" == "" || "$1" == "-h" || "$1" == "--help" || "$1" == "help" || "$2" != "" ]]; then
echo "Usage: killscreens <screen-name>"
@broskisworld
broskisworld / get-js-imports.sh
Created June 20, 2022 00:14
A quick way to bulk import a bunch of files (Javascript, Typescript, Images, etc.) into a Node.js app
# USAGE
# get-js-imports [relativeDirectory = '.'] [js var suffix = '']
# EXAMPLES
# get-js-imports
# get-js-imports ../components
# get-js-imports ../media Img
# DESCRIPTION
# A quick way to bulk import a bunch of files (Javascript, Typescript, Images, etc.) into a Node.js app
@broskisworld
broskisworld / EventEmitterCancelable.js
Last active August 10, 2020 15:46
Subclass of the built-in Node.js EventEmitter, which allows events to be canceled, or ignored ahead of time.
// class EventEmitterCancelable
//
// EventEmitterCancelable is a subclass of the built-in Node.js EventEmitter
// class. Three additional functions are exposed: cancelActiveEvent(),
// ignoreNext(e), and cancelActiveEvent().
//
// During an 'event' listener callback, the listener can cancel further callback
// processing by calling either cancelActiveEvent() or cancelEvent('event').
// This is similar to stopImmediatePropogation() from the Event class.
//
@broskisworld
broskisworld / Makefile
Last active February 20, 2023 19:08 — forked from katyo/Makefile
Excellon Specification (fork from katyo with improved markdown formatting)
all: excellon.html excellon.pdf
excellon.html: excellon.md
@pandoc $< -o $@
excellon.pdf.md: excellon.md
@cat $< | sed 's/\.png/\.pdf/g' > $@
excellon.pdf: excellon.pdf.md
@pandoc $< --latex-engine=pdflatex -o $@