Skip to content

Instantly share code, notes, and snippets.

@lewayotte
lewayotte / filter_emails.script
Last active Apr 27, 2022
Automatically delete fake phishing emails from IT
View filter_emails.script
function filter_emails() {
/// 1day is the smallest increment
var threads = GmailApp.search("newer_than:1d");
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
Customer Email Template for BackupBuddy on Liquid Web
View backupbuddy-email-template-lw.php
<?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 Sep 1, 2019
WordPress database backups for EasyEngine v4
View WordPressDatabaseBackupsEE4.sh
#!/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 Apr 12, 2019
Let Britney Spears tell people when they're getting Toxic in Slack... /toxic #
View toxicity-meter.php
<?php
if ( empty( $_POST['command'] ) || $_POST['command'] != '/toxic' ) {
return false;
}
$command = $_POST['command'];
if ( empty( $_POST['text'] ) ) {
return false;
@lewayotte
lewayotte / slack.php
Created Feb 22, 2019
Mute specific Slack channels after hours, Unmute them during business hours...
View slack.php
<?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',
);
View Domain.sh
#!/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 Nov 14, 2018
Merriam Webster Word of the Day integration for Slack
View wotd.php
<?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 Oct 30, 2018
Arduino script used for lighting up the shoulders and headphones of the DJ Yonder cosplay...
View dj_yonder.ino
#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 Sep 8, 2019
Renew all the SSL certificates w/ Easy Engine
View RenewSSL.sh
#!/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 Sep 9, 2020
Automated EasyEngine WordPress Backups
View WordPressDatabaseBackups.sh
#!/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