Skip to content

Instantly share code, notes, and snippets.

View shoelaced's full-sized avatar

Gregory Storkan shoelaced

  • Artbrander
  • London, UK
  • 06:07 (UTC +01:00)
View GitHub Profile
@shoelaced
shoelaced / auto-delete-old-google-drive-files.gs
Last active January 7, 2024 12:07
Google Script: Auto-deletes old files in Google Drive
/**
* Google Apps Script to delete old files and optionally empty folders in Google Drive.
*
* Settings:
* - cutOffDays: Number of days before the current date to consider for file deletion.
* - deleteEmptyFolders: Set to true to delete empty directories, false to keep them.
*
* Instructions:
* 1. Ensure "Drive" advanced service is enabled:
* - In the Google Apps Script dashboard, click "+ Services" in the sidebar.
@shoelaced
shoelaced / auto-delete-old-gmails.gs
Last active December 15, 2023 01:15
Google Script: Auto-delete old Gmail emails
/**
* This script deletes Gmail email threads older than a set time.
*
* To schedule this script to run once a week:
* 1. In the Google Apps Script dashboard, click on the clock icon on the left sidebar.
* 2. Click on the '+' button at the bottom right to add a new trigger.
* 3. Set the function to "DeleteOldEmail", the deployment to "Head", and the event source to "Time-driven".
* 4. Choose the "Week timer" option and select the day and time you'd like the script to run.
* 5. Save the trigger. Ensure that you've granted the necessary permissions for the script to run.
*/
@shoelaced
shoelaced / clean_whmcs_logs.php
Last active February 10, 2025 21:30
Deletes records from WHMCS's `tbllog_register` table that pile up because it logs every freaking thing.
<?php
/**
* Clean WHMCS Logs
*
* Based on the script by @linux4me at:
* https://whmcs.community/topic/289637-database-cleanup-operations-tbllog_register-and-tblactivitylog/
*
* This script deletes records from the WHMCS `tbllog_register` table that are older than the specified date.
* This is useful for keeping the database size down because WHMCS adds records every 5 minutes when the cron runs.
*