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
// MARK - Network Layer | |
// Repository implementation | |
// (here in an extension) | |
extension RestApi: OrganizationRepository { | |
public func fetchCurrent() -> AnyPublisher<Organization, Error> { | |
get("/organizations/current").map { (jsonOrganization: JSONOrganization) in | |
return jsonOrganization.toOrganization() | |
} | |
.eraseToAnyPublisher() |
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
xcrun simctl io booted recordVideo --codec=h264 screenRecording.mp4 |
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
while true; do adb shell am broadcast -a debug; sleep 0.5; done |
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
{ | |
"total": 622, | |
"countryVotes": [ | |
{ | |
"country": "AL", | |
"totalVotes": 12, | |
"votes": { | |
"CZ": 0, | |
"MT": 4, | |
"FI": 1, |
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
typealias ServiceBuilderBlock<T> = () -> T | |
class ServiceBuilderkWrapper<T>(val serviceBuilderBlock:ServiceBuilderBlock<T>, val serviceName: String) | |
object InjectionContainer { | |
var serviceBuilderkWrappers = mutableListOf<ServiceBuilderkWrapper<Any>>() | |
inline fun <reified T>registerService(noinline block: ServiceBuilderBlock<T>) { | |
val wrapper = ServiceBuilderkWrapper(block, T::class.simpleName ?: "noname") as ServiceBuilderkWrapper<Any> |
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 kotlinx.coroutines.* | |
typealias Callback<T> = (T) -> Unit | |
class CallbackWrapper<T>(val callback:Callback<T>, val eventName: String, val receiverHash: Int, val dispatcher: CoroutineDispatcher) | |
object Notifier: CoroutineScope { | |
private val supervisorJob = SupervisorJob() |
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
// Usage | |
fun parse(json: JSONObject): Car { | |
val car = Car() | |
car.apply { | |
::id < json.key("id") | |
::numberOfDoors < json.key("nb_of_doors") | |
::driverName < json.key("driver_name") | |
} | |
return car |
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
package main | |
func main() { | |
// Create our dependency. | |
lf := FileLinkFetcher{} | |
// lf := DatabaseLinkFetcher{} | |
// Here we "inject" the fileLinkFetcher in the App constructor. |
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 class Channel<Message: Equatable>: IsChannel { | |
private var subscriptions = ThreadSafeArray<Subscription>() | |
public func broadcast(_ message: Message) { | |
subscriptions.forEach { $0.trigger(message: message) } | |
} | |
public func subscribe(_ object: AnyObject, | |
for specificMessage: Message, |
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
// | |
// ThreadSafe.swift | |
// ThreadSafeArray | |
// | |
// Created by Sacha DSO on 20/09/2018. | |
// Copyright © 2018 freshOS. All rights reserved. | |
// | |
import Foundation |
NewerOlder