Skip to content

Instantly share code, notes, and snippets.

View amityweb's full-sized avatar

Laurence Cope amityweb

View GitHub Profile
@amityweb
amityweb / rclone-backups
Last active April 16, 2024 00:52
Rclone command to run from Amity Servers
#!/bin/bash
ps_out=`ps -ef | grep "rclone sync\|bash rclone" | grep -v 'grep'`
result=$(echo $ps_out | grep "$1")
if [ "$result" = "" ];then
# DB Dumps First
#for i in $(mysql --batch --skip-column-names -e 'SHOW DATABASES' | egrep -v 'performance_schema|information_schema|mysql|eximstats|leechprotect|cphulkd|modsec|roundcube|logaholicDB_.'); do mysqldump --single-transaction -h localhost --opt $i | gzip -c > /home/_dbbackups/$i.sql.gz; done
# Home Folder Dump
DATE=$(date +%Y-%m-%d.%H:00)
@amityweb
amityweb / add_admin_to_wordpress.php
Last active March 18, 2024 16:25
Function to add new user to Wordpress
/***********************
ADD USER
Useful script to programatically add an admin user to Wordpress if you dont have access to the admin, but do have access to the file system
***********************/
function wpb_admin_account()
{
$user = 'adminusername'; // Your username
$pass = 'adminpassword'; // Your password
$email = 'info@mydomain.co.uk'; // Your email
@amityweb
amityweb / update_all_wp_sites.sh
Last active March 15, 2024 08:53
Bash script to iterate through all Wordpress sites on RunCloud and update the core, plugins and themes
#!/bin/bash
# Change directory to /home
cd /home
# Iterate through all users directories
for user in * ; do
# For every webapp under the user directory
# Count wp-config files to make sure its Wordpess
@amityweb
amityweb / send-test-email-from-to.sh
Last active March 4, 2024 13:10
Simple bash script to send a test email from and to someone
subject="Email Test"
body="Hello World. This is an email test and I am including this paragraph of content to gain extra points if there is a substantial body message included. Thank you."
from="$1"
to="$2"
echo -e "To: Test <$to>\nFrom: Test <$from>\nSubject: $subject\n\n$body\n" | sendmail -f $from -t $to
# USAGE #
# NOTE: Some servers may need BASH not SH
# Directly from this URL:
# curl -s https://gist.githubusercontent.com/amityweb/e0d1288a719e3ec2f028ec76b551cd86/raw/ | sh -s from@domain.com to@domain.com
@amityweb
amityweb / GoogleSpreadsheet.html
Created March 1, 2024 11:30 — forked from terrywbrady/GoogleSpreadsheet.html
Sample HTML/JS to parse a Google Spreadsheet
<!doctype html>
<html>
<head>
<script src="//ajax.googleapis.com/ajax/libs/jquery/2.1.1/jquery.min.js"></script>
<script type="text/javascript">
var spData = null;
function doData(json) {
spData = json.feed.entry;
}
#!/bin/bash
DATE=$(date +%Y-%m-%d.%I-%M-%S)
echo $DATE - $1
<?php
// Replace variables with yours
// Run script with "php clone_wp.php"
// Requires All in One WP Migration Unlimited stored locally and path updated below - other backup plugins can be used with some teaks to WP CLI commands
// Requires All in One Backup file created source website and path and filename copied to that below
// iThemes securiy is used on source system to hide the admin URL
// WP Migrate DB is installed in source system to do find and replace of some settings, like a new Admin URL
// Check WP Config settings at bottom, you probably will want your own or none of these
@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 / 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 / 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"