Skip to content

Instantly share code, notes, and snippets.

View nickccm1122's full-sized avatar
🇭🇰
Searching...

Nick Chan nickccm1122

🇭🇰
Searching...
View GitHub Profile
{
"basics": {
"label": "Software Engineer",
"phone": "+852 60406776",
"email": "nickccm@pm.me",
"website": "https://registry.jsonresume.org/nickccm1122",
"other": [],
"name": "Nick Chan",
"location": {
"city": "Hong Kong SAR",
@nickccm1122
nickccm1122 / job_buffering.go
Created March 11, 2020 15:57
Example code to buffer concurrent long running task
package main
import (
"fmt"
"math/rand"
"strconv"
"sync"
"sync/atomic"
"time"
)
@nickccm1122
nickccm1122 / docker-alias.zsh
Last active August 10, 2019 09:38
my docker command functions or aliases
#!/usr/bin/sh
################################
# functions
################################
# docker contianer logs
dklog(){
docker ps -a \
--format "table{{.ID}}\t{{.Names}}\t{{.Ports}}" \
@nickccm1122
nickccm1122 / fzf.sh
Last active July 21, 2019 09:55
fzf config
#!/usr/bin/sh
# Setup fzf
# ---------
if [[ ! "$PATH" == */usr/local/opt/fzf/bin* ]]; then
export PATH="$PATH:/usr/local/opt/fzf/bin"
fi
# Custom settings
# ------------
@nickccm1122
nickccm1122 / replace_macos_legacy_cli.sh
Last active March 7, 2024 07:00
script to replace macos legacy cli
#!/usr/bin/sh
###################################################
# Check if the brew path of the item exists
# then run brew install if not exits
# set the PATH and MANPATH for each item
###################################################
# check if brew is installed
if ! [ -x "$(command -v brew)" ]; then
@nickccm1122
nickccm1122 / .gitconfig
Created March 17, 2019 17:10 — forked from pksunkara/config
Sample of git config file (Example .gitconfig)
[user]
name = Pavan Kumar Sunkara
email = pavan.sss1991@gmail.com
username = pksunkara
[core]
editor = vim
whitespace = fix,-indent-with-non-tab,trailing-space,cr-at-eol
excludesfile = ~/.gitignore
[sendemail]
smtpencryption = tls
@nickccm1122
nickccm1122 / nodemon.json
Created March 5, 2019 15:27
nodemon.json
{
"restartable": "rs",
"verbose": true,
"env": {
"NODE_ENV": "development"
},
"ext": "js,json,yaml,yml",
"ignore": [
"**/__fixtures__/**",
"**/__mocks__/**",
@nickccm1122
nickccm1122 / createCarRecord.js
Last active February 21, 2019 03:30
Create Nested Immutable Record with full type support
// @flow strict
/**
* Purpose: convert object
* {
* name: 'Andrew',
* email: 'andrew@gmail.com',
* car: {
* type: 'Ford',
* cost: 10,

Understanding Immutable.Record

Functional programming principles and with it immutable data are changing the way we write frontend applications. If the recent de-facto frontend stack of React and Redux feels like it goes perfectly together with immutable data, that's because it's specifically designed for that.

There's several interesting implementations of immutable data for JavaScript, but here I'll be focusing on Facebook's own Immutable.js, and specifically on one of its lesser known features, Records.

Why Records?

Immutable.js provides a beautiful, Clojure-inspired API for dealing with abstract Collections and Sequences, and several concrete data structur

@nickccm1122
nickccm1122 / my-alias.sh
Last active July 21, 2019 11:05
My zsh aliases setting
#!/usr/bin/sh
# check if the alias exists
# TODO: need to excape string input in the 2nd arg
setalias() {
if alias $1 2>/dev/null; then
cmd="$1='$2'"
eval "alias $cmd"
else
echo "$1 has been set alias..."