Skip to content

Instantly share code, notes, and snippets.

View amal's full-sized avatar
👨‍💻

Art Shendrik amal

👨‍💻
View GitHub Profile
@amal
amal / DrawGlyphs.kt
Created June 24, 2024 16:48 — forked from halilozercan/DrawGlyphs.kt
A Set of helper functions and classes to draw each individual glyph separately
import androidx.compose.ui.draw.drawWithCache
import androidx.compose.ui.geometry.CornerRadius
import androidx.compose.ui.geometry.Offset
import androidx.compose.ui.geometry.Rect
import androidx.compose.ui.geometry.Size
import androidx.compose.ui.graphics.BlendMode
import androidx.compose.ui.graphics.Brush
import androidx.compose.ui.graphics.Color
import androidx.compose.ui.graphics.ColorFilter
import androidx.compose.ui.graphics.ImageBitmap
@amal
amal / ColoredShadow.kt
Created June 24, 2024 10:26 — forked from cedrickring/ColoredShadow.kt
Draw a colored shadow in Android Jetpack Compose
/*
Copyright 2020 Cedric Kring.
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
@amal
amal / DynamicBottomSheetScaffold.kt
Created March 20, 2024 20:34 — forked from Nek-12/DynamicBottomSheetScaffold.kt
Dynamic non-modal bottom sheet for Compose that fixes existing issues with material3 implementation
import androidx.compose.animation.core.animateDpAsState
import androidx.compose.animation.fadeIn
import androidx.compose.animation.fadeOut
import androidx.compose.foundation.layout.Box
import androidx.compose.foundation.layout.WindowInsets
import androidx.compose.foundation.layout.consumeWindowInsets
import androidx.compose.foundation.layout.fillMaxSize
import androidx.compose.foundation.layout.navigationBars
import androidx.compose.foundation.layout.padding
import androidx.compose.foundation.layout.windowInsetsPadding
@amal
amal / CMakeLists.txt
Created March 20, 2024 14:36 — forked from blessedbyjobs/CMakeLists.txt
Код, используемый для проверки, что устройство имеет root права
// этот файл поместить в корень проекта
cmake_minimum_required(VERSION 3.4.1)
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -std=gnu++11")
// адаптировать под структуру вашего проекта
set(SOURCES src/main/cpp/NativeRootChecker.cpp)
add_library(root_checker_jni SHARED ${SOURCES})
@amal
amal / StackNavigator.kt
Created March 12, 2024 16:20 — forked from Nek-12/StackNavigator.kt
Decompose - Global navigation events with channel
internal class StackComponent(context: ComponentContext): Component {
private val results = Channel<NavResult<*>>(Channel.CONFLATED)
inline fun <reified R> sendResult(result: R) {
val config = stack.active.configuration
// or popWhile - bring desired page to the front
navigation.pop {
results.trySend(NavResult(config, result))
@amal
amal / gradle_snippet.kt
Created June 1, 2023 11:04 — forked from cies/gradle_snippet.kt
Make Gradle print its task plan
// This prints the dependencies of each task in the current execution graph
gradle.taskGraph.whenReady(
closureOf<TaskExecutionGraph> {
println("About to run ${allTasks.size} tasks: (use `-i` to see why tasks are skipped, use `--rerun-tasks` to prevent UP-TO-DATE checks)")
allTasks.forEachIndexed { i, task ->
val dependenciesString =
if (task.dependsOn.isEmpty()) {
""
} else {
task.dependsOn.joinToString(", ", " (depends on ", ")") { dependency ->
@amal
amal / gist:2cb237497bb296e7c3a7da658734973a
Last active March 19, 2023 21:16 — forked from yorickhenning/gist:3275ea38e1619a5c8aa0efac9370484d
Reentrance checking coroutine Mutex
// https://github.com/Kotlin/kotlinx.coroutines/issues/3626#issuecomment-1451115356
// https://github.com/Kotlin/kotlinx.coroutines/issues/3626#issuecomment-1452820863
suspend fun <ReturnT> Mutex.checkedWithLock(
block: suspend () -> ReturnT
): ReturnT {
val element = LockedMutexesElement(this).key
check (currentCoroutineContext()[element] == null) {
"Reentered Mutex"
}
@amal
amal / ParallaxScreen.kt
Created September 29, 2022 14:26 — forked from surajsau/ParallaxScreen.kt
Parallax effect with Jetpack Compose
@Composable
fun ParallaxScreen(modifier: Modifier = Modifier) {
val context = LocalContext.current
val scope = rememberCoroutineScope()
var data by remember { mutableStateOf<SensorData?>(null) }
DisposableEffect(Unit) {
val dataManager = SensorDataManager(context)
dataManager.init()
@amal
amal / Float128.java
Created October 21, 2017 16:28 — forked from rjeschke/Float128.java
128 bit floats in software (Java)
/*
* Copyright (C) 2012 René Jeschke <rene_jeschke@yahoo.de>
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software