Skip to content

Instantly share code, notes, and snippets.

View benigumocom's full-sized avatar
๐Ÿ 
๐Ÿ™†

chanzmao benigumocom

๐Ÿ 
๐Ÿ™†
View GitHub Profile
val db = SQLiteDatabase.create(null)
val query = "SELECT sqlite_version()"
val sqlite = DatabaseUtils.stringForQuery(db, query, null)
Timber.d("SDK: API-${Build.VERSION.SDK_INT}, SQLite: $sqlite")
// 1658317908.842 D: SDK: API-31, SQLite: 3.32.2
@Suppress("UNUSED_VARIABLE")
val default = listOf(
// https://android.benigumo.com/20220711/default-theme-color/
// material3
// light dark
Color(0xff6750a4), Color(0xffd0bcff), // colorPrimary
Color(0xffffffff), Color(0xff381e72), // colorOnPrimary
Color(0xffeaddff), Color(0xff4f378b), // colorPrimaryContainer
// https://android.benigumo.com/20220703/navbackstackentry-lifecycle/
@Composable
fun LocalLifecycleStateLogger(
screenName: String,
lifecycleOwner: LifecycleOwner = LocalLifecycleOwner.current
) {
val ownerSimpleName = lifecycleOwner.nameHash()
DisposableEffect(lifecycleOwner) {
val observer = LifecycleEventObserver { _, event ->
// dp(Dp) โ†’ px(Float)
@Composable
internal fun Dp.dpToPx(): Float {
return this.value * LocalDensity.current.density
}
// dp(Dp) โ†’ sp(TextUnit)
@Composable
internal fun Dp.dpToSp(): TextUnit {
return (this.value * LocalDensity.current.density / LocalDensity.current.fontScale).sp
ใ‚ฟใ‚คใƒˆใƒซ English ๆ—ฅๆœฌ่ชž
Basics codelabs May 23, 2022 2ๆœˆ 9, 2022 โŒ
Layouts codelabs May 18, 2022 2ๆœˆ 9, 2022 โŒ
State codelab May 16, 2022 2ๆœˆ 24, 2022 โŒ
Theming codelab May 18, 2022 2ๆœˆ 9, 2022 โŒ
Migration codelab Jun 7, 2022 4ๆœˆ 27, 2022 โŒ
Animation codelab May 26, 2022 2ๆœˆ 9, 2022 โŒ
Navigation codelab May 18, 2022 5ๆœˆ 18, 2022 โœ…
Testing codelab May 18, 2022 5ๆœˆ 18, 2022 โœ…
@benigumocom
benigumocom / dot-zshrc
Last active November 25, 2023 02:22
Set JAVA_HOME with Android Studio embed JDK
~ find '/Applications/Android Studio.app/Contents/jre/Contents/Home'
find: /Applications/Android Studio.app/Contents/jre/Contents/Home: No such file or directory
~ find "$HOME/Library/Application Support/JetBrains/Toolbox/apps/AndroidStudio" -path '*/Android Studio.app/Contents/jre/Contents/Home'
/Users/maochanz/Library/Application Support/JetBrains/Toolbox/apps/AndroidStudio/ch-0/212.5712.43.2112.8512546/Android Studio.app/Contents/jre/Contents/Home
# plain android studio
JAVA_HOME='/Applications/Android Studio.app/Contents/jre/Contents/Home'
# jb toolbox android studio
Version: 14.0 โ†“โ†“โ†“
๐Ÿซ  melting face
๐Ÿซข face with open eyes and hand over mouth
๐Ÿซฃ face with peeking eye
๐Ÿซก saluting face
๐Ÿซฅ dotted line face
๐Ÿซค face with diagonal mouth
๐Ÿฅน face holding back tears
๐Ÿซฑ rightwards hand
๐Ÿซฑ๐Ÿป rightwards hand: light skin tone
๐Ÿซ  ๐Ÿซฑ๐Ÿผโ€๐Ÿซฒ๐Ÿฟ ๐Ÿซฐ๐Ÿฝ14.0
๐Ÿ˜ถโ€๐ŸŒซ๏ธ ๐Ÿง”๐Ÿปโ€โ™€๏ธ ๐Ÿง‘๐Ÿฟโ€โค๏ธโ€๐Ÿง‘๐Ÿพ13.1
๐Ÿฅฒ ๐Ÿฅท๐Ÿฟ ๐Ÿปโ€โ„๏ธ13.0
๐Ÿง‘๐Ÿปโ€๐Ÿฆฐ ๐Ÿง‘๐Ÿฟโ€๐Ÿฆฏ ๐Ÿ‘ฉ๐Ÿปโ€๐Ÿคโ€๐Ÿ‘ฉ๐Ÿผ12.1
๐Ÿฆฉ ๐Ÿฆป๐Ÿฟ ๐Ÿ‘ฉ๐Ÿผโ€๐Ÿคโ€๐Ÿ‘ฉ๐Ÿป12.0
fun <T> Flow<T>.log(label: String, tag: String = "###"): Flow<T> {
val prefix = "$tag [$label] ${this.javaClass.simpleName}"
return this
.onStart {
Timber.d("$prefix onStart()")
}
.onEach { value ->
Timber.d("$prefix onEach() value = $value")
}
.onCompletion { cause ->
@benigumocom
benigumocom / sample.kt
Last active April 17, 2022 03:52
Secret Gist ใซใƒชใƒ•ใ‚กใƒฉใƒผใฏใคใใฎใ‹?
val s = """
ๅ‰ใ‹ใ‚‰็–‘ๅ•ใ ใฃใŸใฎใ ใŒ
ใใ‚‰ใคใใ ใ‚?
ใใ‚‚ใใ‚‚
ใ€Œsecretใ€
ใจใ‹
ใƒใƒผใƒŸใƒณใ‚ฐใŒใŠใ‹ใ—ใ„ใ‚ˆใชใ‚ใ€‚
""".trimIndent()