Skip to content

Instantly share code, notes, and snippets.

View es0329's full-sized avatar

Eric es0329

View GitHub Profile
@happysingh23828
happysingh23828 / Extensions.kt
Last active January 24, 2023 07:46
Kotlin extension for applying Spannable text on any textview and getting callback for onclick.
import android.text.SpannableStringBuilder
import android.text.Spanned
import android.text.TextPaint
import android.text.method.LinkMovementMethod
import android.text.style.ClickableSpan
import android.view.View
import androidx.appcompat.widget.AppCompatTextView
fun AppCompatTextView.highLightWord(word: String, onClick: () -> Unit) {
val ssBuilder = SpannableStringBuilder(this.text)
@MarkusKramer
MarkusKramer / Base64.kt
Last active May 6, 2025 01:15
Kotlin Multiplatform Base64 - no extra dependencies. Based on Java's implementation.
/*
* Copyright (c) 2012, 2018, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* This code is free software; you can redistribute it and/or modify it
* under the terms of the GNU General Public License version 2 only, as
* published by the Free Software Foundation. Oracle designates this
* particular file as subject to the "Classpath" exception as provided
* by Oracle in the LICENSE file that accompanied this code.
*
val items = listOf<Item>(..)
@Composable
fun Parallax(modifier: Modifier = Modifier) {
// [1]
val scrollState = rememberScrollState()
// [2]
ScrollableRow(
@serhii-pokrovskyi
serhii-pokrovskyi / OnDestroyNullable.kt
Created December 5, 2020 08:03
Property that will be destroyed in onDestoy
fun <T> LifecycleOwner.onDestroyNullable(): ReadWriteProperty<LifecycleOwner, T> =
object : ReadWriteProperty<LifecycleOwner, T>, DefaultLifecycleObserver {
private var value: T? = null
init {
this@onDestroyNullable
.lifecycle
.addObserver(this)
}
@zjeaton
zjeaton / _Google Analytics 4 with Hugo.md
Last active October 13, 2025 15:18
Google Analytics 4 (with Measurement ID) in Hugo

Google Analytics 4 in Hugo

Blog post with slightly more detail can be found here. If you want to just get to it, read on.

I (very) recently decided to reimplement GA in my site, and found that existing implementation in Hugo was not compatible with GA4's new Measurement ID. This is an easy way to drop your Measurement ID into your site. I'm not going to go into how to sign up for GA.

This implementation requires that you create a site parameter for analytics, create a partial, and call the partial. I tweaked the names of the parameters and files so they didn't collide with the built-in hugo code.

Place the GoogleAnalyicsID (Measurement ID) in config.toml within [params].

@cbeyls
cbeyls / FlowLayout.kt
Created September 17, 2020 00:30
FlowLayout implementation for Jetpack Compose
package be.digitalia.compose.layout
import androidx.compose.runtime.Composable
import androidx.compose.ui.Alignment
import androidx.compose.ui.Layout
import androidx.compose.ui.Modifier
@Composable
fun FlowLayout(
modifier: Modifier = Modifier,
package me.aartikov.storesample
import com.dropbox.android.external.store4.*
import kotlinx.coroutines.delay
import kotlinx.coroutines.flow.Flow
import kotlinx.coroutines.flow.MutableStateFlow
import kotlinx.coroutines.flow.toList
import kotlinx.coroutines.launch
import kotlinx.coroutines.runBlocking
import org.junit.Assert.assertEquals
@gildor
gildor / JetpackComposeScaffoldSnackbar.kt
Created August 25, 2020 07:39
Jetpack Compose Scaffold with snackbar example
package ru.gildor.compose.sandbox
import android.app.Activity
import android.util.Log
import android.view.inputmethod.InputMethodManager
import androidx.compose.animation.AnimatedVisibility
import androidx.compose.animation.ExperimentalAnimationApi
import androidx.compose.animation.slideInVertically
import androidx.compose.animation.slideOutVertically
import androidx.compose.foundation.Text
@osipxd
osipxd / .editorconfig
Last active June 13, 2026 15:50
EditorConfig for Android projects with mapping to IntelliJ IDEA's config
root = true
[*]
charset = utf-8
end_of_line = lf
indent_size = 4
indent_style = space
insert_final_newline = true
trim_trailing_whitespace = true
max_line_length = 120