This file contains 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 UIKit | |
class OnboardingManager { | |
private let userDefaults: UserDefaults | |
init(userDefaults: UserDefaults = .standard) { | |
self.userDefaults = userDefaults | |
} | |
func presentOnboardingControllerIfNeeded(in viewController: UIViewController) { |
This file contains 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
/** | |
* Perform a throwing expression, and throw a custom error in case the expression threw | |
* | |
* - parameter expression: The expression to execute | |
* - parameter error: The custom error to throw instead of the expression's error | |
* - throws: The given error | |
* - returns: The return value of the given expression | |
*/ | |
func perform<T>(_ expression: @autoclosure () throws -> T, orThrow errorExpression: @autoclosure () -> Error) throws -> T { | |
do { |
This file contains 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
target 'MyTarget' do | |
use_frameworks! | |
# Post installation script that enables the Swift 4.2 compiler's | |
# legacy 4.1 mode for 4.2-incompatible pods | |
post_install do |installer| | |
incompatiblePods = ['PodA', 'PodB'] | |
installer.pods_project.targets.each do |target| | |
if incompatiblePods.include? target.name |
This file contains 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 Foundation | |
import Files // marathon:https://github.com/JohnSundell/Files.git | |
import ShellOut // marathon:https://github.com/JohnSundell/ShellOut.git | |
// MARK: - Generation | |
guard let settingsBundle = try? Folder.current.subfolder(named: "Settings.bundle") else { | |
print("Create a Settings.bundle in Xcode, then re-run this script") | |
exit(1) | |
} |
This file contains 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
func testLoadingData() { | |
class NetworkEngineMock: NetworkEngine { | |
typealias Handler = NetworkEngine.Handler | |
var requestedURL: URL? | |
func performRequest(for url: URL, completionHandler: @escaping Handler) { | |
requestedURL = url | |
let data = “Hello world”.data(using: .utf8) |
This file contains 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 bash | |
# Put this file in /usr/local/bin and then run chmod +x on it to make it executable | |
command=$1 | |
shift | |
case $command in | |
"init" ) | |
swift package init "$@" |
This file contains 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 bash | |
# If run without a name, open any current repo | |
if [ -z "$1" ]; then | |
URL=$(git remote get-url origin) | |
URL=${URL/"git@github.com:"/"https://github.com/"} | |
URL=${URL/".git"/""} | |
open $URL | |
else | |
open "https://github.com/$1" |
This file contains 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
struct EnumSequence<T: RawRepresentable> where T.RawValue == Int {} | |
extension EnumSequence: Sequence { | |
func makeIterator() -> AnyIterator<T> { | |
var rawValue = 0 | |
return AnyIterator { | |
let nextCase = T(rawValue: rawValue) | |
rawValue += 1 | |
return nextCase |
This file contains 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 UIKit | |
// Create a protocol that defines what APIs that you need from the singleton | |
protocol Application { | |
func open(url: URL) | |
} | |
// Make the singleton-based class conform to your protocol | |
extension UIApplication: Application { | |
func open(url: URL) { |
This file contains 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 bash | |
# This script switches between the App Store version of Xcode and the beta | |
# Install it by copying it to /usr/local/bin/xcode-switch and running 'chmod +x' on it (to make it executable) | |
# Then run it using 'sudo xcode-switch' | |
if [ "$EUID" -ne 0 ]; then | |
echo "xcode-select requires you to run this script as root; 'sudo xcode-switch'" | |
exit | |
fi |