Skip to content

Instantly share code, notes, and snippets.

@haishanh
haishanh / machine.js
Last active May 2, 2020 10:50
Generated by XState Viz: https://xstate.js.org/viz
// Available variables:
// - Machine
// - interpret
// - assign
// - send
// - sendParent
// - spawn
// - raise
// - actions
Machine({
id: 'SWAPI',
initial: 'idle',
context: {
user: null
},
states: {
idle: {
on: {
FETCH: 'loading'
const fetchUser = userId =>
fetch(`url/to/user/${userId}`).then(response => response.json());
const userMachine = Machine({
id: 'user',
initial: 'idle',
context: {
userId: 42,
user: undefined,
error: undefined
@haishanh
haishanh / script-template.sh
Created December 29, 2020 04:48 — forked from m-radzikowski/script-template.sh
Minimal safe Bash script template - see the article with full description: https://betterdev.blog/minimal-safe-bash-script-template/
#!/usr/bin/env bash
set -Eeuo pipefail
trap cleanup SIGINT SIGTERM ERR EXIT
script_dir=$(cd "$(dirname "${BASH_SOURCE[0]}")" &>/dev/null && pwd -P)
usage() {
cat <<EOF
Usage: $(basename "${BASH_SOURCE[0]}") [-h] [-v] [-f] -p param_value arg1 [arg2...]
@haishanh
haishanh / machine.js
Created January 17, 2021 04:30
Generated by XState Viz: https://xstate.js.org/viz
// Available variables:
// - Machine
// - interpret
// - assign
// - send
// - sendParent
// - spawn
// - raise
// - actions
@haishanh
haishanh / keybase.md
Last active April 27, 2022 09:14
keybase.md

Keybase proof

I hereby claim:

  • I am haishanh on github.
  • I am haishanh (https://keybase.io/haishanh) on keybase.
  • I have a public key ASCVAbSwFIkUm68AJW4o64FypapsMcNM3k1jIAoG7viuRwo

To claim this, I am signing this object: