Skip to content

Instantly share code, notes, and snippets.

@lewayotte
lewayotte / jeopardy.ino
Created January 30, 2017 13:54
Arduino Jeopardy Buzzer Source Code
#include "musical_notes.h"
const int speakerPin = 3;
const int resetPin = 5;
const int player1 = 12;
const int player2 = 10;
const int player3 = 9;
const int pLight1 = 13;
const int pLight2 = 11;
const int pLight3 = 8;
@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 / cloudflare-dns.php
Last active March 17, 2022 09:32
Cloud Flare Automatic DNS Record Updater (PHP Script)
#!/usr/bin/php
<?php
/**
* Script used to update DNS records in Cloud Flare when server IP address changes.
* My use case is to run this script on startup, when I spin up a new Digital Ocean VPS but
* this could easily be used to update for dynamic DNS with a cronjob.
*
* Digital Ocean referral code: https://www.digitalocean.com/?refcode=3655e259ce29
*
* Requires PHP cURL
@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 / 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
@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 / 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 / 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 / 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',
);