Skip to content

Instantly share code, notes, and snippets.

Avatar
🌻
‍To create a little flower is the labor of ages.

Charlton Trezevant ctrezevant

🌻
‍To create a little flower is the labor of ages.
View GitHub Profile
@ctrezevant
ctrezevant / webpgen.sh
Created Apr 4, 2022
Generate corresponding .webp versions of images hosted on cdn.ctis.me
View webpgen.sh
#!/usr/bin/env bash
for f in `find . -type f | grep -v "webp"`
do
fname=`basename $f | rev | cut -d . -f2 | rev`
fext=`basename $f | rev | cut -d . -f1 | rev`
fdir=`dirname $f`
target="$fdir/$fname.webp"
# Skip if target already exists
View samsung_oui41_remove_bloat.rb
#!/usr/bin/env ruby
bloatlist = <<-APPS
com.samsung.android.app.galaxyfinder
com.samsung.android.smartswitchassistant
com.google.android.youtube
com.samsung.android.themestore
com.sec.android.app.chromecustomizations
com.google.android.googlequicksearchbox
com.osp.app.signin
View genesis.rb
#!/usr/bin/env ruby
require 'fileutils'
require 'json'
# Depends on rubyzip
require 'zip'
Dir['./*'].each do |f|
match = /(Volume. )([0-9]+[.0-9]*)( Chapter. )([0-9]+[.0-9]*)/.match(f)
@ctrezevant
ctrezevant / nc_fetcher.rb
Last active Jan 25, 2022
Nextcloud Backer-Upper for Calendar/Contacts/Todo lists, with a dash of Git
View nc_fetcher.rb
#!/usr/bin/env ruby
# frozen_string_literal: true
# NextCloud Backer-Upper
# Charlton Trezevant, 2021
# This script is provided as-is, under the MIT license.
#
# The purpose of this script is to automatically fetch backup exports of my contacts,
# calendars, and todo lists from Nextcloud.
#
@ctrezevant
ctrezevant / problem-v01i01.md
Last active Dec 29, 2021
Esoteric Programming Challenge #1: "A to Z" :: Vol. 1, Issue #1 in the "Daniel Fucking Nerd-Sniped Me" Series
View problem-v01i01.md
@ctrezevant
ctrezevant / 03-ntp.conf
Created Nov 1, 2021
Tools I built to manage & support captive NTP internally
View 03-ntp.conf
# NTP Server Overrides
# https://gist.github.com/mutin-sa/eea1c396b1e610a2da1e5550d94b0453
addn-hosts=/etc/ntp_upstream.hosts
cname=time.google.com,time.nhq
cname=time1.google.com,time.nhq
cname=time2.google.com,time.nhq
cname=time3.google.com,time.nhq
cname=time4.google.com,time.nhq
@ctrezevant
ctrezevant / cloudflare_ddns.sh
Created Nov 1, 2021
CloudFlare API Dynamic DNS Updater
View cloudflare_ddns.sh
api_key="your_api_key"
zone_id="some_string"
record_id="some_string"
zone_name="example.com"
record_name="dynamic-record.example.com"
record_content=`curl -s http://whatismyip.akamai.com/`
curl_result=$(curl "https://api.cloudflare.com/client/v4/zones/$zone_id/dns_records/$record_id" \
-X PUT -H 'NOPE Dynamic DNS Client/1.0' \
@ctrezevant
ctrezevant / qemu_boot_tiger.sh
Created Nov 1, 2021
Boot Mac OS X Tiger in QEMU with full networking support
View qemu_boot_tiger.sh
HDD="/path/to/MacOS_Tiger_HDD.qcow2"
CDROM="/path/to/Mac_OS_X_10.4_Tiger_Installer.iso"
IFACE="your-parent-nic-name-here"
IFACEMAC="FC:FC:48:c0:ff:ee"
TAP="tap0"
NETBKND="tigernet0"
NICMODEL="rtl8139"
View wireguard_healthcheck.sh
#!/bin/bash
STATUS_FILE='/tmp/.wg_fixer_state_unhealthy'
REBOOT_MINIMUM_UPTIME='300' # 5 minutes
SYSTEM_UPTIME=`cat /proc/uptime | cut -d ' ' -f1 | cut -d '.' -f1`
systemctl status wg-quick@wg0 2>&1 >/dev/null
WG_QUICK_STATUS=$?
WG_PEERS=`wg | wc -l`
@ctrezevant
ctrezevant / grandstream_ddns.sh
Created Nov 1, 2021
GrandStream HT801/HT802 dynamic DNS autoupdater.
View grandstream_ddns.sh
#!/bin/bash
EMAIL="you@example.com"
GS_HOSTNAME="your-grandstream-hostname"
STATUS_FILE='/tmp/.voip_ip_stat'
touch $STATUS_FILE
timeout 3 bash -c "printf '@' | telnet -e \@ $GS_HOSTNAME 22" 2>&1 >/dev/null
host_alive=$?