Skip to content

Instantly share code, notes, and snippets.

import sys, os, os.path, tempfile, plistlib, shutil, marshal, subprocess, pickle, textwrap
class TempApp(object):
_skeleton_app = textwrap.dedent("""
import sys, marshal, types, pickle
main_func_marshal = %s
args_pickle = %s
code = marshal.loads(main_func_marshal)
main_func = types.FunctionType(code, globals(), "main_func")
args = dict(pickle.loads(args_pickle))
@Norod
Norod / openssl-build.sh
Last active July 19, 2020 22:33 — forked from foozmeat/openssl-build.sh
A shell script to build openssl for iOS and Mac. >>>>> It currently builds: Mac (i386, x86_64) >>>>> iOS (armv7, arm64) >>>>> iOS Simulator (i386, x86_64) >>>>> Updated to work with Xcode 7 and produce bitcode enabled binaries >>>>> Minimum deployment target can be easily configured
#!/bin/bash
# This script builds the iOS and Mac openSSL libraries with Bitcode enabled
# Download openssl http://www.openssl.org/source/ and place the tarball next to this script
# Credits:
# https://github.com/st3fan/ios-openssl
# https://github.com/x2on/OpenSSL-for-iPhone/blob/master/build-libssl.sh
# Peter Steinberger, PSPDFKit GmbH, @steipete.
# Doron Adler, GlideTalk, @Norod78
@pudquick
pudquick / osx_backdrop.py
Last active September 30, 2016 13:56
Python to show an image centered on a black background as your OS X desktop while other python code can run
#!/usr/bin/python
# Put a background in the same directory as this .py file and name it
backdrop_filename = "backdrop.jpg"
# http://wallreborn.com/wp-content/uploads/2015/05/cool-desktop-backgrounds-8-Cool-Wallpaper.jpg
# is a pretty sweet example to try with
# Then run this script from the Terminal :)
@pudquick
pudquick / purl.py
Last active May 14, 2020 15:44
This example builds on the Gurl class from gurl.py in munki and creates a POST variant called Purl
# Based on: https://developer.apple.com/library/mac/documentation/Cocoa/Conceptual/URLLoadingSystem/Tasks/UsingNSURLConnection.html#//apple_ref/doc/uid/20001836-SW5
from gurl import *
from Foundation import NSData, NSString
class Purl(Gurl):
'''A POST variant of Gurl'''
def initWithOptions_(self, options):
'''Set up our Purl object'''
# Inherit our basic setup from Gurl
@pudquick
pudquick / reorder_wifi.py
Last active July 16, 2022 01:03
This python code uses Objective-C calls to reorder pre-existing SSIDs in your WiFi interfaces to place a preferred SSID at the top (without removing / re-adding)
#!/usr/bin/python
# As written, this requires the following:
# - OS X 10.6+ (may not work in 10.10, haven't tested)
# - python 2.6 or 2.7 (for collections.namedtuple usage, should be fine as default python in 10.6 is 2.6)
# - pyObjC (as such, recommended to be used with native OS X python install)
# Only tested and confirmed to work against 10.9.5
# Run with root
@pudquick
pudquick / beamsync.py
Last active September 28, 2023 15:16
#!/usr/bin/python
import ctypes, ctypes.util
# Import CoreGraphics as a C library, so we can call some private functions
c_CoreGraphics = ctypes.CDLL(ctypes.util.find_library('CoreGraphics'))
def disable_beam_sync(doDisable):
if doDisable:
# Disabling beam sync:
# 1st: Enable Quartz debug
@rmanly
rmanly / frogor_current_user.py
Last active January 26, 2016 18:37
use SystemConfiguration to get console user vs. stat'ing /dev/console etc.
# frogor user check v1
# http://osx.michaellynn.org/freenode-osx-server/freenode-osx-server_2013-04-09.html
from SystemConfiguration import SCDynamicStoreCopyConsoleUser
from objc import NULL
import sys
username = (SCDynamicStoreCopyConsoleUser(NULL, NULL, NULL) or [NULL])[0]
username = [username,''][username in [u"loginwindow", None]]
sys.stdout.write(username + "\n")
@Eccenux
Eccenux / archive.py
Last active October 8, 2015 06:54
Python archive (zip) helper class
#!/usr/bin/env python
import os
import zipfile
"""
Helper class that lets one add whole directory contents.
License
--------------------
@ashishb
ashishb / gist:da145a877139fcd91e3f
Created July 6, 2014 08:36
Fix for "Unapproved caller. SecurityAgent may only be invoked by Apple software"
- Start on single user mode: Hit the Command and S keys at start-up
Wait until the writing stops completely
-At the line, type (after root): /sbin/fsck -fy (space after the k)
Hit the ENTER key
wait until it finishes and says "... appears to be OK"
next, type: /sbin/mount -uw / (space after the t and after the w)
@bruienne
bruienne / sample_802.1x_loginwindow.mobileconfig
Last active March 9, 2018 15:41
Skeleton mobileconfig plist that enables 802.1x login to Wifi network at OS X login window
<?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>PayloadCertificateFileName</key>
<string>my.org.cer</string>
<key>PayloadContent</key>