Skip to content

Instantly share code, notes, and snippets.

View IanField90's full-sized avatar
:shipit:

Ian Field IanField90

:shipit:
View GitHub Profile
@IanField90
IanField90 / pr-protection.yml
Created June 14, 2022 16:24
Protection for PRs
name: PR Protection
on:
pull_request:
branches:
- main
jobs:
check_source_is_develop:
runs-on: ubuntu-latest
@IanField90
IanField90 / AndroidManifest.xml
Last active September 15, 2020 15:53
Android 11(SDK 30, R) androidx.test.runner.AndroidJUnitRunner and Orchestrator fix.
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
...>
<!--
Super important for getting tests to run on Android 30/R
Without this you will see
java.lang.RuntimeException: Exception thrown in onCreate() of ComponentInfo{com.example.lib.test/androidx.test.runner.AndroidJUnitRunner}: java.lang.RuntimeException: Cannot connect to androidx.test.orchestrator.OrchestratorService
E/AndroidJUnitRunner: An unhandled exception was thrown by the app.
E/InstrumentationResultPrinter: Failed to mark test No Tests as finished after process crash
fun <T, S, U> partial1(t: T, f: (T, S) -> U): (S) -> U {
return { s -> f(t, s) }
}
val greeter: (String, String) -> String = { greeting, name -> "$greeting, $name" }
val helloer = partial1("Hello", greeter)
fun main() {
println(helloer("Ian"))
}
@IanField90
IanField90 / MockitoKotlinHelpers.kt
Created November 22, 2018 16:56
Kotlin Mockito Rx Callback
/**
* Helper functions that are workarounds to kotlin Runtime Exceptions when using kotlin.
*/
import org.mockito.ArgumentCaptor
import org.mockito.Mockito
/**
* Returns Mockito.eq() as nullable type to avoid java.lang.IllegalStateException when
* null is returned.

Keybase proof

I hereby claim:

  • I am ianfield90 on github.
  • I am ianfield90 (https://keybase.io/ianfield90) on keybase.
  • I have a public key ASCxauT5cVUq8rRvNjE3xAecc_y-oi0sHX-bk93hGo4RfQo

To claim this, I am signing this object:

@IanField90
IanField90 / rx.java
Last active February 3, 2023 16:47
Update using cache
@Override
public Observable<Void> onRefreshAction() {
return Observable.fromEmitter(emitter -> {
swipeRefreshLayout.setOnRefreshListener(() -> emitter.onNext(null));
emitter.setCancellation(() -> swipeRefreshLayout.setOnRefreshListener(null));
}, Emitter.BackpressureMode.ERROR).startWith((Void) null).map(ignored -> null);
}
addToUnsubscribe(view.onRefreshAction()
@IanField90
IanField90 / gist:932b47c8239f7af4c1b4f4516f3c552f
Created November 29, 2016 11:12
Android Debug keystore sha1
keytool -list -v -keystore ~/.android/debug.keystore -alias androiddebugkey -storepass android -keypass android
export PS1="\[\n\033[49;31;1m\]--- \[\033[49;33;1m\]\u@\h\[\033[49;37;1m\] \w\[\033[49;31;1m\] \$(parse_git_branch) ---\n\[\033[49;32;1m\]\!\[\033[49;31;1m\] \$ \[\033[0m\]"

Analyse contents

jar tf yourapk.apk | grep .yourfileextension

Unzip

jar xf yourapk.apk

@IanField90
IanField90 / AppComponent.java
Last active March 24, 2016 17:02
Basic AndroidApplication class
@Singleton @Component(modules = AppModule.class) public interface AppComponent {
void inject(MainActivity activity);
}