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); |
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 } | |
} |
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) | |
} |
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(); |
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; | |
} |
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 CustomNotificationCenterTestCase: XCTestCase { | |
var notificationCenter: NotificationCenter! | |
override func setUp() { | |
super.setUp() | |
notificationCenter = NotificationCenter() | |
} |
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
// | |
// VerticalGradientImageView.swift | |
// | |
// Created by Felix Mau on 23/09/18. | |
// Copyright © 2018 Felix Mau. All rights reserved. | |
// | |
import UIKit | |
class VerticalGradientImageView: UIImageView { |
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
// | |
// For reusability reasons I've moved the code into a Framework. | |
// https://github.com/fxm90/LightweightObservable | |
// |
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 |
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
SWIFTFORMAT="${PODS_ROOT}/SwiftFormat/CommandLineTool/swiftformat" | |
if [ ! -f "$SWIFTFORMAT" ]; then | |
echo "warning: SwiftFormat not installed!" | |
exit 1 | |
fi | |
$SWIFTFORMAT ./ |
OlderNewer