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 DispatchQueue { | |
class func mainSyncSafe(execute work: () -> Void) { | |
if Thread.isMainThread { | |
work() | |
} else { | |
DispatchQueue.main.sync(execute: work) | |
} | |
} | |
class func mainSyncSafe<T>(execute work: () throws -> T) rethrows -> T { |
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 protocol StoryboardInstantiatable { | |
static var storyboardName: String { get } | |
static var viewControllerIdentifier: String? { get } | |
static var bundle: Bundle? { get } | |
} | |
public extension StoryboardInstantiatable where Self: UIViewController { | |
public static var storyboardName: String { | |
return String(describing: self) | |
} |
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
{ | |
"freezed":{ | |
"prefix": "freezed", | |
"body": [ | |
"import 'package:flutter/foundation.dart';", | |
"import 'package:freezed_annotation/freezed_annotation.dart';", | |
"", | |
"part '$1.freezed.dart';", | |
"part '$1.g.dart';", | |
"", |
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 UIScrollView { | |
public enum ScrollDirection { | |
case top | |
case bottom | |
case left | |
case right | |
} | |
public func scroll(to direction: ScrollDirection, animated: Bool) { | |
let offset: CGPoint |
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
struct ComposeTransformer<T, R> { | |
let transformer: (Observable<T>) -> Observable<R> | |
init(transformer: @escaping (Observable<T>) -> Observable<R>) { | |
self.transformer = transformer | |
} | |
func call(_ observable: Observable<T>) -> Observable<R> { | |
return transformer(observable) | |
} | |
} |
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 AnyObserver { | |
static func create<E>(_ relay: PublishRelay<E>) -> AnyObserver<E> { | |
return .init { event in | |
guard case let .next(value) = event else { return } | |
relay.accept(value) | |
} | |
} | |
static func create<E>(_ relay: BehaviorRelay<E>) -> AnyObserver<E> { | |
return .init { event in |
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 'dart:math' as math; | |
import 'package:flutter/material.dart'; | |
extension SliverListEx on SliverList { | |
static SliverList separated({ | |
required int itemCount, | |
required NullableIndexedWidgetBuilder itemBuilder, | |
required NullableIndexedWidgetBuilder separatorBuilder, | |
}) { | |
return SliverList( |
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
//: Playground - noun: a place where people can play | |
import UIKit | |
var json: String = """ | |
{ | |
"result": { | |
"persons": [ | |
{ |
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
rules_version = '2'; | |
service cloud.firestore { | |
match /databases/{database}/documents { | |
// Create `Path` from array of string. | |
function documentPath(paths) { | |
return path([ | |
['databases', database, 'documents'].join('/'), | |
paths.join('/') | |
].join('/')); | |
} |
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 NibInstantiatable { | |
static var NibName: String { get } | |
} | |
extension NibInstantiatable { | |
static var NibName: String { return String(Self) } | |
static func instantiate() -> Self { | |
return instantiateWithName(NibName) |
NewerOlder