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 fp<A, B, C>(fn:((A, B) -> C), arg:A) -> (B -> C) { | |
| func apply(b:B) -> C { | |
| return fn(arg, b) | |
| } | |
| return apply | |
| } | |
| func add(x: Int, y: Int) -> Int { | |
| return x + y | |
| } |
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 twoWords(a: String) (b: String) -> String { | |
| return "\(a) \(b)" | |
| } | |
| twoWords("Hello")(b: "Ayaka") // Note that you need to explicitly name your second parameter | |
| // Now for currying... | |
| let greet = twoWords("Hello") | |
| greet(b: "Ayaka") |
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 | |
| extension NSLocale { | |
| class func currentLocale() -> NSLocale { | |
| return NSLocale.localeWithLocaleIdentifier("en_GB"); | |
| } | |
| } | |
| NSLocale.currentLocale().localeIdentifier |
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 cocoaPodsDir = "Pods/" | |
| let carthageDir = "Carthage/Checkouts/" | |
| let options: NSDirectoryEnumerationOptions = [.SkipsPackageDescendants, .SkipsHiddenFiles] | |
| let fileManager = NSFileManager.defaultManager() | |
| guard | |
| let cocoaPodsDirURL = NSURL(string: cocoaPodsDir), | |
| let cocoaPodsEnumerator = fileManager.enumeratorAtURL(cocoaPodsDirURL, includingPropertiesForKeys: nil, options: options, errorHandler: nil) | |
| else { |
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 licenseURLs = allURLs.filter { URL in | |
| return URL.lastPathComponent?.rangeOfString("LICENSE") != nil || URL.lastPathComponent?.rangeOfString("LICENCE") != nil | |
| } |
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 licenses = licenseURLs.flatMap { try? getLicense($0) } |
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 getLicense(URL: NSURL) throws -> License { | |
| let legalText = try String(contentsOfURL: URL, encoding: NSUTF8StringEncoding) | |
| let pathComponents = URL.pathComponents! | |
| let libraryName = pathComponents[pathComponents.count - 2] | |
| return License(libraryName: libraryName, legalText: legalText) | |
| } |
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 Streamable { | |
| var title: String { get } | |
| var body: String { get } | |
| } | |
| extension Streamable { | |
| var writableString: String { | |
| return "# \(title)\n\n\(body)" | |
| } | |
| } |
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
| var markdown = Markdown() | |
| let html = licenses.map { markdown.transform($0.writableString) }.joinWithSeparator("\n") | |
| try html.writeToFile("Venmo/Resources/LICENSES.html", atomically: false, encoding: NSUTF8StringEncoding) |
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/env xcrun swift -F Carthage/Build/Mac | |
| import Foundation | |
| import Markingbird | |
| protocol Streamable { | |
| var title: String { get } | |
| var body: String { get } | |
| } |
OlderNewer