Skip to content

Instantly share code, notes, and snippets.

View keith's full-sized avatar

Keith Smiley keith

View GitHub Profile
@keith
keith / sudoers
Last active July 4, 2025 00:24
The default macOS 14.2.1 sudoers file
#
# Sample /etc/sudoers file.
#
# This file MUST be edited with the 'visudo' command as root.
#
# See the sudoers man page for the details on how to write a sudoers file.
##
# Override built-in defaults
##
@keith
keith / testflight.sh
Last active March 7, 2025 06:21
Upload an ipa to testflight using altool
#!/bin/bash
set -euo pipefail
xcrun altool --upload-app --type ios --file "path/to/foo.ipa" --username "$ITC_USER" --password "$ITC_PASSWORD"
@keith
keith / exclusivity.md
Last active January 11, 2025 03:47
The matrix of Xcode build settings to compiler flags for Swift memory exclusivity
  • Compiler flag: -enforce-exclusivity=<value>
  • Build setting: SWIFT_ENFORCE_EXCLUSIVE_ACCESS

Xcode 10.1 & Swift 4.2

  • Compiler default for non optimized builds if you pass no argument is the same as if you passed checked
  • Compiler default for optimized builds if you pass no argument is the same as if you passed unchecked
Configuration Compiler Flag Value Build Setting Description Build Setting Value Notes
@keith
keith / README.md
Last active January 8, 2025 18:59
A test of `@_dynamicReplacement` in Swift

Usage

  1. swiftc main.swift -emit-module-path main.swiftmodule -emit-executable -enable-private-imports -Xfrontend -enable-implicit-dynamic
  2. ./main -> prints From original bar()
  3. swiftc -emit-library inject.swift -o inject.dylib -I . -Xlinker -undefined -Xlinker suppress -Xlinker -flat_namespace -Xfrontend -disable-access-control
  4. DYLD_INSERT_LIBRARIES=inject.dylib ./main -> prints From replacement bar()

Notes

  • Passing -Xfrontend -enable-implicit-dynamic removes you from having to add dynamic to everything you want to be replacable
@keith
keith / newSite.rb
Created September 25, 2012 18:03
Quickly create a new site complete with boilerplate
#!/usr/bin/ruby
#
# Purpose:
# This script is for easily creating new websites with different boilerplates
# to minimize the amount of wasted time downloading and renaming files
#
# Installation:
# 1. Put this script somewhere permanent where you can call it from
# 2. In terminal run `chmod 755 newSite.rb` # Or whatever you name the script
@keith
keith / simctl-commands.txt
Last active December 7, 2022 23:27
All the subcommands of `xcrun simctl` (including ones that aren't listed in `simctl help`) LC_SOURCE_VERSION 776.1 (Xcode 13.0 beta 5)
addmedia
addphoto
addvideo
appinfo
boot
bootstatus
clone
create
darwinup
delete
@keith
keith / SpawniTerm.applescript
Last active July 22, 2022 19:37
Spawn a new iTerm window in the pwd
on run argv
tell application "iTerm"
set t to make new terminal
tell t
activate current session
launch session "Default Session"
tell the last session
write text "cd \"" & item 1 of argv & "\"; clear; pwd"
end tell
end tell
@keith
keith / RadarDocument.swift
Created July 20, 2017 07:17
NSDocument canClose in Swift
/// So, lets talk about AppKit. The way this function works is by passing a delegate (which is required
/// to be a NSObject, but here is typed as Any) which turns out to be the same type as `self`, a Selector,
/// which in this case is `_something:didSomething:soContinue:` (not kidding), and some "contextInfo"
/// (which is actually a block). While all of these arguments appear to be optional, passing nil through
/// to the function call that `shouldCloseSelector` defines, or passing nil to super, will cause the app
/// to crash. So then we need to call the function on `delegate` defined by `shouldCloseSelector`.
///
/// According to the documentation the function signature for this selector looks like this:
/// - (void)document:(NSDocument *)doc shouldClose:(BOOL)shouldClose contextInfo:(void *)contextInfo
///
@keith
keith / delete-apps.rb
Last active September 10, 2018 23:39
A script for prompting to delete app ids from the provisioning portal
require 'spaceship'
Spaceship::Portal.login
Spaceship::Portal.select_team
Spaceship::Portal.app.all.collect do |app|
print "Delete #{ app.bundle_id }? [y/N]: "
delete = gets.strip.downcase == "y"
if delete
puts "Deleting #{ app.bundle_id }"
@keith
keith / medium-draft.rb
Last active September 1, 2017 16:01
Create a medium post from a GitHub flavored markdown file
#!/usr/bin/env ruby
#
# Usage: medium-draft TOKEN FILENAME
# Where TOKEN is a medium integration token and FILENAME is the path to the
# markdown file you'd like to post
#
# Get your token from https://medium.com/me/settings (integration tokens section)
#
# This requires httparty and redcarpet
# Install with: