Skip to content

Instantly share code, notes, and snippets.

View yongjhih's full-sized avatar
🏠
Working from home

Andrew Chen yongjhih

🏠
Working from home
View GitHub Profile
@yongjhih
yongjhih / ParseQueryTest.java
Created March 6, 2015 16:38
ParseQueryTest
public class MyActivity extends Activity {
@Override public void onResume() {
super.onResume();
ParseQuery<ParseObject> query = ParseQuery.getQuery(ParseObject.class);
query.findInBackground(new FindCallback() {
@Override done(List<ParseObject> objects, ParseException e) {
getActivity().runOnUiThread(new Runnable() {
@Override public void run() {
@yongjhih
yongjhih / Optional.java
Last active August 29, 2015 14:16
Optional Observable
public class Optional<T> {
Observable<T> obs;
public Optional(Observable<T> obs) {
this.obs = obs;
}
public static <T> Optional<T> of(T value) {
if (value == null) {
throw new NullPointerException();
package com.infstory.ui.adapter;
import android.content.Context;
import android.support.v7.widget.RecyclerView;
import android.view.View;
import android.view.ViewGroup;
import java.util.List;
import butterknife.ButterKnife;
@yongjhih
yongjhih / AsyncAwait.dart
Last active August 29, 2015 14:17
RxAsyncAwait.java
// ref. http://news.dartlang.org/2015/03/dart-19-release-youve-been-await-ing-for.html?m=1
Future<int> getCount(bool showCustomers) async {
try {
var database = await connectDb();
var count = await database.queryEmployees().length;
if (showCustomers) {
count += await database.queryCustomers().length;
}
return count;
} on DbError catch (error, stack) {
@yongjhih
yongjhih / BindViewHolder.java
Last active August 29, 2015 14:18
ListRecyclerAdapter.java
public abstract class BindViewHolder<T> extends RecyclerView.ViewHolder {
public BindViewHolder(View itemView) {
super(itemView);
}
abstract void onBind(int position, T item);
}
@yongjhih
yongjhih / OperatorFrequency.java
Last active August 29, 2015 14:18
Frequency emit
/**
* Copyright 2015 8tory, Inc.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
@yongjhih
yongjhih / OperatorReverse.java
Last active August 29, 2015 14:18
OperatorToReversedList.java
/**
* Copyright 2015 8tory, Inc.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
@yongjhih
yongjhih / OperatorShuffle.java
Last active August 29, 2015 14:18
OperatorToShuffledList.java
/**
* Copyright 2015 8tory, Inc.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
@yongjhih
yongjhih / SimpleSubscriber.java
Created April 3, 2015 11:23
SimpleSubscriber.java
/**
* Copyright 2015 8tory, Inc.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
@yongjhih
yongjhih / OperatorFlatList.java
Created April 3, 2015 11:43
OperatorFlatList.java
/**
* Copyright 2015 8tory, Inc.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software