https://twitter.com/macgirl84/status/529097548338692096
https://twitter.com/agerstein/status/529443019800711168
https://twitter.com/tvsutton/status/529600119730343936
https://twitter.com/grahamgilbert/status/529702244602888192
https://twitter.com/mikeymikey/status/529718389972156416
https://twitter.com/Sacrilicious/status/529720151743406082
https://twitter.com/Sacrilicious/status/529750604437291008
https://twitter.com/mikeymikey/status/529760228884348928
https://twitter.com/natewalck/status/529780724321091584
https://twitter.com/rtrouton/status/529998791022489600
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| # Variations on a theme. | |
| # This first example uses a poorly documented trick in python regarding strings: | |
| # | |
| # https://docs.python.org/2/tutorial/introduction.html | |
| # "Two or more string literals (i.e. the ones enclosed between quotes) next to each other | |
| # are automatically concatenated." | |
| # | |
| # Then it's combined with the python implied line continuation by wrapping it in an outer | |
| # set of parentheses. |
When Apple moved to Xcode 5 (and later 6), they changed how you embed the Python.framework in a project: https://developer.apple.com/library/mac/technotes/tn2328/_index.html
This is a basic walkthrough of the process of conversion per that documentation for Xcode 6.
The example used here is the latest version of grahamgilbert's Crypt (at the time of this writeup): https://github.com/grahamgilbert/Crypt/tree/bdd49c849ed07fbc86d8c6f5bc31a525061d5077
(If you're viewing this via a gist blogging platform like roughdraft.io, make sure to view the original gist as there are image files included within the steps)
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| #!/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 |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| # Standalone mini version of pip | |
| # Geared towards Pythonista, but easily adaptable to other pure python installs | |
| import argparse, copy, gzip, os, os.path, re, requests, shutil, site, sys, tarfile, time, xmlrpclib | |
| # Where packages will end up installed | |
| site_packages = site.USER_SITE | |
| # Root of Pythonista saveable document location | |
| pythonista_base = os.path.split(site_packages)[0] | |
| # Temporary directory for work |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| # You need python 2.7 for this | |
| # FYI: There's a filepath hardcoded in this example at the end | |
| # If you've got python installed, you can run this with: python prison_json.py | |
| import re, mmap, collections, json, os | |
| # These are special keys which should be treated as an array/list of values | |
| multi_keys = ["Traits", "Reputation", "ReputationHigh"] | |
| def dequote(keyname): |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| import struct, hashlib | |
| def hashStringForPath(cls, path): | |
| hash_path = [None] * 28; | |
| md5_digest_hex = hashlib.md5(path).digest(); | |
| first_value = struct.unpack('>Q', md5_digest_hex[:8])[0]; | |
| second_value = struct.unpack('>Q', md5_digest_hex[8:])[0]; | |
| counter = 13; | |
| while counter >= 0: |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| #!/usr/bin/env python | |
| # To look at: https://github.com/kcrawford/mac-network/blob/master/lib/mac-network/wifi.rb | |
| # To look at: https://stackoverflow.com/questions/28096630/mac-os-x-10-10-reorder-preferred-networks | |
| ''' | |
| Playing around with CoreWLAN to return information about the wi-fi connection | |
| Documentation: | |
| https://developer.apple.com/library/mac/documentation/CoreWLAN/Reference/CWInterface_reference/translated_content/CWInterface.html |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| #!/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 |