This file contains 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 CommandLine { | |
static execute(String command) { | |
command.execute().waitForProcessOutput(System.out, System.err) | |
} | |
} |
This file contains 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 HexToBase64 { | |
fun encode(hex: String): String { | |
return Base64.getUrlEncoder().encodeToString(hex.decodeHex()) | |
} | |
private fun String.decodeHex(): ByteArray { | |
check(length % 2 == 0) { "Must have an even length" } | |
return chunked(2) |
This file contains 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.ExperimentalSerializationApi | |
import kotlinx.serialization.KSerializer | |
import kotlinx.serialization.builtins.serializer | |
import kotlinx.serialization.descriptors.SerialDescriptor | |
import kotlinx.serialization.descriptors.buildClassSerialDescriptor | |
import kotlinx.serialization.descriptors.element | |
import kotlinx.serialization.encoding.CompositeDecoder | |
import kotlinx.serialization.encoding.Decoder | |
import kotlinx.serialization.encoding.Encoder | |
import kotlinx.serialization.encoding.decodeStructure |
This file contains 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
ext.getChangeLog = { lastCommitsCount = 10 -> | |
return formatGitLog(getGitLogUntilCommitNumber(lastCommitsCount)) | |
} | |
ext.getReleaseChangeLog = { | |
def lastTag = getLastTag() | |
return formatGitLog(getGitLogUntilTag(lastTag)) | |
} |
This file contains 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
val activityManager = (context.getSystemService(Context.ACTIVITY_SERVICE) as ActivityManager) | |
val memoryInfo = ActivityManager.MemoryInfo() | |
activityManager.getMemoryInfo(memoryInfo) | |
val totalMemory = memoryInfo.totalMem |
This file contains 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 androidx.paging.ExperimentalPagingApi | |
import androidx.paging.LoadType | |
import androidx.paging.PagingState | |
import androidx.paging.RemoteMediator | |
import com.github.michaelbull.result.Result | |
import com.github.michaelbull.result.get | |
import com.github.michaelbull.result.onFailure | |
import kotlinx.coroutines.Dispatchers | |
import kotlinx.coroutines.withContext |
This file contains 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 java.math.RoundingMode | |
import java.text.DecimalFormat | |
import java.text.DecimalFormatSymbols | |
fun Double.withDecimalDigits(number: Int = 1): Double { | |
var diesisForDecimals = "" | |
repeat(number) { | |
diesisForDecimals = "#" | |
} |
This file contains 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 PREFS_SEQUENTIAL_REQUEST = "sequential-request-preferences" | |
private const val KEY_LAST_URL = "lastUrl" | |
private const val KEY_LAST_REQUEST_TIME = "lastRequestTime" | |
class SequentialRequestInterceptor(context: Context) : Interceptor { | |
private val preferences = | |
context.getSharedPreferences(PREFS_SEQUENTIAL_REQUEST, Context.MODE_PRIVATE) | |
override fun intercept(chain: Interceptor.Chain): Response { | |
val baseRequest = chain.request() |
This file contains 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
fun String.convertToDouble(): Double { | |
val newValue: String = this.replace(",", ".") | |
var withoutExtraDots = "" | |
var indexOfFirstDot: Int? = null | |
var index = 0 | |
for (c in newValue) { | |
if (index == 0 && c == '.') return 0.0 | |
if (indexOfFirstDot == null && c == '.') indexOfFirstDot = index |
NewerOlder