Skip to content

Instantly share code, notes, and snippets.

View HeroCC's full-sized avatar

HeroCC

View GitHub Profile
@HeroCC
HeroCC / CopyCalendar.gs
Last active October 31, 2023 18:51
Google Calendar Sync and Copy Utilities written in Google Apps Scripts
/*
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
@HeroCC
HeroCC / TopGmailSenders.gs
Created July 6, 2023 15:39
Google Apps Script to scan through all GMail emails, and tally the number of unique senders and the size of their emails
function getEmailStatistics() {
var sheet = SpreadsheetApp.getActiveSpreadsheet().getActiveSheet();
var startRow = 2; // Starting row for data (excluding header)
var token = PropertiesService.getUserProperties().getProperty('TOKEN');
const query = "in:inbox";
var senderStats = JSON.parse(PropertiesService.getUserProperties().getProperty('SenderStats')) || {};
var processedCount = 0;
@HeroCC
HeroCC / code.gs
Created March 20, 2022 21:28
Trash & delete old promotions from Gmail inbox
// Go to https://script.google.com/home
// Create a new script, pase all of this, and click run
// The first run will ask you for permissions, and it may time-out before trashing all the emails, so run it again as necessary
// Optionally, create a time based trigger to run the script periodically (when first clearing my email I had it run every ~15 mins, but now once a day)
function purgeGmail() {
// Paste this query in your gmail search bar BEFORE running the script, and make sure nothing you need is matched
const search = "category:promotions older_than:1y -is:important -is:starred -has:attachment";
Logger.log("Removing messages matching: " + search);
@HeroCC
HeroCC / metricbeat-template.sh
Created August 5, 2020 14:57
Metricbeat Template auto-load
#!/bin/bash
set -euo pipefail
# This is a hack since Metricbeat doesn't support importing templates through LogStash, only a direct elastic connection
# This script checks to see if there is a newer version of Metricbeat avaliable, and if there is, runs it so the new template gets installed.
# This works around the issue I described here https://discuss.elastic.co/t/illegal-argument-exception-when-metricbeat-begins-new-index/243269
# You should only run this script on the machine running elasticsearch
# ALWAYS run this BEFORE using a new version of metricbeat
# Requires Docker (or podman) and jq. Tweak as you may.
@HeroCC
HeroCC / UMassCSScrape.py
Created May 14, 2020 21:32
Grabs all courses from the Course Listings, and formats them as CSV
#!/usr/bin/env python3
import csv
import requests
from bs4 import BeautifulSoup
# WHY DO THE <TD>s LACK CLOSING BRACKETS!?!
CS_TABLE_URL = "https://web.cs.umass.edu/csinfo/autogen/cmpscicoursesfull.html"
#!/bin/bash
echo "Opening $@"
nxmlink="$@"
/usr/bin/playonlinux --run "nxmhandler" "$nxmlink"
sleep 5
@HeroCC
HeroCC / noassign.user.js
Created November 20, 2019 04:15
NoAssign
// ==UserScript==
// @name NoAssign
// @namespace http://tampermonkey.net/
// @version 0.1
// @description WebAssign Auto Try-Again
// @author CC
// @match https://www.webassign.net/v4cgi/student/practice.tpl*
// @grant none
// ==/UserScript==
<VirtualHost *:80>
ServerName YOUR.DOMAIN.HERE
Redirect permanent / https://YOUR.DOMAIN.HERE/ # Redirect all nonsecure requests to use HTTPS
</VirtualHost>
<VirtualHost *:443>
ServerName YOUR.DOMAIN.HERE
SSLProxyEngine On
SSLCertificateFile /etc/letsencrypt/live/YOUR.DOMAIN.HERE/cert.pem
# From https://github.com/certbot/certbot/issues/2164
<IfModule mod_proxy.c> # If Proxy is installed
ProxyPass "/.well-known/acme-challenge" "!" # Do not proxy the acme verification
</IfModule>
Alias /.well-known/acme-challenge /var/www/html/.well-known/acme-challenge # Send all requests for the acme verification to this location
<Directory "/var/www/html/.well-known/acme-challenge"> # Allow any requests for it
Options None
AllowOverride None
Require all granted
AddDefaultCharset off
@HeroCC
HeroCC / post.bbc
Last active December 11, 2016 16:36
Sysadmin Forum Post
[CENTER][B][SIZE=7][IMG]https://cravatar.eu/helmhead/e6505ed0eacb4bbca6f6adc2b753f02a.png[/IMG][/SIZE]
[FONT=Courier New][SIZE=7]HeroCC's Super SysAdmin Shop[/SIZE][/FONT]
[SIZE=7][COLOR=#006600]OPEN[/COLOR][/SIZE][/B][/CENTER]
[IMG]https://ga-beacon.appspot.com/UA-83941472-1/spigotmc-thread?pixel&useReferer[/IMG]
Hello, [COLOR=#ff8000]SpigotMC[/COLOR]! I am [COLOR=#006600]HeroCC[/COLOR], a Minecraft Server admin for 3[I]+ years[/I], and Linux SysAdmin for 2.5[I]+ years[/I] from the USA. I love configuring and setting up anything and everything. Some of my services are below, but if you have any special requests please drop me a line! I often will do small jobs for Vouches if you are a reputable member. I have the most experience in Ubuntu Server / Debian, but I should be able to use any OS, including BSD and Windows! I prefer working on services and backend stuff rather than simple plugin/world configs, but can do both (just not build, you don't want to see that ;)). I'll even explain what I'm doing live if