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 DateComponents { | |
| subscript(unit: String) -> Int { | |
| get { | |
| switch unit { | |
| case "month": | |
| return self.month! | |
| case "day": | |
| return self.day! | |
| case "hour": | |
| return self.hour! |
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
| # Open File or Folder with an application | |
| # | |
| # Create Automator new Quick Action workflow with these 3 actions: | |
| # 1. Workflow receives "files or folders" in "any application | |
| # 2. Get Specified Finder Items - used for debugging | |
| # 3. Run Apple Script | |
| # | |
| # Paste script below and change Atom.app to any other appp | |
| # Test shell script command works in terminal | |
| # Test Automator workflow by adding items in step 2 |
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
| objc_exception_throw: | |
| console command: | |
| script lldb.process.Continue() if (lldb.frame.GetThread().GetName() == "skip-objc_exception_throw") else None |
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 ChainedResolver: ResolveDependency { | |
| public func resolve<Service>(_: Service.Type, name: String?) -> Service? { | |
| child.resolve(name: name) ?? parent.resolve(name: name) | |
| } | |
| let child, parent: ResolveDependency | |
| public init(child: ResolveDependency, parent: ResolveDependency) { | |
| self.child = child | |
| self.parent = parent |
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 class NameGenerator: NSObject { | |
| @Inject var now: () -> Date | |
| public func nextName() -> String { | |
| now().description | |
| } | |
| } |
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
| # Xcode Dervide Data clear | |
| alias xdd='rm -rf /tmp/DerivedData' | |
| # WorkSpace open | |
| alias ws='find . -name *.xcworkspace -exec open {} \;' |
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
| let defaultAssert = { | |
| (_ condition: @autoclosure () -> Bool, | |
| _ message: @autoclosure () -> String, | |
| file: StaticString, | |
| line: UInt) in | |
| Swift.assert(condition(), message(), file: file, line: line) | |
| } | |
| var evaluateAssert: (@autoclosure () -> Bool, | |
| @autoclosure () -> String, | |
| _ file: StaticString, |
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
| import Quick | |
| import Nimble | |
| class ActionSpec: QuickSpec { | |
| override func spec() { | |
| describe("UIAction") { | |
| it("should invoke handler") { | |
| waitUntil { done in | |
| let action = UIAction(title: "a title") { action in | |
| done() |
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 func frequencies(input: [String]) -> [String: Int] { | |
| return Dictionary(input.map {($0, 1)}, uniquingKeysWith: +) | |
| } |
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
| import UIKit | |
| import Siesta | |
| class LoginOrSignupViewController: UIViewController { | |
| @IBAction func logIn() { | |
| let user = User(email: emailTextField.text!, password: passwordTextField.text!, name: nameTextField?.text) | |
| api.login(user) | |
| .onSuccess(weak(self, type(of: self).transitionToApp)) | |
| .onFailure(weak(self, type(of: self).showError)) |