Skip to content

Instantly share code, notes, and snippets.

View cdzombak's full-sized avatar

Chris Dzombak cdzombak

View GitHub Profile
@cdzombak
cdzombak / com.dzombak.iperf3.plist
Created March 8, 2023 01:21
launchd job to run iperf3 server as a global daemon
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
<plist version="1.0">
<dict>
<key>GroupName</key>
<string>staff</string>
<key>InitGroups</key>
<true/>
<key>Label</key>
<string>com.dzombak.iperf3</string>
@cdzombak
cdzombak / screenlocked.sh
Last active January 20, 2023 14:31
telling if macOS screen is locked from bash script
#!/usr/bin/env bash
set -euo pipefail
# from https://stackoverflow.com/a/66723000
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
cdzombak / rss-media-info
Created March 30, 2022 19:34
generate YAML header matter for MP3s attached to Jekyll posts
#!/usr/bin/env bash
if [ "$#" -ne 1 ]; then
echo "usage: rss-media-info path/to/attachment.mp3"
exit 1
fi
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")
try
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
cdzombak / Chrome Tab List to Things.scpt
Created March 15, 2021 17:55
Add browser tab lists as Things tasks
-- RESET VALUES
set urlList to {}
set currentTab to 0
-- SET DATE STAMP
set the dateStamp to ((the current date) as string)
set noteTitle to "URL List from Chrome Tabs on " & the dateStamp
-- PROCESS TABS OF FRONTMOST CHROME WINDOW
tell application "Google Chrome.app"
@cdzombak
cdzombak / Sample Template
Last active March 15, 2021 17:48
Bear templates for Things projects
# 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
cdzombak / DeferredThings.scpt
Last active December 13, 2023 04:05
OmniFocus-style deferred tasks for Things
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
WHITE='\033[0;37m'
RED='\033[0;31m'
YELLOW='\033[0;33m'
GREEN='\033[0;32m'
NC='\033[0m'
if [ -e "/Volumes/Chris Dzombak's iPhone 11 co.brushedtype.doppler-ios" ] ; then
@cdzombak
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.
#!/usr/bin/env bash
set -e
urlencode() {
# from https://gist.github.com/cdown/1163649
# urlencode <string>
old_lc_collate=$LC_COLLATE
LC_COLLATE=C
@cdzombak
cdzombak / 10-banner
Last active September 26, 2019 16:31
automatic figlet based banner
#!/bin/sh
figlet -f big "$(hostname --fqdn)" | grep -v "^ *$"