Skip to content

Instantly share code, notes, and snippets.

View tranngoclam's full-sized avatar
🇻🇳
Vietnam

Lam Tran tranngoclam

🇻🇳
Vietnam
View GitHub Profile
@tranngoclam
tranngoclam / activity_main2.xml
Created February 16, 2018 14:59 — forked from mohamedebrahim96/activity_main2.xml
The function of the button at the center is to call an activity and the TabLayout will be place at the bottom of the screen.
<?xml version="1.0" encoding="utf-8"?>
<android.support.design.widget.CoordinatorLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent"
android:layout_height="match_parent"
tools:context="com.vacuum.app.cinema.MainActivity">
<!--SOME CODE FOR MY AppBarLayout-->
<!--SOME CODE FOR MY ToolBar-->
import org.junit.Test;
import java.util.concurrent.TimeUnit;
import rx.Observable;
import rx.Scheduler;
import rx.functions.Func1;
import rx.observers.AssertableSubscriber;
import rx.schedulers.TestScheduler;
@tranngoclam
tranngoclam / BaseBottomNavActivity.java
Created December 30, 2017 03:23 — forked from adroitandroid/BaseBottomNavActivity.java
Custom bottom navigation bar
abstract class BaseBottomNavActivity extends BaseActivity { // you can directly extend AppCompatActivity
@Override
@CallSuper
protected void onCreate(@Nullable Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
initOnCreate(savedInstanceState);
getBottomNavigationBar().setOnTabSelectionListener(
new CustomBottomNavigationBar.OnTabSelectionListener() {
@Override
@tranngoclam
tranngoclam / Container.go
Created October 22, 2017 04:11 — forked from urakozz/Container.go
Flat Buffers with Golang
// automatically generated, do not modify
package encoder
import (
flatbuffers "github.com/google/flatbuffers/go"
)
type Container struct {
_tab flatbuffers.Table
}
@tranngoclam
tranngoclam / PatternEditableBuilder.java
Created September 13, 2017 10:40 — forked from nesquena/PatternEditableBuilder.java
PatternEditableBuilder - Easy way to create colored clickable spans within a TextView!
import android.text.SpannableStringBuilder;
import android.text.Spanned;
import android.text.TextPaint;
import android.text.method.LinkMovementMethod;
import android.text.style.ClickableSpan;
import android.view.View;
import android.widget.TextView;
import java.util.ArrayList;
import java.util.regex.Matcher;
@tranngoclam
tranngoclam / README.md
Created September 6, 2017 04:35 — forked from hofmannsven/README.md
My simply MySQL Command Line Cheatsheet
@tranngoclam
tranngoclam / GitCommitEmoji.md
Created August 11, 2017 01:11 — forked from parmentf/GitCommitEmoji.md
Git Commit message Emoji
@tranngoclam
tranngoclam / gist:0a8dd199daf3302f943f2e0092188867
Created August 9, 2017 07:43 — forked from daschl/gist:db9fcc9d2b932115b679
Draft: Writing Code for Production

Writing Resilient Reactive Applications

This guide is a first draft (that will end up in the official docs) on writing resilient code for production with the Couchbase Java SDK. At the end, the reader will be able to write code that withstands bugs, latency issues or anything else that can make their application fail.

Note that lots of concepts can be applied for both synchronous and asynchronous access. When necessary, both patterns are discussed separately. Also, the focus is on database interaction, but if you are using RxJava as part of your stack you can apply most of the principles there as well (and should!).

RxJava 101 Recap: Cold and Hot Observables

When working with Observables, it is important to understand the difference between cold and hot. Cold Observables will start to emit events once a Observer subscribes, and will do it "fresh" for each Observer. Hot Observables instead are starting to emit data as soon as it becomes available, and will return the same (or parts of the same)

package net.lamtran.rxjava2.bill;
import android.text.TextUtils;
import java.util.List;
import rx.Observable;
import rx.android.schedulers.AndroidSchedulers;
import rx.schedulers.Schedulers;
package net.lamtran.rxjava2.bill;
import android.text.TextUtils;
import java.util.List;
import rx.Observable;
import rx.android.schedulers.AndroidSchedulers;
import rx.schedulers.Schedulers;