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 / 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 / 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 / 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 / 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 / MyCustomView.kt
Created March 3, 2018 10:37
Kotlin Android CustomView with default parameters
class MyCustomView @JvmOverloads constructor(
context: Context, attrs: AttributeSet? = null, defStyleAttr: Int = 0
) : View(context, attrs, defStyleAttr)
@sebaslogen
sebaslogen / Toolbar.java
Created March 3, 2018 10:46
Android Toolbar constructor
public class Toolbar extends ViewGroup {
public Toolbar(Context context, @Nullable AttributeSet attrs) {
this(context, attrs, R.attr.toolbarStyle);
}
}
@sebaslogen
sebaslogen / Toolbar.java
Last active March 3, 2018 14:43
Imaginary new Android Toolbar constructor
public class Toolbar extends ViewGroup {
public Toolbar(Context context, @Nullable AttributeSet attrs) {
this(context, attrs, getToolbarStyle());
}
private static int getToolbarStyle() {
return (BuildConfig.VERSION_CODE >= Build.VERSION_CODES.O) ? R.attr.newCompatToolbarStyle : R.attr.toolbarStyle;
}
}