Encrypted Disk Images
- Start
Disk Utility
- Choose
File -> New Image -> Blank Image
- Pick a maximum
Size
- take care with this, as your disk image won’t be able to grow larger than the value you set Format
should beAPFS (Case-sensitive)
unless you’re running a spinning disk drive, in which case pickMac OS Extended (Case-sensitive, Journaled)
Encryption
should be256-bit AES
unless that’s too slow for youImage Format
should be eithersparse bundle disk image
orsparse disk image
.- Use
sparse disk image
if you want to create a single, large, encrypted file - Use
sparse bundle disk image
if you want to create a lot of smaller, encrypted files - useful if you want to sync this image using something like OneDrive/Dropbox/whatever.
- Use
– via Apple Support and Eclectic Light Company
Format external drive as APFS
Issue: When trying to reformat a drive in Disk Utility, APFS is missing from the formats list, with only Mac OS Extended, MS-DOS and ExFAT present.
Solution: View -> Show All Devices
. Then, select the disk (and not the volume) you want to format, pick the GUID Partition Map
scheme, and you’ll find that APFS becomes available.
Check DNS caching duration for a domain
Run dig TYPE <domain>
in a console, and make note of the number to the left of IN - that’s the cache duration, in seconds.
– via Ciberciti
Flush DNS cache
sudo dscacheutil -flushcache
sudo killall -HUP mDNSResponder
– via Mackeeper Blog
Fix that 🤬 issue when I can’t type anything and I can’t focus any apps either
It seems to appear when I have an OS update pending. Rebooting doesn’t work, even when long pressing the power button. Here’s what worked:
- Open
Finder
- Use that to open
Activity Monitor
- Notice that I can’t focus on anything
- It may help to also start
iTerm2
? Not sure - Quit
Activity Monitor
- Start it again.
- Notice I can focus on things
- Kill
mds_stores
- Kill another
update
process, can’t remember the name - That seemed to work last time.
Automatically eject external drives when Mac goes to sleep
I’ve used BetterTouchTool to schedule an action to run Before Mac Goes To Sleep
. It’s running an Execute Shell Script / Task
with the following content:
VOLUME_NAME="DataData"
VOLUME_ID=$(diskutil info "$VOLUME_NAME" | grep 'Device Node:' | awk '{print $3}')
if [ ! -z "$VOLUME_ID" ]; then
diskutil eject "$VOLUME_ID"
echo "Successfully ejected $VOLUME_NAME"
else
echo "Drive not found: $VOLUME_NAME"
fi
– some info via Stack Exchange and Folivora Community
Check swap file size and memory usage
sysctl vm.swapusage
Tools
iCloud
Never trust that it will upload any file you put in the iCloud folder(s). It will silently fail to upload some files, and you’ll only notice when you try to access them from another device, which is always fun. Verify that the files are actually uploaded.
If you notice it’s not uploading files, kill the bird
process, and it will restart and start uploading again. Hopefully.
Once again, never trust the thing to upload files you need on other devices.
Safari
Disable Narrow Tabs in Safari 14
- Make sure you have enabled website icons, via Preferences -> Tabs -> Show website icons in tabs
- Quit Safari
- Allow Full Disk Access for Terminal, via System Preferences -> Security & Privacy -> Privacy -> Full Disk Access
- Open Terminal and run
defaults write com.apple.Safari IncludeInternalDebugMenu 1
- Start Safari
- Open the new Debug menu and unselect Debug -> Tab Features -> Narrow Tabs
- Enjoy the old, sane tab behavior
- (Optional) You can disable the menu afterwards by running
defaults write com.apple.Safari IncludeInternalDebugMenu 0
in Terminal. - (Recommended) Remove Full Disk Access for Terminal via System Preferences -> Security & Privacy -> Privacy -> Full Disk Access
– via Reddit and Yuriy Shiryaev
Unarchive a Safari webarchive file
Use textutil
.
textutil -convert html <filename>
– via Apple StackExchange
Whitelist a site in any Safari content blocker
Look for the site in Safari -> Preferences -> Websites -> Content Blockers
, set content blocking to Off
– via Reddit
Disable Cmd+Q for Safari
System Preferences > Keyboard > Shortcuts > App Shortcuts >
Add one for Safari, with menu title Stop
and shortcut Cmd+Q
Calendar.app
Display shared Google calendars in Calendar.app
Select the calendars to sync here.
– via Stack Overflow
Refresh Exchange calendars not syncing with Calendar.app in Monterey
Temporarily fixes Calendar.app not showing new events from Exchange calendars in MacOS Monterey (including v12.6.1).
launchctl stop com.apple.CalendarAgent
launchctl start com.apple.CalendarAgent
The issue will come back after a while, but you can run the commands again to refresh the calendars. Alternatively, you can schedule them to run every hour or so with a cron job.
# Let's just not use vi shall we?
export VISUAL=/usr/bin/nano
# Edit crontab
crontab -e
# Add the following line
0 * * * * launchctl stop com.apple.CalendarAgent && launchctl start com.apple.CalendarAgent
– via Apple Community
Alfred
Alfred cheatsheet
https://www.alfredapp.com/help/getting-started/cheatsheet/
Exclude files from Alfred search
- Add the file/folder to
System Preferences -> Spotlight -> Privacy
and rebuild Alfred’s cache - Add
alfred:ignore
to the Spotlight comments of the file/folder to ignore
Little Snitch
Little Snitch Blocklists
- Peter Lowe’s Blocklist seems to be the best one (it’s handcrafted) plus it’s recommended on the obdev blog.
- Fabston’s Blocklist looks cool too, but I haven’t tried it (but I like that it merges a lot of sources).
ImageMagick
ImageMagick Commands
Convert pngs or heics to jpegs.
# Convert png to jpg, with 95% quality, while stripping any metadata
convert -strip -quality 95% <source>.png <destination>.jpg
# Convert HEIC to jpg, with 99% quality
mogrify -quality 99 -format jpg IMG_8672.HEIC
mogrify -quality 99 -format jpg *.HEIC
ffmpeg
Install ffmpeg with libvpx-vp9 support (for webm conversion)
Commands such as brew install ffmpeg --with-libvpx
don’t work anymore, I’ve found that simply installing libvpx with Homebrew and then reinstalling ffmpeg will work.
brew install libvpx
brew uninstall ffmpeg
brew install ffmpeg
# Check available encoders
ffmpeg -encoders
Some info here too.
Convert gifs to mp4/webm
ffmpeg -i my-animation.gif my-animation.mp4
ffmpeg -i my-animation.gif -c vp9 -b:v 0 -crf 41 my-animation.webm
– via Google Developers
libmbedcrypto errors
Such as dyld[67892]: Library not loaded: /opt/homebrew/opt/mbedtls/lib/libmbedcrypto
.
Fixed them with
brew uninstall librist --ignore-dependencies
brew uninstall mbedtls --ignore-dependencies
brew reinstall ffmpeg
– via Stack Overflow
youtube-dl/yt-dlp
Download videos from YouTube using yt-dlp
yt-dlp <url> -S ext:mp4:m4a
# bestest everything
yt-dlp <url> -f "bestvideo[ext=mp4]+bestaudio[ext=m4a]/best[ext=mp4]/best"
# mp3
yt-dlp <url> -x --audio-format mp3 --audio-quality 0
– via this GitHubIssue
Chrome
Detect and remove externally added extensions
Like this unsolicited/unconfirmed, spyware-like extension that Adobe Acrobat Reader installs without your consent and which you should totally remove and report.
# this is where the external extensions are stored
cd /Users/<user>/Library/Application Support/Google/Chrome/External Extensions
# list the extensions
ls -l
# in my case, there was only efaidnbmnnnibpcajpcglclefindmkaj.json
cat efaidnbmnnnibpcajpcglclefindmkaj.json
> {
> "external_update_url": "https://clients2.google.com/service/update2/crx"
> }
# kill it with fire, then restart Chrome
rm efaidnbmnnnibpcajpcglclefindmkaj.json
– via Dan’s comment to my LinkedIn post
Find and kill processes listening to ports
# get a list of processes that are listening to ports
sudo lsof -iTCP -sTCP:LISTEN -n -P
# and, you know..
sudo kill -9 <PID>
– via StackOverflow
Copy some text and/or file contents to clipboard
Use pbcopy
(there’s also pbpaste
!).
pbcopy < ~/.ssh/id_rsa.pub
– via StackOverflow
Stop apps from running automatically on startup
Settings -> General -> Login Items
, but you’ve tried this already/Library/LaunchAgents
/Library/LaunchDaemons
/Users/<you>/Library/LaunchAgents
/Users/<you>/Library/LaunchDaemons
Don’t touch /System/Library/LaunchAgents
and /System/Library/LaunchDaemons
though.
Check running processes with launchctl list
– via MacWorld
Remove app settings
Remove app settings from:
~/Library/Preferences
- , and
~/Application Support/<app name>
as well
Generate a random base64 key
head -c 64 /dev/random | base64