[![Swift][swift-badge]][swift-url] [![Zewo][zewo-badge]][zewo-url] [![Platform][platform-badge]][platform-url] [![License][mit-badge]][mit-url] [![Slack][slack-badge]][slack-url]
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 protocol Error: ErrorProtocol { | |
var status: Status { get } | |
} | |
public enum ClientError: Error { | |
case badRequest | |
case unauthorized | |
case paymentRequired | |
case forbidden | |
case notFound |
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
func getDateTime() -> (String, String) { | |
let now = NSDate() | |
let dayTimePeriodFormatter = NSDateFormatter() | |
dayTimePeriodFormatter.dateFormat = "E, d MMM yyyy" | |
let date = dayTimePeriodFormatter.string(from: now) | |
dayTimePeriodFormatter.dateFormat = "HH:mm:ss Z" | |
let time = dayTimePeriodFormatter.string(from: now) |
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/swift | |
#if os(Linux) | |
@_exported import Glibc | |
#else | |
@_exported import Darwin.C | |
#endif | |
public struct Environment { | |
public subscript(variable: String) -> 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
public func solution(N : Int) -> Int { | |
let bytes = String(N, radix: 2) | |
var max = 0 | |
var current = 0 | |
for n in bytes.characters { | |
if n == "0" { | |
current += 1 | |
} else { | |
if current > max { |
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
protocol A { | |
static var a: String { get } | |
} | |
extension A { | |
static var a: String { | |
return "a" | |
} | |
} |
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 Foundation | |
struct HTTPRequest { | |
enum Method { | |
case get | |
case post | |
case put | |
case patch | |
case delete | |
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 Foundation | |
extension String : CodingKey { | |
public var stringValue: String { | |
return self | |
} | |
public var intValue: Int? { | |
return Int(self) | |
} |