Skip to content

Instantly share code, notes, and snippets.

View dfmarulanda's full-sized avatar

Daniel Marulanda dfmarulanda

View GitHub Profile
@dfmarulanda
dfmarulanda / Gallery+Rx.swift
Last active February 15, 2017 21:36
hyperoslo/Gallery RxSwift Extension
@dfmarulanda
dfmarulanda / SJFSegmentedControl+Rx
Created February 13, 2017 20:42
SJFSegmentedControl RxSwift Extension
extension UIControl {
static func valuePublic<T, ControlType: UIControl>(_ control: ControlType, getter: @escaping (ControlType) -> T, setter: @escaping (ControlType, T) -> Void) -> ControlProperty<T> {
let values: Observable<T> = Observable.deferred { [weak control] in
guard let existingSelf = control else {
return Observable.empty()
}
return (existingSelf as UIControl).rx.controlEvent([.allEditingEvents, .valueChanged])
.flatMap { _ in
return control.map { Observable.just(getter($0)) } ?? Observable.empty()
@dfmarulanda
dfmarulanda / IntegerExtesionFormatter.swift
Last active February 11, 2016 20:20
//Extension that allows format numbers into words -> 1.000 = 1K 1.500 -> 1.5K 1.000.000 -> 1M. //Usage: myInt.abbreviateNumber()
//Extension that allows format numbers into words -> 1.000 = 1K 1.500 -> 1.5K 1.000.000 -> 1M.
//Usage: myInt.abbreviateNumber()
extension Int{
func abbreviateNumber() -> String {
if self < 1000 {
return "\(self)"
}
if self < 1000000 {