Skip to content

Instantly share code, notes, and snippets.

@rtrouton
rtrouton / gist:8032d209b3c810f0912f
Created June 4, 2014 14:22
Script that fixes the Casper MDM certificate on a Casper 9.x-managed Mac running 10.7.x or later.
#!/bin/bash
# Determine OS version
OSVERS=$(sw_vers -productVersion | awk -F. '{print $2}')
# Macs running 10.6.x or earlier are not able to use profiles.
# If the script detects that it is running on an OS earlier than
# 10.7.0, the script will exit at this point to avoid problems.
if [[ ${OSVERS} -lt 7 ]]; then
import sys, os, os.path, tempfile, plistlib, shutil
class TempApp(object):
def __init__(self, infoPlist_dict, app_path=None, bundle_name='TempApp', cleanup=True, app_icon=None):
# infoPlist_dict: A dict containing key values that should be set/overridden
# vs. the normal Python.app keys.
# app_path: The path to where your app should go. Example: '/usr/local/myOrgStuff'
# This directory needs to pre-exist. If app_path is left at None,
# a temporary directory will be created and used and the value of
# cleanup will be forced to True
@Eccenux
Eccenux / archive.py
Last active October 8, 2015 06:54
Python archive (zip) helper class
#!/usr/bin/env python
import os
import zipfile
"""
Helper class that lets one add whole directory contents.
License
--------------------
@homebysix
homebysix / EclipseIDE.download.recipe
Last active November 13, 2015 01:08
EclipseIDE.download.recipe
<?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>Description</key>
<string>Downloads the current release version of Eclipse.</string>
<key>Identifier</key>
<string>com.github.sheagcraig.download.EclipseIDE</string>
<key>Input</key>
<dict>
@rmanly
rmanly / frogor_current_user.py
Last active January 26, 2016 18:37
use SystemConfiguration to get console user vs. stat'ing /dev/console etc.
# frogor user check v1
# http://osx.michaellynn.org/freenode-osx-server/freenode-osx-server_2013-04-09.html
from SystemConfiguration import SCDynamicStoreCopyConsoleUser
from objc import NULL
import sys
username = (SCDynamicStoreCopyConsoleUser(NULL, NULL, NULL) or [NULL])[0]
username = [username,''][username in [u"loginwindow", None]]
sys.stdout.write(username + "\n")
@ashishb
ashishb / gist:da145a877139fcd91e3f
Created July 6, 2014 08:36
Fix for "Unapproved caller. SecurityAgent may only be invoked by Apple software"
- Start on single user mode: Hit the Command and S keys at start-up
Wait until the writing stops completely
-At the line, type (after root): /sbin/fsck -fy (space after the k)
Hit the ENTER key
wait until it finishes and says "... appears to be OK"
next, type: /sbin/mount -uw / (space after the t and after the w)
@pudquick
pudquick / osx_backdrop.py
Last active September 30, 2016 13:56
Python to show an image centered on a black background as your OS X desktop while other python code can run
#!/usr/bin/python
# Put a background in the same directory as this .py file and name it
backdrop_filename = "backdrop.jpg"
# http://wallreborn.com/wp-content/uploads/2015/05/cool-desktop-backgrounds-8-Cool-Wallpaper.jpg
# is a pretty sweet example to try with
# Then run this script from the Terminal :)
@pudquick
pudquick / secure_gurl.py
Last active September 30, 2016 14:43
Security automation for ca.pem + client.pem
"""
First attempt at bringing security into play with the .pem files.
Only the security tool is used, no additional tools (openssl, etc.).
This code does the following:
- Creates the specified keychain if it doesn't exist
- Unlocks it with the specified password
- Configures it to not lock
- Adds it to the keychain search paths if it's not present already (necessary for 10.9)
- Import the client.pem cert / identity
@pudquick
pudquick / http_flatpkg_pkginfo.py
Created May 11, 2014 07:13
This python project is able to retrieve the PackageInfo metadata from flatpkg files over HTTP without downloading the entire .pkg file (if the web server it's hosted on supports partial file transfer / byte ranges)
# Skip to the end to see what this can do.
#
# http://s.sudre.free.fr/Stuff/Ivanhoe/FLAT.html
# Flat packages are xar files with a particular structure
# We're looking for the PackageInfo file within the xar file
import urllib2, ctypes, zlib
import xml.etree.ElementTree as ET
class SimpleObj(object):
@bruienne
bruienne / sample_802.1x_loginwindow.mobileconfig
Last active March 9, 2018 15:41
Skeleton mobileconfig plist that enables 802.1x login to Wifi network at OS X login window
<?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>PayloadCertificateFileName</key>
<string>my.org.cer</string>
<key>PayloadContent</key>