Jim Cheung

Monday, July 04, 2022

The new wave of React state management

I don't quite understand why react's state management needs to be so complicated, maybe I'm not doing many crud apps?

I did read the book it mentioned: Micro State Management with React Hooks

and I found valtio is the most simple one: mutable and provides snapshot and tracking, makes it very easy to understand

I also learned using WeakMap to optimize memory usage

and use Proxy to detect mutation to object properties

I was writing a rules engine before reading this, I used _.cloneDeep to guard mutation but I know memory usage could be an issue.

Tuesday, July 05, 2022

gonna read some new books:

Core Kubernetes, my main focus will be on this book.

In-Memory Analytics with Apache Arrow

I'm not using Apache Arrow, but Chapter 4: Format and Memory Handling is interesting

Network Programming with Go Language

just see is there anything new inside

Programmer Passport: OTP

I'm always interested in otp, try read it this time

Friday, July 15, 2022

I think since vim8, it displays Vim: Reading from stdin... when using vim -, to hide it add --not-a-term argument

vim added a shortcut to execute current line by a command (using echo as example):

nnoremap <leader>e :r !echo <C-r>=getline('.')<CR><CR>

or dangerously, pass current line to bash: :.w !bash, sudo version: :.w !sudo bash

an alias to pass current tmux pane visible content to vim:

tmux capture-pane -p | sed '/^$/d' | vim --not-a-term -c "setlocal buftype=nofile bufhidden=hide noswapfile" -

the sed removed empty lines

this one is useful for testing api call timeout or simulate slow connection:

json-server db.json --port 3001 --delay 3000

to support git push in tig, add this line to ~/.tigrc:

bind status P !git push origin

Saturday, July 16, 2022

to grep project files anywhere in a git repo, add :/, it's same as git rev-parse --show-toplevel:

git grep pattern -- :/

the nice thing of it is it's using relative path, which is shorter and you can still open files at pointer

previously I have to use realpath --relative-to . filename to convert absolute path to relative

Monday, July 25, 2022

I love Semantic UI, sad that it is not under development anymore, luckily there's a community fork: Fomantic-UI

some interesting ideas here: Non-Obvious Docker Uses

also this talk: Lightning Talk: OCI Images for More Than Containers

like using docker as make, also some existing tools that have the similar approach:

Blog Archive