Skip to content

Instantly share code, notes, and snippets.

cdzombak / com.dzombak.iperf3.plist
Created March 8, 2023 01:21
launchd job to run iperf3 server as a global daemon
View com.dzombak.iperf3.plist
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "">
<plist version="1.0">
cdzombak /
Last active January 20, 2023 14:31
telling if macOS screen is locked from bash script
#!/usr/bin/env bash
set -euo pipefail
# from
function screenIsLocked { [ "$(/usr/libexec/PlistBuddy -c "print :IOConsoleUsers:0:CGSSessionScreenIsLocked" /dev/stdin 2>/dev/null <<< "$(ioreg -n Root -d1 -a)")" = "true" ] && return 0 || return 1; }
function screenIsUnlocked { [ "$(/usr/libexec/PlistBuddy -c "print :IOConsoleUsers:0:CGSSessionScreenIsLocked" /dev/stdin 2>/dev/null <<< "$(ioreg -n Root -d1 -a)")" != "true" ] && return 0 || return 1; }
if screenIsLocked; then
echo "Screen locked"
cdzombak / rss-media-info
Created March 30, 2022 19:34
generate YAML header matter for MP3s attached to Jekyll posts
View rss-media-info
#!/usr/bin/env bash
if [ "$#" -ne 1 ]; then
echo "usage: rss-media-info path/to/attachment.mp3"
exit 1
read -r -d '' retv <<EOF
itunes_duration: '$(ffmpeg -i "$1" 2>&1 | grep "Duration:" | cut -d ' ' -f 4 | sed s/,//)'
episode_length: $(stat -f%z "$1")
View Quick Find in Things.scpt
tell application id "com.culturedcode.ThingsMac" to activate
tell application "System Events"
tell process "Things"
click menu item "New Things Window" of menu "File" of menu bar item "File" of menu bar 1
click menu item "Quick Find…" of menu "Edit" of menu bar item "Edit" of menu bar 1
end tell -- Things
end tell -- System Events
on error e number n
display dialog "Error " & n & ": " & e
cdzombak / Chrome Tab List to Things.scpt
Created March 15, 2021 17:55
Add browser tab lists as Things tasks
View Chrome Tab List to Things.scpt
set urlList to {}
set currentTab to 0
set the dateStamp to ((the current date) as string)
set noteTitle to "URL List from Chrome Tabs on " & the dateStamp
tell application "Google"
cdzombak / Sample Template
Last active March 15, 2021 17:48
Bear templates for Things projects
View Sample Template
# Sample Bear-Things Template
* item a
notes for item A
* item b
* item c
notes for item C
; comments/empty lines begin with `;`
a second line of notes for C
cdzombak / DeferredThings.scpt
Last active March 15, 2021 17:50
OmniFocus-style deferred tasks for Things
View DeferredThings.scpt
use AppleScript version "2.4" -- Yosemite (10.10) or later
on replace_chars(this_text, search_string, replacement_string)
set AppleScript's text item delimiters to the search_string
set the item_list to every text item of this_text
set AppleScript's text item delimiters to the replacement_string
set this_text to the item_list as string
set AppleScript's text item delimiters to ""
return this_text
end replace_chars
#!/usr/bin/env bash
set -u
if [ -e "/Volumes/Chris Dzombak's iPhone 11 co.brushedtype.doppler-ios" ] ; then
cdzombak / git-google
Last active February 2, 2021 18:15
Shell script adding `git google *` to git subcommands. Put this file, named `git-google`, somewhere in your $PATH, and be sure to make this file executable. Then, type "git google commit," for example, to open a Google search for "git commit tutorial." Hacky AF, but it does generally work.
View git-google
#!/usr/bin/env bash
set -e
urlencode() {
# from
# urlencode <string>
cdzombak / 10-banner
Last active September 26, 2019 16:31
automatic figlet based banner
View 10-banner
figlet -f big "$(hostname --fqdn)" | grep -v "^ *$"