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
#!/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 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 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 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 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 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 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
public void onDeleteChatAt(int id) { | |
interactor.deleteChat(id) | |
.retryWhen(errors -> errors.flatMap(error -> view.showDeleteFailedWithRetry())) | |
.subscribe(() -> view.removeChat(id), logError()) | |
} |
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
public void onDeleteChatAt(int id) { | |
interactor.deleteChat(id) | |
.retryWhen(errors -> view.showDeleteFailedWithRetry()) | |
.subscribe(() -> view.removeChat(id), logError()) | |
} |
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
@Override public Observable showDeleteFailedWithRetry() { | |
Snackbar snackbar = Snackbar.make(rootView, "Can't delete chat", Snackbar.LENGTH_LONG); | |
Observable<Integer> observable = RxSnackbar.actionClicked(snackbar, "Retry")); | |
snackbar.show(); | |
return observable; | |
} |
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
public void onDeleteChatAt(int id) { | |
interactor.deleteChat(id) | |
.subscribe(() -> view.removeChat(id), logError()) | |
} |