Skip to content

Instantly share code, notes, and snippets.

View realdadfish's full-sized avatar

Thomas Keller realdadfish

View GitHub Profile
@realdadfish
realdadfish / PersistentCookieJar.kt
Last active January 16, 2019 11:17
Naive persistent cookie jar for OkHttp3
package de.aoksystems.ma.abp.smp.common
import android.content.Context
import android.support.annotation.VisibleForTesting
import de.aoksystems.ma.abp.common.util.InstanceFactory
import de.aoksystems.ma.abp.common.util.TimeProvider
import de.aoksystems.ma.abp.common.util.callbacks.AppCodeResetCallbackRegistry
import io.reactivex.Completable
import okhttp3.Cookie
import okhttp3.CookieJar

Keybase proof

I hereby claim:

  • I am realdadfish on github.
  • I am deadfish (https://keybase.io/deadfish) on keybase.
  • I have a public key ASCO19XrNn4ZihRPMImt_195hWoFLLZ28Rx-G0Sd-d_qwQo

To claim this, I am signing this object:

@realdadfish
realdadfish / MissingSubscriptionToMethodException.kt
Last active September 21, 2018 07:47
Testing actual subscriptions
package com.xing.android.test.rules.subscription
class MissingSubscriptionToMethodException : Exception()
curl -X POST \
--digest --user test:... \
-H "Content-Type: application/json"
-d '{"project":"Foo","branch":"master","change_id":"I4428a11e0bee8d9dbc43fe7adc1e61039218ef24","status":"NEW","merge":{"source":"refs/heads/new-bar"},"subject":"New bar"}' \
https://my.gerrit.instance/a/changes/
java.lang.IllegalArgumentException: Cannot convert field of typeandroid.util.SparseArray<java.lang.String>
E at nl.qbusict.cupboard.internal.convert.ConverterRegistry.getFieldConverter(ConverterRegistry.java:242)
E at nl.qbusict.cupboard.Cupboard.getFieldConverter(Cupboard.java:202)
E at nl.qbusict.cupboard.convert.ReflectiveEntityConverter.getFieldConverter(ReflectiveEntityConverter.java:119)
E at nl.qbusict.cupboard.convert.ReflectiveEntityConverter.<init>(ReflectiveEntityConverter.java:79)
E at nl.qbusict.cupboard.convert.ReflectiveEntityConverter.<init>(ReflectiveEntityConverter.java:51)
E at nl.qbusict.cupboard.internal.convert.ConverterRegistry$1.create(ConverterRegistry.java:163)
E at nl.qbusict.cupboard.internal.convert.ConverterRegistry.getEntityConverter(ConverterRegistry.java:191)
E at nl.qbusict.cupboard.Cupboard.getEntityConverter(Cupboard.java:217)
E at nl.qbusict.cupboard.BaseCompartment.getConverter(BaseCompartment.java:28)
StrictMode E A resource was acquired at attached stack trace but never released. See java.io.Closeable for information on avoiding resource leaks.
E java.lang.Throwable: Explicit termination method 'close' not called
E at dalvik.system.CloseGuard.open(CloseGuard.java:184)
E at android.database.CursorWindow.<init>(CursorWindow.java:168)
E at android.database.CursorWindow.<init>(CursorWindow.java:127)
E at android.database.AbstractWindowedCursor.generateNewWindowCursor(AbstractWindowedCursor.java:195)
E at android.database.AbstractWindowedCursor.clearOrCreateWindow(AbstractWindowedCursor.java:210)
E at android.database.sqlite.SQLiteCursor.fillWindow(SQLiteCursor.java:165)
E at android.database.sqlite.SQLiteCursor.getCount(SQLiteCursor.java:159)
@realdadfish
realdadfish / ActivityResultMatchers.java
Last active October 22, 2015 10:39
A pair of hamcrest matchers to check for activity results / intent data.
/**
* A pair of hamcrest matchers that expose the result code and intent data of activities.
*
* Usage:
*
* @RunWith(AndroidJUnit4.class)
* public class YourActivityTest extends ActivityTestBase {
* @Rule
* public final ActivityTestRule<YourActivity> mActivityTestRule = new ActivityTestRule<>(YourActivity.class);
*
@realdadfish
realdadfish / filter.js
Last active August 29, 2015 14:23
JIRA Rapid View Exclusive Filter
// ==UserScript==
// @name Single-click filter selection
// @namespace http://thomaskeller.biz
// @version 0.1
// @description Exclusively selects a filter from the configured list of filters amongst the others (i.e. deselects the others).
// @author You
// @match https://your.jira.server/secure/RapidBoard.jspa?rapidView=*
// @grant none
// ==/UserScript==
@realdadfish
realdadfish / ViewMatchers.java
Created October 29, 2014 07:44
Workaround for Espresso / Android Test Kit to "support" RecyclerView matching.
public class ViewMatchers
{
@SuppressWarnings("unchecked")
public static Matcher<View> withRecyclerView(@IdRes int viewId)
{
return allOf(isAssignableFrom(RecyclerView.class), withId(viewId));
}
@SuppressWarnings("unchecked")
public static ViewInteraction onRecyclerItemView(@IdRes int identifyingView, Matcher<View> identifyingMatcher, Matcher<View> childMatcher)
public class ViewUtils
{
/**
* Starts animations inside a LayerDrawable
*
* @param drawable
*/
public static void startLayerAnimation(LayerDrawable drawable)
{
for (int i = 0; i < drawable.getNumberOfLayers(); ++i)