Skip to content

Instantly share code, notes, and snippets.

View kafkahw's full-sized avatar

Wei Hou kafkahw

View GitHub Profile
@kafkahw
kafkahw / Network_layers.md
Last active October 23, 2019 15:39
network layers

Network 5 layers:

At the very bottom of the network stack is the physical layer. This is where electrical signals or light pulses or radio waves actually transmit information from place to place. The physical layer doesn't really have protocols, but instead has standards for voltages, frequencies, and other physical properties. You can transmit information directly this way, but you need a lot of power or a dedicated line, and without higher layers you won't be able to share bandwidth.

The next layer up is the link layer. This layer covers communication with devices that share a physical communications medium. Here, protocols like Ethernet, 802.11a/b/g/n, and Token Ring specify how to handle multiple concurrent accesses to the physical medium and how to direct traffic to one device instead of another. In a typical home network, this is how your computer talks to your home "router."

The third layer is the network layer. In the majority of cases, this is dominated by Internet Protocol (IP). This is whe

docker ps -a docker stop $(docker ps -aq) docker rm docker rmi docker container ls docker container kill

@kafkahw
kafkahw / loader_process.md
Created October 23, 2019 15:26
SYSTEM loader process

BIOS (on the motherboard) -> Boot loader(e.g. GRUB -Grand Unified Boot Loader) -> Loads linux kernel -> start init/systemd -> start daemons, background processes and services required for OS

@kafkahw
kafkahw / shell-commands.md
Last active September 16, 2019 15:12
Common shell commands

show history of recent commands

history

run command from history line number

!15

run command with the same arguments as the last time it was called.

!cd # this would cd into the last directory path I used.

@kafkahw
kafkahw / frontend-tricks.md
Last active July 17, 2019 19:14
Frontend Tricks

Calculate heights

  • clientHeight - visible content
  • offsetHeight - visible content + scrollbar
  • scrollHeight - all content (including overflown part)

Find offset to nearest positioned parent

  • element.offsetTop

Find parent

  • element.parentElement or element.parentNode
@kafkahw
kafkahw / jest-func-module-mock.md
Last active June 28, 2019 03:21
how to mock exported functions in module in Jest
@kafkahw
kafkahw / compare-routers.md
Created December 28, 2018 20:17
Compare routers
@kafkahw
kafkahw / diff-btw-CORS-CSP.md
Created October 24, 2018 15:04
CORS and CSP

CORS

Cross-origin Resource Sharing (CORS) is a mechanism that uses additional HTTP headers to tell a browser to let a web app running at one origin have permission to access selected reosurces from a server at a different origin.

HTTP Headers

  • Access-Control-Allow-Origin: http://foo.example
  • Access-Control-Allow-Methods: POST, GET, OPTIONS
  • Access-Control-Allow-Headers: X-PINGOTHER, Content-Type
  • Access-Control-Max-Age: 86400

CSP

@kafkahw
kafkahw / Salesforce-lightning-3rd-party-UI.md
Last active October 23, 2018 16:22
Salesforce Lightning integration with 3rd party UI

3rd party UI in Lightning

Two ways to build UI in SF Lightning

  1. Lightning App Builder (Drag & Drop; no code required)
  2. Lightning Component Framework (programmatically)

We need to use the latter for 3rd party UI integration.

Lightning Component Framework

@kafkahw
kafkahw / Setup.md
Last active October 23, 2019 15:14
Bootstrap a new device