Skip to content

Instantly share code, notes, and snippets.

View yoonseopshin's full-sized avatar
🏠
Working from home

Yoonseop Shin yoonseopshin

🏠
Working from home
View GitHub Profile
@yoonseopshin
yoonseopshin / AndroidRsaCipherHelper.kt
Created March 17, 2022 05:32 — forked from FrancescoJo/AndroidRsaCipherHelper.kt
Android RSA cipher helper with system generated key. No more static final String key in our class - an approach which is very vulnerable to reverse engineering attack.
import android.os.Build
import android.security.KeyPairGeneratorSpec
import android.security.keystore.KeyGenParameterSpec
import android.security.keystore.KeyProperties
import android.util.Base64
import timber.log.Timber
import java.math.BigInteger
import java.security.GeneralSecurityException
import java.security.KeyPairGenerator
import java.security.KeyStore
@yoonseopshin
yoonseopshin / README.md
Created July 16, 2022 06:48 — forked from lopspower/README.md
Hexadecimal color code for transparency

Hexadecimal color code for transparency

Twitter

How to set transparency with hex value ?

For example, you want to set 40% alpha transparence to #000000 (black color), you need to add 66 like this #66000000.

Download This sample on Google Play Store

@yoonseopshin
yoonseopshin / color-blender-rgba.kt
Last active July 16, 2022 07:27
Color blender(RGBA)
data class RGBA(var red: Long = 0, var green: Long = 0, var blue: Long = 0, var alpha: Double = 0.0)
fun main() {
// rgba-order
val base = RGBA(124, 77, 255, 0.06)
val added = RGBA(255, 255, 255, 0.06)
val mix = RGBA()
// alpha
mix.alpha = 1 - (1 - added.alpha) * (1 - base.alpha)
@yoonseopshin
yoonseopshin / CustomSpeedLinearLayoutManager
Created February 4, 2025 14:28
Sample for RecyclerView smooth scroll animation speed and offset.
class CustomSpeedLinearLayoutManager(
context: Context,
private val offsetProvider: (position: Int) -> Int
) : LinearLayoutManager(context) {
override fun smoothScrollToPosition(recyclerView: RecyclerView, state: RecyclerView.State, position: Int) {
val viewHolder = recyclerView.findViewHolderForAdapterPosition(position)?.itemView
val itemHeight = viewHolder?.height ?: 0
// just sample value, speed up if viewholder's height is long enough.