This file contains hidden or 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 com.github.fluidsonic.nestedrecyclerview | |
| import android.content.Context | |
| import android.support.v4.view.NestedScrollingParent | |
| import android.support.v7.widget.RecyclerView | |
| import android.util.AttributeSet | |
| import android.view.MotionEvent | |
| import android.view.View | |
This file contains hidden or 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
| const contenteditableElement = … | |
| const selection = window.getSelection() | |
| selection.selectAllChildren(contenteditableElement) | |
| selection.collapseToEnd() |
This file contains hidden or 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 io.ktor.application.ApplicationCallPipeline | |
| import io.ktor.application.ApplicationFeature | |
| import io.ktor.application.call | |
| import io.ktor.features.ContentNegotiation | |
| import io.ktor.features.UnsupportedMediaTypeException | |
| import io.ktor.http.HttpMethod | |
| import io.ktor.http.HttpStatusCode | |
| import io.ktor.http.content.HttpStatusCodeContent | |
| import io.ktor.http.content.OutgoingContent | |
| import io.ktor.http.content.transformDefaultContent |
This file contains hidden or 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
| actual fun StringBuilder.replace(start: Int, end: Int, replacement: String) = apply { | |
| check(start in 0 .. length) { "start must be in 0 .. $length: $start" } | |
| check(end in start .. length) { "end must be in $start .. $length: $end" } | |
| when { | |
| start == end -> Unit | |
| start == 0 -> | |
| when (end) { | |
| length -> { |
This file contains hidden or 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.reflect.KProperty | |
| import kotlin.reflect.KProperty0 | |
| import kotlin.reflect.jvm.isAccessible | |
| class SomeClass { | |
| var someProperty by observable(1) | |
| } |
This file contains hidden or 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
| type Merge<Union> = AddOptionalProperties<Union, keyof UnionToIntersection<Union>> | |
| type AddOptionalProperties<Union, Properties extends keyof any> = | |
| Union extends (infer Component) | |
| ? { [P in keyof Union]: Union[P] } & { [P in Exclude<Properties, keyof Union>]?: never } | |
| : never | |
| // https://stackoverflow.com/a/50375286/1183577 | |
| type UnionToIntersection<Union> = | |
| (Union extends any ? (_: Union) => void : never) extends ((_: infer Component) => void) ? Component : never |
This file contains hidden or 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 Foo { | |
| a: number; // no b | |
| } | |
| interface Bar { | |
| a: number; b: string | |
| } | |
| function logB(value: Foo | Bar) { | |
| console.log(value.b) // We cannot access .b as it isn't defined on Foo. |
This file contains hidden or 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 Foo { | |
| a: number; // no b | |
| } | |
| interface Bar { | |
| a: number; b: string | |
| } | |
| function logB(value: Merge<Foo | Bar>) { | |
| console.log(value.b) // .b is now an optional 'string' property |
This file contains hidden or 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
| // same as Merge<Foo | Bar> | |
| interface MergeOfFooAndBar { | |
| a: number | |
| b?: string | |
| } |
This file contains hidden or 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.coroutines.* | |
| import kotlinx.coroutines.channels.* | |
| import kotlinx.coroutines.flow.* | |
| import kotlinx.coroutines.sync.* | |
| import kotlin.coroutines.* | |
| @Suppress("EXPERIMENTAL_API_USAGE") | |
| suspend fun main() { | |
| coroutineScope { |