Skip to content

Instantly share code, notes, and snippets.

@dreness
dreness / batch-transcribe-whisper.py
Created November 27, 2023 01:31
Batch audio transcription with whisper.cpp
#!python
"""
Configure the arguments to the process_directory call at the bottom.
Start additional instances of this script until your hw is full. If you
have multiple GPUs, you're responsible for setting CUDA_VISIBLE_DEVICES.
Using the 'medium' model, a V100 is mostly utilized with two instances.
This still has some bugs probably...
"""
@dreness
dreness / pidpersec.c
Last active November 20, 2023 11:42
pidpersec.c
/*
By Andre LaBranche, with extensive help from your friend and mine, ChatGPT.
In other words, assume this code eats babies.
This program attempts to be a reasonably inexpensive replacement for
/usr/bin/pidpersec.d in macOS, which still ships, but is broken by default
(i.e. when SIP is enabled).
compile with: clang -o pidpersec pidpersec.c
*/
@dreness
dreness / powermetrics_reader.py
Created November 20, 2023 11:40
Extract just one data point from powermetrics, suitable for graphing
#!python -u
import subprocess
import plistlib
import sys
"""
Print selected power metrics from /usr/bin/powermetrics at intervals, suitable
for graphing.
"""
@dreness
dreness / keynote_shape_to_svg.py
Created September 26, 2021 06:31
Convert Keynote shapes (built-in and user-generated) to SVG
#!/usr/bin/env python3
# Instructions:
# 1) install svgpathtools with the command:
# pip install svgpathtools
# 2) Run this script with no arguments:
# python keynote_shape_to_svg.py
from svgpathtools import parse_path, svg2paths, wsvg
import sqlite3
@dreness
dreness / plotframetimes.py
Last active June 28, 2023 01:29
Graphical and statistical analysis of frame rate in a video
#!/usr/bin/env python
# dre at mac dot com
# Graphical and statistical analysis of frame rate in a video
# Requires ffmpeg and gnuplot
# Example output:
# https://youbeill.in/scrap/Screen-Recording-2018-09-07-at-3.17.33-PM.mov.png
from sys import platform
from subprocess import check_output, DEVNULL
@dreness
dreness / iShapeParser.py
Created July 22, 2020 20:29
Export Keynote shapes to SVG
#!/usr/bin/env python3
# -*- coding: utf-8 -*-
import json # Native JSON Library
import argparse # Native Argument parser Library
# This is a slightly updated version of a script found on ye cyberwebs to
# add batch conversion support. Just don't specify an image ID to export the world.
# ==============================#
@dreness
dreness / thyme-snippets.md
Last active April 17, 2023 03:25
A bunch of Algodoo script snippets, extracted from public files

... is pretty great. If you somehow arrived here without knowing what Algodoo is, I implore you to go try it right now.

I had a hard time finding good examples of Thyme code on ye interwebs, and this document tries to remedy that. I downloaded a bunch of public compositions by the talented matto and then made a Jupyter notebook to extract interesting Thyme snippets from the project files (which are just zip archives after all). For this purpose, I define "interesting" as:

@dreness
dreness / VLCxcallbacker.py
Last active February 15, 2023 16:46
VLCxcallbacker: generate and host a web page of vlc-x-callback links to every video file in a given directory (for #VLC clients on iOS)
# -*- coding: utf-8 -*-
from __future__ import print_function, unicode_literals
import os
import socket
from datetime import datetime
from urllib import parse
from klein import Klein
from twisted.web.static import File
from twisted.python.filepath import FilePath
@dreness
dreness / transcribe.sh
Created February 11, 2023 08:29
Batch-transcribe audio files with whisper.cpp
#!/bin/zsh
#
# Batch transcribe audio files with whisper.cpp and ffmpeg
# This script wants:
# - ffmpeg installed and accessible via $PATH
# - whisper.cpp built locally:
# git clone https://github.com/ggerganov/whisper.cpp
# cd whisper.cpp
# make
# The compiled binary will be called 'main' in the whisper.cpp directory.
@dreness
dreness / animated-prompts.py
Last active January 5, 2023 19:03
stable diffusion animation prompts
#!/usr/bin/env python
import numpy as np
p1 = "portrait of a robot cyberpunk cat,"
p2 = "a cyborg steampunk dog,"
common = "octane render, 8k, high detail, global illumination, artstation, [out of frame]"
blendSteps = 300
f = open('prompts.txt', 'w')