Skip to content

Instantly share code, notes, and snippets.

#!/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
@chilcote
chilcote / gist:10010307
Created April 6, 2014 19:14
Fun with CoreWLAN and python
#!/usr/bin/env python
'''
Playing around with CoreWLAN to return information about the wi-fi connection
Documentation:
https://developer.apple.com/library/mac/documentation/CoreWLAN/Reference/CWInterface_reference/translated_content/CWInterface.html
'''
import objc
@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"
@chilcote
chilcote / gist:f5af1a788ac4a2e4d5df
Created September 2, 2014 03:49
python script to set dns servers and search domains in os x
#!/usr/bin/env python
'''
This script sets dns servers and search domains for all
Ethernet adapters and Wi-fi interfaces.
Requirements
------------
+ OS X 10.9.x
+ python 2.7
AnsibleFest notes
==============
Keynote
-------
1.7.1
- enable windows powershell remoting modules in PowerShell
- can push raw powershell scripts
#!/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/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
'''