Skip to content

Instantly share code, notes, and snippets.

@apeckham
apeckham / gist:037b155c8abea13c7f56f54f5b3e86ea
Last active April 24, 2024 04:16
mount bucket on a remote instance and run filebrowser via port forward
gcloud compute instances stop "instance-xxx" --zone="zzz" --project="project-yyy"
gcloud beta compute instances set-scopes "instance-xxx" --scopes=storage-full --zone="zzz" --project="project-yyy"
gcloud compute instances start "instance-xxx" --zone="zzz" --project="project-yyy"
gcloud compute ssh --zone "zzz" "instance-xxx" --project "project-yyy" -- -L 8080:localhost:8080
# on the remote machine
gcloud init
export GCSFUSE_REPO=gcsfuse-`lsb_release -c -s`
@apeckham
apeckham / go.sh
Created April 23, 2024 07:10
Merge MKV video files with a random OPUS audio file, creating new video files with varied background audio
#!/bin/bash
set -euo pipefail
# Define directories
video_dir="./video"
audio_dir="./audio"
# Create an array of all opus files
mapfile -t music_files < <(find "$audio_dir" -type f -name '*.opus')
@apeckham
apeckham / gist:a97592b0d7a5337a985f512d41885871
Created April 21, 2024 07:33
open filtered mails with mutt
- Download Google Takeout/Gmail
- apt-get install mutt mb2md mboxgrep
- mb2md -s $PWD/all.mbox -d $PWD/maildir
- mboxgrep -m maildir -H -E "From:.+(a|b|c)@" -o out.mbox maildir
- mutt -f out.mbox
alias runlike="docker run --rm -v /var/run/docker.sock:/var/run/docker.sock assaflavie/runlike"
for i in $(sudo docker ps | awk '{print $1}' | tail -n +2); do runlike $i; done
@apeckham
apeckham / htmlcs_runner2.js
Created January 7, 2024 22:24
pa11y htmlcs runner that ignores certain rules for certain elements, using `data-htmlcs-ignore` attribute
"use strict";
const runner = (module.exports = {});
/**
* The Pa11y versions supported by this runner.
* @public
* @type {Array}
*/
runner.supports = "^6.0.0 || ^6.0.0-alpha || ^6.0.0-beta";
@apeckham
apeckham / import.py
Created December 8, 2023 10:18
firestore import in parallel
from google.cloud import firestore
from datetime import datetime
import json
import concurrent.futures
from tqdm import tqdm
import math
client = firestore.Client(database="xxxxx", project="xxxxx")
@apeckham
apeckham / gitlab-runner-priority.yaml
Last active November 26, 2023 01:35
gitlab runner on GKE autopilot
# Created new Autopilot cluster
# https://docs.gitlab.com/runner/install/kubernetes.html
# Create a runner at https://gitlab.com/groups/GROUP/-/runners
wget https://github.com/derailed/k9s/releases/download/v0.28.2/k9s_Linux_amd64.tar.gz
tar xvfz k9s*gz
gcloud container clusters get-credentials CLUSTER --region REGION --project PROJECT
helm repo add gitlab https://charts.gitlab.io
helm repo update gitlab
@apeckham
apeckham / del.sh
Created November 18, 2023 05:31
delete gitlab runners for a group
#!/usr/bin/env bash
set -ex
curl -s --fail --header "Private-Token: $GITLAB_TOKEN" "https://gitlab.com/api/v4/groups/$GITLAB_GROUP_ID/runners" | \
jq -r '.[] .id' | \
while read -r runner_id; do
echo "Deleting runner: $runner_id"
curl --fail --header "Private-Token: $GITLAB_TOKEN" --request DELETE "https://gitlab.com/api/v4/runners/${runner_id}"
done
@apeckham
apeckham / yt-subs.sh
Created November 18, 2023 04:50
download subs from a channel
#!/bin/bash
# yt-dlp --skip-download --write-auto-subs --convert-subs srt "https://www.youtube.com/@CHANNEL"
# run this script
# for f in out/*.txt; do echo "$f"; cat "$f"; echo -e "\n\n\n"; done | split -l 100000
output_directory="out"
if [ $# -eq 0 ]; then
echo "Usage: $0 file1.srt file2.srt ..."
@apeckham
apeckham / reflection-linter.sh
Created October 1, 2023 01:44
ci script for lein reflection check
#!/bin/bash
set -euf -o pipefail
get_warnings() {
lein check 2>&1 | grep "Reflection" || { echo "Error in reflection-linter.sh"; exit 1; }
}
parse_line() {
echo $1 | awk -F 'Reflection warning, |:| - ' '{print $2, $3, $4, $5}'