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 Foundation | |
struct Contains { | |
let value: String | |
init(_ str: String) { | |
value = str | |
} | |
} |
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 Foundation | |
public struct CartesianProductIterator<X, Y>: IteratorProtocol where X: IteratorProtocol, Y: Collection { | |
private var xIt: X | |
private let yCol: Y | |
private var x: X.Element? | |
private var yIt: Y.Iterator | |
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 f(_ jsonValue: Any, prefix: String? = nil) throws -> [URLQueryItem] { | |
var items: [URLQueryItem] = [] | |
switch jsonValue { | |
case let d as Dictionary<String, Any>: | |
try d.forEach { | |
let newPrefix = prefix == nil ? $0.key : prefix! + "[\($0.key)]" | |
items.append(contentsOf: try f($0.value, prefix: newPrefix)) | |
} | |
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
#!/bin/bash | |
if [ "${CONFIGURATION}" != "Debug" ] | |
then | |
buildNumber=$(date +"%Y%m%d%H%M") | |
/usr/libexec/PlistBuddy -c "Set :CFBundleVersion $buildNumber" ${INFOPLIST_FILE} | |
fi |
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 Foundation | |
protocol `enum` { | |
func `protocol`() | |
} | |
struct `class`: `enum` { | |
func `protocol`() { | |
print("hello!") | |
} |
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
<?xml version="1.0" encoding="UTF-8"?> | |
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd"> | |
<plist version="1.0"> | |
<dict> | |
<key>ANSIBlueColor</key> | |
<data> | |
YnBsaXN0MDDUAQIDBAUGFRZYJHZlcnNpb25YJG9iamVjdHNZJGFyY2hpdmVyVCR0b3AS | |
AAGGoKMHCA9VJG51bGzTCQoLDA0OVU5TUkdCXE5TQ29sb3JTcGFjZVYkY2xhc3NPECcw | |
LjM1MDgzOTA3NzIgMC4zNTA4MzkwNzcyIDAuNjg5ODcwODQ1NAAQAoAC0hAREhNaJGNs | |
YXNzbmFtZVgkY2xhc3Nlc1dOU0NvbG9yohIUWE5TT2JqZWN0XxAPTlNLZXllZEFyY2hp |
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
<?xml version="1.0" encoding="UTF-8"?> | |
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd"> | |
<plist version="1.0"> | |
<dict> | |
<key>DVTConsoleDebuggerInputTextColor</key> | |
<string>0.324366 0.407177 0.438506 1</string> | |
<key>DVTConsoleDebuggerInputTextFont</key> | |
<string>SourceCodePro-Medium - 14.0</string> | |
<key>DVTConsoleDebuggerOutputTextColor</key> | |
<string>0.505992 0.564858 0.563637 1</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
<?xml version="1.0" encoding="UTF-8"?> | |
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd"> | |
<plist version="1.0"> | |
<dict> | |
<key>DVTConsoleDebuggerInputTextColor</key> | |
<string>0.324366 0.407177 0.438506 1</string> | |
<key>DVTConsoleDebuggerInputTextFont</key> | |
<string>SourceCodePro-Medium - 14.0</string> | |
<key>DVTConsoleDebuggerOutputTextColor</key> | |
<string>0.505992 0.564858 0.563637 1</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 UIKit | |
func singlePixelLine(at y: CGFloat, in rect: CGRect, topBias: Bool = true) { | |
let offset = pixelUnit/2.0 | |
let adjustedY = round(from: y - offset, fraction: pixelUnit, down: topBias) + offset | |
let line = makeLine(at: adjustedY, in: rect) | |
strokePath(line, width: pixelUnit) | |
} | |
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
/* Doesn't work. */ | |
NSLocale.currentLocale().displayNameForKey(NSLocaleCountryCode, value: "DE") | |
//> nil | |
/* Does work. */ | |
NSLocale(localeIdentifier: "en_US").displayNameForKey(NSLocaleCountryCode, value: "DE") | |
//> "Germany" | |