Skip to content

Instantly share code, notes, and snippets.

@ApoloApps
ApoloApps / map-string-any-kotlin-serialization-tests.kt
Created October 1, 2025 21:10 — forked from 3v1n0/map-string-any-kotlin-serialization-tests.kt
Kotlin Map<String, Any?> (andy Any type in general) (de)serialization tests with both Binary (CBOR) and JSON support
import kotlinx.serialization.*
import kotlinx.serialization.descriptors.SerialDescriptor
import kotlinx.serialization.encoding.CompositeDecoder
import kotlinx.serialization.encoding.Decoder
import kotlinx.serialization.encoding.Encoder
import kotlinx.serialization.json.*
import kotlin.reflect.KType
import kotlin.reflect.full.isSubtypeOf
import kotlin.reflect.full.starProjectedType
open class ScopedViewModel : ViewModel() {
private val job = Job()
protected val scope: CoroutineScope = job + Dispatchers.Main
override fun onCleared() {
super.onCleared()
job.cancel()
}
}
@ApoloApps
ApoloApps / BrowserCursorById.kt
Last active December 3, 2024 15:04
Get Browser Cursor by id
/**
* Retrieves a [PointerIcon] based on the provided cursor ID.
*
* This function accepts a string ID corresponding to various browser-supported cursors and returns
* a [PointerIcon] instance representing the requested cursor. It does not throw an exception if the
* provided ID is invalid.
*
* Below are the IDs for all available cursors:
* * **Note:** The availability of specific cursors may vary depending on the browser and operating system.