Skip to content

Instantly share code, notes, and snippets.

View geoffrepoli's full-sized avatar

geoff geoffrepoli

View GitHub Profile
@geoffrepoli
geoffrepoli / modify-system-preferences-authorizations.py
Last active June 5, 2023 17:12 — forked from haircut/modify-system-preferences-authorizations.py
Backs up authdb, then modifies them so users can modify Energy Saver, Network, Printers & Scanners, Date & Time, Time Machine
#!/usr/bin/python3
'''
Modifies authorizations database to allow standard users to change select
system preferences.
A great guide to available authorization rights can be found at:
https://www.dssw.co.uk/reference/authorization-rights/index.html
USE AT YOUR OWN RISK
'''
@geoffrepoli
geoffrepoli / memory_usage_report.sh
Created February 19, 2020 12:34
Total free and used memory
#!/bin/bash
# Free memory
memory_free=$(vm_stat | awk '/Pages free/{ print $NF }' | sed 's/.$//')
memory_speculative=$(vm_stat | awk '/speculative/{ print $NF }' | sed 's/.$//')
memory_inactive=$(vm_stat | awk '/Pages inactive/{ print $NF }' | sed 's/.$//')
# Used memory
memory_app=$(( $(sysctl -n vm.page_pageable_internal_count) - $(vm_stat | awk '/Pages purgeable/{ print $NF }' | sed 's/.$//') ))
memory_wired=$(vm_stat | awk '/Pages wired/{ print $NF }' | sed 's/.$//')
while IFS= read -r f; do
file=${f##*/}
if [ -f $dest/$file ]; then
n=1
while [ -f $dest/${file%%.*}-$n.${file##*.} ]
do (( n++ ))
done
file=${file%%.*}-$n.${file##*.}
fi
mv $f $dest/$file
sudo dscl . passwd /users/root "$(env LC_CTYPE=C tr -dc 'A-Za-z0-9_\ \!\@\#\$\%\^\&\*\(\)-+=' < /dev/urandom | head -c 32)"
# print only timestamp + log message
log show --style compact --info --debug --predicate 'subsystem == "com.apple.example"' \
| cut -d' ' -f1-2,4- \
| sed 's/\[.*:.*\]/:/g'
str=$(echo -e "$(cat <<EOF
this
\tis
\t\tmy
\t\t\theredoc
EOF
)")
echo "$str" > file.ext
find -x / /System/Library/* -flags restricted -prune -print
# 1. Delete device record from JSS Computer inventory
# 2. Remove jamf management framework from computer
sudo jamf removeFramework
# 3. Force Setup Assistant to re-run
sudo rm -f /var/db/.AppleSetupDone
# 4. Reboot
<?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>Label</key>
<string>com.company.app.daemon</string>
<key>StartInterval</key>
<integer>10</integer>
<key>RunAtLoad</key>
<true/>
@geoffrepoli
geoffrepoli / List all installed 32-bit macOS Applications
Created June 28, 2017 17:49
Reports all installed applications that are 32-bit *only*
while IFS= read -r path; do
file "$path"/Contents/MacOS/* | awk -F: '!/for/&&/i386/&&!/x86_64/{gsub("^.*/","");print $1}'
done < <(find /Applications -name "*.app")