Skip to content

Instantly share code, notes, and snippets.

View tranngoclam's full-sized avatar
🇻🇳
Vietnam

Lam Tran tranngoclam

🇻🇳
Vietnam
View GitHub Profile
package net.lamtran.rxjava2.validation;
/**
* Created by lam on 9/25/16.
*/
public enum FieldType {
USERNAME, PASSWORD, EMAIL, PHONE_NUMBER, CARD_NUMBER
}
@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;
@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 / 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 / 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) {