Skip to content

Instantly share code, notes, and snippets.

View WardsParadox's full-sized avatar

Zack McCauley WardsParadox

View GitHub Profile
@macshome
macshome / IOKit.swift
Last active April 29, 2024 14:42
This playground shows you a few different ways to get device info via IOKit.
// This playground shows you a few different ways to get device info via IOKit.
// If you want to explore IOKit and look for interesting data I would download
// the Additional Developer Tools from Apple and use the IORegistryExplorer app.
// It makes it super easy to poke around in the IOKit planes.
import IOKit
import Foundation
// For convient access we can make a computed getter for the PlatformExpert.
// Traditionally this has been where you go to find all sorts of data about the
@santisbon
santisbon / Search my gists.md
Last active April 26, 2024 18:39
How to #search gists

Enter this in the search box along with your search terms:

Get all gists from the user santisbon.
user:santisbon

Find all gists with a .yml extension.
extension:yml

Find all gists with HTML files.
language:html

@DerekSelander
DerekSelander / objc_description.m
Last active April 22, 2024 19:48
Dumps Objective-C class/instance info at runtime
//
// MIT License
//
// Copyright (c) 2024 Derek Selander
//
// Permission is hereby granted, free of charge, to any person obtaining a copy
// of this software and associated documentation files (the "Software"), to deal
// in the Software without restriction, including without limitation the rights
// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
// copies of the Software, and to permit persons to whom the Software is
@miketaylr
miketaylr / defaultbrowser.py
Last active April 22, 2024 18:01
Set default browser on OSX with Python
#/usr/bin/env python
from LaunchServices import LSSetDefaultHandlerForURLScheme
from LaunchServices import LSSetDefaultRoleHandlerForContentType
# 0x00000002 = kLSRolesViewer
# see https://developer.apple.com/library/mac/#documentation/Carbon/Reference/LaunchServicesReference/Reference/reference.html#//apple_ref/c/tdef/LSRolesMask
LSSetDefaultRoleHandlerForContentType("public.html", 0x00000002, "com.operasoftware.operanext")
LSSetDefaultRoleHandlerForContentType("public.xhtml", 0x00000002, "com.operasoftware.operanext")
LSSetDefaultHandlerForURLScheme("http", "com.operasoftware.operanext")
LSSetDefaultHandlerForURLScheme("https", "com.operasoftware.operanext")
@pudquick
pudquick / self_signed.sh
Last active April 2, 2024 21:04
Non-interactive self-signed unencrypted keypair generation for HTTPS for arbitrary domain with SAN
# Make a self-signed private/public keypair usable for HTTPS, including SAN / Subject Alternative Name and CN / Common Name, non-interactively and without additional files
# Parentheses around the command spin it up in a subshell so that the FQDOMAIN variable is local to execution and doesn't persist after it's created
(FQDOMAIN="example.local" && openssl req -x509 -nodes -newkey rsa:4096 -keyout server_key.pem -keyform PEM -days 365 -subj "/CN=${FQDOMAIN}" -addext 'basicConstraints=CA:FALSE' -addext "subjectAltName=DNS:${FQDOMAIN}" -addext 'keyUsage=digitalSignature' -addext 'extendedKeyUsage=serverAuth' -out server_cert.pem -outform PEM 2>/dev/null)
# Alternatively, if you're setting FQDOMAIN somewhere else, you can just run directly:
openssl req -x509 -nodes -newkey rsa:4096 -keyout server_key.pem -keyform PEM -days 365 -subj "/CN=${FQDOMAIN}" -addext 'basicConstraints=CA:FALSE' -addext "subjectAltName=DNS:${FQDOMAIN}" -addext 'keyUsage=digitalSignature' -addext 'extendedKeyUsage=serverAuth' -out server_
@SchizoDuckie
SchizoDuckie / build_mac.sh
Created July 7, 2015 20:55
Build an OSX .pkg installer from Linux using mkbom and xar
#!/bin/bash
# change the values below to match your system.
# target the BUILD_DIR to output from an nw.io build process. nwjs-shell-builder recommended!
# https://github.com/Gisto/nwjs-shell-builder
# BASE_DIR is the target directory for this script, where files will be gathered and packaged to
BUILD_DIR=”/var/www/deploy/TMP/osx-ia32/latest-git”
BASE_DIR=”/var/www/deploy/osx” 
@gregneagle
gregneagle / fancy_defaults_read.py
Last active February 6, 2024 15:14
fancy_defaults_read.py: Reads a preference, prints its value, type, and where it is defined.
#!/usr/bin/python
import os
import sys
from CoreFoundation import (CFPreferencesAppValueIsForced,
CFPreferencesCopyAppValue,
CFPreferencesCopyValue,
kCFPreferencesAnyUser,
kCFPreferencesAnyHost,
@pudquick
pudquick / isM1.py
Last active September 28, 2023 16:27
Determine if a Mac can run ARM64 code, whether or not the binary is running in Rosetta 2 via pyobjc
# https://developer.apple.com/documentation/corefoundation/3684868-cfbundleisarchitectureloadable?language=objc
# https://developer.apple.com/documentation/foundation/1495005-mach-o_architecture?language=occ
# https://developer.apple.com/documentation/foundation/1495005-mach-o_architecture/nsbundleexecutablearchitecturearm64?language=occ
from Foundation import NSBundle
import objc
CF = NSBundle.bundleWithPath_('/System/Library/Frameworks/CoreFoundation.framework')
f = [('CFBundleIsArchitectureLoadable', 'BQ')]
objc.loadBundleFunctions(CF, globals(), f)
NSBundleExecutableArchitectureARM64 = 0x0100000c
@pudquick
pudquick / nibbler.py
Last active February 16, 2023 06:07
nibbler - Use .nib files with python to quickly make UIs
# OFFICIAL REPO: https://github.com/pudquick/nibbler
# (this gist will be preserved for historical purposes)
# demo video here:
# https://www.dropbox.com/s/k0bpekd13muknmz/nibbler%20-%20by%20frogor.mp4?dl=0
# Example script using nibbler:
# from nibbler import *
#
@pudquick
pudquick / mount_shares_better.py
Last active January 19, 2023 22:07
Mounting shares in OS X using python and pyobjc - works with OS X 10.8+
import objc, CoreFoundation, Foundation
class attrdict(dict):
__getattr__ = dict.__getitem__
__setattr__ = dict.__setitem__
NetFS = attrdict()
# Can cheat and provide 'None' for the identifier, it'll just use frameworkPath instead
# scan_classes=False means only add the contents of this Framework
NetFS_bundle = objc.initFrameworkWrapper('NetFS', frameworkIdentifier=None, frameworkPath=objc.pathForFramework('NetFS.framework'), globals=NetFS, scan_classes=False)