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
final class HelloWorldViewModel: ViewModelType { | |
let input: Input | |
let output: Output | |
struct Input { | |
let name: Anyobserver<String> | |
} | |
struct Output { | |
let greeting: Driver<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
extension Collection { | |
func anySatisfy(_ p: (Element) -> Bool) -> Bool { | |
return !self.allSatisfy { !p($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
public struct PermutationIterator<T>: IteratorProtocol { | |
private var hasReturnedInitial = false | |
private var a: [T] | |
private var c: [Int] | |
private let n: Int | |
private var i = 0 | |
public init<C: Collection>(_ values: C) where C.Element == T { | |
a = Array(values) | |
n = a.count |
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 sh | |
set -e | |
fancy_echo() { | |
local fmt="$1"; shift | |
printf "\n$fmt\n" "$@" | |
} |
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 sh | |
# Xcode sometimes gets sad and won't index or other shenanigans. You can easily cheer up Xcode | |
# and get things happy again by simply removing some files. This little script does just that. | |
# Quit Xcode | |
osascript -e 'tell app "Xcode" to quit' | |
# Remove derived data | |
rm -rf ~/Library/Developer/Xcode/DerivedData/* |
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
#!/bin/sh | |
# | |
# Lint any changed files using swiftlint. | |
# | |
# This works both independently and as a run phase script. | |
# Path to installed version of Swift lint. | |
readonly SWIFT_LINT_PATH=$(which swiftlint) | |
if [ -z "$SWIFT_LINT_PATH" ]; then |
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
-- Sets your audio input source to "Internal Microphone" | |
-- Frequently needed if you use bluetooth headpohones and | |
-- run the Xcode iOS simulator, which will often set your | |
-- headphones to be the input device, resulting in a drastic | |
-- decrease in sound quality, and making it mono | |
tell application "System Preferences" to activate | |
tell application "System Preferences" | |
reveal anchor "input" of pane id "com.apple.preference.sound" | |
end tell |
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
extension UIWindow { | |
final class StatusBarPreferringViewController: UIViewController { | |
// MARK: - Inputs | |
private let statusBarStyle: UIStatusBarStyle | |
// MARK: - Initialization | |
init(statusBarStyle: UIStatusBarStyle) | |
self.statusBarStyle = statusBarStyle |
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
public enum AssociationPolicy { | |
case assign | |
case retain | |
case copy | |
case retainNonatomic | |
case copyNonatomic | |
fileprivate var policy: objc_AssociationPolicy { | |
switch self { |
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
/// The HasCustomView protocol defines a customView property for UIViewControllers to be used in exchange of the regular view property. | |
/// In order for this to work, you have to provide a custom view to your UIViewController at the loadView() method. | |
public protocol HasCustomView { | |
associatedtype CustomView: UIView | |
} | |
extension HasCustomView where Self: UIViewController { | |
/// The custom typed view | |
public var customView: CustomView { | |
guard let customView = view as? CustomView else { |