Skip to content

Instantly share code, notes, and snippets.

View Mishkun's full-sized avatar
🏠

Mikhail Levchenko Mishkun

🏠
View GitHub Profile
@Mishkun
Mishkun / .atamanrc.config
Last active April 9, 2024 13:34
My config for plugin https://github.com/Mishkun/ataman-intellij. Leader key set for `SPACE`as I am also using IdeaVim
# This file is written in HOCON (Human-Optimized Config Object Notation) format.
# For more information about HOCON see
# https://github.com/lightbend/config/blob/master/HOCON.md
bindings {
b {
description: Buffer/Tabs Navigation...
bindings {
b {actionId: RecentFiles, description: Recent Files}
B {actionId: RecentChangedFiles, description: Recent Changed Files}
set easymotion
set surround
set keep-english-in-normal-and-restore-in-insert
set showmode
set ideajoin
set showcmd
set incsearch
set argtextobj
set exchange
set sneak
@Mishkun
Mishkun / .ideavimrc
Last active March 15, 2020 12:21
This LivePlugin https://github.com/dkandalov/live-plugin#liveplugin snippet toggles comma character at the end of the line. Combine this with ideavim for optimal experience
# you can use any other character. Just replace `,` with the vim expr of your choice
nmap , :action ToggleEndOfLineComma<cr>
registerAction(id = "OptimizeImportsInBranchAction") { event: AnActionEvent ->
val project = project ?: run {
show("Project is null")
return@registerAction
}
val cmd = exec("git diff --name-only origin/dev .")
// val diffs = exec("git status")
if (cmd.first.isNotBlank()) {
show(cmd.first)
return@registerAction
package com.example.benchmark
import androidx.benchmark.BenchmarkRule
import androidx.benchmark.measureRepeated
import androidx.test.ext.junit.runners.AndroidJUnit4
import org.junit.Rule
import org.junit.Test
import org.junit.runner.RunWith
import kotlin.reflect.KProperty
/**
* @author themishkun on 24/07/2018.
*/
typealias ViewAction<View> = (View) -> Unit
@DslMarker
annotation class ViewStateDslMarker
/**
interface Monoid<T> {
operator fun T.plus(other: T): T
fun empty(): T
}
object StringMonoid : Monoid<String> {
override fun String.plus(other: String): String = plus(other)
override fun empty(): String = ""
}
object a<T> {
operator fun get(vararg values:T) = values
}
a[] // empty array
a[1, 2, 3] // arrayOf(1,2,3)
class Memoize0<out R>(val f: () -> R) : () -> R {
private val value = lazy(f)
override fun invoke(): R {
return value
}
}
fun <R> memoize(block: () -> R): () -> R = Memoize0(block)
class Memoize1<in T, out R>(val f: (T) -> R) : (T) -> R {
package jmh
import org.openjdk.jmh.annotations.*
import org.openjdk.jmh.infra.Blackhole
@State(Scope.Benchmark)
@Fork(1)
open class KotlinLazy {
@State(Scope.Thread)