Skip to content

Instantly share code, notes, and snippets.

View glureau's full-sized avatar
🏡

Grégory Lureau glureau

🏡
View GitHub Profile
@glureau
glureau / versionRegexGenerator.kt
Created April 10, 2024 16:10
Kotlin Regex generator for semver/maven versioning style (<major>.<minor>.<patch>)
data class Group(val matches: Boolean, val testedVersions: MutableList<String>) {
val range: String get() = "[${testedVersions.first()} - ${testedVersions.last()}]"
}
fun main() {
val major = 2
val minor = 62
val patch = 103
println("Input version: $major.$minor.$patch")
@glureau
glureau / ProtoBufSchemaGenerator.kt
Created July 20, 2023 10:36
ProtoBufSchemaGenerator with v3 partial support, value/inline class support and more
@file:OptIn(ExperimentalSerializationApi::class) // buildSerialDescriptor requires this annotation
package com.sumup.oms.pos.configuration
import kotlinx.serialization.Contextual
import kotlinx.serialization.ExperimentalSerializationApi
import kotlinx.serialization.InternalSerializationApi
import kotlinx.serialization.Polymorphic
import kotlinx.serialization.Serializable
import kotlinx.serialization.builtins.serializer
document$.subscribe(() => {
// this executes after each navigation
alert(25)
})
function greg(){
alert(33);
}
@glureau
glureau / androidMain-SqliteExceptionMapper.kt
Created February 20, 2023 15:39
SQLDelight: deal with platform exceptions from commonMain
import android.database.sqlite.SQLiteAbortException
import android.database.sqlite.SQLiteAccessPermException
import android.database.sqlite.SQLiteBindOrColumnIndexOutOfRangeException
import android.database.sqlite.SQLiteBlobTooBigException
import android.database.sqlite.SQLiteCantOpenDatabaseException
import android.database.sqlite.SQLiteConstraintException
import android.database.sqlite.SQLiteDatabaseCorruptException
import android.database.sqlite.SQLiteDatabaseLockedException
import android.database.sqlite.SQLiteDatatypeMismatchException
@glureau
glureau / markdown-supports-nested-details-summary.md
Created October 25, 2022 15:38
markdown supports nested details-summary
Toggle me!Peek a boo!
But there is more here!YOUHOU
class ExportCompilerTest {
@Test
fun classWithOneVal() {
assertCompilationOutput(
"""
package foo.bar
import deezer.kmp.Export
@Export
class BasicClass(val id: String)
@glureau
glureau / ThemeColorPreview.kt
Last active September 13, 2021 10:41
Display
package com.glureau
import android.content.res.Configuration.UI_MODE_NIGHT_NO
import android.content.res.Configuration.UI_MODE_NIGHT_YES
import androidx.compose.foundation.ExperimentalFoundationApi
import androidx.compose.foundation.background
import androidx.compose.foundation.layout.aspectRatio
import androidx.compose.foundation.lazy.GridCells
import androidx.compose.foundation.lazy.LazyVerticalGrid
import androidx.compose.material.MaterialTheme
package glureau.frameradar
import android.content.Context
import android.graphics.Canvas
import android.graphics.Color
import android.graphics.Paint
import android.util.AttributeSet
import android.view.View
import java.util.*
/**********************************************************************************************************************
* Storage of AutoSizeConfiguration
*
* 1 - We cannot setTextSize without disabling autosize (or use Reflection but way more fragile...)
* 2 - Disabling autosize reset all values and attrs is not re-parsed so data is lost.
* Due to these 2 reasons, we need a way to keep track of the previous values to restore them when required.
*
* The solution is to store in a static map a weak reference of the view and an AutoSizeConfiguration data class.
* So if there is no data available (first usage or first view destroyed and recreated),
* we store the attributes in our data class, and if there is already a data class, we re-use them.