Skip to content

Instantly share code, notes, and snippets.

@lewayotte
lewayotte / filter_emails.script
Last active November 9, 2023 19:04
Automatically delete fake phishing emails from IT
function filter_emails() {
/// 1day is the smallest increment
var threads = GmailApp.search("newer_than:1d in:inbox");
for (var i = 0; i < threads.length; i++) {
// get all messages in a given thread
var messages = threads[i].getMessages();
for (var j = 0; j < messages.length; j++) {
@lewayotte
lewayotte / backupbuddy-email-template-lw.php
Last active May 7, 2019 19:29
Customer Email Template for BackupBuddy on Liquid Web
<?php
/**
* Email Template
*
* @package BackupBuddy
*/
?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
@lewayotte
lewayotte / WordPressDatabaseBackupsEE4.sh
Last active September 1, 2019 02:08
WordPress database backups for EasyEngine v4
#!/bin/bash
if [ ! -d /var/backups/wpdb/ ]; then
mkdir -p /var/backups/wpdb/
fi
for x in `/usr/local/bin/ee site list --format=text | sed -r "s/\x1B\[([0-9]{1,2}(;[0-9]{1,2})?)?[mGK]//g"`; do
cd /opt/easyengine/sites/$x/app/htdoc
/usr/bin/wp --allow-root db export --add-drop-table /var/backups/wpdb/$x.sql
done
@lewayotte
lewayotte / toxicity-meter.php
Created April 12, 2019 16:43
Let Britney Spears tell people when they're getting Toxic in Slack... /toxic #
<?php
if ( empty( $_POST['command'] ) || $_POST['command'] != '/toxic' ) {
return false;
}
$command = $_POST['command'];
if ( empty( $_POST['text'] ) ) {
return false;
@lewayotte
lewayotte / slack.php
Created February 22, 2019 15:24
Mute specific Slack channels after hours, Unmute them during business hours...
<?php
// cronjob:
// 0 8 * * * /usr/bin/php /path/to/file.php unmute > /dev/null 2>&1
// 0 18 * * * /usr/bin/php /path/to/file.php mute > /dev/null 2>&1
if ( 1 < $argc ) {
$channels = array(
'CHANNEL_ID',
);
@lewayotte
lewayotte / Domain.sh
Last active September 25, 2020 18:37
#!/bin/bash
/usr/local/bin/aws ec2 describe-tags --filters "Name=resource-id,Values=`wget -q -O - http://169.254.169.254/latest/meta-data/instance-id`" "Name=key,Values=domain" | grep Value | tr -d ' ' | cut -f2 -d: | tr -d '"' | tr -d ','
#/usr/local/bin/aws ec2 describe-tags --filters "Name=resource-id,Values=`wget -q -O - http://169.254.169.254/latest/meta-data/instance-id`" | grep -b1 domain | grep Value | tr -d ' ' | cut -f2 -d: | tr -d '"' | tr -d ','
@lewayotte
lewayotte / wotd.php
Created November 14, 2018 01:38
Merriam Webster Word of the Day integration for Slack
<?php
$wotd = get_wotd();
if ( !empty( $wotd ) ) {
send_to_slack( $wotd );
}
function get_wotd() {
$rss = new DOMDocument();
$rss->load( 'https://www.merriam-webster.com/wotd/feed/rss2' );
@lewayotte
lewayotte / dj_yonder.ino
Last active October 30, 2018 21:12
Arduino script used for lighting up the shoulders and headphones of the DJ Yonder cosplay...
#include <FastLED.h>
//Using these LEDs: https://amzn.to/2qkaduF
//INVOLT WS2812B LED Strip Individually Addressable 60LED/M 3.2FT 1M, No Waterproof Flexible for DIY Decoration, DC 5V with Smart IC Chip Built-in Self Adhesive
#define LED_PIN 3 //Using pin 3 on an Adafruit Pro Trinket - 3V 12MHz: https://amzn.to/2yKQMQp
#define NUM_LEDS 52 //Didn't use all the LEDs in the strip
#define LED_TYPE WS2812B
#define COLOR_ORDER GRB
#define BRIGHTNESS 255
@lewayotte
lewayotte / RenewSSL.sh
Last active September 8, 2019 12:26
Renew all the SSL certificates w/ Easy Engine
#!/bin/bash
for x in `/usr/local/bin/ee site list | sed -r "s/\x1B\[([0-9]{1,2}(;[0-9]{1,2})?)?[mGK]//g"`; do
/usr/local/bin/ee site update $x --le=renew
done
/usr/sbin/service nginx reload
@lewayotte
lewayotte / WordPressDatabaseBackups.sh
Last active September 9, 2020 16:59
Automated EasyEngine WordPress Backups
#!/bin/bash
if [ ! -d /var/backups/wpdb/ ]; then
mkdir -p /var/backups/wpdb/
fi
for x in `/usr/local/bin/wo site list | sed -r "s/\x1B\[([0-9]{1,2}(;[0-9]{1,2})?)?[mGK]//g"`; do
cd /var/www/$x/htdocs/
/usr/local/bin/wp --allow-root db export --add-drop-table /var/backups/wpdb/$x.sql
done