Skip to content

Instantly share code, notes, and snippets.

@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}'
@apeckham
apeckham / gist:8e91d4bc66c32d6730db
Created August 4, 2015 19:18
aria2 on amazon linux
# download from http://sourceforge.net/projects/aria2/files/stable/aria2-1.19.0
sudo yum install gcc-g++ openssl-devel -y
tar xvfj aria2...tar.bz2
./configure
make -j$(nproc)
sudo make install
@apeckham
apeckham / delete.rb
Last active September 11, 2023 15:16
sidekiq: delete all jobs of a certain class/worker
Sidekiq::Stats.new.queues.each { |queue_name, _| Sidekiq::Queue.new(queue_name).each { |j| j.delete if j.klass == 'MyWorker' } }
@apeckham
apeckham / clean.sh
Created August 14, 2023 17:11
remove comments, spaces and duplicates from an ads.txt file
sed -e 's/ *#.*$//' -e 's/[ ,]*$//' -e 's/ *, */,/g' | sort | uniq
@apeckham
apeckham / gist:fb2aafc352d07033d915c8915418b078
Created July 19, 2023 02:07
decrypt credentials.yml.enc, etc, on stdin
echo 'your_encrypted_data' | ruby -ractive_support -ractive_support/message_encryptor -e "puts ActiveSupport::MessageEncryptor.new([ENV['DECRYPTION_KEY']].pack('H*'), cipher: 'aes-256-gcm').decrypt_and_verify(STDIN.read)"
@apeckham
apeckham / discord.yml
Created July 7, 2023 22:44
discord openapi spec
openapi: "3.0.0"
info:
title: "Discord API"
version: "1.0.0"
servers:
- url: "https://discord.com/api"
paths:
/oauth2/token:
post:
summary: "Refresh the access token"
@apeckham
apeckham / ack.clj
Created July 7, 2023 00:41
wiremock in clojure
(ns xxx-test
(:require [clojure.test :refer [deftest use-fixtures]]
[clj-http.client :as http]
[cheshire.core :as json])
(:import (com.github.tomakehurst.wiremock.core WireMockConfiguration)
(com.github.tomakehurst.wiremock WireMockServer)
(com.github.tomakehurst.wiremock.client WireMock)))
(def ^:dynamic *server* nil)