Skip to content

Instantly share code, notes, and snippets.

@homebysix
homebysix / update_changelog_diffs.py
Created November 16, 2021 06:29
update_changelog_diffs.py
View update_changelog_diffs.py
#!/usr/bin/env python3
"""Given the path to a Markdown-formatted change log, this script will update
the diff links for each version at the bottom of the document. For an example
of the diff links, see: https://keepachangelog.com
Currently only supports GitHub, GitLab, and Bitbucket diff links.
"""
@homebysix
homebysix / docklib_example.py
Last active May 17, 2022 16:30
docklib_example.py
View docklib_example.py
#!/usr/local/bin/managed_python3
"""docklib_example.py
This example script demonstrates how Mac admins can use the docklib module to
manage the default state of Mac users' Docks. The script is meant to run at
login in user context using a tool like Outset or a custom LaunchAgent.
For details, see: https://www.elliotjordan.com/posts/resilient-docklib/
"""
@homebysix
homebysix / .pre-commit-config.yaml
Last active June 28, 2021 16:54
Pre-commit config for private AutoPkg recipe repository (with processors)
View .pre-commit-config.yaml
repos:
- repo: https://github.com/homebysix/pre-commit-macadmin
rev: v1.10.1
hooks:
- id: check-autopkg-recipes
args: [
"--recipe-prefix=com.pretendco.cpe.",
"--override-prefix=local.",
"--strict",
"--",
@homebysix
homebysix / .pre-commit-config.yaml
Last active June 28, 2021 16:55
Pre-commit config for private AutoPkg recipe repository (YAML recipes and overrides)
View .pre-commit-config.yaml
repos:
- repo: https://github.com/homebysix/pre-commit-macadmin
rev: v1.10.1
hooks:
- id: check-autopkg-recipes
args: [
"--recipe-prefix=com.pretendco.cpe.",
"--override-prefix=local.",
"--",
]
@homebysix
homebysix / .pre-commit-config.yaml
Last active June 28, 2021 16:55
Pre-commit config for public AutoPkg recipe repository (with processors)
View .pre-commit-config.yaml
repos:
- repo: https://github.com/homebysix/pre-commit-macadmin
rev: v1.10.1
hooks:
- id: check-autopkg-recipes
args: [
"--recipe-prefix=com.github.yourusername.",
"--strict",
"--",
]
@homebysix
homebysix / .pre-commit-config.yaml
Last active June 28, 2021 16:55
Pre-commit config for public AutoPkg recipe repository (extended)
View .pre-commit-config.yaml
repos:
- repo: https://github.com/homebysix/pre-commit-macadmin
rev: v1.10.1
hooks:
- id: check-autopkg-recipes
args: [
"--recipe-prefix=com.github.yourusername.",
"--strict",
"--",
]
@homebysix
homebysix / .pre-commit-config.yaml
Last active June 28, 2021 16:46
Pre-commit config for public AutoPkg recipe repository (basic)
View .pre-commit-config.yaml
repos:
- repo: https://github.com/homebysix/pre-commit-macadmin
rev: v1.10.1
hooks:
- id: check-autopkg-recipes
args: ["--recipe-prefix=com.github.yourusername."]
- id: forbid-autopkg-overrides
- id: forbid-autopkg-trust-info
@homebysix
homebysix / anonymizer.py
Created April 5, 2021 23:23
anonymizer.py
View anonymizer.py
#!/usr/bin/env python3
"""
Name: anonymizer.py
Description: Simple Python script that anonymizes personal and company
information in an input file. Useful for running on logs
and Terminal outputs before sharing on GitHub or Slack.
Author: Elliot Jordan <elliot@elliotjordan.com>
Created: 2021-02-03
View readable_time.py
def readable_time(seconds):
"""Converts a number of seconds to a human-readable time in seconds, minutes, and hours."""
parts = []
if seconds >= 86400: # 1 day
days = seconds // 86400
if days == 1:
parts.append("{} day".format(int(days)))
else:
parts.append("{} days".format(int(days)))
View detect_autopkg_variable_changes.py
#!/usr/local/autopkg/python
import os
import plistlib
from glob import glob
from Foundation import CFPreferencesCopyAppValue
# Input keys we don't care about comparing.
EXCLUDED_KEYS = (