Skip to content

Instantly share code, notes, and snippets.

View psteiger's full-sized avatar
🎯
Focusing

Patrick Steiger psteiger

🎯
Focusing
View GitHub Profile
@salamanders
salamanders / test.kt
Created September 30, 2019 21:56
Kotlin Firestore API (Collection documentChanges) to Flow
@ExperimentalCoroutinesApi
fun CollectionReference.toFlow(): Flow<DocumentChange> = callbackFlow {
val snapshotListener = this@toFlow.addSnapshotListener { snapshots, e ->
if (e != null) {
logger.error { "${this@toFlow.path} listen:error:$e" }
cancel(CancellationException("Collection Listener Error in ${this@toFlow.path}", e))
return@addSnapshotListener
}
for (dc in snapshots!!.documentChanges) {
@elizarov
elizarov / Delimited.kt
Last active October 23, 2023 20:19
Delimited Continuations shift/reset in Kotlin
import kotlin.coroutines.*
import kotlin.coroutines.intrinsics.*
/**
* Implementation for Delimited Continuations `shift`/`reset` primitives via Kotlin Coroutines.
* See [https://en.wikipedia.org/wiki/Delimited_continuation].
*
* The following LISP code:
*
* ```
@AndrewReitz
AndrewReitz / settings.gradle.kts
Last active December 6, 2021 23:19
settings.gradle pluginManagement
pluginManagement {
repositories {
gradlePluginPortal()
google()
jcenter()
maven { url = uri("https://maven.fabric.io/public") }
}
resolutionStrategy {
eachPlugin {