Skip to content

Instantly share code, notes, and snippets.

@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')
@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 / wake_requests.py
Last active January 26, 2024 01:10
Reconstitute the "wake requests" data from `pmset -g log` into a more digestible form
#!python3
import re
import fileinput
import sys
import csv
# 2022-10-31 01:57:27 -0700 Wake Requests [*process=mDNSResponder request=Maintenance deltaSecs=7198 wakeAt=2022-10-31 03:57:25 info="upkeep wake"] [process=powerd request=TCPKATurnOff deltaSecs=316637 wakeAt=2022-11-03 17:54:44] [process=powerd request=UserWake deltaSecs=7850 wakeAt=2022-10-31 04:08:17 info="com.apple.alarm.user-visible-com.apple.CalendarNotification.EKTravelEngine.periodicRefreshTimer,14054"]
# 2024-01-18 18:18:15 -0800 Wake Requests [process=mDNSResponder request=Maintenance deltaSecs=2648 wakeAt=2024-01-18 19:02:23 info="DHCP lease renewal"] [*process=dasd request=SleepService deltaSecs=950 wakeAt=2024-01-18 18:34:05 info="com.apple.dasd:501:com.apple.proactive.ProactiveHarvesting.Harvest.DelayedBudgeted"] [process=powerd request=TCPKATurnOff deltaSecs=316858 wakeAt=2024-01-22 10:19:13] [process=powerd request=CSPNEvaluation deltaSecs=7253 wakeAt=2024-01-18 20:19:08] [process=powerd request=UserWake del
@dreness
dreness / logrc
Created November 6, 2022 09:13
logrc config for log(1) in macOS
# ~/.logrc config for log(1) in macOS
show:
--style compact
--color always
--last 4h
stream:
--info
--debug
@dreness
dreness / open_in_background_kinda.scpt
Created October 9, 2022 04:45
This is about as close as I can get to opening an app in the background from AppleScript.
-- can't get `open -g` to work...
tell application "System Events"
set prevApp to name of first process whose frontmost is true
end tell
tell application "mpv" to launch
tell application prevApp to activate
tell application "mpv"
@dreness
dreness / vuo-load-isf-synch.patch
Created October 2, 2022 01:25
In Vuo, load ISF modules synchronously
diff --git a/compiler/VuoCompiler.cc b/compiler/VuoCompiler.cc
index 6f281f04..2c7af1af 100644
--- a/compiler/VuoCompiler.cc
+++ b/compiler/VuoCompiler.cc
@@ -1731,7 +1731,7 @@ set<dispatch_group_t> VuoCompiler::Environment::compileModulesFromSourceCode(con
__block VuoModuleCompilationQueue::Item *queueItem = moduleCompilationQueue->next();
VUserLog("Compiling %s", queueItem->moduleKey.c_str());
- dispatch_async(queue, ^{
+ dispatch_sync(queue, ^{
@dreness
dreness / dns-checkup.md
Created July 25, 2022 07:44
What does macOS or iOS think about YOUR dns server?

Context

macOS (MacBookPro18,2) and iOS (iphone 11 pro) claims the DNS service in my router is flaky, occasionally displaying a dialog accusing me of being offline.

not-online-supposedly

(no, this isn't MaxMSP for iPhone - just a youtube video, settle down...)

This doesn't happen often, but when it does, it's always just after a wake or unlock. The problem is more than cosmetic, though - when it occurs, I am actaully offline on that device until it decides that I'm online again. Usually it doesn't take long, perhaps because I generally don't take this news quietly... OR, maybe recovery is hastened by a background heuristic tasked with mitigating and sharpening the other heuristics, taking a page from the generative adversarial network design... Maybe that sounds far fetched, but I would certainly like to opt into "shake to over-r

@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}"