Skip to content

Instantly share code, notes, and snippets.

Avatar
:shipit:
SHIP IT

Benoît Quenaudon oldergod

:shipit:
SHIP IT
View GitHub Profile
@oldergod
oldergod / hyperlink.js
Created Nov 18, 2020
Hyperlink on slack
View hyperlink.js
@oldergod
oldergod / AndroidViewEvent.kt
Created Sep 18, 2019
Android view events for tests
View AndroidViewEvent.kt
import com.jakewharton.rxrelay2.PublishRelay
import io.reactivex.Observable
import io.reactivex.Observer
import org.junit.rules.TestRule
import org.junit.runner.Description
import org.junit.runners.model.Statement
/**
* [PublishRelay]-like [Observable] enforcing:
* 1. a unique observer at a time, and
@oldergod
oldergod / EditingDemo.kt
Created Jun 25, 2019
IntelliJ Edit & Shortcut demo
View EditingDemo.kt
package okio
/**
* Tools ->
* Create Command-line Launcher
* IntelliJ can diff.
* Alt+F1 -> Select in...
*/
class EditingDemo(private val log: (String) -> Unit) {
View close_activities.java
private static void closeAllActivities(Instrumentation instrumentation) throws Exception {
final int NUMBER_OF_RETRIES = 100;
int i = 0;
while (closeActivity(instrumentation)) {
if (i++ > NUMBER_OF_RETRIES) {
// throw new AssertionError("Limit of retries excesses");
break;
}
}
}
@oldergod
oldergod / 01_Activity.java
Last active Sep 23, 2019
Managing RxState Ending point
View 01_Activity.java
/**
* Many things are omitted to focus on the relevant data.
*/
public class Activity extends AppCompatActivity {
Binder binder;
@Override protected void onCreate(@Nullable Bundle savedInstanceState) {
Object lastCustomNonConfigInstance = getLastCustomNonConfigurationInstance();
if (lastCustomNonConfigInstance != null) {
binder = (Binder) lastCustomNonConfigInstance;
@oldergod
oldergod / 01_Activity.java
Last active Jan 19, 2018
Managing RxState Starting point
View 01_Activity.java
/**
* Many things are omitted to focus on the relevant data.
*/
public class Activity extends AppCompatActivity {
Binder binder;
@Override protected void onCreate(@Nullable Bundle savedInstanceState) {
bind();
}
@oldergod
oldergod / DataBindingAdapters.java
Last active Mar 30, 2017
DataBinding with <include> tags
View DataBindingAdapters.java
public class DataBindingAdapters {
@BindingAdapter("visible") public static void setVisibility(View view, boolean isVisible) {
view.setVisibility(isVisible ? VISIBLE : GONE);
}
}
@oldergod
oldergod / XmlOrJsonConverterFactory.java
Last active Jun 4, 2018
Retrofit: Xml or Json converter
View XmlOrJsonConverterFactory.java
public class XmlOrJsonConverterFactory extends Converter.Factory {
final Converter.Factory xml = SimpleXmlConverterFactory.create();
final Converter.Factory gson = GsonConverterFactory.create();
@Override
public Converter<ResponseBody, ?> responseBodyConverter(
Type type, Annotation[] annotations, Retrofit retrofit) {
// Retrofit gives us all the annotations so we just need to check
for (Annotation annotation : annotations) {
View LoginContextUnwrappingConverter.java
public class LoginContextUnwrappingConverter extends Converter.Factory {
@Override
public Converter<ResponseBody, LoginContext>
responseBodyConverter(Type type,
Annotation[] annotations,
Retrofit retrofit) {
if (type != LoginContext.class) {
return null;
}
View keybase.md

Keybase proof

I hereby claim:

  • I am oldergod on github.
  • I am oldergod (https://keybase.io/oldergod) on keybase.
  • I have a public key whose fingerprint is 8B6C 86DC 67D8 0CE9 B1C8 2822 AADC 8990 FC32 3E48

To claim this, I am signing this object: