Author: Chris Lattner
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
| find . -type f -name "*.swift" -exec grep -H -c '[^[:space:]]' {} \; | \sort -nr -t":" -k2 | awk -F: '{printf("Your largest file %s contains: %s lines \n", $1, $2); exit;}' |
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
| // | |
| // Config.swift | |
| // Analytics | |
| // | |
| public protocol AnalyticsConfig { | |
| static var analyticsKey: String { get } | |
| static var appVersion: String { get } | |
| } |
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
| // Three different lexer implementations. First a "consume everything" lexer, then a "lazy" lexer (that is, an iterator), then a lazy lexer without explicit state. | |
| enum Token { | |
| case heading(level: Int) | |
| case star | |
| case text(String) | |
| } | |
| import Foundation |
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 | |
| class ViewController: UIViewController, UITableViewDelegate, UITableViewDataSource { | |
| @IBOutlet weak var tableView: UITableView! | |
| override func viewDidLoad() { | |
| super.viewDidLoad() | |
| NSLayoutConstraint.activate([ | |
| tableView.topAnchor.constraint(equalTo: view.topAnchor), |
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
| //: Playground - noun: a place where people can play | |
| import UIKit | |
| protocol SectionModel { | |
| var count: Int { get } | |
| func cell(at: Int) -> UITableViewCell | |
| func selected(at: Int) | |
| } |
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 Character { | |
| var asciiValue: Int { | |
| get { | |
| let s = String(self).unicodeScalars | |
| return Int(s[s.startIndex].value) | |
| } | |
| } | |
| } |
Inspired by dannyfritz/commit-message-emoji
See also gitmoji.
| Commit type | Emoji |
|---|---|
| Initial commit | π :tada: |
| Version tag | π :bookmark: |
| New feature | β¨ :sparkles: |
| Bugfix | π :bug: |
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 | |
| public protocol AlmostEquatable { | |
| @warn_unused_result | |
| func ==~(lhs: Self, rhs: Self) -> Bool | |
| } | |
| public protocol EquatableWithinEpsilon: Strideable { | |
| static var Epsilon: Self.Stride { get } | |
| } |
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 DictionaryConvertable { | |
| static func fromDictionary(dictionary: [String: AnyObject]) throws -> Self | |
| func toDictionary() -> [String: AnyObject] | |
| } | |
| protocol DictionaryValueType { | |
| func dictionaryValue() -> AnyObject? | |
| } | |
| extension Optional: DictionaryValueType { | |
| func dictionaryValue() -> AnyObject? { |
NewerOlder