Skip to content

Instantly share code, notes, and snippets.

@pudquick
pudquick / measure.py
Last active February 8, 2023 16:05
Get a sorted descriptive json output of hashes for a directory, suitable for diffing
#!/usr/bin/env python3
import os, os.path, json, hashlib, subprocess, argparse, sys, stat
BUFFER_SIZE = 65536
def checksum_directory(source_path, progress=False):
filesystem_details = dict()
# rough guess of how many files are in a directory
# horrible hack with a little fudge
if not os.path.isdir(source_path):
'''Routines for manipulating the Dock'''
import os
import subprocess
from Foundation import NSURL
from Foundation import CFPreferencesAppSynchronize
from Foundation import CFPreferencesCopyAppValue
from Foundation import CFPreferencesSetAppValue
@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 / visible_apps.py
Created March 29, 2017 22:57
Getting the list of visible apps (think: Force Quit) in macOS via python and pyobjc
from Foundation import NSBundle
import objc
CoreServices = NSBundle.bundleWithIdentifier_('com.apple.CoreServices')
functions = [
('_LSCopyRunningApplicationArray', '@I'),
('_LSCopyApplicationInformation', '@I@@'),
]
constants = [
parse_array() {
FS=':'
key=(); val=()
for (( i=0 ; i < $(eval echo \${#$1[@]}) ; i++ )); do
key+=( "$(eval echo \${$1[$i]} | awk -F${FS} '{print $1}')" )
val+=( "$(eval echo \${$1[$i]} | awk -F${FS} '{print $2}')" )
done
}
# Assuming script contains myarray=( "key1:value1" "key2:value2" )
parse_array myarray
@mrik23
mrik23 / MSOL-BulkRemoveDirectAssignedLicense.ps1
Last active June 7, 2023 04:23
Remove in bulk direct assigned license to users who have group assigned license with Azure AD PowerShell v1
<#
Modified version of the script from Microsoft Documentation.
Removed the part that checks if the users is assigned more products than the group assigned license.
Added connection part and help to find Sku and Group Object ID.
This script requires Azure AD (aks MSOL) PowerShell v1. It doesn't seem possible to do so with v2.
Ref: https://docs.microsoft.com/en-us/azure/active-directory/active-directory-licensing-ps-examples
#>
Import-Module MSOnline
$UserCredential = Get-Credential
@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,
@opragel
opragel / forcefully_remove_mdm_1015.sh
Last active August 2, 2022 19:39
forcefully_remove_mdm_1015.sh
#!/bin/bash
# Seriously there still apparently aren't enough warning labels
# If you don't understand the consequences don't do it
REMOVE_PATHS=( # "/var/db/ConfigurationProfiles/.passcodePolicesAreInstalled"
# "/var/db/ConfigurationProfiles/.cloudConfigHasActivationRecord"
# "/var/db/ConfigurationProfiles/.cloudConfigNoActivationRecord"
# "/var/db/ConfigurationProfiles/.cloudConfigProfileObtained"
# "/var/db/ConfigurationProfiles/.cloudConfigRecordFound"
# "/var/db/ConfigurationProfiles/.profilesAreInstalled"
@erikng
erikng / kextidentifiers.py
Last active April 19, 2021 22:51
kextidentifiers.py
#!/usr/bin/python
# For mojave only
# In order for this to work, you will need to go to System Preferences in Mojave -> Security & Privacy -> Privacy -> Full Disk Access and grant Terminal.app permissions
import sqlite3
conn = sqlite3.connect('/var/db/SystemPolicyConfiguration/KextPolicy')
c = conn.cursor()
query = 'SELECT * FROM kext_policy'
c.execute(query)
@dahoba
dahoba / ikbc-td108-manual.txt
Created July 5, 2019 03:08
IKBC TD108 Manual
# ⌨️ TD 108 Functions Description
***Light Mode:***
PRESS FN + F4
+ Light up
+ Wave
+ Rain drop
+ Aurora
+ Breathing