Skip to content

Instantly share code, notes, and snippets.

View anhvt52's full-sized avatar

Anh Vu anhvt52

  • Hochiminh City, Vietnam
  • 02:57 (UTC +07:00)
  • X @anhvt52
View GitHub Profile
@anhvt52
anhvt52 / RemoteImage.kt
Last active April 5, 2021 17:37
Jetpack Compose Remote Image using Glide
fun RemoteImage(uri: String, modifier: Modifier = Modifier, default: @Composable () -> Unit) {
val bitmapState = remember { mutableStateOf<Bitmap?>(null) }
Glide.with(AmbientContext.current).asBitmap().load(uri).into(
object : CustomTarget<Bitmap>() {
override fun onResourceReady(resource: Bitmap, transition: Transition<in Bitmap>?) {
bitmapState.value = resource
}
override fun onLoadCleared(placeholder: Drawable?) {
}
@anhvt52
anhvt52 / changelog.gradle
Created August 14, 2020 04:29
Groovy script to parse changelog from merge commit message
def parseCommitTxt(commit) {
def commitPattern = /^(feat|fix|docs|ci|style|refactor|test|chore)(?:\((.+)\))?: (.+)$/
def commitBody = "git show -s ${commit} --pretty=format:%b".execute().text
def commitMsg = commitBody.split("See merge request")[0].trim()
def type, scope, subject
try {
def (_, t, sc, s) = (commitMsg =~ commitPattern)[0]
type = t
scope = sc
subject = s
@anhvt52
anhvt52 / AppDatabse.kt
Created November 5, 2018 04:34 — forked from tinmegali/AppDatabse.kt
Android Room @TypeConverter using Kotlin
@Database(entities = arrayOf(Note::class, User::class), version = 1)
@TypeConverters(Converters::class)
abstract class AppDatabse : RoomDatabase() {
abstract fun userDAO(): UserDAO
abstract fun noteDAO(): NoteDAO
}