Skip to content

Instantly share code, notes, and snippets.

Avatar

Mike Solin flammable

View GitHub Profile
@talkingmoose
talkingmoose / Manage App Notifications.bash
Last active Jun 3, 2021
macOS Catalina will prompt users to allow Notifications from each app that makes a request. Administrators can manage these prompts using a Configuration Profile. If running Jamf Pro 10.19 or later, I suggest instead using this manifest: https://github.com/talkingmoose/jamf-manifests/blob/master/macOS%20Notifications%20(com.apple.notificationset…
View Manage App Notifications.bash
#!/bin/bash
<<ABOUT_THIS_SCRIPT
-----------------------------------------------------------------------
Written by:William Smith
Professional Services Engineer
Jamf
bill@talkingmoose.net
https://gist.github.com/talkingmoose/9faf50deaaefafa9a147e48ba39bb4b0
View random_sn
randomsn() {
python -c "import string; from random import randint, sample; print('VM' + ''.join(sample((string.ascii_lowercase + string.digits),10)))"
}
@haircut
haircut / tcc-reset.py
Last active Sep 15, 2021
Completely reset TCC services database in macOS
View tcc-reset.py
#!/usr/bin/python
"""
Completely reset TCC services database in macOS
Note: Both the system and individual users have TCC databases; run the script as both
a user and as root to completely reset TCC decisions at all levels.
2018-08-15: Resetting the 'Location' service fails; unknown cause
2018-08-16: Confirmed the 'All' service does not really reset _all_
services, so individual calls to each service is necessary.
@grahamgilbert
grahamgilbert / clean_old_apple_updates.py
Created May 9, 2018
Clean out old apple updates (older than 24 hours) because softwareupdate often refuses to install them
View clean_old_apple_updates.py
#!/usr/bin/python
"""
Removes cached apple updates that are older than 24 hours
"""
import datetime
import os
import shutil
import sys
@erikng
erikng / 32bitapps.py
Last active Apr 16, 2018
32bitapps.py
View 32bitapps.py
#!/usr/bin/python
import subprocess
import plistlib
cmd = ['/usr/sbin/system_profiler', '-xml', 'SPApplicationsDataType']
proc = subprocess.Popen(cmd, shell=False, bufsize=-1, stdin=subprocess.PIPE, stdout=subprocess.PIPE, stderr=subprocess.PIPE)
output, err = proc.communicate()
plist = plistlib.readPlistFromString(output)
items = plist[0]['_items']
for item in sorted(items, key=lambda x: x.get('path')):
@gregneagle
gregneagle / fancy_defaults_read.py
Last active Mar 19, 2021
fancy_defaults_read.py: Reads a preference, prints its value, type, and where it is defined.
View fancy_defaults_read.py
#!/usr/bin/python
import os
import sys
from CoreFoundation import (CFPreferencesAppValueIsForced,
CFPreferencesCopyAppValue,
CFPreferencesCopyValue,
kCFPreferencesAnyUser,
kCFPreferencesAnyHost,
View com.company.config.applicationaccess.mobileconfig
<?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>PayloadContent</key>
<array>
<dict>
<key>PayloadType</key>
<string>com.apple.applicationaccess.new</string>
<key>PayloadVersion</key>
View beamsync.py
#!/usr/bin/python
import ctypes, ctypes.util
# Import CoreGraphics as a C library, so we can call some private functions
c_CoreGraphics = ctypes.CDLL(ctypes.util.find_library('CoreGraphics'))
def disable_beam_sync(doDisable):
if doDisable:
# Disabling beam sync:
# 1st: Enable Quartz debug
@gregneagle
gregneagle / NSPredicateTester.py
Last active Jun 1, 2018
NSPredicateTester.py
View NSPredicateTester.py
#!/usr/bin/python
import sys
import os
from Foundation import NSDate
from Foundation import NSPredicate
def doComparison(comp_string, obj):
print 'Comparison: %s' % comp_string