Navigation Menu

Skip to content

Instantly share code, notes, and snippets.

@chilcote
chilcote / checkLoginItems.swift
Created June 23, 2022 22:08
Use this to list out all the launchd plists in LaunchDaemons and LaunchAgents, and report the SMAppService.statusForLegacyPlist status.
import Foundation
import ServiceManagement
func printStatus(plistPath: String) -> String {
let plistURL = URL(fileURLWithPath: plistPath)
let status = SMAppService.statusForLegacyPlist(at: plistURL)
switch status {
case .notRegistered:
return plistPath + " is not registered"
#!/usr/bin/python
import sys, datetime, time, subprocess
def apple_year_offset(dateobj, years=0):
# Convert to a maleable format
mod_time = dateobj.timetuple()
# Offset year by number of years
mod_time = time.struct_time(tuple([mod_time[0]+years]) + mod_time[1:])
# Convert back to a datetime obj
return datetime.datetime.fromtimestamp(int(time.mktime(mod_time)))
#!/bin/bash
until [[ -d "/Volumes/Deploy Studio Test" ]]; do
sleep 5
done
cp -r "/Volumes/Deploy Studio Test/Deploy/Workflows/High Sierra Install/Macintosh HD/copy" "~/Desktop"
#!/usr/bin/python3
'''
Display CPU usage for a given process
emoji ref: https://github.com/sheagcraig/Spruce/blob/master/spruce.py
'''
import subprocess
import time
import argparse
#!/usr/bin/python
import sys, os
import urllib, urllib2
import base64
import json
import requests
import xml.etree.ElementTree as ET
def requests_xml(jss_user, jss_pass, jss_url, category):
@chilcote
chilcote / get_msa_videos.py
Last active April 17, 2018 20:55
Download MacSysAdmin2016 videos
#!/usr/bin/env python
'''
download macsysadmin videos
requires:
pip install requests
pip install beautifulsoup4
'''
@chilcote
chilcote / check-10.12-sierra-compatibility
Created September 10, 2016 01:16
Check 10.12 Sierra Compatibility EA
#!/usr/bin/env python
# encoding: utf-8
# ================================================================================
# check-1012-sierra-compatibility.py
#
# This script checks if the current system is compatible with macOS 10.12 Sierra.
# These checks are based on the installCheckScript and volCheckScript in
# distribution file of OSInstall.mpkg installer package. The OSInstall.mpkg can be
# found in the root of InstallESD disk image.
{
"output_name": "macos-netboot",
"bridged": true,
"netboot": true,
"netboot_hdsize": 60,
"netboot_osvers": "10.12"
}
@chilcote
chilcote / gist:6649e2867e1a547f4a06
Created October 11, 2015 18:58
Get primary interface name and IP
#!/usr/bin/python
from SystemConfiguration import SCDynamicStoreCreate, SCDynamicStoreCopyValue
net_config = SCDynamicStoreCreate(None, "net", None, None)
def get_primaryinterface():
states = SCDynamicStoreCopyValue(net_config, "State:/Network/Global/IPv4")
return states['PrimaryInterface']
#!/usr/bin/env python
# I got the meat of this script from somewhere but I can't remember where...
# if it was yours, let me know and I'll give credit.
'''
download macsysadmin videos
requires: