Skip to content

Instantly share code, notes, and snippets.

View AlexGladkov's full-sized avatar
🦆
Quack Quack

Alex AlexGladkov

🦆
Quack Quack
View GitHub Profile
@AlexGladkov
AlexGladkov / script.sh
Created February 22, 2024 12:29
Docker VPS install script
apt update
apt install apt-transport-https ca-certificates curl software-properties-common
curl -fsSL https://download.docker.com/linux/ubuntu/gpg | sudo apt-key add -
add-apt-repository "deb [arch=amd64] https://download.docker.com/linux/ubuntu focal stable"
apt update
@AlexGladkov
AlexGladkov / KtorFeatureTokenQueue.kt
Created August 15, 2022 09:08
Ktor feature token queue
internal class AuthRefreshFeature(
private val localAuthDataSource: LocalAuthDataSource,
private val refreshTokenDataSource: KtorRefreshTokenDataSource,
private val localAuthErrorDataSource: LocalAuthErrorDataSource,
private val json: Json
) {
class Config(
var localAuthDataSource: LocalAuthDataSource? = null,
var refreshTokenDataSource: KtorRefreshTokenDataSource? = null,
@AlexGladkov
AlexGladkov / DesktopWebView.kt
Created July 7, 2022 11:11
Desktop Web View
@Composable
fun DesktopWebView() {
val finishListener = object : PlatformImpl.FinishListener {
override fun idle(implicitExit: Boolean) {}
override fun exitCalled() {}
}
PlatformImpl.addListener(finishListener)
println("Desktop Web View start")
Window(
public class DesktopWebView {
public static JFrame renderWebView(String url) {
JFrame frame = new JFrame();
final JFXPanel fxPanel = new JFXPanel();
frame.add(fxPanel);
frame.setSize(300, 200);
frame.setVisible(true);
frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
@AlexGladkov
AlexGladkov / Example.swift
Created July 26, 2021 08:22
SwiftUI + Kotlin Flow
struct ExampleView: View {
let viewModel: AuthViewModel = AuthViewModel()
var body: some View {
ObservingView(statePublisher: asPublisher(viewModel.viewStates()),
actionPublisher: asPublisher(viewModel.viewActions()),
content: { state, action in
// your view here
})
@AlexGladkov
AlexGladkov / TagHost.kt
Last active November 15, 2022 04:05
Jetpack Compose Layout To Tag Cloud
@Composable
fun TagHost(
modifier: Modifier = Modifier,
verticalPadding: Dp = 24.dp,
content: @Composable () -> Unit
) {
Layout(
modifier = modifier,
content = content
) { measurables, constraints ->
@AlexGladkov
AlexGladkov / build.gradle.kts
Created May 15, 2021 12:34
Android KMP gradle.kts
plugins {
id("com.android.application")
kotlin("android")
kotlin("kapt")
id("org.jetbrains.compose")
}
android {
compileSdkVersion(30)
buildToolsVersion("30.0.2")
@AlexGladkov
AlexGladkov / ProductScreen.kt
Last active August 28, 2024 18:21
ProductDetails + Jetpack Compose
package ru.leroymerlin.library_sdk.screens.product_details
import android.media.Rating
import androidx.compose.foundation.ExperimentalFoundationApi
import androidx.compose.foundation.background
import androidx.compose.foundation.layout.*
import androidx.compose.foundation.lazy.LazyColumn
import androidx.compose.foundation.shape.RoundedCornerShape
import androidx.compose.material.*
import androidx.compose.runtime.Composable
@AlexGladkov
AlexGladkov / GitResponse.kt
Created February 26, 2021 13:57
Gist parse
data class GistResponse(
val url: String,
...,
val files: FilesRemote
)
data class FilesRemote(
val filename: FilesFilename
)
@AlexGladkov
AlexGladkov / Repo.kt
Created February 24, 2021 11:39
Repositories
class CatalogVersionRepositoryImpl @Inject constructor(
private val catalogVersionRemoteDataSource: CatalogVersionRemoteDataSource,
private val catalogVersionLocalDataSource: CatalogVersionLocalDataSource
) : CatalogVersionRepository {
override fun checkNeedUpdate(): Single<Boolean> {
return catalogVersionRemoteDataSource.getCurrentCatalogVersion()
.map { remoteCatalogueVersion ->
val localCatalogueVersion = catalogVersionLocalDataSource.getCurrentCatalogVersion()
val hasActualVersion = localCatalogueVersion == remoteCatalogueVersion