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 ruby | |
require 'xcodeproj' | |
require 'open3' | |
require 'ostruct' | |
require 'timeout' | |
require 'benchmark' | |
class Device |
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
ACTION = build | |
AD_HOC_CODE_SIGNING_ALLOWED = NO | |
ALTERNATE_GROUP = staff | |
ALTERNATE_MODE = u+w,go-w,a+rX | |
ALTERNATE_OWNER = grantdavis | |
ALWAYS_SEARCH_USER_PATHS = NO | |
ALWAYS_USE_SEPARATE_HEADERMAPS = YES | |
APPLE_INTERNAL_DEVELOPER_DIR = /AppleInternal/Developer | |
APPLE_INTERNAL_DIR = /AppleInternal | |
APPLE_INTERNAL_DOCUMENTATION_DIR = /AppleInternal/Documentation |
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
def app_store_license(bundle_id: nil, license: "", countries: nil) | |
# Make sure your Spacehip::Tunes.client is already logged in | |
app = Spaceship::Tunes::Application.find(bundle_id) | |
raise "Could not find an app with the bundle ID `#{bundle_id}`" unless app | |
app_id = app.apple_id | |
details = app.details | |
url = "https://appstoreconnect.apple.com/WebObjects/iTunesConnect.woa/ra/apps/#{app_id}/details" |
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
def set_data_protection(bundle_id: nil, level: nil) | |
puts "Setting data protection level to `#{level}` for `#{bundle_id}`" | |
token = Spaceship::ConnectAPI::Token.create() | |
client = Spaceship::ConnectAPI::Provisioning::Client.new(token: token) | |
# Bundle IDs have, themselves, a unique ID. We’ll have to look that up first before firing off this request. | |
bundle_info = Spaceship::ConnectAPI::BundleId.all(filter: {identifier: bundle_id}).first | |
bundle_id_id = bundle_info.id |
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
now = DateTime.now.to_time | |
# You can test different times, like testing 300 days in the future with: now = (DateTime.now + 300).to_time | |
provisioning_profile = "~/Library/MobileDevice/Provisioning Profiles/11BBCC...AF21BD2.mobileprovision" | |
expiration_string = `/usr/libexec/PlistBuddy -c 'Print :ExpirationDate' /dev/stdin <<< $(security cms -D -i #{provisioning_profile})`.chomp | |
expiration_date = DateTime.strptime(expiration_string, '%a %b %d %H:%M:%S PST %Y').to_time | |
remaining_days = (expiration_date.to_i - now.to_i) / (3600 * 24) | |
if remaining_days < 1 | |
# Delete ".red" if you aren’t using the Colorize gem |
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 ruby | |
#coding:utf-8 | |
require "open-uri" | |
require "fileutils" | |
destination_path = ENV['RSS_DOWNLOAD_DESTINATION'] || File.expand_path('.') | |
feed_url = ENV['RSS_FEED'] | |
feed_file = URI.parse(feed_url).open | |
feed_file.close |
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
fileprivate extension NSObject { | |
/** | |
Initializes private init() subclasses of NSObject. Pure Swift classes | |
(and especially structs) will not work here. | |
``` | |
// Given a class “PrivateInitClass” where `init()` is private | |
let somePrivateInitClassInstance = (PrivateInitClass.forcedInit() as PrivateInitClass) | |
``` | |
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
// Douglas Hill, December 2018 | |
// Made for https://douglashill.co/reading-app/ | |
import UIKit | |
/// A table view that allows navigation and selection using a hardware keyboard. | |
/// Only supports a single section. | |
class KeyboardTableView: UITableView { | |
// These properties may be set or overridden to provide discoverability titles for key commands. | |
var selectAboveDiscoverabilityTitle: String? |
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
// Normal array of strings | |
let array = ["This", "is", "string", "array"] | |
let characters = array.flatMap { | |
$0.characters | |
} | |
// This prints ["T", "h", "i", "s", "i", "s", "s", "t", "r", "i", "n", "g", "a", "r", "r", "a", "y"] | |
print(characters) | |
let words = array.flatMap { |
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
// Light syntax cleanup from https://gist.github.com/daehn/f17e8cdcf8d91b046f3c | |
private extension String { | |
subscript(index: Int) -> Character { | |
return self[startIndex.advancedBy(index)] | |
} | |
subscript(range: Range<Int>) -> String { | |
let start = startIndex.advancedBy(range.startIndex) |
NewerOlder