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 android.content.Intent | |
| import android.os.Bundle | |
| @Suppress("DEPRECATION") | |
| fun Bundle.contentToString(): String { | |
| return "Bundle(${ | |
| keySet().joinToString { key -> | |
| when (val value = get(key)) { | |
| is Bundle -> "$key=${value.contentToString()}" | |
| is Array<*> -> "$key=${value.contentToString()}" |
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 yourpackage | |
| import android.content.Context | |
| import android.os.Build | |
| import android.util.AttributeSet | |
| import android.view.View | |
| import androidx.cardview.widget.CardView | |
| import yourpackage.R | |
| /** |
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 android.annotation.SuppressLint | |
| import android.app.Application | |
| import android.content.ComponentCallbacks | |
| import android.content.Context | |
| import android.content.ContextWrapper | |
| import android.content.res.Configuration | |
| import android.content.res.Resources | |
| import android.os.Build | |
| import android.os.LocaleList | |
| import androidx.core.os.ConfigurationCompat |
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
| /** | |
| * Source: https://github.com/JuliaMath/LambertW.jl/blob/master/src/LambertW.jl | |
| */ | |
| object LambertW { | |
| // Lambert W function for real z | |
| fun lambertW(z: Double, k: Int = 0, maxIts: Int = 1000): Double { | |
| return _lambertW(z, k, maxIts) | |
| } |
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
| using System; | |
| // From the Kotlin standard library | |
| public class XorWowRandom | |
| { | |
| private int x, y, z, w, v, addend; | |
| private XorWowRandom() { } | |
| public static XorWowRandom FromSeed(int seed) |
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 kotlin.random.Random | |
| import kotlin.reflect.full.declaredMemberProperties | |
| import kotlin.reflect.jvm.isAccessible | |
| fun main() { | |
| val random = Random(42) | |
| println(random.nextInt()) | |
| println(random.nextInt()) | |
| println(random.nextInt()) | |
| println(random.nextInt()) |
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
| function Get-PrimeNumber([ulong] $position) { | |
| return [System.UInt128] ("prime($position)" | gp.exe -q) | |
| } | |
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 kotlin.experimental.and | |
| import kotlin.experimental.or | |
| import kotlin.experimental.xor | |
| fun UByte.toFixedBinaryString(): String { | |
| return toString(2).padStart(UByte.SIZE_BITS, '0') | |
| } | |
| fun UShort.toFixedBinaryString(byteSeparator: String = ""): String { | |
| val binaryString = toString(2).padStart(UShort.SIZE_BITS, '0').also { binaryString -> |
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 android.content.Context | |
| import android.graphics.Color | |
| import android.util.AttributeSet | |
| import android.view.ViewGroup | |
| import androidx.annotation.ColorInt | |
| import androidx.annotation.ColorRes | |
| import androidx.annotation.DimenRes | |
| import androidx.annotation.Dimension | |
| import androidx.annotation.Px | |
| import androidx.core.content.ContextCompat |
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.* | |
| import kotlinx.coroutines.flow.* | |
| import kotlinx.coroutines.sync.* | |
| interface AsyncResource<out T> { | |
| sealed interface State<out T> { | |
| data object NotStarted : State<Nothing> | |
| data class Loading<out T>(val currentResource: Completed<T>?) : State<T> | |
| sealed interface Completed<out T> : State<T> { |