Skip to content

Instantly share code, notes, and snippets.

View nmcspadden's full-sized avatar

Nick McSpadden nmcspadden

View GitHub Profile
@nmcspadden
nmcspadden / WP_adobeapi_adobetools.py
Created October 19, 2016 03:45
adobe_tools (Complete)
#!/usr/bin/python
"""Adobe API tools."""
import sys
import time
import json
import os
try:
import jwt
@nmcspadden
nmcspadden / WP_adobeapi_start.py
Last active October 19, 2016 02:41
adobe_tools start
#!/usr/bin/python
"""Adobe API tools."""
import sys
import time
import json
import os
try:
import jwt
# Ported from https://github.com/timsutton/osx-vm-templates/blob/master/scripts/support/set_kcpassword.py
key = [125, 137, 82, 35, 210, 188, 221, 234, 163, 185, 31]
key_len = key.length
newpasswd = []
passwd.each_char do |char|
newpasswd << char.ord
end
r = newpasswd.length % key_len
@nmcspadden
nmcspadden / bootstrap.py
Last active June 30, 2020 18:23
Bootstrap Chef
#!/usr/bin/python
"""Bootstrap Chef with no other dependencies."""
import os
import sys
import platform
import subprocess
import json
import plistlib
import urllib2
def app_paths(bundle_identifier)
# Search Spotlight for matching identifier, strip newlines
Mixlib::ShellOut.new(
"/usr/bin/mdfind \"kMDItemCFBundleIdentifier==#{bundle_identifier}\""
).run_command.stdout.split('\n').map!(&:chomp)
end
def installed?(bundle_identifier)
paths = app_paths(bundle_identifier)
!paths.empty?
paths_file = File.readlines('/etc/paths').map(&:strip)
[
'/opt/path/to/A',
'/opt/path/to/B',
].each do|path|
paths_file.unshift(path) unless paths_file.include?(path)
end
#!/usr/bin/python
import os
import sqlite3
tccpath = '/Library/Application Support/com.apple.TCC/TCC.db'
connection = sqlite3.connect(tccpath)
c = connection.cursor()
values = ('kTCCServiceAccessibility', 'com.rescuetime.RescueTime', 0)
c.execute('INSERT or REPLACE into access values(?, ?, ?, 1, 1, NULL, NULL)', values)
@nmcspadden
nmcspadden / ChefDK.download.recipe.xml
Last active February 4, 2016 18:28
ChefDK.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 latest Chef DK for Mac version.</string>
<key>Identifier</key>
<string>com.facebook.autopkg.download.chefdk</string>
<key>Input</key>
<dict>
@nmcspadden
nmcspadden / autodmg_output.py
Created December 28, 2015 18:41
sys.excepthook error generating a PyObjc exception
Build finished successfully, image saved to /Library/AutoDMG/AutoDMG_full.hfs.dmg
Build successful
2015-12-28 09:35:29.059 AutoDMG[1429:313432] PyObjC: Converting exception to Objective-C:
sys.excepthook is missing
lost sys.stderr
2015-12-28 09:35:29.059 AutoDMG[1429:313440] PyObjC: Converting exception to Objective-C:
sys.excepthook is missing
lost sys.stderr
2015-12-28 09:35:29.059 AutoDMG[1429:313434] PyObjC: Converting exception to Objective-C:
sys.excepthook is missing
def run(cmd):
'''Runs a command with subprocess, printing output in realtime'''
proc = subprocess.Popen(
cmd,
stdout=subprocess.PIPE,
stderr=subprocess.STDOUT
)
while proc.poll() is None:
l = proc.stdout.readline()
print l,