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> conditionalTimeout(delay: Long, unit: TimeUnit, condition: () -> Boolean): ObservableTransformer<T, T> { | |
| return ObservableTransformer { upstream: Observable<T> -> | |
| upstream.timeout( | |
| // Timeout on first result after delay if condition is true | |
| Observable.timer(delay, unit) | |
| .switchMap { | |
| if (condition.invoke()) { | |
| // Trigger timeout | |
| Observable.empty<T>() | |
| } else { |
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
| /** | |
| * A logging implementation which reports exceptions to Crashlytics and omits other log messages | |
| */ | |
| public class CrashlyticsTree extends Timber.DebugTree { | |
| @Override | |
| public void i(String message, Object... args) { | |
| // omit | |
| } | |
| @Override |
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
| class MyPresenter implements Presenter<MyPresenter.View> { | |
| private final DataRepository dataRepository; | |
| private final CompositeDisposable subscriptions = new CompositeDisposable(); | |
| @Inject | |
| MyPresenter(DataRepository dataRepository) { | |
| this.dataRepository = dataRepository; | |
| } |
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
| [ | |
| { | |
| "url": "https://basetrip.s3.amazonaws.com/api/v2/countries/covers/afghanistan.jpg", | |
| "attribution_url": "https://commons.wikimedia.org/wiki/File:Kabul_Skyline.jpg", | |
| "code": "AF", | |
| "name": "Afghanistan" | |
| }, | |
| { | |
| "url": "https://basetrip.s3.amazonaws.com/api/v2/countries/covers/aland-islands.jpg", | |
| "attribution_url": "https://www.flickr.com/photos/karinbacklund/6217642273", |
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
| public static Action1<Throwable> crashOnError() { | |
| final Throwable checkpoint = new Throwable(); | |
| return throwable -> { | |
| StackTraceElement[] stackTrace = checkpoint.getStackTrace(); | |
| StackTraceElement element = stackTrace[1]; // First element after `crashOnError()` | |
| String msg = String.format("onError() crash from subscribe() in %s.%s(%s:%s)", | |
| element.getClassName(), | |
| element.getMethodName(), | |
| element.getFileName(), | |
| element.getLineNumber()); |
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
| package com.bbc.tve.util; | |
| import com.bbc.tve.api.db.Timestamped; | |
| import com.bbc.tve.api.util.CacheUtils; | |
| import java.util.HashMap; | |
| import java.util.Map; | |
| import rx.Observable; |
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
| unzip -p build/outputs/apk/app-debug.apk classes.dex | head -c 92 | tail -c 4 | hexdump -e '1/4 "%d\n"' |
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
| #!/bin/bash | |
| EMULATOR_PORT=5556 | |
| echo "Android HOME : $ANDROID_HOME" | |
| function start_emulator() { | |
| echo "Starting emulator" | |
| $ANDROID_HOME/tools/emulator -port $EMULATOR_PORT -prop persist.sys.language=en -prop persist.sys.country=GB -avd hudson_en-GB_480_WXGA720_android-23_x86 -no-snapshot-load -no-snapshot-save -no-window & |
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
| # p1 is the baseline conversion, choose 0.5 if unknown to get maximum sample size | |
| # p2 = (p1 + minumum detectable effect) | |
| # power = 1 -(type II error) | |
| power.prop.test(p1=0.5, p2=0.40, power=0.9, alternative='two.sided', sig.level=0.05) |