This file contains hidden or 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.async | |
import kotlinx.coroutines.awaitAll | |
import kotlinx.coroutines.coroutineScope | |
suspend fun <T> Collection<T>.forEachAsync(action: suspend (T) -> Unit) = | |
coroutineScope { | |
map { item -> | |
async { action(item) } | |
}.awaitAll() | |
} |
This file contains hidden or 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
<!-- stroke width = 3 --> | |
<svg class="animate-spin h-6 w-6 text-[CHANGE_THIS_COLOR]" xmlns="http://www.w3.org/2000/svg" fill="none" | |
viewBox="0 0 24 24"> | |
<circle class="opacity-25" cx="12" cy="12" r="10.5" stroke="currentColor" stroke-width="3"></circle> | |
<path fill="currentColor" | |
d="M3,19.9c-1.9-2.2-3-5-3-7.9C0,5.4,5.4,0,12,0v3c-5,0-9,4-9,9c0,2.2,0.8,4.3,2.2,6L3,19.9z"/> | |
</svg> | |
<!-- stroke width = 3.5 --> | |
<svg class="animate-spin h-6 w-6 text-[CHANGE_THIS_COLOR]" xmlns="http://www.w3.org/2000/svg" fill="none" |
This file contains hidden or 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
<div class="progress progress-striped active"> | |
<div class="progress-bar" role="progressbar"></div> | |
</div> |
This file contains hidden or 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
export class Lazy<T> { | |
private _value?: T | |
constructor(private initializer: () => T) { | |
} | |
get value(): T { | |
if (this._value == undefined) { | |
this._value = this.initializer() | |
} |
This file contains hidden or 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
class LatLngSerializer : KSerializer<LatLng> { | |
override val descriptor: SerialDescriptor = buildClassSerialDescriptor("LatLng") { | |
element<Double>("latitude") | |
element<Double>("longitude") | |
} | |
override fun serialize(encoder: Encoder, value: LatLng) { | |
encoder.encodeStructure(descriptor) { | |
encodeDoubleElement(descriptor, 0, value.latitude) | |
encodeDoubleElement(descriptor, 1, value.longitude) |