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
protocol KeyValuePathing { | |
subscript(keyPathWithString keyPath: String) -> Any? { get } | |
} | |
extension Array: KeyValuePathing { | |
subscript(keyPathWithString keyPath: String) -> Any? { | |
get { | |
var parts = keyPath.components(separatedBy: ".") | |
let initialKey = parts.removeFirst() |
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
const os = require('os') | |
const fs = require('fs') | |
const path = require('path') | |
const { exec } = require('child_process') | |
const tmpdir = os.tmpdir() | |
const directory = path.join(tmpdir, './docker-hook') | |
const avatar = "https://www.docker.com/sites/default/files/d8/2019-07/Moby-logo.png" |
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
'use strict'; | |
var chai = require('chai') | |
var mongoose = require('mongoose'); | |
var Schema = mongoose.Schema; | |
const BaseSchema = new Schema({ | |
name: { type: String, required: true } | |
}, { collection: 'products', discriminatorKey: 'type' }); |
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 (!Promise.allSettled) { | |
// Polyfill | |
Promise.prototype.allSettled = function(values) { | |
if (this == null) { | |
throw new TypeError('this is null or not defined'); | |
} | |
return this.all(values.map(reflect)); | |
}; |
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 AddressSchema = mongoose.Schema({ | |
formattedAddress: String, | |
components: [ | |
{ | |
longName: String, | |
shortName: String, | |
types: [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 | |
@objc extension UIView { | |
@nonobjc public func addConstraintsWithFormat(_ format: String, views: UIView...) { | |
var viewsDictionary = [String: UIView]() | |
for (index, view) in views.enumerated() { | |
let key = "v\(index)" | |
viewsDictionary[key] = view | |
view.translatesAutoresizingMaskIntoConstraints = false |
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 AnyCodable: Codable { | |
public init(from decoder: Decoder) throws { | |
let container = try decoder.singleValueContainer() | |
if let intValue = try? container.decode(Int.self) { | |
self._box = _ConcreteCodableBox<Int>(intValue) | |
} else if let doubleValue = try? container.decode(Double.self) { | |
self._box = _ConcreteCodableBox<Double>(doubleValue) | |
} else if let floatValue = try? container.decode(Float.self) { | |
self._box = _ConcreteCodableBox<Float>(floatValue) |
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 | |
internal protocol _AnyCodableBox { | |
var _base: Any { get } | |
var objectIdentifier: ObjectIdentifier { get } | |
} |
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 | |
/// Predicatable is the protocol that all predicting objects conform. | |
public protocol Predicatable: CustomStringConvertible { | |
/// Returns a Boolean value indicating whether the specified object matches the conditions specified by the predicate. | |
/// | |
/// - Parameter object: The object against which to evaluate the predicate. | |
/// - Returns: `true` if object matches the conditions specified by the predicate, otherwise `false`. | |
func evaluate(with object: Any?) -> Bool |