Skip to content

Instantly share code, notes, and snippets.

@dreness
dreness / yt-over-here.sh
Last active July 11, 2022 03:41
One-liner to open the most recent video in your YouTube watch history
# This is for macOS, and requires that you have yt-dlp and Chrome installed.
# yt-dlp gains easy access to your youtube profile by borrowing cookies from
# Chrome, so you'll need to have logged into youtube with Chrome. The yt-dlp
# command will return the URL to the video at the top of your history, which
# can then be opened using your tool of choice - in this case, I pass it to
# 'open' to use the default browser.
# I use this primarily when I am (or was) watching a YT video on my
# Internet telephone, but then I want to pick it up on the mac.
# This technique is faster for me than anything done from the phone, even if
@dreness
dreness / fix-synalize-it.md
Last active August 14, 2022 14:32
A somewhat brutal repair of Synalize It! Pro for macOS, which is broken by linking against the system-provided python which no longer exists.

check current python linkage

% otool -L /Applications/Synalyze\ It\!\ Pro.app/Contents/MacOS/Synalyze\ It\!\ Pro | grep Python
	/System/Library/Frameworks/Python.framework/Versions/2.7/Python (compatibility version 2.7.0, current version 2.7.16)

Download and install Python2.7.16 for macOS. By default this lands in /Library/Frameworks/Python.framework/Versions/2.7

Make a copy of the Synalize It! Pro app bundle, e.g. to your desktop.

cp -R /Applications/Synalyze\ It\!\ Pro.app ~/Desktop
@dreness
dreness / gist:3879922517d6403e7f0e6b76be1a4275
Created March 15, 2022 06:28
run tcpdump to capture chrome activity
#!/bin/zsh
# This script uses apple-specific features of tcpdump
INT=en0
PIDS=($(pgrep Chrome | tr '\n' ' '))
PID_FILTER=$(echo pid=${(j: or pid=:)PIDS})
FILTER="-Q \"$(echo -n "if=${INT} and ("${PID_FILTER}))\""
OUT=$(mktemp)
CMD="/usr/bin/sudo /usr/sbin/tcpdump -i pktap,${INT} -s0 -w ${OUT} -nk ${FILTER}"
echo "Capturing to ${OUT} with command:\n${CMD}"
#!/bin/zsh
TARGET=$1
# to be used as an egrep pattern
SYMS='getprogname|NSGetArgv|NSGetArgc|optarg|optind|getopt|getopt_long'
sudo find ${TARGET} -type f -perm +111 \! -name "*.dylib" | \
while read f ; do
sudo nm -u ${f} 2> /dev/null | \
@dreness
dreness / tpt_the_pie_is_a_lie_maybe.md
Last active December 28, 2021 05:40
The Powder Toy build produces malformed executable?

Working out of this repo: [email protected]:The-Powder-Toy/The-Powder-Toy.git

(base) andre@boom The-Powder-Toy % git remote -v
origin	[email protected]:The-Powder-Toy/The-Powder-Toy.git (fetch)
origin	[email protected]:The-Powder-Toy/The-Powder-Toy.git (push)

I had to change the SDL includes from two-level style to one-level style.

@dreness
dreness / longtone_finder.py
Last active April 9, 2024 12:58
Extract "long notes" from audio, optimized for speech.
import parselmouth
# import IPython
import os
import sys
import pandas as pd
# Feed me audio files as command line arguments
# uncomment this to stop pandas from being so coy in its repr()s
# pd.set_option("display.max_rows", None, "display.max_columns", None)
@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 / xplot.rb
Created September 11, 2021 20:50
A slight tweak to sra's xplot formula for homebrew
# Based on https://git.hactrn.net/sra/Homebrew-Tap/raw/master/xplot.rb
# Updated by dre for macOS 11.5.3
# - prepended `autoconf` and `autoupdate`, which are really living up
# to their names. The *newest* part of xplot is from 1996.
# Documentation: https://docs.brew.sh/Formula-Cookbook
# http://www.rubydoc.info/github/Homebrew/brew/master/Formula
class Xplot < Formula
desc "xplot"
homepage "http://www.xplot.org"
@dreness
dreness / logfreq.sh
Created September 7, 2021 19:02
macOS log haystack needler
#!/bin/zsh
# set -x
# Reference: https://dreness.com/blog/archives/155773
usage() {
print "$1: Use histograms to explore os_log data.
Usage: $1 [-k logKey] [-l logtime] [-h] [predicate]
-k Calculate frequency of unique values of this log attribute.
@dreness
dreness / basic_compute.xml
Created July 28, 2021 00:30
basic compute kernel Kodelife project XML
<?xml version='1.0' encoding='UTF-8'?>
<klxml v='16' a='MTL'>
<document><properties><creator><![CDATA[net.hexler.KodeLife]]></creator><creatorVersion><![CDATA[1.0.1.153]]></creatorVersion><versionMajor>1</versionMajor><versionMinor>1</versionMinor><versionPatch>1</versionPatch><author><![CDATA[]]></author><comment><![CDATA[]]></comment><enabled>1</enabled><size><x>500</x><y>500</y></size><clearColor><x>0</x><y>0</y><z>0</z><w>1</w></clearColor><selectedRenderPassIndex>1</selectedRenderPassIndex><selectedKontrolPanelIndex>0</selectedKontrolPanelIndex><uiExpandedPreviewDocument>0</uiExpandedPreviewDocument><uiExpandedPreviewRenderPass>1</uiExpandedPreviewRenderPass><uiExpandedProperties>1</uiExpandedProperties></properties><params><uiExpanded>1</uiExpanded><param type='CLOCK'><displayName><![CDATA[Clock]]></displayName><variableName><![CDATA[time]]></variableName><uiExpanded>0</uiExpanded><running>1</running><direction>1</direction><speed>1</speed><loop>0</loop><loopStart>0</loopStart><loopEnd>6.28319</loopEnd>