Skip to content

Instantly share code, notes, and snippets.

View Skeptick's full-sized avatar
💁‍♂️

Danil Yudov Skeptick

💁‍♂️
  • 08:37 (UTC +05:00)
View GitHub Profile
@Skeptick
Skeptick / ChildSlot+BottomSheet.kt
Created October 30, 2024 16:39
rememberBottomSheetChild
@Composable
fun <C : Any, T : Any> ChildSlot<C, T>.rememberBottomSheetChild(onDismiss: suspend () -> Unit): Child.Created<C, T>? {
var bottomSheetChild: Child.Created<C, T>? by remember { mutableStateOf(child) }
LaunchedEffect(child) {
if (child == null) {
onDismiss()
bottomSheetChild = null
} else {
bottomSheetChild = child
}
@Skeptick
Skeptick / KtorSignerFeature.kt
Created May 15, 2023 07:27
Подпись запроса в ktor
package com.example.data.network.features
import io.ktor.client.HttpClient
import io.ktor.client.features.HttpClientFeature
import io.ktor.client.request.HttpRequestBuilder
import io.ktor.client.request.HttpRequestPipeline
import io.ktor.client.request.header
import io.ktor.content.TextContent
import io.ktor.http.clone
import io.ktor.util.AttributeKey
@Skeptick
Skeptick / UIActivityViewController+Show.kt
Created May 3, 2023 12:53
Present UIActivityViewController from KMM
fun UIActivityViewController.show() {
val topController = TopMostController ?: return
if (UIDevice.currentDevice.userInterfaceIdiom == UIUserInterfaceIdiomPad) {
popoverPresentationController()!!.apply {
sourceView = topController.presentingViewController!!.view
sourceRect = CGRectMake(0.0, 0.0, 0.0, 0.0)
}
}
topController.presentViewController(this, true, null)
}
@Skeptick
Skeptick / ByteWriteChannel.kt
Created September 19, 2022 15:38
iOS ByteWriteChannel
import io.ktor.client.utils.*
import io.ktor.utils.io.*
import io.ktor.utils.io.bits.*
import kotlinx.cinterop.*
import kotlinx.coroutines.*
import platform.CoreFoundation.*
import platform.Foundation.*
import platform.UIKit.*
import platform.posix.memcpy
import platform.posix.uint8_tVar
@Skeptick
Skeptick / HttpEngine.kt
Created March 10, 2021 09:39
OkHttp. Trust all SSL certificates
private fun buildHttpClientEngine(): HttpClientEngine = OkHttp.create {
config {
retryOnConnectionFailure(true)
hostnameVerifier { _, _ -> true }
val trustManager = object : X509TrustManager {
override fun checkClientTrusted(chain: Array<out X509Certificate>?, authType: String?) = Unit
override fun checkServerTrusted(chain: Array<out X509Certificate>?, authType: String?) = Unit
override fun getAcceptedIssuers(): Array<X509Certificate> = emptyArray()
}
val sslContext = SSLContext.getInstance("TLS")
@Skeptick
Skeptick / KeyBinding.md
Last active April 11, 2020 13:06
Биндинг доп. кнопок мышки в Ubuntu

Вызываем xev в терминале, чтоб узнать номера нужных кнопок, интерес представляют события ButtonPress или ButtonRelease в которых и будет указан номер кнопки, например: button 9.

Устанавливаем утилиту для биндинга и создаём файл конфига:

sudo apt install xbindkeys
xbindkeys --defaults > $HOME/.xbindkeysrc

Также ставим утилиту для генерации фейковых нажатий:

sudo apt install xautomation