Navigation Menu

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
@jlehikoinen
jlehikoinen / clean_up_infected_handbrake.sh
Last active May 9, 2017 00:08
Clean up infected HandBrake (1.0.7) for macOS
#!/bin/sh
###
# Clean up infected HandBrake (1.0.7) for macOS
# Note that this script is WIP and does not remove all the traces of the malware
# e.g. reverting /etc/sudoers back to previous state is left out here
# Based on the information posted here:
@pudquick
pudquick / spotlight_exclusions.py
Last active April 27, 2022 16:47
List and control Spotlight exclusions in OS X via python and pyobjc on OS X 10.11
# Only tested on OSX 10.11.5
import objc
from Foundation import NSBundle
Metadata_bundle = NSBundle.bundleWithIdentifier_('com.apple.Metadata')
functions = [
('_MDCopyExclusionList', b'@'),
('_MDSetExclusion', b'@@I'),
]
@timsutton
timsutton / installer_choices_xml.plist
Last active March 6, 2018 03:27
Office 2016 workarounds for MAU and the AU Daemon
<!-- This can be added to a Munki pkginfo so as to deselect the MAU component
from being installed. However, some version of MAU would be probably
already installed if Office 2011 had ever been installed on this system. -->
<key>installer_choices_xml</key>
<array>
<dict>
<key>attributeSetting</key>
<integer>0</integer>
<key>choiceAttribute</key>
<string>selected</string>
@trodemaster
trodemaster / alternateSSHPort10.11.txt
Last active October 29, 2015 16:47
Configure OS X 10.11 to listen on an alternate ssh port.
1. Pick a port and hack up your /etc/services file
Change existing port entry from
mbus 47000/udp # Message Bus
mbus 47000/tcp # Message Bus
to..
ssh-47000 47000/udp # Alternate port SSH Remote Login Protocol
ssh-47000 47000/tcp # Alternate port SSH Remote Login Protocol
@bruienne
bruienne / munki_fuzzinator.py
Created October 9, 2015 19:29
Simple makecatalogs-based script to perform some level of Munki-specific linting on pkginfo files
#!/usr/bin/env python
# encoding: utf-8
#
# Copyright 2014 - The Regents of the University of Michigan.
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#!/usr/bin/python
import os
import subprocess
import urllib
import urllib2
import tempfile
import json
import shutil
from time import localtime
#!/usr/bin/python
# As written, this requires the following:
# - OS X 10.6+ (may not work in 10.10, haven't tested)
# - python 2.6 or 2.7 (for collections.namedtuple usage, should be fine as default python in 10.6 is 2.6)
# - pyObjC (as such, recommended to be used with native OS X python install)
# Only tested and confirmed to work against 10.9.5
# Run with root
@pudquick
pudquick / defaut_ip.py
Created June 2, 2015 17:17
This snippet gets you the default routing interface for a machine for general traffic
def default_interface():
# 203.0.113.1 is reserved in TEST-NET-3 per RFC5737
# Should never be local, essentially equal to "internet"
# This should get the 'default' interface
s = socket.socket(socket.AF_INET, socket.SOCK_DGRAM)
try:
# Uses UDP for instant 'connect' and port 9 for discard
# protocol: http://en.wikipedia.org/wiki/Discard_Protocol
s.connect(('203.0.113.1', 9))
client = s.getsockname()[0]
@homebysix
homebysix / shard.sh
Last active February 1, 2021 23:44
shard.sh
#!/bin/bash
###
#
# Name: shard.sh
# Description: This Casper extension attribute takes a Mac serial
# number as input and uses that serial number to output a
# number from 0 to 9. This can be useful in scoping Casper
# policies to a specific percentage of the fleet.
# Author: Elliot Jordan <elliot@elliotjordan.com>