Skip to content

Instantly share code, notes, and snippets.

Felix M. fxm90

View GitHub Profile
@fxm90
fxm90 / 01 - Observable.swift
Last active Feb 15, 2019
A super lightweight and fast observable implementation.
View 01 - Observable.swift
//
// Observable.swift
//
// Created by Felix Mau on 11/02/19.
// Copyright © 2018 Felix Mau. All rights reserved.
//
import Foundation
class Observable<T> {
@fxm90
fxm90 / UIView+AnimateIsHidden.swift
Last active Feb 11, 2019
Animate the `alpha` value of a UIView and update the `isHidden` flag accordingly.
View UIView+AnimateIsHidden.swift
//
// UIView+AnimateIsHidden.swift
//
// Created by Felix Mau on 17/12/18.
// Copyright © 2018 Felix Mau. All rights reserved.
//
import UIKit
extension UIView {
@fxm90
fxm90 / VerticalGradientImageView.swift
Last active Feb 11, 2019
An image view containing a vertical gradient as background.
View VerticalGradientImageView.swift
//
// VerticalGradientImageView.swift
//
// Created by Felix Mau on 23/09/18.
// Copyright © 2018 Felix Mau. All rights reserved.
//
import UIKit
class VerticalGradientImageView: UIImageView {
@fxm90
fxm90 / String+Log.swift
Last active Feb 11, 2019
A simple log extension on `String` using literal expressions
View String+Log.swift
//
// String+Log.swift
//
// Created by Felix Mau on 16/09/18.
// Copyright © 2018 Felix Mau. All rights reserved.
//
import Foundation
extension String {
@fxm90
fxm90 / CustomNotificationCenterTestCase.swift
Created Aug 6, 2018
XCTest - Use custom notification center in test case and assert notification (not) triggered.
View CustomNotificationCenterTestCase.swift
class CustomNotificationCenterTestCase: XCTestCase {
var notificationCenter: NotificationCenter!
override func setUp() {
super.setUp()
notificationCenter = NotificationCenter()
}
@fxm90
fxm90 / NotificationTestCase.swift
Last active Oct 25, 2018
XCTest - Assert notification (not) triggered.
View NotificationTestCase.swift
import XCTest
class NotificationTestCase: XCTestCase {
func testTriggerNotification() {
expectation(forNotification: .fooBar,
object: nil,
handler: nil)
let notificationCenter = NotificationCenter.default
@fxm90
fxm90 / WebViewExampleViewController.swift
Last active Mar 3, 2019
Show progress of WKWebView in UIProgressBar that is attached to an UINavigationBar
View WebViewExampleViewController.swift
//
// WebViewExampleViewController.swift
//
// Created by Felix Mau on 06.01.18.
// Copyright © 2018 Felix Mau. All rights reserved.
//
import UIKit
import WebKit
@fxm90
fxm90 / swiftlint.sh
Created Sep 30, 2017
Check "SwiftLint" installed via CocoaPods. Add a new "Run Script Phase" with this gist.
View swiftlint.sh
if [ -f "${PODS_ROOT}/SwiftLint/swiftlint" ]; then
${PODS_ROOT}/SwiftLint/swiftlint
else
echo "warning: SwiftLint not installed!"
fi
@fxm90
fxm90 / NotificationCenter+ObserveOnce.swift
Last active Dec 27, 2017
Extension for "NotificationCenter" to observe a notification just once and directly unsubscribe.
View NotificationCenter+ObserveOnce.swift
extension NotificationCenter {
/// Adds an observer to the given notification center, which fires just once.
///
/// Note:
/// - Same parameters as "addObserver", but with default properties
/// See http://apple.co/2zZIYJB for details.
///
/// Parameters:
/// - name: The name of the notification for which to register the observer
@fxm90
fxm90 / isNumeric.php
Last active Apr 28, 2018
Checks whether all given parameters are numeric (Same as php-vanilla "is_numeric" but as variadic function).
View isNumeric.php
// 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;
}
You can’t perform that action at this time.