Skip to content

Instantly share code, notes, and snippets.

View clburlison's full-sized avatar

Clayton Burlison clburlison

View GitHub Profile
@clburlison
clburlison / args.py
Last active September 23, 2016 20:27 — forked from olooney/.gitignore
worked examples of argparse and python logging
#! /usr/bin/env python
"""Sample Code Demonstrating argparse and logging
Demonstrates appropriate logging techniques for a trivial command line program
that supports a variety of "verbosity" flags.
"""
import argparse
import logging
import logging.handlers
@clburlison
clburlison / reverseGeo.py
Created September 16, 2016 21:23
Using CoreLocation GeoCoder in PyObjC
#!/usr/bin/python
from CoreLocation import CLLocation
from CoreLocation import CLGeocoder
from Foundation import NSLog, NSRunLoop, NSDate
location = CLLocation.alloc().initWithLatitude_longitude_(37.331762, -122.030561)
address = "1 Infinite Loop, Cupertino, CA 95014"
def myCompletionHandler(placemarks, error):
#!/usr/bin/python
"""
Go use this instead: https://github.com/pbowden-msft/OfficeCDNCheck
A script to help determine which CDN you're client is talking to for
Microsoft Office 2016 updates.
Author: Clayton Burlison <https://clburlison.com>
Date Modifed: Sept. 14th, 2016
@clburlison
clburlison / GPG and git on macOS.md
Created July 28, 2016 13:25 — forked from danieleggert/GPG and git on macOS.md
How to set up git to use the GPG Suite

GPG and git on macOS

Setup

No need for homebrew or anything like that. Works with https://www.git-tower.com and the command line.

  1. Install https://gpgtools.org -- I'd suggest to do a customized install and deselect GPGMail.
  2. Create or import a key -- see below for https://keybase.io
  3. Run gpg --list-secret-keys and look for sec, use the key ID for the next step
  4. Configure git to use GPG -- replace the key with the one from gpg --list-secret-keys
@clburlison
clburlison / MAContent10_GarageBandCoreContent-2.0.0.0.1.1256150330.plist
Created March 1, 2016 15:34
GarageBand CoreContents Full pkginfo Examples
<?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>techsupport</string>
<key>creation_date</key>
<date>2015-10-26T19:49:14Z</date>
@clburlison
clburlison / simple_python_args_logging.py
Created February 15, 2016 18:54
Simple method for handling verbose logging with Python using argparse
#!/usr/bin/python
#http://stackoverflow.com/a/34065768/4811765
import argparse
import logging
parser = argparse.ArgumentParser()
parser.add_argument('-v', '--verbose', action='count', default=0)
args = parser.parse_args()
levels = [logging.WARNING, logging.INFO, logging.DEBUG]
@clburlison
clburlison / set_desktop.py
Created February 4, 2016 14:03
Outset Desktop Set Example
#!/usr/bin/python
'''Uses Cocoa classes via PyObjC to set a desktop picture on all screens.
Tested on Mountain Lion and Mavericks. Inspired by Greg Neagle's work: https://gist.github.com/gregneagle/6957826
See:
https://developer.apple.com/library/mac/documentation/cocoa/reference/applicationkit/classes/NSWorkspace_Class/Reference/Reference.html
https://developer.apple.com/library/mac/documentation/Cocoa/Reference/Foundation/Classes/NSURL_Class/Reference/Reference.html
@clburlison
clburlison / _0help.md
Last active January 31, 2016 02:10
Using Puppet Settings inside Puppet Code

So this took me a while to figure out. Puppet Code can use settings from puppet but they need to be defined by settings::LOOPUP_THING_HERE. As such, here a quick reference for myself.

You can retrevie your settings with:

sudo /usr/bin/puppet config print
sudo /opt/puppetlabs/bin/puppet config print

And for testing:

<?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.ScreenSharingSharedDefaults</key>
@clburlison
clburlison / preinstall_script
Created January 16, 2016 21:18
Office 2016 VL Serializer preinstall_script
#!/bin/bash
#
# Check for the existance of Microsoft's licensing file. If it exsits remove
# it prior to running Microsoft_Office_2016_VL_Serializer.pkg.
if [ -f '/Library/Preferences/com.microsoft.office.licensingV2.plist' ]; then
/bin/rm -f '/Library/Preferences/com.microsoft.office.licensingV2.plist'
fi
exit 0