Skip to content

Instantly share code, notes, and snippets.

View geoffrepoli's full-sized avatar
🏄‍♂️

geoff geoffrepoli

🏄‍♂️
View GitHub Profile
@geoffrepoli
geoffrepoli / Reset Printing System
Last active June 23, 2017 23:28
command-line dupe of System Preferences "Reset printing system" advanced option. As with that option, this does not remove drivers.
#!/usr/bin/env bash
# stop print services
launchctl stop org.cups.cupsd
# back up existing configs
mv /Library/Printers/InstalledPrinters.plist /Library/Printers/InstalledPrinters.plist.bak
mv /etc/cups/cupsd.conf /etc/cups/cupsd.conf.bak
mv /etc/cups/printers.conf /etc/cups/printers.conf.bak
## REMOVE FIRST CHARACTER FROM STRING
sed '/^.//'
== Example ==
$ echo "foo" | sed 's/^.//'
oo
____________________________________________________________________
#!/usr/bin/env bash
user=$(/usr/bin/python -c 'from SystemConfiguration import SCDynamicStoreCopyConsoleUser;import sys;username = (SCDynamicStoreCopyConsoleUser(None, None, None) or [None])[0];username = [username,""][username in [u"loginwindow", None, u""]];sys.stdout.write(username + "\n");')
pass=$(osascript -e 'display dialog "Enter password:" default answer "" giving up after 60 with text buttons {"Authenticate"} default button 1 with hidden answer' -e 'return text returned of result')
attempts=1
until dscl . authonly "$user" "$pass" &>/dev/null ; do
# lines 9 and 10 are only necessary if you wish to display no. of attempts remaining before failure
attemptsRemaining=$(( 4 - attempts ))
[[ $attemptsRemaining -eq 1 ]] && s= || s=s
@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")
<?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/>
# 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
find -x / /System/Library/* -flags restricted -prune -print
str=$(echo -e "$(cat <<EOF
this
\tis
\t\tmy
\t\t\theredoc
EOF
)")
echo "$str" > file.ext
# print only timestamp + log message
log show --style compact --info --debug --predicate 'subsystem == "com.apple.example"' \
| cut -d' ' -f1-2,4- \
| sed 's/\[.*:.*\]/:/g'
sudo dscl . passwd /users/root "$(env LC_CTYPE=C tr -dc 'A-Za-z0-9_\ \!\@\#\$\%\^\&\*\(\)-+=' < /dev/urandom | head -c 32)"