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 / controller.js
Created April 24, 2016 13:29
An example for reversing population in Mongoose
// Gets a list of Types
export function index(req, res) {
Type.find({})
.populate('products')
.exec((err, types) => {
if (err) handleErr(err, res);
async.forEach(types, function (type, done) {
Product.find({type: type._id}, '-type -market')
.exec(function (err, products) {
@tranngoclam
tranngoclam / SchedulersTest.java
Last active September 19, 2016 16:05
Debounce vs Throttle (RxJava)
package net.lamtran.rxjava2;
import org.junit.Before;
import org.junit.Test;
import java.util.List;
import java.util.concurrent.TimeUnit;
import rx.observers.TestSubscriber;
import rx.schedulers.TestScheduler;
@tranngoclam
tranngoclam / BuilderTest.java
Created September 23, 2016 03:38
Example for Builder Pattern
package net.lamtran.rxjava2;
import org.junit.Test;
import static org.hamcrest.MatcherAssert.assertThat;
import static org.hamcrest.core.IsEqual.equalTo;
import static org.junit.Assert.assertNotNull;
/**
* Created by lam on 9/23/16.
@tranngoclam
tranngoclam / MultiSourcesTest.java
Created September 23, 2016 06:42
Example for fetching data from remote or local using RxJava
package net.lamtran.rxjava2;
import org.junit.After;
import org.junit.Before;
import org.junit.Test;
import java.util.List;
import rx.observers.TestSubscriber;
package net.lamtran.rxjava2.validation;
/**
* Created by lam on 9/25/16.
*/
public enum FieldType {
USERNAME, PASSWORD, EMAIL, PHONE_NUMBER, CARD_NUMBER
}
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;
@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)

@tranngoclam
tranngoclam / GitCommitEmoji.md
Created August 11, 2017 01:11 — forked from parmentf/GitCommitEmoji.md
Git Commit message Emoji
@tranngoclam
tranngoclam / README.md
Created September 6, 2017 04:35 — forked from hofmannsven/README.md
My simply MySQL Command Line Cheatsheet