Skip to content

Instantly share code, notes, and snippets.

View chtzvt's full-sized avatar
🧿
If the fool would persist in his folly he would become wise.

Charlton Trezevant chtzvt

🧿
If the fool would persist in his folly he would become wise.
View GitHub Profile
@chtzvt
chtzvt / iptables_rules.sh
Last active September 26, 2022 16:00
AnyConnect transparent VPN bridge/router
SYSTEM_LAN_IFACE="eth0"
VPN_CLIENT_IFACE="tun0"
DEST_IP="10.173.204.63"
FWDED_PORT="22"
SOURCE_NET_WHITELIST="10.0.2.0/24,10.0.3.0/24"
get_iface_ip() {
IP=`ip addr show $1 | grep -o "inet [0-9]*\.[0-9]*\.[0-9]*\.[0-9]*" | grep -o "[0-9]*\.[0-9]*\.[0-9]*\.[0-9]*"`
if [[ $? -ne 0 ]];
then
@chtzvt
chtzvt / exif_fix_first_pass.rb
Last active September 16, 2022 18:00
Fixing missing/clobbered EXIF data on a portion of my photos library
# frozen_string_literal: true
require 'exif'
require 'fileutils'
require 'shellwords'
formats = ['.jpg', '.png', '.jpeg', '.mov', '.mp4', '.m4v']
def update_exif(year, month, day, f)
f = f.strip
package main
import (
"sync"
"net/http"
"net/url"
"strings"
"time"
"fmt"
"io/ioutil"
@chtzvt
chtzvt / webpgen.sh
Created April 4, 2022 13:39
Generate corresponding .webp versions of images hosted on cdn.ctis.me
#!/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
#!/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
#!/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)
@chtzvt
chtzvt / nc_fetcher.rb
Last active January 25, 2022 19:58
Nextcloud Backer-Upper for Calendar/Contacts/Todo lists, with a dash of Git
#!/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.
#
@chtzvt
chtzvt / problem-v01i01.md
Last active December 29, 2021 02:29
Esoteric Programming Challenge #1: "A to Z" :: Vol. 1, Issue #1 in the "Daniel Fucking Nerd-Sniped Me" Series
@chtzvt
chtzvt / 03-ntp.conf
Created November 1, 2021 16:05
Tools I built to manage & support captive NTP internally
# 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
@chtzvt
chtzvt / cloudflare_ddns.sh
Created November 1, 2021 16:02
CloudFlare API Dynamic DNS Updater
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' \