Skip to content

Instantly share code, notes, and snippets.

public class Main {
private static class ConsolePrinter implements Runnable {
private final String text = "my text";
private ConsolePrinter(String text) {
this.text = text;
}
@Override
val validators = mapOf(
String::class to { s: String -> s != "123" })
inline fun <vararg T, R> validate(vars: tuple<T>, action: (tuple<T>) -> R): R? =
if (vars.all { validators(it::class)(it) })

action(vars)
else
null
get("/methor") { request, _ ->
Observable.just(1)
.flatMap { digit ->
Observable.just("my digit is $digit")
}
.flatMap { string ->
Observable.just("awesome $string")
}
.subscribeOn(io())
.observeOn(mainThread())
.subscribe { string ->
package io.adev.fast_pet;
import android.os.Bundle;
import android.support.annotation.Nullable;
import android.support.v7.app.AppCompatActivity;
import android.support.v7.widget.LinearLayoutManager;
import android.support.v7.widget.RecyclerView;
import android.view.ViewGroup;
import android.widget.TextView;
package io.adev.rxwrapper
import io.reactivex.Observable
import io.reactivex.Scheduler
import io.reactivex.schedulers.Schedulers
import java.lang.System.currentTimeMillis
abstract class CacheObservableFactory<T, in C>(
private val expireTime: Long = 2000,
workScheduler: Scheduler = Schedulers.io()) : ObservableFactory<T, C>(workScheduler) {
fun Drawable.copy(context: Context) = run {
when (this) {
is BitmapDrawable -> {
BitmapDrawable(bitmap)
}
else -> {
null
@a-dminator
a-dminator / A.kt
Created September 25, 2017 10:44
primary-constructor
class A(foo: Bar)
fun main(args: Array<String>) {
val a = args[0].toDouble()
val b = args[1].toDouble()
val c = args[2].toDouble()
val r = println(x1(a, b, c))
println(r)
}
// fun run(action: () -> Any): Any = <...>
import de.nielsfalk.playground.ktor.swagger.*
import entity.Magazine
import entity.Publisher
import entity.aggregate.ApplicationSettingsResponse
import exceptions.installExceptions
import io.ktor.application.Application
import io.ktor.application.call
import io.ktor.application.install
import io.ktor.content.resources
void doFrame(long frameTimeNanos, int frame) {
final long startNanos;
synchronized (mLock) {
if (!mFrameScheduled) {
return; // no work to do
}
if (DEBUG_JANK && mDebugPrintNextFrameTimeDelta) {
mDebugPrintNextFrameTimeDelta = false;
Log.d(TAG, "Frame time delta: "
+ ((frameTimeNanos - mLastFrameTimeNanos) * 0.000001f) + " ms");