Skip to content

Instantly share code, notes, and snippets.

@apeckham
apeckham / gist:2db891e45d0649eda10748c9d22be4ca
Created August 30, 2024 17:50
custom appsmith component for wavesurfer audio player
import WaveSurfer from 'https://cdn.jsdelivr.net/npm/wavesurfer.js@7/dist/wavesurfer.esm.js';
appsmith.onReady(() => {
const wavesurfer = WaveSurfer.create({
container: '#root',
waveColor: '#4F4A85',
progressColor: '#383351',
url: '[url with cors setup]',
});
document.getElementById('startButton').addEventListener('click', () => {
@apeckham
apeckham / reverse.sh
Created August 10, 2024 23:29
ffmpeg reverse video in memory-friendly chunks
#!/bin/bash
set -ex
# Input file name
input_file="input.mp4"
# Output file name
output_file="output.mp4"
# Duration of each segment in seconds (5 minutes)
@apeckham
apeckham / sum.sh
Created July 27, 2024 22:40
sum of PDF page count on mac
find . -maxdepth 1 -name "*.pdf" -exec mdls -name kMDItemNumberOfPages {} \; | awk '/kMDItemNumberOfPages/ {sum += $3} END {print sum}'
@apeckham
apeckham / extract.py
Created July 18, 2024 06:44
extract contents of a HAR file to disk, and request the URL if the content is not in the HAR
import json
import base64
import os
import sys
from urllib.parse import urlparse
import requests
def fetch_url(url):
try:
response = requests.get(url, timeout=10)
@apeckham
apeckham / claude.js
Created July 11, 2024 05:20
claude delete all conversations
async function deleteAllConversations() {
const organizationId = 'XXXXXXX';
const conversations = await fetch(`https://claude.ai/api/organizations/${organizationId}/chat_conversations`)
.then(response => response.json());
console.log(`Found ${conversations.length} conversations to delete.`);
for (const conversation of conversations) {
const deleteUrl = `https://claude.ai/api/organizations/${organizationId}/chat_conversations/${conversation.uuid}`;
@apeckham
apeckham / ffmpeg.sh
Created June 3, 2024 04:51
slow all webm's to 69%
for i in *.webm; do [ ! -f "${i%.webm}.slow.mp4" ] && ffmpeg -i "$i" -vf "setpts=1/0.69*PTS" -af "atempo=0.69" -c:v libx264 -preset ultrafast -crf 23 -c:a aac -b:a 128k "${i%.webm}.slow.mp4"; done
@apeckham
apeckham / r.sh
Created May 5, 2024 06:21
100 random size images
for i in {1..100}; do
curl -L -o $i.jpg $(ruby -e 'puts "https://picsum.photos/" + (rand(1..100) * 10).to_s + "/" + (rand(1..100) * 10).to_s')
done
@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