Skip to content

Instantly share code, notes, and snippets.

View joshua-d-miller's full-sized avatar

Joshua D. Miller joshua-d-miller

View GitHub Profile
@muffinresearch
muffinresearch / spotify_dbus_screensaver.py
Last active April 7, 2016 12:58
Dbus Spotify Screensaver Toggle
#!/usr/bin/env python
"""
Spotify Screensaver Toggle
By Stuart Colville
http://muffinresearch.co.uk/
Requires Spotify Linux Preview.
"""
@rudyryk
rudyryk / make_random_password.py
Last active July 14, 2016 14:32
Python os.urandom example: make random password
import os
def make_random_password(length=12, symbols='abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789@$^_+&'):
password = []
for i in map(lambda x: int(len(symbols)*x/255.0), os.urandom(length)):
password.append(symbols[i])
return ''.join(password)
@joshua-d-miller
joshua-d-miller / java7u51exception
Created January 20, 2014 17:04
Java 7 Update 51 Exception.sites script to allow all users to modify the file as well as add your own on the administrative side. Use as postinstall_script.
#!/bin/sh
# Java script to add the exception.sites in a shared location for the
# new version of Java. Script created and updated by Josh Miller and
# Matt Hansen. Last update January 20, 2014.
# This command will check to see if the Java Deployment directory
# exists. If not, it will create it for you.
test -d /Library/Application\ Support/Oracle/Java/Deployment || mkdir -p /Library/Application\ Support/Oracle/Java/Deployment
@skyl
skyl / install.rb
Last active October 28, 2024 14:17
Homebrew without sudo
#!/System/Library/Frameworks/Ruby.framework/Versions/Current/usr/bin/ruby
# SET YOUR_HOME TO THE ABSOLUTE PATH OF YOUR HOME DIRECTORY
# chmod +x install.rb
# ./install.rb
YOUR_HOME = ''
HOMEBREW_PREFIX = "#{YOUR_HOME}/usr/local"
HOMEBREW_CACHE = '/Library/Caches/Homebrew'
HOMEBREW_REPO = 'https://github.com/Homebrew/homebrew'
@arubdesu
arubdesu / LSbootstrapper.py
Last active September 7, 2016 20:10
For running at first boot, to enable both location services and whitelist Maps and AutoTimeZone('based on current location')
#!/usr/bin/python
"""Enables location services, allows Maps and Timezone"""
import os
import platform
import subprocess
import sys
try:
sys.path.append('/usr/local/munki/munkilib/')
import FoundationPlist
except ImportError as error:
@pudquick
pudquick / get_platform.py
Last active August 18, 2022 21:02
Get Mac's serial number, hardware UUID, and board-id via python
import objc
from Foundation import NSBundle
IOKit_bundle = NSBundle.bundleWithIdentifier_('com.apple.framework.IOKit')
functions = [("IOServiceGetMatchingService", b"II@"),
("IOServiceMatching", b"@*"),
("IORegistryEntryCreateCFProperty", b"@I@@I"),
]
@pudquick
pudquick / 8021x_inspect.py
Last active September 27, 2022 10:04
802.1x configuration / data collection on OS X using python and the PrivateFramework "EAP8021X.framework"
# This was all run from user space
# I haven't tested it with root
# ... but it didn't prompt for any permissions under userspace ^_^
# Tested on 10.11.5
import objc
from Foundation import NSBundle
EAP8021X_bundle = NSBundle.bundleWithPath_('/System/Library/PrivateFrameworks/EAP8021X.framework')
Security_bundle = NSBundle.bundleWithIdentifier_('com.apple.security')
@pudquick
pudquick / battery.py
Last active April 20, 2023 06:06
Accessing battery details via python and pyobjc on macOS / OS X
import objc
from Foundation import NSBundle
IOKit = NSBundle.bundleWithIdentifier_('com.apple.framework.IOKit')
functions = [("IOServiceGetMatchingService", b"II@"),
("IOServiceMatching", b"@*"),
("IORegistryEntryCreateCFProperties", b"IIo^@@I"),
("IOPSCopyPowerSourcesByType", b"@I"),
("IOPSCopyPowerSourcesInfo", b"@"),
@pudquick
pudquick / pyobjc_keychain.py
Last active February 28, 2020 17:09
Manipulating the Keychain in macOS via python and pyobjc
from Foundation import NSBundle
import objc, array
# from CoreFoundation import CFGetTypeID
Security = NSBundle.bundleWithPath_('/System/Library/Frameworks/Security.framework')
# First we need the CF TypeIDs to build some signatures
functions = [
('SecKeychainGetTypeID', 'I'),
]
@pudquick
pudquick / iousb.py
Created October 7, 2020 00:18
IOKit IOUSBDevice enumeration
import objc
from Foundation import NSBundle
IOKit_bundle = NSBundle.bundleWithIdentifier_('com.apple.framework.IOKit')
functions = [
("IORegistryEntryCreateCFProperties", b"IIo^@II"),
("IOServiceMatching", b"@*"),
("IOServiceGetMatchingServices", b"II@o^I"),
("IOIteratorNext", b"II"),
]