Skip to content

Instantly share code, notes, and snippets.

View thomaswitt's full-sized avatar
💭
Investing pre-seed/seed into tech startups via @ExpediteVentures

Thomas Witt thomaswitt

💭
Investing pre-seed/seed into tech startups via @ExpediteVentures
View GitHub Profile
@thomaswitt
thomaswitt / quicktime-video-capture.sh
Created October 31, 2024 16:36
A script to capture frames from a QuickTime video
#!/bin/zsh
# Check if the video filename is provided as an argument
if [ $# -eq 0 ]; then
echo "Please provide the video filename as an argument."
exit 1
fi
video_filename=$1
@thomaswitt
thomaswitt / aws-ses-convert-credentials.rb
Created October 29, 2024 16:32
Convert an AWS secret access key to an SES SMTP password using Ruby (https://docs.aws.amazon.com/ses/latest/dg/smtp-credentials.html)
#!/usr/bin/ruby
require 'openssl'
require 'base64'
# Define a method to calculate HMAC SHA-256
def hmac_sha256(key, data)
OpenSSL::HMAC.digest('sha256', key, data)
end
@thomaswitt
thomaswitt / pdf-invoice-textract-and-rename
Created May 20, 2024 14:38
Take Invoice Scans from a Canon RS40 into a Hazel-Watched Folder, send them to AWS Textract and rename them into Date and Company
# Load Homebrew environment
eval "$(/opt/homebrew/bin/brew shellenv)"
# Variables
dir_path=$(dirname "$1")
base_filename=$(basename "$1")
log_file="${dir_path}/${base_filename}-error.log"
# Base64 encode the PDF file
base64_string=$(qpdf "$1" --pages . 1 -- - | base64)
@thomaswitt
thomaswitt / gist:95c0cc2a182c34aca991f188c3290c35
Created January 31, 2024 14:54
copy-ssh-key-to-all-aws-regions.sh
for region in $(aws ec2 describe-regions --all-regions | jq -r '.Regions | map(.RegionName) | join(" ")'); do echo $region; aws ec2 import-key-pair --region $region --key-name "SSH Key" --public-key-material fileb://<(head -n 1 ~/.ssh/authorized_keys) ; done
@thomaswitt
thomaswitt / personal-voice.c
Created January 19, 2024 10:30
Enable "Personal Voice" in a terminal to use 'say' with your own voice
/*
Compile via:
gcc -x objective-c -framework AVFoundation -framework Foundation personal-voice.c -o personal-voice
Run it in a terminal (make sure you authorized apps to use your personal voice)
*/
#import <AVFoundation/AVFoundation.h>
int main(){
[AVSpeechSynthesizer requestPersonalVoiceAuthorizationWithCompletionHandler:^(AVSpeechSynthesisPersonalVoiceAuthorizationStatus status){
@thomaswitt
thomaswitt / remove_unwanted_macos_agents.bash
Last active December 7, 2023 08:13
How to monitor and remove unwanted Launch Agents and Daemons in macOS (for .bash_profile)
# Remove unwanted helpers
process_agents() {
local directory=$1
shift
local agents=("$@")
local pattern=$(IFS=\|; echo "${agents[*]}")
shopt -s nullglob
for plist in "$directory"/{LaunchAgents,LaunchDaemons,PrivilegedHelperTools}/*; do
if ! echo "$plist" | egrep -q "$pattern"; then
if [[ $directory = /Library* ]]; then
@thomaswitt
thomaswitt / sonyTVRemote.sh
Created February 10, 2023 06:46
Turn Sony Bravia TV on and off – To be used with EventScripts (https://www.mousedown.net/software/EventScripts.html)
#!/usr/bin/env bash
# Turn Sony Bravia TV on and off
# To be used with EventScripts (https://www.mousedown.net/software/EventScripts.html)
# Get Auth Cookie Script from https://github.com/breunigs/bravia-auth-and-remote.git
IP="0.0.0.0"
MACADDR="00:00:00:00:00:00"
COOKIE="output from https://github.com/breunigs/bravia-auth-and-remote/blob/master/auth_cookie_examples/auth.sh"
OWN_SSID="MY_SSID"
@thomaswitt
thomaswitt / instagram-media-rename.bash
Created May 24, 2022 11:59
Take an Instagram data export, use metadata from media.json file, rename pictures and add EXIF/IPTC date and title, so they're ready to import in a photo management application like iPhoto
#!/bin/bash
if [[ ! -s "media.json" ]]; then
echo "*** ERROR: No media.json file in current directory"
exit 1
fi
mkdir result
echo -n "Processing "
aws --profile MY_PROFILE route53 list-resource-record-sets --hosted-zone-id '/hostedzone/ZOHE_ID' --output json | jq -jr '.ResourceRecordSets[] | "\(.Name) \t\(.TTL) \t\(.Type) \t\(.ResourceRecords[]?.Value)\n"'
@thomaswitt
thomaswitt / keybase.md
Created October 1, 2018 23:52
Keybase proof

Keybase proof

I hereby claim:

  • I am thomaswitt on github.
  • I am thomas_witt (https://keybase.io/thomas_witt) on keybase.
  • I have a public key ASDd6BzSb0TMTRzkv_0yh6Vy0yzZ0NRbzKk2J8ADRo2fcgo

To claim this, I am signing this object: