Skip to content

Instantly share code, notes, and snippets.

'''Routines for manipulating the Dock'''
import os
import subprocess
from Foundation import NSURL
from Foundation import CFPreferencesAppSynchronize
from Foundation import CFPreferencesCopyAppValue
from Foundation import CFPreferencesSetAppValue
@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
% curl -s http://www.getmacapps.com/raw/3
#!/bin/bash
mkdir ~/getmacapps_temp
cd ~/getmacapps_temp
# Installing Chrome
curl -L -O "https://dl.google.com/chrome/mac/stable/GGRO/googlechrome.dmg"
hdiutil mount -nobrowse googlechrome.dmg
cp -R "/Volumes/Google Chrome/Google Chrome.app" /Applications
@gregneagle
gregneagle / gist:9c684ed9366bc12091da
Last active August 29, 2015 14:25
Notes on getting Project iMAS MDM Server running under virtualenv on OS X
See https://github.com/project-imas/mdm-server#setup for starting point.
Assuming you have virtualenv installed....
bash-3.2$ virtualenv mdm-server-env
New python executable in mdm-server-env/bin/python
Installing setuptools, pip...cd mdone.
bash-3.2$ cd mdm-server-env/
bash-3.2$ source bin/activate
(mdm-server-env)bash-3.2$ easy_install web.py
@gregneagle
gregneagle / gist:2c5b535c723aea5d3fc7
Last active January 7, 2018 19:45
Proper software version comparisons in Python
% python
Python 2.7.6 (default, Sep 9 2014, 15:04:36)
[GCC 4.2.1 Compatible Apple LLVM 6.0 (clang-600.0.39)] on darwin
Type "help", "copyright", "credits" or "license" for more information.
>>> os_vers_1 = "10.9.5"
>>> os_vers_2 = "10.10"
>>> os_vers_2 > os_vers_1
False
>>> from distutils import version
>>> version.LooseVersion(os_vers_2) > version.LooseVersion(os_vers_1)
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:
<?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>_metadata</key>
<dict>
<key>created_by</key>
<string>gneagle</string>
<key>creation_date</key>
<date>2015-04-08T22:51:57Z</date>
#!/usr/bin/python
import os
some_dir = "/Users/Shared/temp"
for filename in os.listdir(some_dir):
name, ext = os.path.splitext(filename)
new_name = name[0:29] + ext
os.rename(os.path.join(some_dir, filename), os.path.join(some_dir, new_name))
@gregneagle
gregneagle / SetJavaSiteExceptionList.py
Last active August 29, 2015 14:18
A Python version of rtrouton's script that can handle an arbitrary number of URLs to be whitelisted
#!/usr/bin/python
'''Ensures urls are in the Oracle Java exception.sites list'''
# See https://derflounder.wordpress.com/2014/01/16/managing-oracles-java-exception-site-list/
import os
import sys
urls = [
'http://server1.some.com',
'http://server2.another.com',
<?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">
<array>
<dict>
<key>Application ID</key>
<string>UCCP14</string>
<key>Date</key>
<date>2014-10-29T07:00:00Z</date>
<key>Download Time</key>