Skip to content

Instantly share code, notes, and snippets.

View amityweb's full-sized avatar

Laurence Cope amityweb

View GitHub Profile
@amityweb
amityweb / backup.sh
Last active December 2, 2021 09:41
Incremental RSync Backup with 14 Day Retention for Databases and Home Folder
#!/bin/sh
rsync="/usr/bin/rsync"
################################
# VARIABLES
################################
# General Variables
remote_server="yourserver.com"
remote_port="22"
@amityweb
amityweb / gist:5419600
Created April 19, 2013 10:47
AppleScript to Move/Archive Mail Emails After Certain Number of Days
on run
tell application "System Events"
set isMailRunning to (count of (every process whose bundle identifier is "com.apple.mail")) > 0
end tell
if isMailRunning then
# Set Date the Mail is Old
set oldemaildate to ((current date) - (71 * days))
@amityweb
amityweb / receive-gmail-at-specified-time.js
Last active December 17, 2015 14:48
Receive GMail Email at a Specified Time
/*
The problem with email is it arrives at the time it arrives, and not when you you want it to arrive,
and it's a common habit to press the Send and Receive button all the time. So this script and technique
will prevent any email that has arrived in Gmail from in fact being downloaded to your mail client apart
from the specified times. Good for productivity, email management and less distractions
This script is best used when a third party mail application is used to read mail, and not the Gmail
interface itself.
GMail Requirements:
@amityweb
amityweb / Mail_to_Things.scpt
Last active September 17, 2018 09:43
AppleScript to Add Things task from Mail in Apple Mail Folder
on run
tell application "System Events"
set isThingsRunning to (count of (every process whose bundle identifier is "com.culturedcode.things")) > 0
set isMailRunning to (count of (every process whose bundle identifier is "com.apple.mail")) > 0
end tell
if isThingsRunning and isMailRunning then
tell application "Mail"
@amityweb
amityweb / send-mail-to-omnifocus2
Last active March 4, 2022 17:11
Send Mail to Omnifocus 2
-- Thanks to https://github.com/HunterHillegas/OmniFocusMailFlags/blob/master/PushFlaggedMessagesToOmniFocus.applescript
-- This AppleScript will send email messages in a specific folder in Mail.app to your Omnifocus 2 inbox
-- Only runs if Mail and OF2 are open
-- Run the script with /usr/bin/osascript "/path/to/script/send-follow-up-to-omnifocus.scpt"
-- I use Lingon to manage my scheduled scripts
-- Edit the variables below
on run
@amityweb
amityweb / csv_to_xml.php
Last active May 12, 2022 18:22
CSV to XML using PHP
<?php
// Map CSV file to array
$rows = array_map('str_getcsv', file('data.csv'));
$header = array_shift($rows);
$data = array();
foreach ($rows as $row)
{
$data[] = array_combine($header, $row);
}
@amityweb
amityweb / ee_update.sh
Last active October 15, 2015 16:36
Bash Script to Update Expression Engine from Source Zip
#!/bin/bash
# Save in public folder
# run with "sh ee_update.sh"
# Variables
database=your_db_name
username=your_useraccountname_name
now=$(date +'%Y-%d-%m-%H%M')
@amityweb
amityweb / email-test.php
Last active October 23, 2015 10:18
Simple script to test sending an email to an email address using PHP
<?php
/* DO NOT LEAVE THIS LIVE ON A SERVER */
$sendemail = true; // Simple switch to enable or disable sending to be safe
if (isset($_POST['email']) && $sendemail)
{
$to = $_POST['email'];
@amityweb
amityweb / acf.php
Created January 15, 2017 11:42
Work in progress of using PHP to create ACF fields in Wordpress. Posting here in an effort to improve and make more efficient and easier to manage
<?php
if( function_exists('acf_add_local_field_group') ):
// Main Content Group
acf_add_local_field_group(array
(
'key' => 'content_1',
'title' => 'Content',
'fields' => array (
@amityweb
amityweb / update_pmpro_members_expiry_dates
Created December 22, 2017 16:07
Paid Memberships Pro SQL to Update Expiry Dates for Member Groups
UPDATE wp_pmpro_memberships_users
SET enddate = '2018-01-30 23:59:59'
WHERE (membership_id = 10 OR membership_id = 11)
AND enddate = '0000-00-00 00:00:00'
AND status = 'active';