- www.haiku-os.org / www.mobileinteraction.se
- @konrad1977
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
--recurse | |
--exclude=.git | |
--exclude=venv | |
--exclude=Pods | |
--exclude=Carthage | |
--exclude=vendor | |
--exclude=node_modules |
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
;; -*- mode: emacs-lisp; lexical-binding: t -*- | |
;; This file is loaded by Spacemacs at startup. | |
;; It must be stored in your home directory. | |
(defun dotspacemacs/layers () | |
"Layer configuration: | |
This function should only modify configuration layer settings." | |
(setq-default | |
;; Base distribution to use. This is a layer contained in the directory | |
;; `+distribution'. For now available distributions are `spacemacs-base' |
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 XCTest | |
// MARK: Comparable --- | |
@discardableResult | |
public func assertGreaterThan<A: Comparable>(_ lhs: A, _ rhs: A) -> String { | |
return lhs > rhs ? "✅" : "❌" | |
} | |
@discardableResult | |
public func assertGreaterThanOrEqual<A: Comparable>(_ lhs: A, _ rhs: A) -> String { |
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 Kitura | |
let router = Router() router.get("/") { request, response, next in | |
response.send("Hello, World!") | |
next() | |
} | |
Kitura.addHTTPServer(onPort: 8090, with: router) | |
Kitura.run() |
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 login() { | |
do { | |
let token = try loginUserWithUsername("konrad1977", password: nil) | |
print("user logged in \(token)") | |
} catch let error as LoginError { | |
print(error.description) | |
} catch { | |
print(error) | |
} |
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
extension LoginError : CustomStringConvertible { | |
var description: String { | |
switch self { | |
case .EmptyUsername: | |
return "Username cannot be empty" | |
case .EmptyPassword: | |
return "Password cannot be empty" | |
} | |
} |
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 login() { | |
do { | |
let token = try loginUserWithUsername("konrad1977", password: nil) | |
print("user logged in \(token)") | |
} catch LoginError.EmptyUsername { | |
print("empty username") | |
} catch LoginError.EmptyPassword { | |
print("empty password") | |
} catch { |
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 loginUserWithUsername(username: String?, password: String?) throws -> String { | |
guard let username = username where username.characters.count != 0 else { | |
throw LoginError.EmptyUsername | |
} | |
guard let password = password where password.characters.count != 0 else { | |
throw LoginError.EmptyPassword | |
} | |
///Handle all the other, | |
return "token:" + username |
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
enum LoginError : ErrorType { | |
case EmptyUsername | |
case EmptyPassword | |
} |
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
enum TextCase { | |
case Uppercase(String) | |
case Lowercase(String) | |
} | |
let values: [TextCase] = [ | |
.Uppercase("FOO"), | |
.Lowercase("iamlow"), | |
.Uppercase("BAR"), | |
] |
NewerOlder