Skip to content

Instantly share code, notes, and snippets.

View flammable's full-sized avatar

Mike Solin flammable

View GitHub Profile
@gregneagle
gregneagle / NSPredicateTester.py
Last active June 14, 2023 21:47
NSPredicateTester.py
#!/usr/local/munki/munki-python
import sys
import os
from Foundation import NSDate
from Foundation import NSPredicate
def doComparison(comp_string, obj):
print('Comparison: %s' % comp_string)
@pudquick
pudquick / beamsync.py
Last active September 28, 2023 15:16
#!/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
<?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>
@gregneagle
gregneagle / fancy_defaults_read.py
Last active February 6, 2024 15:14
fancy_defaults_read.py: Reads a preference, prints its value, type, and where it is defined.
#!/usr/bin/python
import os
import sys
from CoreFoundation import (CFPreferencesAppValueIsForced,
CFPreferencesCopyAppValue,
CFPreferencesCopyValue,
kCFPreferencesAnyUser,
kCFPreferencesAnyHost,
@erikng
erikng / 32bitapps.py
Last active April 16, 2018 11:46
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')):
@grahamgilbert
grahamgilbert / clean_old_apple_updates.py
Created May 9, 2018 16:35
Clean out old apple updates (older than 24 hours) because softwareupdate often refuses to install them
#!/usr/bin/python
"""
Removes cached apple updates that are older than 24 hours
"""
import datetime
import os
import shutil
import sys
@haircut
haircut / tcc-reset.py
Last active April 5, 2024 11:27
Completely reset TCC services database in macOS
#!/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.
@smashism
smashism / random_sn
Last active December 10, 2022 15:52
random_sn
randomsn() {
managed_python3 -c "import string; from random import randint, sample; print('VM' + ''.join(sample((string.ascii_lowercase + string.digits),10)))"
}
@talkingmoose
talkingmoose / Manage App Notifications.bash
Last active January 25, 2024 15:26
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…
#!/bin/bash
<<ABOUT_THIS_SCRIPT
-----------------------------------------------------------------------
Written by:William Smith
Professional Services Engineer
Jamf
bill@talkingmoose.net
https://gist.github.com/talkingmoose/9faf50deaaefafa9a147e48ba39bb4b0