Skip to content

Instantly share code, notes, and snippets.

@LukasGibb
LukasGibb / Auto-Forward-Invoice-to-Xero
Last active September 21, 2025 16:28
Google Apps Script: Auto-Forward Emails to Xero
/*
* Google Apps Script: Auto-Forward Emails to Xero
* Author: Lukas Gibb (Written with help from ChatGPT o1)
* Email: lg@cloudjourneyman.com
* Credit for idea: Reddit User 'zfa' (https://www.reddit.com/user/zfa/) mentioned this idea here:
* https://www.reddit.com/r/GMail/comments/hk4gc1/comment/fwrcghc/
*
* Purpose:
* Xero (accounting tool) allows PDF invoices to be forwarded manually to create draft invoices.
* Doing this one-by-one can be time consuming and tedious so it would be great to just set up filters
<?php
function deleteProduct($id, $force = FALSE) {
$product = wc_get_product($id);
if(empty($product))
return new WP_Error(999, sprintf(__('No %s is associated with #%d', 'woocommerce'), 'product', $id));
// If we're forcing, then delete permanently.
if ($force) {
if ($product->is_type('variable')) {
@mtruitt
mtruitt / delete_variations_based_on_date.php
Last active August 19, 2019 04:48
Delete Variations from Products
<?php
function delete_variations(){
// Lets grab the product type
$product_id = get_the_ID();
$product_type = WC_Product_Factory::get_product_type( $product_id );
// Lets skip everything if its not a product.
if( $product_type == false ) return;
// Lets make sure we are working with registrations
@magicoli
magicoli / copy-from-time-machine.sh
Last active April 18, 2023 19:31 — forked from vjt/copy-from-time-machine.sh
Copy data from a Time Machine volume mounted on a Linux box.
#!/bin/bash
#
# Copy data from a Time Machine volume mounted on a Linux box.
#
# Usage: copy-from-time-machine.sh <source> <target>
#
# source: the source directory inside a time machine backup
# target: the target directory in which to copy the reconstructed
# directory trees. Created if it does not exists.
#
@mogsdad
mogsdad / Apps Script pdfToText utility.md
Last active September 3, 2025 23:32
For http://stackoverflow.com/questions/26613809, a question about getting pdf attachments in gmail as text. I got a little carried away - this does much more than asked.

Google Apps Script pdfToText Utility#

This is a helper function that will convert a given PDF file blob into text, as well as offering options to save the original PDF, intermediate Google Doc, and/or final plain text files. Additionally, the language used for Optical Character Recognition (OCR) may be specified, defaulting to 'en' (English).

Note: Updated 12 May 2015 due to deprecation of DocsList. Thanks to Bruce McPherson for the getDriveFolderFromPath() utility.

    // Start with a Blob object
    var blob = gmailAttchment.getAs(MimeType.PDF);