Skip to content

Instantly share code, notes, and snippets.

View eahrold's full-sized avatar

Eldon Ahrold eahrold

View GitHub Profile
@eahrold
eahrold / github_latest_release.py
Created July 12, 2014 04:06
get the URL for the uploaded dmg, zip, or gzip from the latest release using api.github.com
import json
import urllib2
def github_latest_release(user,repo):
SUPPORTED_TYPES=['dmg','zip','gz']
DEST=str(u'https://api.github.com/repos/%s/%s/releases' % (user,repo))
data = json.load(urllib2.urlopen(DEST))
try:
latest_release = data[0]['assets'][0]['browser_download_url']
for t in SUPPORTED_TYPES:
@eahrold
eahrold / format_string.m
Created April 23, 2014 17:40
formatted strings in objective-c classes
-(void)writeFormatString:(NSString*)format, ...
{
if(format){
va_list args;
va_start(args, format);
NSString *str = [[NSString alloc] initWithFormat:format arguments:args];
va_end(args);
}
}
@eahrold
eahrold / Jave SE6 for OS X
Last active August 29, 2015 13:58
Adobe CS6 Needs Java SE6 Runtime... Here's the OS X Link
http://swcdn.apple.com/content/downloads/21/49/091-7363/o9veiecea89qkdmk94met1af4wu2fuwn2j/JavaForOSX.pkg
@eahrold
eahrold / HelperTool_CodeSign_RunScript.py
Created February 24, 2014 22:45
Automatically get the proper Values in a PriviledgedHelperTool's Info.plist / LaunchD
#!/usr/bin/python
''' Place this script at the root of the project directory
and enter this for a Run Script during build phase of the helper app
${PROJECT_DIR}"/HelperTool_CodeSign_RunScript.py
put the run script right after Target Dependencies
What this script does is write the SMPrivilegedExecutables dictionary
@eahrold
eahrold / closeapp.py
Created January 14, 2014 18:00
close a running application with python and NSWorkspace
#!/usr/bin/python
from AppKit import NSWorkspace
def closeRunningApplication(bundle_id):
ws = NSWorkspace.sharedWorkspace()
runningApps = ws.runningApplications()
for i in runningApps:
if i.bundleIdentifier() == bundle_id:
i.terminate()
@eahrold
eahrold / rm_global_login.py
Last active January 3, 2016 04:49
Global Login Item are deprecated remove them with this
#!/usr/bin/python
'''
Pass in the Full path to the application as the first arg
for example /usr/local/sbin/rm_global_login.py /Applicaitons/MunkiMenu.app
'''
import os
import sys
from LaunchServices import *
@eahrold
eahrold / launchatlogin.py
Last active June 22, 2020 16:41
Launch App At Login via LaunchAgent py (for munki)
#!/usr/bin/python
import subprocess
import plistlib
from os import seteuid
from ServiceManagement import *
from SystemConfiguration import SCDynamicStoreCopyConsoleUser
installdir = 'Applications'
@eahrold
eahrold / CFPreference Domains
Last active June 22, 2020 17:50
CFPreference Domains
Precedence is:
/Library/Managed Preferences/ -- MCX
~/Library/Preferences -- User Home
/Library/Preferences/ -- Shared
~/Library/Preferences/com.app.plist = kCFPreferencesCurrentUser
kCFPreferencesCurrentApplication
kCFPreferencesAnyHost
~/Library/Preferences/.GlobalPreferences = kCFPreferencesCurrentUser
@eahrold
eahrold / cecho
Created January 8, 2014 23:12
Color Read / Color Echo in bash
#!/bin/bash
cread(){
case "$1" in
red|alert) local COLOR=$(printf "\\e[1;31m");;
green|attention) local COLOR=$(printf "\\e[1;32m");;
yellow|warn) local COLOR=$(printf "\\e[1;33m");;
blue|question) local COLOR=$(printf "\\e[1;34m");;
purple|info) local COLOR=$(printf "\\e[1;35m");;
cyan|notice) local COLOR=$(printf "\\e[1;36m");;
@eahrold
eahrold / mwa_to_xls
Last active January 2, 2016 12:59
Export MunkiWebAdmin Data to CVS
sqlite3 -csv munkiwebadmin.db "SELECT * FROM reports_machine;"