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 import kotlinx.io.Source | |
| import kotlinx.io.readLine | |
| import kotlinx.serialization.json.Json | |
| private inline fun <reified T> jsonlFlowOf(json: Json, source: Source): Flow<T> { | |
| return flow { | |
| val line = source.readLine() ?: return@flow | |
| emit(json.decodeFromString(line)) | |
| } | |
| } |
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
| package com.bitgrind.scrabble.ext | |
| import kotlin.concurrent.atomics.AtomicReference | |
| import kotlin.concurrent.atomics.ExperimentalAtomicApi | |
| import kotlin.reflect.KProperty | |
| fun <T : Any> mutableLazy(initializer: () -> T) = MutableLazy(initializer) | |
| /** | |
| * A PUBLICATION-style atomic lazy that’s also mutable. |
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.serialization.KSerializer | |
| import kotlinx.serialization.Serializable | |
| import kotlinx.serialization.descriptors.PrimitiveKind | |
| import kotlinx.serialization.descriptors.PrimitiveSerialDescriptor | |
| import kotlinx.serialization.descriptors.SerialDescriptor | |
| import kotlinx.serialization.encoding.Decoder | |
| import kotlinx.serialization.encoding.Encoder | |
| class IntHexSerializer : KSerializer<Int> { |
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
| private const val CRC32_POLYNOMIAL_MSB = 0xEDB88320.toInt() | |
| private val CRC32_REVERSE_TABLE = IntArray(256) { | |
| var crc = it | |
| repeat(8) { | |
| if ((crc and 1) != 0) { | |
| crc = (crc ushr 1) xor CRC32_POLYNOMIAL_MSB | |
| } else { | |
| crc = crc ushr 1 | |
| } | |
| } |
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
| private fun String.indexAfter(token: String): Int { | |
| return indexOf(token).let { if (it < 0) -1 else it + token.length } | |
| } |
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
| package com.bitgrind.common.trees | |
| import java.util.* | |
| class SuffixTree { | |
| private class SuffixRef(val word: Int, val offset: Int) | |
| private class Edge(val word: Int, var first: Int, val last: Int, var node: Node) { | |
| val length: Int |
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
| object LChHues { | |
| // --- Palette L*=67 C*=40 (24 Colors) --- | |
| val lch_L67_C40_01 = Color(0xffe586a5) | |
| val lch_L67_C40_02 = Color(0xffe78793) | |
| val lch_L67_C40_03 = Color(0xffe48a81) | |
| val lch_L67_C40_04 = Color(0xffdd8f72) | |
| val lch_L67_C40_05 = Color(0xffd39566) | |
| val lch_L67_C40_06 = Color(0xffc59c5d) | |
| val lch_L67_C40_07 = Color(0xffb5a25a) | |
| val lch_L67_C40_08 = Color(0xffa3a85b) |
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
| package com.android.atool.ui | |
| import kotlinx.coroutines.channels.BufferOverflow.DROP_LATEST | |
| import kotlinx.coroutines.flow.buffer | |
| import kotlinx.coroutines.flow.channelFlow | |
| import kotlinx.coroutines.flow.Flow | |
| /** | |
| * Creates a [Flow] that emits sliding windows of the elements from the original [Flow]. | |
| * Each emitted list represents a window of the specified [length]. The window starts with |
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
| private const val FILE_TYPES = "?pc?d?b?-?l?s???" | |
| fun String.toPosixModeInt(): Int { | |
| require(length == 10) { "Should have 10 characters" } | |
| // type | |
| val type = when(get(0)) { | |
| 'p' -> 1 | |
| 'c' -> 2 | |
| 'd' -> 4 | |
| 'b' -> 6 |
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
| package adb | |
| import kotlinx.coroutines.CoroutineName | |
| import kotlinx.coroutines.CoroutineScope | |
| import kotlinx.coroutines.DelicateCoroutinesApi | |
| import kotlinx.coroutines.Dispatchers | |
| import kotlinx.coroutines.isActive | |
| import kotlinx.coroutines.launch | |
| import java.lang.ref.Reference | |
| import java.lang.ref.ReferenceQueue |
NewerOlder