Skip to content

Instantly share code, notes, and snippets.

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

Juang Wiantoro broerjuang

🏠
Working from home
View GitHub Profile
@broerjuang
broerjuang / machine.js
Last active August 25, 2019 19:16
Generated by XState Viz: https://xstate.js.org/viz
let auth = {
initial: 'login_screen',
states: {
login_screen: {
on: {
NAVIGATE_REGISTER_SCREEN: 'register_screen'
}
},
@broerjuang
broerjuang / machine.js
Created September 15, 2019 06:29
Generated by XState Viz: https://xstate.js.org/viz
let splash = {
initial: 'idle',
states: {
idle: {
on: {
LOAD_DATA: 'spinner',
},
},
spinner: {
type: 'final',
@broerjuang
broerjuang / feedback_form.re
Created September 15, 2019 19:15
An experiment using state machine using ReasonML
open ReactUpdate;
type context = {
rate: int,
comment: string,
};
type action =
| Open
| Close
@broerjuang
broerjuang / useWindowResize.re
Created September 23, 2019 06:51
Custom Hooks
type windowSize = {
height: int,
width: int,
};
let useWindowResize = () => {
let getWindowSize = (): option(windowSize) =>
switch ([%external window]) {
| None => None
| Some(w) =>
-- We want to prove this:
fmap (compose g f) == compose (fmap g) (fmap f)
-- Fact:
fmap :: (b -> c) -> (a -> b) -> (a -> c)
compose :: (b -> c) -> (a -> b) -> (a -> c)
-- Prove
fmap id f
(\ h g x -> h (g x)) id f
-- We want to prove this:
fmap (compose g f) == compose (fmap g) (fmap f)
-- Fact:
fmap :: (b -> c) -> (a -> b) -> (a -> c)
compose :: (b -> c) -> (a -> b) -> (a -> c)
-- Prove
fmap id f
(\ h g x -> h (g x)) id f
@broerjuang
broerjuang / .vimrc
Last active January 5, 2020 15:18
Vim config
" Plugins will be downloaded under the specified directory.
call plug#begin('~/.vim/plugged')
Plug 'preservim/nerdtree'
Plug 'vim-airline/vim-airline'
"Plug 'vim-airline/vim-airline-themes'
Plug 'liuchengxu/space-vim-theme'
"Plugin to insert and delete pair of chars
Plug 'jiangmiao/auto-pairs'
@broerjuang
broerjuang / .tmux.conf
Created January 5, 2020 15:19
Tmux config
# vim style tmux config
# use C-a, since it's on the home row and easier to hit than C-b
set-option -g prefix C-a
unbind-key C-a
bind-key C-a send-prefix
set -g base-index 1
# Easy config reload
bind-key R source-file ~/.tmux.conf \; display-message "tmux.conf reloaded."
Code
module AsyncResult = Relude.AsyncResult;
module Effect = ReludeReact.Effect;
module IO = Relude.IO;
module Option = Relude.Option;
module Reducer = ReludeReact.Reducer;
let (toBusy, completeOk, completeError) =
AsyncResult.(toBusy, completeOk, completeError);
type state('a, 'e) = AsyncResult.t('a, 'e);