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
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
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
@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 { |
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 main | |
/* | |
* A simple go program to download all the high resolution pictures from your facebook albums. | |
* | |
* To run this: | |
* 1. Go to https://developers.facebook.com/tools/explorer/?method=GET&path=me&version=v2.8 | |
* 2. Get an Access Token: Get Token > Get User Access Token > Check "user_photos" | |
* 3. Paste in the app. | |
*/ |
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
// | |
// gorun - Script-like runner for Go source files. | |
// | |
// https://wiki.ubuntu.com/gorun | |
// | |
// Copyright (c) 2011 Canonical Ltd. | |
// | |
// Written by Gustavo Niemeyer <[email protected]> | |
// | |
package main |
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
// animated GIF: https://i.stack.imgur.com/mHOIc.gif | |
// see https://stackoverflow.com/a/46244263/1306903 | |
import 'package:flutter/material.dart'; | |
import 'ink_text_selection_layout.dart'; | |
class Demo extends StatelessWidget { | |
@override | |
Widget build(context) => inkTextSelectionLayout( |
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 rx.Observable | |
import rx.subjects.BehaviorSubject | |
import SingletonObservable.ItemWrapper | |
/** | |
* Represents the current subscription status (either 'unsubscribed' or 'subscribed') of a [SingletonObservable]. | |
* The index starts at [SingletonObservable.firstSubscriptionIndex] as 'unsubscribed', and every subsequent value alternates between the two states. | |
* Use [SingletonObservable.isSubscribed] to calculate the status for a specific [SubscriptionIndex]. | |
* | |
* Note that a subscription index is constant for the lifetime of a stream, which is completed by the first time either one of |
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
fun test() { | |
val item1 = Item(GameObject()) | |
val item2 = Item(GameObject()) | |
assert(ItemStack(setOf(item1, item2)) is ItemStack) | |
assert(ItemStack(setOf(item1)) is Item) | |
assert(ItemStack(emptySet()) is Empty) | |
} | |
class ItemStack private constructor(val items: Set<Item>) : Elem() { | |
companion object { |