Skip to content

Instantly share code, notes, and snippets.

View dniHze's full-sized avatar
🐵
Hacking

Artem Dorosh dniHze

🐵
Hacking
View GitHub Profile
@dniHze
dniHze / Resources.kt
Created September 29, 2022 12:42
Create painter with adjustable FilterQuality
@Composable
public fun painterResource(
@DrawableRes id: Int,
filterQuality: FilterQuality,
): Painter {
LocalConfiguration.current
val resources = LocalContext.current.resources
val value = remember { TypedValue() }
resources.getValue(id, value, true)
val path = value.string

Keybase proof

I hereby claim:

  • I am dnihze on github.
  • I am dnihze (https://keybase.io/dnihze) on keybase.
  • I have a public key ASByZo8kODOeOxkgF9D7qphOIM73vofAgoDHZUFBzxbHugo

To claim this, I am signing this object:

@dniHze
dniHze / SavedStateHandle.kt
Last active December 20, 2021 15:42
Add MutableStateFlow integration to SavedStateHandle
package dev.kaitei.utils
import androidx.lifecycle.SavedStateHandle
import kotlinx.coroutines.flow.MutableStateFlow
private fun <T> SavedStateHandle.getMutableStateFlow(
key: String,
): MutableStateFlow<T?> = getMutableStateFlowInternal(
key = key,
hasInitialValue = true,
@dniHze
dniHze / test.kt
Created January 23, 2018 13:14
How to pack circles in rectange in Kotlin.
import java.util.*
import kotlin.math.*
data class Point(var x: Double, var y: Double) {
fun vect(p: Point) = Point(p.x - x, p.y - y)
fun norm() = sqrt(x.pow(2) + y.pow(2))
fun dist(p: Point) = vect(p).norm()
fun add(p: Point) = Point(x + p.x, y + p.y)
fun mult(a: Double) = Point(x * a, y * a)
}
@dniHze
dniHze / gist:a64aa5fd1212cc864294
Last active August 29, 2015 14:12
KPI Live Notificator
import vk_api
import time
from subprocess import call
def main():
# your vk login and password
login, password = 'yourlogin@vk.com', 'password'
# sometext
sometext = "text"
# path to KPI Live logo