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
//Weak reference to layout attribute on controller level. | |
var currentTimeIndicatorAttribute:UICollectionViewLayoutAttributes? { | |
guard self._currentTimeIndicatorAttribute == nil else { return self._currentTimeIndicatorAttribute } | |
self._currentTimeIndicatorAttribute = self.layout.layoutAttributesForDecorationView(ofKind: EPGCollectionViewElementKind.Decoration.currentTimeIndicatorOverTimeline.rawValue, at: IndexPath(item: 0, section: 0)) | |
print("adding again") | |
return self._currentTimeIndicatorAttribute | |
} | |
private weak var _currentTimeIndicatorAttribute:UICollectionViewLayoutAttributes? |
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
//First | |
if let superview = backgroundImageView.superview { | |
backgroundImageView.topAnchor.constraint(equalTo: superview.topAnchor).isActive = true | |
backgroundImageView.leftAnchor.constraint(equalTo: superview.leftAnchor).isActive = true | |
backgroundImageView.rightAnchor.constraint(equalTo: superview.rightAnchor).isActive = true | |
backgroundImageView.bottomAnchor.constraint(equalTo: superview.bottomAnchor).isActive = true | |
} | |
//Second | |
let superView = backgroundImageView.superview |
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 slowAsyncCall() -> Observable<Int> { | |
return Observable.create { obs -> Disposable in | |
DispatchQueue.main.asyncAfter(deadline: .now() + .seconds(5)) { | |
obs.onNext(5) | |
obs.onCompleted() | |
} | |
return Disposables.create() | |
} | |
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
#Component | |
- <SettingsCollectionViewCell: | |
- .view: | |
- background-color: "#fa0046" | |
- .name-label: | |
- text-color : white | |
- font-name : AmericanTypewriter-Bold | |
- font-size : 32 |
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
// Can use - border-bottom : "purple,3" | |
// Can use - border-bottom : "#444, 3" | |
// etc | |
conf.interpreter.map(UILabel.self, forAttributeKey: "border-bottom", withType:Borderized.self) { | |
let key = $0.key.appending("C-") | |
let layer = $0.component.layer.sublayers?.lazy.filter { $0.name == key }.first ?? CALayer() | |
layer.frame = $0.component.frame |
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
// | |
// EitherProtocol+Error.swift | |
// CaoCaoKit | |
// | |
// Created by Seivan Heidari on 16/08/29. | |
// | |
// | |
import Foundation |
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
var Promise = require('bluebird'); | |
var funcs = Promise.resolve([500, 100, 400, 200].map((n) => makeWait(n))); | |
funcs | |
.each(iterator) // logs: 500, 100, 400, 200 | |
.then(console.log) // logs: [ [Function], [Function], [Function], [Function] ] | |
funcs | |
.mapSeries(iterator) // logs: 500, 100, 400, 200 |
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
/*: | |
## Phone Words | |
Generate a collection of words that can be represented by a given phone number. If a phone number contains the digits `1` or `0` then split up the phone number and find the words for each of the substrings as long as each substring has more than one digit. Non-keypad characters can be ignored. Optionally, filter out words so that only dictionary words are present in the result. | |
╔═════╦═════╦═════╗ | |
║ 1 ║ 2 ║ 3 ║ | |
║ ║ abc ║ def ║ | |
╠═════╬═════╬═════╣ | |
║ 4 ║ 5 ║ 6 ║ |
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 struct Promise<T> { | |
typealias Fulfiller = (T) -> (Void) | |
typealias Rejecter = (Void) -> (Void) | |
typealias Resolver = (_ fulfill: @escaping Fulfiller, _ reject: @escaping Rejecter) -> (Void) | |
let resolver: Resolver | |
init(_ resolver: @escaping Resolver){ | |
self.resolver = resolver | |
} | |
func then<U>(_ execute: @escaping ((T) -> U)) -> Promise<U> { | |
return Promise<U>({(fulfill, reject) 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
//////public struct ConfuciusKeyValueMapResultList<C, V> : ArrayLiteralConvertible { | |
////// | |
////// public typealias ComponentType = C.Type | |
////// public typealias ValueType = V.Type | |
////// public typealias Element = ConfuciusKeyValueMapResult<C, V> | |
////// | |
////// private let results:Set<ConfuciusKeyValueMapResult<C, V>> | |
////// | |
////// public subscript(key:String) -> V? { return self.value(forKey: key) } | |
////// |