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
| cd ~/.gradle/wrapper/dists/ | |
| find . ! -name 'gradle-2.14.1-all' -type d -depth 1 -exec rm -f -r {} + |
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
| @Override public Observable showDeleteFailedWithRetry() { | |
| Snackbar snackbar = Snackbar.make(rootView, "Can't delete chat", Snackbar.LENGTH_LONG); | |
| Observable<Integer> observable = RxSnackbar.actionClicked(snackbar, "Retry")); | |
| Observable<Integer> dismissObservable = RxSnackbar.dismisses(snackbar) | |
| .filter(event -> event != Snackbar.Callback.DISMISS_EVENT_ACTION) | |
| .flatMap(ignored -> Observable.error(new Throwable())); | |
| snackbar.show(); | |
| return observable.mergeWith(dismissObservable); | |
| } |
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
| // Source: http://stackoverflow.com/a/39687177/616119 | |
| infix fun <T> Boolean.then(param: T): T? = if (this) param else null | |
| // Usage: | |
| println(condition then "true" ?: "false") |
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
| // Considerably inefficient implementation for test purposes | |
| fun fib(k: Int): Long = when (k) { | |
| 0 -> 1 | |
| 1 -> 1 | |
| else -> fib(k - 1) + fib(k - 2) | |
| } |
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
| sealed class Option<out A> { | |
| object None : Option<Nothing>() | |
| data class Some<out A>(val value: A) : Option<A>() | |
| inline fun <B> map(f: (A) -> B): Option<B> = when (this) { | |
| is None -> this | |
| is Some -> Some(f(value)) | |
| } | |
| } |
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
| #!/usr/bin/env python | |
| import subprocess | |
| import sys | |
| def run_command(command): | |
| return subprocess.check_output(command, shell=True, stderr=subprocess.STDOUT).strip() | |
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
| Completable.complete() | |
| .subscribe( | |
| Action { throw exception }, | |
| Consumer { /* wont be called */ } | |
| ) | |
| Observable.just(str) | |
| .subscribe( | |
| Consumer { throw exception }, |
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
| fun <T> Single<T>.doCompletableOnSuccess(function: (T) -> Completable): Single<T> = | |
| flatMap { function(it).andThen(Single.just(it)) } | |
| fun <T> Maybe<T>.doCompletableOnSuccess(function: (T) -> Completable): Maybe<T> = | |
| flatMap { function(it).andThen(Maybe.just(it)) } |
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.reactivex.CompletableObserver | |
| import io.reactivex.MaybeObserver | |
| import io.reactivex.Observer | |
| import io.reactivex.SingleObserver | |
| import io.reactivex.disposables.Disposable | |
| import io.reactivex.exceptions.CompositeException | |
| import io.reactivex.exceptions.Exceptions | |
| import io.reactivex.functions.Action | |
| import io.reactivex.functions.Consumer | |
| import io.reactivex.internal.functions.Functions |
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
| def publish = project.tasks.create("copyApkToCustomDir") | |
| android.applicationVariants.all { variant -> | |
| variant.outputs.all { output -> | |
| def task = project.tasks.create("copy${variant.name}Apk", Copy) | |
| task.from(output.outputFile) | |
| task.into("$project.buildDir/outputs/apk/") | |
| println "Done" | |
| task.dependsOn variant.assemble |