Skip to content

Instantly share code, notes, and snippets.

@nicktogo
nicktogo / BaseListFragment.java
Created March 10, 2017 12:45
This is a base list (RecyclerView) fragment with data binding.
package us.ktv.android.fragment;
import android.app.Activity;
import android.databinding.DataBindingUtil;
import android.databinding.ViewDataBinding;
import android.os.Bundle;
import android.support.v4.app.Fragment;
import android.support.v4.view.ViewCompat;
import android.support.v7.widget.LinearLayoutManager;
import android.support.v7.widget.RecyclerView;
@nicktogo
nicktogo / Reverse Polish.cpp
Created March 10, 2017 12:41
The following code snippet is used toconvert an infix notation to a Reverse Polish notation and calculate it.
void RPOUtil::Parse(TCHAR* exp) { // exp is the right hand side of an math equation, such as "2x + sin(x)"
int length = ::wcslen(exp);
char* cexp = new char[length + 1];
for (size_t i = 0; i < length; i++) {
cexp[i] = exp[i];
}
cexp[length] = '\0';
string str(cexp);
Replace(str); // replace "sin", "cos", "tan", "log" with "s", "c", "t", "l" respectively
length = str.length();