Skip to content

Instantly share code, notes, and snippets.

View dwightmulcahy's full-sized avatar

dWiGhT dwightmulcahy

  • San Antonio, TX
  • 09:45 (UTC -05:00)
View GitHub Profile
@dwightmulcahy
dwightmulcahy / emptygmailtrash.js
Last active July 15, 2025 16:09
Google app script to empty the trash. A time out of 5 minutes is built in to avoid the "Function execution has timed out" error if it runs too long.
// ----------------------------
// --- GLOBAL CONFIGURATION ---
// ----------------------------
// Define the list of Gmail folders (labels) to be cleaned.
// These names must exactly match your Gmail labels (e.g., "Trash", "Spam", "My Custom Label").
// To specify a custom label that is nested under another custom label in Gmail, you use a
// forward slash '/' as a separator, just like you would see it displayed in the Gmail web interface.
//
// For example, if you have:
@dwightmulcahy
dwightmulcahy / trigger_refresh.js
Last active January 30, 2025 23:39
Google Sheet App Script function that will trigger an refresh of cells that are dependent on it.
//
// Trigger function that updates just one cell 'MySheet:$A$1`.
//
// Why? So that it triggers a refresh!
//
// How? Thats the fun part, if you add dependent cells to a
// user formula it causes a refresh.
//
// You can tell the spreadsheet which cells the function is
// dependent on by passing them to the formula at the end of
@dwightmulcahy
dwightmulcahy / decision_matrix.js
Last active January 30, 2025 22:24
Google Sheets appscript functions for use in Generic Decision Matrix.
/**
* Utility function to remove empty values from an array
*
* @param {array} arr - The array to clean.
*
* @return {array} - An array with no empty values.
**/
function removeEmptyCells(arr) {
return arr.filter(v => v && v != "")
}
@dwightmulcahy
dwightmulcahy / YahooFinance.js
Last active January 23, 2025 19:35
Google Sheets appscript to retrieve a stock quote from Yahoo Finance Api V8 with a lot of error recovery and checking
//
// Helper function that retrieves the JSON data from google finance
// and handles all the error processing involved.
//
function getYahooF(symbol, range="1d") {
const baseUrl = "https://query1.finance.yahoo.com/v8/finance/chart/";
const maxRetries = 5; // Maximum number of retry attempts
let attempt = 0;
while (attempt < maxRetries) {