Skip to content

Instantly share code, notes, and snippets.


Vitaliy ultraon

View GitHub Profile
View tuples.kt
fun main(args: Array<String>) {
println("a" to "b")
println("a" to "b" tre "c")
println("a" to "b" tre "c" fo "d")
println("a" to "b" tre "c" fo "d" fi "e")
println("a" to "b" tre "c" fo "d" fi "e" sik "f")
println("a" to "b" tre "c" fo "d" fi "e" sik "f" seva "g")
infix fun <A, B, C> Pair<A, B>.tre(c: C) = Triple(first, second, c)
hrach / channel.kt
Last active Apr 8, 2020
Kotlin Channels Debounce & Throttle
View channel.kt
import kotlinx.coroutines.experimental.*
import kotlinx.coroutines.experimental.channels.ReceiveChannel
import kotlinx.coroutines.experimental.channels.consumeEach
import kotlinx.coroutines.experimental.channels.produce
import kotlin.coroutines.experimental.CoroutineContext
fun <E> ReceiveChannel<E>.debounce(
wait: Long = 50,
context: CoroutineContext = DefaultDispatcher
): ReceiveChannel<E> = produce(context) {
imminent / ClickActors.kt
Created Nov 25, 2017
Kotlin actor extensions for Android listeners
View ClickActors.kt
* MIT License
* Copyright (c) 2017 Dandré Allison
* Permission is hereby granted, free of charge, to any person obtaining a copy
* of this software and associated documentation files (the "Software"), to deal
* in the Software without restriction, including without limitation the rights
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
* copies of the Software, and to permit persons to whom the Software is
View Example.kt
import kotlinx.coroutines.experimental.*
suspend fun f1(i: Int): Int {
Thread.sleep(if (i != 2) 2000L else 200L)
return 1
suspend fun f2(i: Int): Int {
Thread.sleep(if (i != 2) 2000L else 200L)
koral-- / build.gradle
Last active Dec 12, 2017
testApt to testAnnotationProcessor migration, workaround for issue:
View build.gradle
android.applicationVariants.all {
def aptOutputDir = new File(buildDir, "generated/source/apt/${it.unitTestVariant.dirName}")
gtomek /
Created Feb 10, 2016
Read files with Okio
* Utils for I/O operations.
* <p/>
* Created by Tomek on 09/06/15.
public class IoUtils {
* Reads file and returns a String.
vaughandroid /
Last active Mar 11, 2020
Not quite the easiest way to override Dagger 2 modules for unit tests...
public interface MyComponent {
void inject(MyApplication application);
public class MyModule {
@Provides @ApplicationScope
frogermcs /
Last active Apr 23, 2020
Sources for blog post "Dependency injection with Dagger 2 - the API"
public @interface ActivityScope {
daverix /
Last active Dec 30, 2017
Dagger2 sub components example
package com.example;
import javax.inject.Scope;
import javax.inject.Singleton;
import dagger.Component;
import dagger.Module;
import dagger.Provides;
import dagger.Subcomponent;
You can’t perform that action at this time.