Skip to content

Instantly share code, notes, and snippets.

View sebaslogen's full-sized avatar

Sebas LG sebaslogen

View GitHub Profile
@sebaslogen
sebaslogen / gist:9466beeb213cb82804d3
Created August 11, 2014 20:35
Verifying that +sebas is my Bitcoin username. You can send me #bitcoin here: https://onename.io/sebas
Verifying that +sebas is my Bitcoin username. You can send me #bitcoin here: https://onename.io/sebas
@sebaslogen
sebaslogen / gist:7054935e77002263ca57
Created August 11, 2014 20:44
Verifying that +neoranga55 is my Bitcoin username. You can send me #bitcoin here: https://onename.io/neoranga55
Verifying that +neoranga55 is my Bitcoin username. You can send me #bitcoin here: https://onename.io/neoranga55
Verifying that +sebas is my blockchain ID. https://onename.com/sebas
@sebaslogen
sebaslogen / Picasso idlingresource.md
Last active April 27, 2021 22:54 — forked from Maragues/Picasso idlingresource.md
Implementation and usage of an IdlingResource that waits for Picasso actions to finish.

Note that the file lives in the package as Picasso (src/androidTest/java/com/squareup/picasso). Otherwise we don't have access to targetToAction

package com.squareup.picasso;

import android.app.Activity;
import android.os.Handler;
import android.support.test.espresso.IdlingResource;
import android.support.test.runner.lifecycle.ActivityLifecycleCallback;
import android.support.test.runner.lifecycle.Stage;
@sebaslogen
sebaslogen / RelaySharedWithMultipleProblematicOnSubscribeAndOnUnSubscribeEvents.java
Last active March 15, 2017 00:31
BehaviorRelay shared with multiple observers produces problematic onSubscribe and onUnSubscribe events
BehaviorRelay<Integer> brelay = BehaviorRelay.create();
Observable<Integer> relayObservable = brelay
.doOnSubscribe(() -> {
Log.i("RxExperiments", "BehaviorRelayProblem->doOnSubscribe");
}).doOnUnsubscribe(() -> {
Log.i("RxExperiments", "BehaviorRelayProblem->doOnUnsubscribe");
});
Log.i("RxExperiments", "BehaviorRelayProblem->observer-1 subscribes");
Subscription subscription1 = relayObservable.subscribe(i -> {
@sebaslogen
sebaslogen / RelaySharedWithSingleOnSubscribeAndOnUnSubscribe.java
Last active August 28, 2016 09:04
BehaviorRelay shared with single onSubscribe and onUnSubscribe
BehaviorRelay<Integer> behaviorRelay = BehaviorRelay.create();
Observable<Integer> relayObservable = behaviorRelay
.doOnSubscribe(() -> {
Log.i("RxExperiments", "share->doOnSubscribe");
}).doOnUnsubscribe(() -> {
Log.i("RxExperiments", "share->doOnUnsubscribe");
})
.share();
Log.i("RxExperiments", "share->observer-1 subscribes");
@sebaslogen
sebaslogen / RelaySharedWithSingleOnSubscribeAndOnUnSubscribeUsingRxReplayingShare.java
Last active March 15, 2017 00:10
PublishRelay shared with single onSubscribe and onUnSubscribe using RxReplayingShare
PublishRelay<Integer> publishRelay = PublishRelay.create();
Observable<Integer> relayObservable = publishRelay
.doOnSubscribe(() -> {
Log.i("RxExperiments", "ReplayingShare->doOnSubscribe");
// Register to event here...
}).doOnUnsubscribe(() -> {
Log.i("RxExperiments", "ReplayingShare->doOnUnsubscribe");
// Un-register from event here...
})
.compose(ReplayingShare.instance());
@sebaslogen
sebaslogen / Project_Default.xml
Last active October 3, 2016 09:50
Autocorrect suggestion: Escape apostrophes in Android string XMLs (file should be inside .idea/inspectionProfiles/)
<component name="InspectionProjectProfileManager">
<profile version="1.0">
<option name="myName" value="Project Default" />
<inspection_tool class="AndroidLintDrawAllocation" enabled="true" level="ERROR" enabled_by_default="true" />
<inspection_tool class="SSBasedInspection" enabled="true" level="ERROR" enabled_by_default="true">
<replaceConfiguration name="Escape apostrophes in Android string XMLs" text="&lt;string $attributes$&gt;$text$&lt;/string&gt;" recursive="false" caseInsensitive="true" type="XML" reformatAccordingToStyle="true" shortenFQN="true" useStaticImport="true" replacement="&lt;string $attributes$&gt;$fixedText$&lt;/string&gt;">
<constraint name="attributes" minCount="0" maxCount="2147483647" within="" contains="" />
<constraint name="text" regexp=".*[^\\]'.*" maxCount="2147483647" within="" contains="" />
<variableDefinition name="fixedText" script="&quot;text.getValue().replaceAll( &quot;\\\\'|\'&quot;, &quot;\\\\'&quot; )&quot;" />
</replace
@sebaslogen
sebaslogen / LiveObservable.kt
Created July 9, 2017 21:15
LiveObservable: Android lifecycle aware wrapper for an RxJava Observable
import android.arch.lifecycle.Lifecycle
import android.arch.lifecycle.LifecycleObserver
import android.arch.lifecycle.LifecycleOwner
import android.arch.lifecycle.OnLifecycleEvent
import com.jakewharton.rxrelay.BehaviorRelay
import rx.Observable
import rx.android.schedulers.AndroidSchedulers
import rx.functions.Action1
import rx.subscriptions.CompositeSubscription
@sebaslogen
sebaslogen / MyAndroidApplication.kt
Created January 28, 2018 17:06
Finish all opened activities in my Android app (also across different tasks)
class MainApplication : Application() {
private val createdActivities = mutableListOf<WeakReference<Activity>>()
override fun onCreate() {
super.onCreate()
registerActivityLifecycleCallbacks(activityLifecycleCallbacks())
}
fun closeAllActivities() {