Skip to content

Instantly share code, notes, and snippets.

Python 2.7.5 (default, Mar 9 2014, 22:15:05)
[GCC 4.2.1 Compatible Apple LLVM 5.0 (clang-500.0.68)] on darwin
Type "help", "copyright", "credits" or "license" for more information.
>>> a = "AdobeDreamweaverCS5.5.png"
>>> import os
>>> os.path.splitext(a)[1]
'.png'
>>> os.path.splitext(a)[0]
'AdobeDreamweaverCS5.5'
@gregneagle
gregneagle / gist:60ce73c7e267d993f1c1
Created August 13, 2014 17:23
Using the SystemConfiguration framework via PyObjC to get "ComputerName"
import SystemConfiguration
prefs = SystemConfiguration.SCPreferencesCreate(None, "SystemConfiguration", None)
print SystemConfiguration.SCPreferencesGetValue(prefs, "System")["System"]["ComputerName"]
@gregneagle
gregneagle / First run
Last active August 29, 2015 14:05
Autopkg .install recipe demo
% ./autopkg run Firefox.install -v
Processing Firefox.install...
MozillaURLProvider
MozillaURLProvider: Found URL http://ftp.mozilla.org/pub/mozilla.org//firefox/releases/latest/mac/en-US/Firefox%2031.0.dmg
URLDownloader
URLDownloader: Storing new Last-Modified header: Thu, 17 Jul 2014 03:38:41 GMT
URLDownloader: Storing new ETag header: "4b25e62-3c17d83-4fe5b607b1240"
URLDownloader: Downloaded /Users/gneagle/Library/AutoPkg/Cache/com.github.autopkg.install.Firefox_EN/downloads/Firefox.dmg
EndOfCheckPhase
AppDmgVersioner
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE plist PUBLIC "-//Apple Computer//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
<plist version="1.0">
<dict>
<key>catalogs</key>
<array>
</array>
<key>conditional_items</key>
<array>
<dict>
# sudo managedsoftwareupdate -vvvv --applesus
Managed Software Update Tool
Copyright 2010-2014 The Munki Project
http://code.google.com/p/munki
Starting...
Performing preflight tasks...
preflight stdout: Preflight report submmitted for Greg-Neagle--tic.
NOTE: managedsoftwareupdate is configured to process Apple Software Updates only.
Checking Apple Software Update catalog...
#!/bin/sh
# Master login hook script
#
# runs each script found in the login hooks directory
LOGINHOOKSDIR="/etc/hooks/login"
if [ -d ${LOGINHOOKSDIR} ]; then
for script in ${LOGINHOOKSDIR}/* ; do
@gregneagle
gregneagle / gist:fc66882e6fae64d82c8d
Created December 10, 2014 18:12
Demo of determining if a Google account has 2FA active
#!/usr/bin/python
# Demo of determinining if a Google account has 2FA active
# Needs a Google account ID (email address) and a password
# If the password is the "main" password (not an app-specific password)
# and "Two-factor authentication required" is returned; then 2FA is active
import urllib
import urllib2
@gregneagle
gregneagle / gist:a46a7d80504d3364525a
Created January 2, 2015 16:44
Xprotect and Gatekeeper
% softwareupdate -l
Software Update Tool
Copyright 2002-2012 Apple Inc.
Finding available software
Software Update found the following new or updated software:
* XProtectPlistConfigData-1.0
XProtectPlistConfigData (1.0), 10K [recommended]
* Gatekeeper Configuration Data-54
Gatekeeper Configuration Data (54), 3259K [recommended]
@gregneagle
gregneagle / 031-17159.dist
Created January 27, 2015 19:12
Dist for 10.10.2 update
<?xml version="1.0" encoding="UTF-8" standalone="no"?>
<installer-gui-script minSpecVersion="1">
<options allow-install-later="true" should-authenticate-reboot="true" post-logout="true" should-launch-first-login-optimization="true"/>
<title>SU_TITLE</title>
<script/>
<volume-check script="VolumeCheck()"/>
<installation-check script="InstallationCheck()"/>
<script>
function compareBuildVersions(lhs, rhs) {
var lhsMatch = lhs.match(/([0-9]+)([A-Z])([0-9]+)([a-z])?/);
<?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 Firefox disk image, builds a package, including autoconfig
resources (typically as generated via the CCK2 tool), then imports the pkg into
your Munki repo.
Place the autoconfig.zip in the same directory as the recipe. You may