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
extension JSONDecoder { | |
func decode<T: Decodable>(_ type: T.Type, from data: Data, keyedBy key: String?) throws -> T { | |
if let key = key { | |
// Pass the top level key to the decoder. | |
userInfo[.jsonDecoderRootKeyName] = key | |
let root = try decode(DecodableRoot<T>.self, from: data) | |
return root.value | |
} else { |
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
#!/usr/bin/env bash | |
# ~/.git_template.local/hooks/pre-commit | |
# format-objc-hook | |
# pre-commit hook to check if any unformatted Objective-C files would be committed. Fails the check if so, and provides instructions. | |
# | |
# Copyright 2015 Square, Inc | |
IFS=$'\n' | |
export CDPATH="" | |
DIR=$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd ) |