Skip to content

Instantly share code, notes, and snippets.

@ttscoff
ttscoff / sizes.rb
Last active July 12, 2021 03:33
sizes: Calculate and sort all filesizes for current folder
#!/usr/bin/env ruby
# Sizes - Calculate and sort all filesizes for current folder Includes
# directory sizes, colorized output Brett Terpstra 2019 WTF License
VERSION = "1.0.1"
require 'shellwords'
# Just including term-ansicolor by @flori and avoiding all the
# rigamarole of requiring multiple files when it's not a gem... - Brett
#
@talkingmoose
talkingmoose / Verify Computer Name.sh
Created March 13, 2018 19:04
Jamf Extension Attribute reports whether computer name matches serial number.
#!/bin/sh
computerName=$( scutil --get ComputerName )
serialNumber=$( system_profiler SPHardwareDataType | grep 'Serial Number' | awk -F: '{ print $2 }' | xargs )
if [ "$computerName" = "$serialNumber" ]; then
echo "<result>Computer Name is correct</result>"
else
echo "<result>Computer Name is incorrect</result>"
fi
@n8felton
n8felton / extract_printer_icon.sh
Last active March 16, 2020 19:22
Small snippet to extract printer icons from macOS printer drivers
MODEL="Xerox WorkCentre 6655"
ICON=$(gunzip -c "/Library/Printers/PPDs/Contents/Resources/${MODEL}.gz" | awk '/APPrinterIconPath/ {gsub(/"/,"",$2); print $2}')
/usr/bin/sips -s format png "${ICON}" --out "${MODEL}.png" --addIcon --resampleHeightWidthMax 512
@talkingmoose
talkingmoose / RenameMac.sh
Created November 1, 2017 13:53
Customer script for renaming a Mac using a Self Service policy.
#!/bin/sh
ComputerName=$( osascript <<'END'
set serialNumber to do shell script "system_profiler SPHardwareDataType | grep 'Serial Number' | awk -F: '{ print $2 }' | xargs"
set computername to ""
repeat while computername is "" or computername is "Type Computer Name Here"
@talkingmoose
talkingmoose / RemoveConfigurationProfilesByName.sh.txt
Created October 12, 2017 13:51
Set the profileName variable on line 4 to the name or partial name of the profile(s) to remove. All profiles containing the profileName variable will be removed.
#!/bin/sh
# MDM profile name to remove
profileName="ABC Wi-Fi"
# list existing profiles and their UUIDs - must be run with elevated privileges
UUIDList=$( /usr/bin/profiles -Pv | grep "name: $profileName" -A 5 | grep profileUUID | awk -F "profileUUID: " '{ print $2 }' )
# remove each profile by UUID
while IFS= read -r aUUID
#!/usr/bin/python
# Credit to frogor for the objc
from Foundation import NSBundle
import json
import objc
import os
import plistlib
import subprocess
@joyrexus
joyrexus / README.md
Last active February 24, 2024 15:16
collapsible markdown

collapsible markdown?

CLICK ME

yes, even hidden code blocks!

print("hello world!")
@pudquick
pudquick / remove_bt.py
Created October 7, 2016 19:53
Remove all Bluetooth devices from OS X / macOS in the style of the Bluetooth debug menu "Remove all devices" with python and pyobjc
#!/usr/bin/python
from Foundation import NSBundle
IOBluetooth = NSBundle.bundleWithIdentifier_('com.apple.Bluetooth')
IOBluetoothDevice = IOBluetooth.classNamed_('IOBluetoothDevice')
# remove configured devices
try:
devices = list(IOBluetoothDevice.configuredDevices())
except:
@sheagcraig
sheagcraig / uninstall_office2016.py
Created September 26, 2016 15:05
Silent Uninstall of Office 2016
#!/usr/bin/python
# Completely uninstall Office 2016, as per:
# https://support.office.com/en-us/article/Uninstall-Office-2016-for-Mac-eefa1199-5b58-43af-8a3d-b73dc1a8cae3
# and
# https://support.office.com/en-us/article/Troubleshoot-Office-2016-for-Mac-issues-by-completely-uninstalling-before-you-reinstall-ec3aa66e-6a76-451f-9d35-cba2e14e94c0?ui=en-US&rs=en-US&ad=US
import glob
import os
@pudquick
pudquick / marketing.py
Last active December 5, 2019 22:52
Using PrivateFrameworks to get marketing model information for Apple Macs without hitting their internet API (where possible) via python and pyobjc
# Tested on 10.11
# Note:
# The marketing information embedded in the ServerInformation.framework is not the same as what
# About This Mac displays - there are differences.
#
# For example:
# ServerInformation: 15" MacBook Pro with Retina display (Mid 2015)
# About This Mac: MacBook Pro (Retina, 15-inch, Mid 2015)
#