Skip to content

Instantly share code, notes, and snippets.

@junhuif
junhuif / machine.js
Last active April 17, 2020 02:11
Generated by XState Viz: https://xstate.js.org/viz
const SERVICE_ORDER_FETCHER = "orderFetcher";
const STATE_COMPLETED = "completed";
const STATE_FAILED = "failed";
const FETCH_INTERVAL = 500;
const MAX_FETCH_COUNT = 3;
const ERROR_ORDER_CODE_IS_UNDEFINED = new Error("orderCode is undefined");
const ERROR_FETCH_TIMES_OVER_LIMITS = new Error(
@junhuif
junhuif / machine.js
Last active April 15, 2020 10:50
Generated by XState Viz: https://xstate.js.org/viz
const SERVICE_ORDER_FETCHER = "orderFetcher";
const STATE_COMPLETED = "completed";
const STATE_FAILED = "failed";
const FETCH_INTERVAL = 1000;
const MAX_FETCH_COUNT = 60;
const ERROR_ORDER_CODE_IS_UNDEFINED = new Error("orderCode is undefined");
const ERROR_FETCH_TIMES_OVER_LIMITS = new Error(
@junhuif
junhuif / machine.js
Created April 7, 2020 07:33
Generated by XState Viz: https://xstate.js.org/viz
// Available variables:
// - Machine
// - interpret
// - assign
// - send
// - sendParent
// - spawn
// - raise
// - actions
@junhuif
junhuif / machine.js
Last active April 7, 2020 06:22
Generated by XState Viz: https://xstate.js.org/viz
const SERVICE_CONFIRM_ORDER_FETCHER = "confirmOrderFetcher";
const ACTION_ON_ORDER_CONFIRMED = "onOrderConfirmed";
const STATE_SUBMITTING = "submitting";
// https://xstate.js.org/viz/?gist=886857c070d6f5a20bc1fd638e99192c
const confirmationMachine = Machine({
id: "confirmation",
initial: "editing",
context: {},
states: {
@junhuif
junhuif / machine.js
Last active April 7, 2020 07:30
Generated by XState Viz: https://xstate.js.org/viz
// Available variables:
// - Machine
// - interpret
// - assign
// - send
// - sendParent
// - spawn
// - raise
// - actions
@junhuif
junhuif / machine.js
Last active December 20, 2019 13:34
Generated by XState Viz: https://xstate.js.org/viz
const submitMachine = Machine(
{
initial: "idle",
context: {
orderCode: "some"
},
states: {
idle: {
on: {
SUBMIT: [
App&
Content
Stores
pick store -> Categories
Categories
pick category -> Product List
back to store list -> Stores
Product List
choose product -> Product
back to categories -> Categories
@junhuif
junhuif / dabblet.css
Created June 30, 2018 05:28
Translucent borders
/**
* Translucent borders
*/
body {
background: url('http://csssecrets.io/images/stone-art.jpg');
}
div {
border: 10px solid hsla(0,0%,100%,.5);
@junhuif
junhuif / index.pug
Created September 25, 2017 10:10
react-redux with immutable instead of pureRenderMixin demo
#root
@junhuif
junhuif / gorm-insert-bug-in-boolean-field.go
Created December 2, 2015 03:30
Gorm doesn't insert false value into database for boolean field
package main
import (
"fmt"
"github.com/jinzhu/gorm"
_ "github.com/lib/pq"
)
var DB *gorm.DB