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
//1 | |
let keychain = Keychain(server: domain, protocolType: .https).synchronizable(true) | |
let email = UserDefaults.standard.object(forKey: "account") as? String | |
//2 | |
if let account = email, let password = try? keychain.get(account) { | |
return password | |
}else { | |
//3 |
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
let keychain = Keychain(server: domain, protocolType: .https).synchronizable(true) | |
let email = UserDefaults.standard.object(forKey: "account") as? String | |
if let account = email, let password = try? keychain.get(account) { | |
return password | |
}else { | |
keychain.getSharedPassword({ [weak self] (account, password, error) in | |
guard let account = account, let password = password else { return } | |
keychain[account] = password // save in local keychain |
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
if which swiftlint >/dev/null; then | |
swiftlint | |
else | |
echo "warning: SwiftLint not installed, download from https://github.com/realm/SwiftLint" | |
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
#if [ "${CONFIGURATION}" = "Debug" ]; then | |
if which swiftlint >/dev/null; then | |
count=0 | |
for file_path in $(git diff --diff-filter=ACM --name-only | grep ".*.swift$"); do | |
export SCRIPT_INPUT_FILE_$count=$file_path | |
count=$((count + 1)) | |
done | |
for file_path in $(git diff --cached --name-only --diff-filter=ACM | grep ".*.swift$"); do |
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
// Original Source http://www.dotnetperls.com/rot13-swift | |
// Edited version | |
extension String { | |
func rot13() -> String { | |
// Empty character array. | |
var result = [Character]() | |
// Some ASCII constants. |
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
+ (NSMutableURLRequest *)imageRequestWithURL:(NSURL *)url { | |
NSMutableURLRequest *request = [NSMutableURLRequest requestWithURL:url]; | |
request.cachePolicy = NSURLRequestReturnCacheDataElseLoad; // this will make sure the request always returns the cached image | |
request.HTTPShouldHandleCookies = NO; | |
request.HTTPShouldUsePipelining = YES; | |
[request addValue:@"image/*" forHTTPHeaderField:@"Accept"]; | |
return request; | |
} |