Skip to content

Instantly share code, notes, and snippets.

pudquick /
Created Mar 6, 2017
Storing and retrieving a generic password in the login.keychain in macOS via python and pyobjc
import objc
from ctypes import c_char
from Foundation import NSBundle
Security = NSBundle.bundleWithIdentifier_('')
S_functions = [
('SecKeychainGetTypeID', 'I'),
('SecKeychainItemGetTypeID', 'I'),
('SecKeychainAddGenericPassword', 'i^{OpaqueSecKeychainRef=}I*I*I*o^^{OpaqueSecKeychainItemRef}'),
('SecKeychainOpen', 'i*o^^{OpaqueSecKeychainRef}'),
pudquick /
Last active Dec 7, 2020
Stupid tricks: using stock macOS python subprocess with curl to download products from Apple's Developer Center
from subprocess import Popen, PIPE, STDOUT, check_output
from mimetools import Message
from StringIO import StringIO
from urlparse import urlparse, parse_qs
from urllib import quote, basejoin, urlencode
AUTH_PATH = '/IDMSWebAuth/authenticate'
APPIDKEY_PATH = "/services-account/download?path=%s"
bruienne /
Created Sep 27, 2016
Basic concept for querying for Google Chrome updates based on current Chrome version/OS/arch
import xml.etree.ElementTree as ET
import requests
import uuid
params = {'cup2hreq': 'foo', 'cup2key': 'bar'}
platform = 'mac'
os_version = '10.12'
jessepeterson /
Last active May 30, 2018
getgrouplist using OS X-specific API
import grp, pwd, os
from ctypes import *
from ctypes.util import find_library
libc = cdll.LoadLibrary(find_library('libc'))
# getgrouplist_2() is an undocumented API which, I beleive, retrives all of
# a user's groups instead of the maximum 16 groups which getgrouplist() gets
timsutton /
Last active Mar 7, 2018
Clear storeagent cache and trigger Mac App Store app updates.
# Trigger an update of MAS (and softwareupdate) apps
# This seems to be all that's needed to schedule an immediate update of
# MAS apps. This should be run as a normal user. You can run this and
# tail the install log to get an idea of what's happening.
# You can also take a look at this user's ~/Library/Caches/
# directory to get a report on what apps were available, installable, etc.
pudquick /
Last active Mar 9, 2021
Mac App Store updates
# App Store playing
import urllib, urllib2, json, plistlib
# Utility function for performing an iTunes-style search
def perform_itunes_search(api_url, query_list=[]):
query_str = urllib.urlencode(query_list)
response_handle = urllib2.urlopen('' % (api_url, query_str))
gregneagle /
Last active Jun 1, 2018
import sys
import os
from Foundation import NSDate
from Foundation import NSPredicate
def doComparison(comp_string, obj):
print 'Comparison: %s' % comp_string