Skip to content

Instantly share code, notes, and snippets.

View htdangkhoa's full-sized avatar
💪
Every problem has more than one way to solve it.

Huỳnh Trần Đăng Khoa htdangkhoa

💪
Every problem has more than one way to solve it.
View GitHub Profile
@htdangkhoa
htdangkhoa / jwtRS256.sh
Created January 3, 2020 03:53 — forked from ygotthilf/jwtRS256.sh
How to generate JWT RS256 key
ssh-keygen -t rsa -b 4096 -m PEM -f jwtRS256.key
# Don't add passphrase
openssl rsa -in jwtRS256.key -pubout -outform PEM -out jwtRS256.key.pub
cat jwtRS256.key
cat jwtRS256.key.pub
@htdangkhoa
htdangkhoa / CounterActivity.kt
Created December 1, 2019 15:56
CounterActivity
class CounterActivity: AppCompatActivity(), Enhancer<CounterState> {
private val store: Store<CounterState> by lazy {
Store(
CounterReducer(),
CounterState()
// applyMiddleware(...)
)
}
/**
@htdangkhoa
htdangkhoa / Reducer.kt
Created December 1, 2019 15:56
Reducer
class CounterReducer: Reducer<CounterState> {
override fun reduce(state: CounterState, action: Action): CounterState {
return when (action) {
CounterAction.INCREASE -> state.copy(number = state.number + 1)
CounterAction.DECREASE -> state.copy(number = state.number - 1)
else -> state
}
}
@htdangkhoa
htdangkhoa / Action.kt
Created December 1, 2019 15:54
Action
sealed class CounterAction: Action {
object INCREASE: CounterAction()
object DECREASE: CounterAction()
companion object {
fun increaseAction(dispatch: Dispatch) = dispatch(INCREASE)
fun decreaseAction(dispatch: Dispatch) = dispatch(DECREASE)
}
@htdangkhoa
htdangkhoa / State.kt
Created December 1, 2019 15:53
State
data class CounterState(val number: Int = 0): State
@htdangkhoa
htdangkhoa / Client.java
Last active December 28, 2017 04:17
[OkHttpClient] Mini client using OkHttp #Android #Java
public class ClientHttp {
static String BASE_HOST = "https://8days.localtunnel.me";
private OkHttpClient.Builder clientBuilder = new OkHttpClient.Builder();
private Request.Builder requestBuilder = new Request.Builder();
private HttpLoggingInterceptor loggingInterceptor = new HttpLoggingInterceptor();
private HttpUrl.Builder urlBuilder;
private Request request;
private OkHttpClient client;