View Array+PlusAssignment.swift
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 += <T>(left: inout [T], right: T) { | |
left.append(right) | |
} |
View Dictionary+PlusAssignment.swift
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 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) |
View UIColor+Initializers.swift
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
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) | |
/// |
View Deferred.js
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
class Deferred { | |
constructor() { | |
this.promise = new Promise((resolve, reject) => { | |
this.reject = reject; | |
this.resolve = resolve; | |
}); | |
} | |
resolve(value) { | |
this.resolve(value); |
View isset.swift
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 isset(_ args: Any?...) -> Bool { | |
return !args.contains { $0 == nil } | |
} |
View randomHelpers.php
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
// 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(); |
View isNumeric.php
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
// 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; | |
} |
View NotificationCenter+ObserveOnce.swift
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
// | |
// NotificationCenter+ObserveOnce.swift | |
// | |
// Created by Felix Mau on 18.10.20. | |
// Copyright © 2020 Felix Mau. All rights reserved. | |
// | |
import UIKit | |
extension NotificationCenter { |
View swiftlint.sh
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
SWIFTLINT="${PODS_ROOT}/SwiftLint/swiftlint" | |
if [ ! -f "$SWIFTLINT" ]; then | |
echo "warning: SwiftLint not installed!" | |
exit 1 | |
fi | |
$SWIFTLINT |
View WebViewExampleViewController.swift
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
// | |
// WebViewExampleViewController.swift | |
// | |
// Created by Felix Mau on 06.01.18. | |
// Copyright © 2018 Felix Mau. All rights reserved. | |
// | |
import UIKit | |
import WebKit |
OlderNewer