Skip to content

Instantly share code, notes, and snippets.

View deda9's full-sized avatar
🍁
Learning is always fun

Bassem Qoulta deda9

🍁
Learning is always fun
View GitHub Profile
@deda9
deda9 / SyncAppstore.rb
Created June 16, 2020 15:29
Bitrise-Example-Sync-Appstore
desc "Sync appstore certificates via match (readonly)"
lane :certificates_appstore do
match(app_identifier: ["deda9.Bitrise-Example"], type: "appstore", readonly: true)
end
@deda9
deda9 / Release.rb
Created June 16, 2020 15:25
Bitrise-Example-Release
desc "Deploy a new version to the App Store"
lane :release do
cocoapods
certificates_appstore
gym(scheme: "Bitrise-Example")
deliver(skip_screenshots: true, force: true)
end
@deda9
deda9 / Bitrise-Example-Stage.rb
Last active June 16, 2020 15:31
Submit iOS TestFlight stage build
desc "Submit a new Testing Build pointing to staging to Apple TestFlight"
lane :testflight do
certificates_appstore
gym(scheme: "Bitrise-Example")
upload_to_testflight(
skip_submission: true,
notify_external_testers: false,
skip_waiting_for_build_processing: true
)
end
@deda9
deda9 / EnumLinkedList.swift
Created July 11, 2019 15:22
How to create LinkedList with enum
indirect enum LinkedList<T> {
case value(element: T, next: LinkedList<T>)
case end
}
extension LinkedList: Sequence {
func makeIterator() -> LinkedListIterator<T> {
return LinkedListIterator(current: self)
}
}
@deda9
deda9 / NestedFunctions.Swift
Created June 25, 2019 14:47
How to create nested function
let multiply: (Int, Int) -> Int = { $0 * $1 }
let divide: (Int, Int) -> Int = { $0 / $1 }
let minus: (Int, Int) -> Int = { $0 - $1 }
minus(multiply(divide(10,2), 2), 1)
@deda9
deda9 / RequestChainable.swift
Last active June 20, 2019 10:56
How to chain two network requests
typealias RequestChainable<T: Codable> = (request: URLRequestBuilder, model: T.Type)
extension NetworkService {
func chain<T, U>(_ r: RequestChainable<T>, _ r2: RequestChainable<U>, completion: @escaping (Result<(T?, U?)>) -> Void) {
self.execute(r.request, model: r.model) { res in
switch res {
case .success(let value): completion(Result.success((value, nil)))
case .failure:
self.execute(r2.request, model: r2.model, completion: { result in
@deda9
deda9 / RxObservableTimer.swift
Created June 18, 2019 08:53
Create RxObservable with timer
func createRxObservable() {
let source: Observable<Int> = Observable<Int>.timer(3, scheduler: ConcurrentDispatchQueueScheduler.init(qos: DispatchQoS.background))
source
.subscribe(onNext: { number in
print("Current emitted number: ", number)
}, onError: { _ in print("On Error") },
onCompleted: { print("Complete") },
onDisposed: nil)
}
@deda9
deda9 / RxObservableRepeat.swift
Created June 18, 2019 08:50
Create RxObservable with repeat
func createRxObservable() {
let source: Observable<Int> = Observable.repeatElement(12).take(2)
source
.subscribe(onNext: { number in
print("Current emitted number: ", number)
}, onError: { _ in print("On Error") },
onCompleted: { print("Complete") },
onDisposed: nil)
}
@deda9
deda9 / RxObservableRange.swift
Last active June 18, 2019 08:49
Create RxObservable with range
func createRxObservable() {
let source: Observable<Int> = Observable.range(start: 3, count: 3)
source
.subscribe(onNext: { number in
print("Current emitted number: ", number)
}, onError: { _ in print("On Error") },
onCompleted: { print("Complete") },
onDisposed: nil)
}
@deda9
deda9 / RxObservableJust.swift
Created June 18, 2019 08:46
Create RxObservable with Just
func createRxObservable() {
let source: Observable<Int> = Observable.just(1)
source
.subscribe(onNext: { number in
print("Current emitted number: ", number)
}, onError: { _ in print("On Error") },
onCompleted: { print("Complete") },
onDisposed: nil)
}