Skip to content

Instantly share code, notes, and snippets.

View Alex009's full-sized avatar
🏔️

Aleksey Mikhailov Alex009

🏔️
View GitHub Profile
@stakancheck
stakancheck / AuthScreen.swift
Last active June 30, 2023 13:42
Binding for moko filed from any place
// ADD THIS CODE
struct Binder {
private static func binding<T, R>(
mutable: CMutableStateFlow<T>,
viewModel: ViewModel,
equals: @escaping (T?, T?) -> Bool,
getMapper: @escaping (T) -> R,
setMapper: @escaping (R) -> T
) -> Binding<R> {
@dellisd
dellisd / Test.kt
Created June 9, 2022 16:37
Explicit Backing Fields
class Test {
val names: List<String>
field: MutableList<String> = mutableListOf<String>()
fun doThing() {
names.add("Hello!")
}
}
fun main() {
@chris-hatton
chris-hatton / DataSizeFormatter.kt
Last active December 31, 2023 11:37
Human Readable Data Size Formatter for Kotlin Multiplatform (uses Common API only)
package datasizeformatter
import kotlin.math.abs
import kotlin.math.pow
import kotlin.math.roundToLong
/**
* Format a human-readable representation of data size, in binary base form.
* e.g. 1024 -> 1 KiB
* @param byteCount The number of bytes to represent in human-readable form. `Long.MIN_VALUE` is unsupported.
import io.ktor.client.request.HttpRequest
import io.ktor.content.TextContent
import java.util.*
class CurlBuilder(
request: HttpRequest,
private val ignoreHeaders: List<String> = emptyList()
) {
private val url: String = request.url.toString()
private val method: String = request.method.value
@nhalase
nhalase / CohortsNavigationScreen.kt
Last active January 10, 2020 06:53
Example of possible ListWidget bug/limitation in Moko Widgets.
import dev.icerock.moko.widgets.screen.NavigationScreen
import dev.icerock.moko.widgets.screen.ScreenFactory
import kotlin.reflect.KClass
class CohortsNavigationScreen(
screenFactory: ScreenFactory
) : NavigationScreen<CohortsScreen>(screenFactory), CohortsScreen.Parent, CohortScreen.Parent {
override val rootScreen: KClass<out CohortsScreen>
get() = CohortsScreen::class
@green-nick
green-nick / LocalizedString.kt
Last active April 1, 2021 20:32
Wrapper for strings without Android-dependency
package ...
private val identityMap: (String) -> String = { it }
sealed class LocalizedString
data class ResourceString(
val id: Int,
val quantity: Int? = null,
val args: List<Any> = emptyList(),
@tonysneed
tonysneed / Mac OS X: Open in Visual Studio Code
Last active June 14, 2024 04:16
Add a command to Finder services in Mac OSX to open a folder in VS Code
- Open Automator
- File -> New -> Service
- Change "Service Receives" to "files or folders" in "Finder"
- Add a "Run Shell Script" action
- Change "Pass input" to "as arguments"
- Paste the following in the shell script box: open -n -b "com.microsoft.VSCode" --args "$*"
- Save it as something like "Open in Visual Studio Code"
ACTION
AD_HOC_CODE_SIGNING_ALLOWED
ALTERNATE_GROUP
ALTERNATE_MODE
ALTERNATE_OWNER
ALWAYS_SEARCH_USER_PATHS
ALWAYS_USE_SEPARATE_HEADERMAPS
APPLE_INTERNAL_DEVELOPER_DIR
APPLE_INTERNAL_DIR
APPLE_INTERNAL_DOCUMENTATION_DIR
@steipete
steipete / gist:3933090
Created October 22, 2012 18:13
Simple main thread usage detector that I'm using in PSPDFKit to find performance problems early on.
// Smart little helper to find main thread hangs. Enable in appDidFinishLaunching.
// Only available with source code in DEBUG mode.
@interface PSPDFHangDetector : NSObject
+ (void)startHangDetector;
@end
@implementation PSPDFHangDetector
+ (void)startHangDetector {
#ifdef DEBUG