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
| extension Dictionary { | |
| /// Combine two dictionaries of same type with `+` operator. | |
| /// | |
| /// - Important: When `left` and `right` are having a same key, the value from `right` will override | |
| /// the value from `left`. E.g. | |
| /// ``` | |
| /// var left = ["a": 1, "b": 2] | |
| /// let right = ["a": 3, "c": 4] | |
| /// left += right | |
| /// print(left) |
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
| public extension UIColor { | |
| /// Create color from RGB(A) | |
| /// | |
| /// Parameters: | |
| /// - absoluteRed: Red value (between 0 - 255) | |
| /// - green: Green value (between 0 - 255) | |
| /// - blue: Blue value (between 0 - 255) | |
| /// - alpha: Blue value (between 0 - 255) | |
| /// |
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
| class Deferred { | |
| constructor() { | |
| this.promise = new Promise((resolve, reject) => { | |
| this.reject = reject; | |
| this.resolve = resolve; | |
| }); | |
| } | |
| resolve(value) { | |
| this.resolve(value); |
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 isset(_ args: Any?...) -> Bool { | |
| !args.contains { $0 == 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
| // Returns a random float value between "$min" and "$max". | |
| // Usage: $latitude = randomFloat(53.394655, 53.694865) | |
| function randomFloat($min, $max) { | |
| return $min + lcg_value() * abs($max - $min); | |
| } | |
| // Returns a random argument, passed to this function. | |
| // Usage: $fruit = randomArgument('Apple', 'Banana', 'Strawberry'); | |
| function randomArgument() { | |
| $numberOfArguments = func_num_args(); |
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
| // Checks whether all given parameters are numeric. | |
| // Usage: $validCoordinates = isNumeric($_GET['p1Lat'], $_GET['p1Lon'])); | |
| function isNumeric() { | |
| $numberOfArguments = func_num_args(); | |
| $arguments = func_get_args(); | |
| return count(array_filter($arguments, 'is_numeric')) === $numberOfArguments; | |
| } |
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
| // | |
| // NotificationCenter+ObserveOnce.swift | |
| // | |
| // Created by Felix Mau on 18.10.20. | |
| // Copyright © 2020 Felix Mau. All rights reserved. | |
| // | |
| import UIKit | |
| extension NotificationCenter { |
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
| SWIFTLINT="${PODS_ROOT}/SwiftLint/swiftlint" | |
| if [ ! -f "$SWIFTLINT" ]; then | |
| echo "warning: SwiftLint not installed!" | |
| exit 1 | |
| fi | |
| $SWIFTLINT |
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
| // | |
| // WebViewExampleViewController.swift | |
| // | |
| // Created by Felix Mau on 06.01.18. | |
| // Copyright © 2018 Felix Mau. All rights reserved. | |
| // | |
| import SwiftUI | |
| import UIKit | |
| import WebKit |
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 XCTest | |
| @MainActor | |
| final class NotificationTestCase: XCTestCase { | |
| func test_notification_isPosted() { | |
| // Given | |
| expectation( | |
| forNotification: .fooBar, | |
| object: nil, |
OlderNewer