Skip to content

Instantly share code, notes, and snippets.

View bryanheinz's full-sized avatar

bryan heinz bryanheinz

View GitHub Profile
@bryanheinz
bryanheinz / munki_eadir_patch.py
Created May 12, 2020 00:14
patches Munki's makecatalogs
#!/usr/bin/python3
# this script patches Munki's makecatalogslib.py file to skip over any files or
# folders containing @eaDir. if you're hosting your munki repo on a Synology,
# then you've likely seen the ton of noisy error output makecatalogs generates
# due to these @eaDir files. this patch skips those files thus silencing those errors.
import os
import shutil
import getpass
@bryanheinz
bryanheinz / get_console_user.py
Last active August 21, 2020 13:53
Get's the current logged in user in macOS using Python.
#!/usr/local/bin/python3
import subprocess
def termy(cmd):
task = subprocess.Popen(cmd, stdout=subprocess.PIPE, stderr=subprocess.PIPE)
out, err = task.communicate()
return(out.decode('utf-8'), err)
user, err = termy(
['/usr/bin/stat', '-f', '"%Su"', '/dev/console']
#
# get all .mobileconfig profiles and add them to SimpleMDM as custom profiles
# using Lucas' fork of simpleMDMpy https://github.com/lucasjhall/simpleMDMpy
# dropped the SimpleMDMpy folder into /usr/local/lib/python3.9/site-packages/ (or whatever your Python 3 path is)
#
api_key = ''
mdm_dir = pathlib.Path('/Users/bryanh/Documents/dev/profiles/mdm/')
tcc_dir = mdm_dir / 'tcc'
@bryanheinz
bryanheinz / 1p_postinstall.sh
Created October 13, 2021 20:02
pre and post-install scripts for 1Password; and their respective pkginfo.
#!/bin/sh
# get the console user, root if it's at the login window
theUser=$(/usr/bin/stat -f "%Su" /dev/console)
# check for and exit if root
[[ $theUser == "root" ]] && exit 0
# should be a logged in user, reopen 1Password
/usr/bin/su - $theUser -c "open -b com.agilebits.onepassword7"
@bryanheinz
bryanheinz / mp4meta.py
Created June 3, 2024 01:16
These are my notes on editing MP4 metadata using Python Mutagen. I found most of it not straight forward and it's required a lot of research, trial, and error.
# pip install mutagen
from mutagen.mp4 import MP4, MP4Cover
video = MP4('video.mp4')
# set a TV show series name
video['tvsh'] = "TV SHOW NAME"
# set the episode title
video['\xa9nam'] = "EPISODE TITLE"
# set the video type to a TV Show