Skip to content

Instantly share code, notes, and snippets.

@gregneagle
gregneagle / munki_do.py
Created September 4, 2016 05:51
munki_do.py
#!/usr/bin/python
# encoding: utf-8
#
# Copyright 2009-2016 Greg Neagle.
#
# 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
@pudquick
pudquick / lockscreen.py
Created December 23, 2015 19:12
Programmatically immediately lock the screen of a Mac running OS X, regardless of security settings, screensaver settings, or Fast User Switch settings
from ctypes import CDLL
loginPF = CDLL('/System/Library/PrivateFrameworks/login.framework/Versions/Current/login')
result = loginPF.SACLockScreenImmediate()
from munkilib import gurl
def run_connection(options):
connection = gurl.Gurl.alloc().initWithOptions_(options)
percent_complete = -1
bytes_received = 0
connection.start()
try:
while not connection.isDone():
if connection.destination_path:
@rmanly
rmanly / download_file_via_munkilib.py
Last active August 29, 2015 14:15
uses munkilib's fetch to dl a file via gurl via NSURL
import sys
sys.path.append('/usr/local/munki/munkilib')
import fetch
fetch.get_url('http://www.irs.gov/pub/irs-prior/f1040ez--2014.pdf', '/Users/ryan/Desktop/1040ez.pdf')
fetch.get_url('https://www.gnu.org/software/wget/index.html', '/Users/ryan/Desktop/index.html')
@pudquick
pudquick / beamsync.py
Last active September 28, 2023 15:16
#!/usr/bin/python
import ctypes, ctypes.util
# Import CoreGraphics as a C library, so we can call some private functions
c_CoreGraphics = ctypes.CDLL(ctypes.util.find_library('CoreGraphics'))
def disable_beam_sync(doDisable):
if doDisable:
# Disabling beam sync:
# 1st: Enable Quartz debug
@bruienne
bruienne / sign_configprofile.sh
Created October 23, 2014 21:11
Sign config profile from CLI
openssl smime -sign -nodetach -in "My Awesome.mobileconfig" -signer MyAwesomeCert.pem -inkey MyAwesome.key -outform DER -out "My Awesome Signed.mobileconfig" -certfile MyAwesomeCert.pem
@bryanzak
bryanzak / SafariPlugInPrefs.mobileconfig
Created March 20, 2014 02:17
Creating a profile (and installer package) from a plist. This gist has a number of pieces. From a plist it creates a profile and from the profile it creates an installer package. There are create shell scripts for each step and the installer package also has a postinstall script that installs the profile. In this particular example we're creatin…
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
<plist version="1.0">
<dict>
<key>PayloadContent</key>
<array>
<dict>
<key>PayloadContent</key>
<dict>
<key>com.apple.Safari</key>
@timsutton
timsutton / autopkg_jenkins_check.py
Last active December 27, 2015 00:19
Basic AutoPkg Jenkins check script in Python.
#!/usr/bin/python
#
# This is a rough Python script that demonstrates running AutoPkg with Jenkins
# as only a "check" action, using the ScriptTrigger plugin. It's assumed
# that AutoPkg is running directly out of a Git checkout from somewhere, but
# this is not necessary.
#
# Also note that the the '-d' option is given to hardcoded recipe
# search directories.
#
@andrewh
andrewh / anyconnect.scpt
Last active April 12, 2024 08:48
Applescript to automate the Cisco AnyConnect SSL VPN client on OS X Mavericks
-- 1. Place in ~/Library/Scripts and enable the Applescript menu via the Applescript Editor
-- 2. Substitute "vpn.example.com" and "redacted" for your VPN server and password
-- 3. Open Security & Privacy System Preferences, go to Privacy, Accessibility
-- 4. Enable Applescript Editor and System UI Server
-- 5. Trigger script from the menu
-- 6. Enjoy being connected
tell application "Cisco AnyConnect Secure Mobility Client"
activate
end tell
#!/usr/bin/python
#
# list_unused_munki_pkgs.py
# Tim Sutton
#
# Simple script to list all Munki pkgs not currently referenced in a specific list
# of catalogs.
# It does not delete anything.
#
# CATALOGS can be modified to a list of catalogs in your repo that should be indexed.