Skip to content

Instantly share code, notes, and snippets.

Nick McSpadden nmcspadden

Block or report user

Report or block nmcspadden

Hide content and notifications from this user.

Learn more about blocking users

Contact Support about this user’s behavior.

Learn more about reporting abuse

Report abuse
View GitHub Profile
View WP_adobeapi_adobetools.py
#!/usr/bin/python
"""Adobe API tools."""
import sys
import time
import json
import os
try:
import jwt
View WP_adobeapi_start.py
#!/usr/bin/python
"""Adobe API tools."""
import sys
import time
import json
import os
try:
import jwt
View kcpassword.rb
# 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 Oct 7, 2016
Bootstrap Chef
View bootstrap.py
#!/usr/bin/python
"""Bootstrap Chef with no other dependencies."""
import os
import sys
import platform
import subprocess
import json
import plistlib
import urllib2
View CPE_utils.rb
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?
View sample.rb
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
View rescueTimeAccessibility.py
#!/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)
View ChefDK.download.recipe.xml
<?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 Dec 28, 2015
sys.excepthook error generating a PyObjc exception
View autodmg_output.py
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
View test.py
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,
You can’t perform that action at this time.