This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
@file:Suppress("PackageDirectoryMismatch") | |
package android.arch.lifecycle | |
fun ViewModel.clear() = clear() |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import kotlinx.cinterop.ObjCAction | |
import kotlinx.cinterop.StableRef | |
import platform.AppKit.NSControl | |
import platform.Foundation.NSSelectorFromString | |
import platform.darwin.NSObject | |
import platform.objc.OBJC_ASSOCIATION_RETAIN | |
import platform.objc.objc_setAssociatedObject | |
/** | |
* Specify a [callback][onAction] for an [NSControl] action, instead of setting |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
git rebase "$(git merge-base HEAD master)" -x 'git commit --amend -C HEAD --date="$(date -R)" && sleep 1.05' |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
interface Cleanup { | |
fun registerForCleanup(onCleanup: () -> Unit): Closeable | |
} | |
class CloseableRefCallback<T : Cleanup>( | |
private val callback: T.() -> Unit | |
) : Closeable { | |
private val resourceRef = AtomicReference<Pair<T, Closeable>?>(null) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/* Coming up ~ April 2020 */ | |
package test | |
import arrow.* | |
inline class TwitterHandle | |
@Suppress("NON_PUBLIC_PRIMARY_CONSTRUCTOR_OF_INLINE_CLASS") | |
private constructor(val handle: String) { | |
companion object : Refined<String> { | |
override val validate: String.() -> Map<String, Boolean> = { |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import kotlin.properties.ReadOnlyProperty | |
import kotlin.properties.ReadWriteProperty | |
import kotlin.reflect.KProperty | |
private typealias GetValue<This, R> = (thisRef: This, property: KProperty<*>) -> R | |
private typealias SetValue<This, R> = (thisRef: This, property: KProperty<*>, value: R) -> Unit | |
inline fun <This, R> property( | |
crossinline getValue: GetValue<This, R> | |
) = |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
apply from: 'strip_play_services.gradle' |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
package me.seebrock3r.extensions.reactivex | |
import io.reactivex.Flowable | |
import io.reactivex.Maybe | |
import io.reactivex.Observable | |
import io.reactivex.Single | |
@Suppress("UNCHECKED_CAST") // The cast happens after we filter by type so it's safe | |
inline fun <reified R> Flowable<*>.filterIsInstance(): Flowable<R> = | |
filter { it is R } |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
val sample: (X, Y, Z) -> Int = multiReceiver { { { x + y + z } } } | |
fun <A, B, C, R> multiReceiver(f: A.() -> B.() -> C.() -> R) = { a: A, b: B, c: C -> f(a)(b)(c) } | |
class X(val x: Int) | |
class Y(val y: Int) | |
class Z(val z: Int) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
@file:Suppress("PackageDirectoryMismatch") // root package looks great when importing, ie. `import exhaustive` | |
/** | |
* Allows requiring an exhaustive mapping in a `when` block when used with the [rangeTo] operator. | |
* @sample [exhaustive_when_example] | |
*/ | |
@Suppress("ClassName") // lowercase because it should look like a keyword | |
object exhaustive { |