Skip to content

Instantly share code, notes, and snippets.

View carlbennett's full-sized avatar
💙
Fedora Linux

Carl Bennett carlbennett

💙
Fedora Linux
View GitHub Profile
@carlbennett
carlbennett / lunch.sh
Last active July 10, 2017 16:28
Lunch Location Randomizer
#!/bin/bash
TODAY=$(date +%Y-%m-%d)
LIST=$(sed -e 's/$/\r/g' lunch.txt | perl -MURI::Escape -ne 'print uri_escape($_)')
curl -s \
-d "list=${LIST}" \
-d "format=plain" \
-d "rnd=date.${TODAY}" \
"https://www.random.org/lists/?mode=advanced"
@carlbennett
carlbennett / dtconvert.php
Created April 23, 2018 15:09
Usage: ./dtconvert.php <timestamp> <to-timezone>
#!/usr/bin/env php
<?php /* vim: set expandtab tabstop=4 shiftwidth=4 softtabstop=4: */
if (php_sapi_name() !== "cli") {
http_response_code(500);
exit("Must be ran by php-cli");
}
if ($argc < 3) {
exit(
#!/usr/bin/env bash
# Credit: https://superuser.com/a/224263
# OpenSSL requires the port number.
SERVER=$1
DELAY=0.2
ciphers=$(openssl ciphers 'ALL:eNULL' | sed -e 's/:/ /g')
echo Obtaining cipher list from $(openssl version).
@carlbennett
carlbennett / system-update.sh
Created July 21, 2018 23:30
Updates the system using either dnf or yum (whichever's available)
#!/bin/sh
/usr/bin/yum --version | /usr/bin/grep dnf >/dev/null 2>&1
[ $? -eq 0 ] && DNF=1 || DNF=0
if [ $DNF -eq 0 ]; then
/usr/bin/yum update -y
else
/usr/bin/dnf update -y --refresh
fi
@carlbennett
carlbennett / discordwebhookrelay.service
Created October 13, 2018 23:58
Discord Webhook Relay for Grafana (deprecated now that Grafana has this built-in)
[Unit]
Description=webhookRelay.js - a Slack to Discord webhook relay for Grafana
Documentation=https://gist.github.com/brussell98/a865ecc2284e958226596accc852ee28
After=network.target
[Service]
Type=simple
User=nobody
ExecStart=/usr/bin/node /opt/discordWebhookRelay/webhookRelay.js
Restart=on-failure
@carlbennett
carlbennett / email-to-discord.php
Last active September 27, 2019 03:30
A php script that takes an email formatted as a POST form and turns it into a Discord webhook
<?php
namespace CarlBennett;
use \DateTime;
use \DateTimeZone;
use \Exception;
use \StdClass;
const GRAVATAR_BASE = 'https://secure.gravatar.com/avatar/';
# Enhanced Network Hosts File
# Authored by Carl Bennett <https://carlbennett.me>
#
# How To <https://support.rackspace.com/how-to/modify-your-hosts-file/>
# (I do not endorse Rackspace, the document is simply of decent quality.)
#
# This file is hereby released under the MIT license. A copy of the license can
# be found at: <https://opensource.org/licenses/MIT>
#
@carlbennett
carlbennett / motd.sh
Last active March 5, 2020 05:29
Prints a dynamic message of the day upon login. To install, copy the file to the `/etc/profile.d/` directory.
#!/bin/bash
# vim: set expandtab tabstop=4 shiftwidth=4 softtabstop=4:
# Only display motd if tty and not sudoing as root
[ "$PS1" ] && [ "$EUID" -ne 0 ] || return 0
# Run the entire function in its own subshell.
#
# The local keyword in functions prevents inheriting values.
# The subshell prevents exporting them.
@carlbennett
carlbennett / certgen.sh
Last active May 27, 2020 03:05
Place this file in its own directory and run it. It generates the certificate files in its current directory.
#!/usr/bin/env bash
# vim: set colorcolumn=:
set -e -o pipefail
[ -z "${TERM}" ] && echo 'Error: TERM not set, this script is exclusively interactive!' 1>&2 && exit 1
echo -e '\e[1;32mCertificate Generator\e[0m'
HOSTNAMES=()
@carlbennett
carlbennett / Dark UPS Tracker.css
Last active August 14, 2020 09:35
Dark UPS Tracker
/**
* Dark UPS Tracker v0.1
* <https://gist.github.com/carlbennett/5569ae5c5217eb51f1dbd0d5ff848cfa>
*
* Written by Carl Bennett <carl@carlbennett.me>
* You are hereby free to use this code under the MIT license.
* 14 August 2020
*
* Official UPS Orange Color: #f7be00
*/