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
{ | |
// must be 1 | |
"formatVersion": 1, | |
// required for "dynamic" passes | |
"authenticationToken": "<secret>", | |
"serialNumber": "<secret>", | |
"webServiceURL": "https://pass.a2.io/", | |
// top-left "logo" text |
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
// Version A | |
// - crashes if viewControllers is empty | |
// - crashes if first VC is not of type MyViewController | |
let navigationController = ... | |
let myViewController = navigationController.viewControllers.first as! MyViewController | |
myViewController.configurationObject = ... | |
// Version B | |
// - doesn't crash, ever | |
// - does nothing if viewControllers is empty or the first is not of type MyViewController |
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 Guaka | |
enum MainError: Error, CustomStringConvertible { | |
case example | |
var description: String { | |
switch self { | |
case .example: | |
return "This is an example error." | |
} |
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 | |
protocol ViewProtocol { | |
var view: UIView { get } | |
} | |
extension ViewProtocol where Self: UIView { | |
var view: UIView { | |
return 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
guard !arguments.isEmpty, | |
nums.count = arguments.count | |
else { | |
print("Usage: \(appName) <list-of-positive-integers>") | |
exit(-1) | |
} |
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
infix operator <+ {} | |
func <+ <C: RangeReplaceableCollectionType>(inout collection: C, element: C.Generator.Element) { | |
collection.append(element) | |
} | |
var array = [String]() | |
array <+ "Foo" | |
array <+ "Bar" |
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
// ---- | |
// libsass (v3.2.5) | |
// ---- | |
@function at2x-name($filename) { | |
$length: str-length($filename); | |
@if $length == 0 { | |
// return empty if input is empty | |
@return $filename; | |
} |
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
sqlite3 -column ~/Library/Safari/history.db 'SELECT "visit_count", "url" FROM "history_items" ORDER BY "visit_count" DESC LIMIT 5;' |
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 RangeReplaceableCollectionType { | |
init<S: SequenceType where S.Generator.Element == Self.Generator.Element>(sequence: S) { | |
self.init() | |
extend(sequence) | |
} | |
} | |
extension RangeReplaceableCollectionType where Index: IntegerType { | |
init<S: SequenceType where S.Generator.Element == Self.Generator.Element>(sequence: S) { | |
self.init() |
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
Verifying I am +a2 on my passcard. https://onename.com/a2 |