Inspired by a Gist from kevinelliott - thanks!
- Xcode - for command line tools required by Homebrew
# Banner-style (default) | |
from Foundation import NSUserNotification, NSUserNotificationCenter | |
def notify(title, subtitle, text): | |
notification = NSUserNotification.alloc().init() | |
notification.setTitle_(str(title)) | |
notification.setSubtitle_(str(subtitle)) | |
notification.setInformativeText_(str(text)) | |
notification.setSoundName_("NSUserNotificationDefaultSoundName") | |
NSUserNotificationCenter.defaultUserNotificationCenter().scheduleNotification_(notification) |
from ctypes import CDLL, sizeof, memset, c_uint32, create_string_buffer | |
MAXPATHLEN = 1024 | |
PROC_PIDPATHINFO_MAXSIZE = MAXPATHLEN*4 | |
PROC_ALL_PIDS = 1 | |
libc = CDLL('libc.dylib') | |
def get_pids(): | |
number_of_pids = libc.proc_listpids(PROC_ALL_PIDS, 0, None, 0) | |
pid_list = (c_uint32 * (number_of_pids * 2))() |
#!/usr/bin/python | |
# | |
# getosversionfromdmg.py | |
# | |
# Copyright (c) 2014 The Regents of the University of Michigan | |
# | |
# Retrieves the OS version and build from the InstallESD.dmg contained in | |
# a typical "Install (Mac) OS X <Name>.app" bundle. | |
# | |
# To run: |
# You need to add these two lines to your bash environment | |
shopt -s histappend | |
export PROMPT_COMMAND="${PROMPT_COMMAND:+$PROMPT_COMMAND$'\n'}history -a; history -c; history -r" | |
# In most *nix variants, that means adding them to your .bashrc file. | |
# However, on OS X, the default session for Terminal is a login session, | |
# meaning that it doesn't run .bashrc. | |
# As such, you'll need to include these commands into your | |
# .profile or .bash_profile (whichever you have/want). |
#!/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 |
import objc | |
from Foundation import NSBundle | |
IOKit_bundle = NSBundle.bundleWithIdentifier_('com.apple.framework.IOKit') | |
functions = [("IOServiceGetMatchingService", b"II@"), | |
("IOServiceMatching", b"@*"), | |
("IORegistryEntryCreateCFProperty", b"@I@@I"), | |
] |
#!/usr/bin/python | |
# Requires passlib: pip install passlib | |
from passlib.hash import pbkdf2_sha512 | |
from passlib.util import ab64_decode | |
from biplist import * | |
# Checksum size must be 128 bytes for use as OS X password hash! | |
pbkdf2_sha512.checksum_size = 128 | |
hash = pbkdf2_sha512.encrypt("password", rounds=38000, salt_size=32) |
Inspired by a Gist from kevinelliott - thanks!
import objc | |
packagekit_bundle = objc.loadBundle('PackageKit', module_globals=globals(), bundle_path='/System/Library/PrivateFrameworks/PackageKit.framework', scan_classes=False) | |
PKReceipt = objc.lookUpClass('PKReceipt') | |
receipts = PKReceipt.receiptsOnVolumeAtPath_('/') | |
first_receipt = receipts[0] | |
# Things you can look up: | |
# installPrefixPath |