Blogs

  • Commands
    • rosnode list
    • rosparam list
    • rostopic list/echo
    • rosservice list
  • Node
  • Param
  • Topic
  • Service
  • References: [1], [2]
  • ECS stands for Entity(实体), Component(组件), and System(系统)
  • E, C, S是并列关系,而不是E, C修饰S的关系
  • Entity
    • 本质上是一个id,可以被创建、销毁,可以添加、删除组件
    • 生命周期由EntityManager管理,创建、销毁、增删组件都通过EntityManager进行
  • Component
    • 仅仅包含代表其特性的数据,不包含任何方法
    • 同种类型的Component在内存中紧密排列,在System遍历时减少cache miss
    • 被不同Entity挂载的Component,在内存中对应不同位置;被Entity挂载的同一个SharedComponent,在内存中对应同一位置,适用于很多实体共享同一种资源的情况
  • System
    • 处理拥有一个或多个相同组件的实体集合,只拥有行为,不存储任何数据
    • 通过依赖注入的方式访问Component
  • Compared with OOP:
    • "Is-A" relation ==> OOP 继承
    • "Has-A" relation ==> ECS 组合
    • "组合优于继承"
  • References: [1], [2]
There are five modes in Vim:
  • normal mode, all other modes go back to normal mode by Esc
    • cursor movement
      • jump to the first line / last line / 5th line of the doc by gg / G / 5G
      • move back / forward one full screen by Ctrl-b / Ctrl-f
      • move back / forward 1/2 screen by Ctrl-u / Ctrl-d
      • move cursor to top / middle / bottom of screen by H / M / L
      • jump to the previous / next paragraph by { / }
      • jump to the start / end of the line by 0 / $
      • jump back / forward to the start of a word by b / w , capitalize if allowing for punctuations
      • move cursor left / down / up / right by h / j / k / l
    • editing
      • copy a line / cut a line / cut a character by yy / dd / x
      • paste before / after cursor by P / p
      • undo / redo by u / Ctrl-r
      • repeat last command by .
  • insert mode
    • insert before / after the cursor by i / a , capitalize if at the start / end of the line
    • append a new line above / below the current line by O / o
  • replace mode, by r
  • visual mode, by v
    • visual line mode, by Shift-v
    • visual block mode, by Ctrl-v
  • command-line mode, by :
    • write by :w
    • write and quit by :wq or :x
    • quit without writing by :q!
    • search & replace by :%s/<old>/<new>/g - , or :%s/<old>/<new>/gc - with confirmation
To start a new session:
  • tmux
  • tmux new -s <sessname>
To kill a session:
  • tmux kill-ses -t <sessname>
To connect to a session:
  • tmux attach -t <sessname>
To rename a session:
  • tmux rename-session -t <oldname> <newname>
To list all sessions:
  • tmux ls
In a session:
  • To split the pane left & right Ctrl-b %
  • To split the pane up & down Ctrl-b "
  • To nevigate between panes Ctrl-b <arrowkey>
  • To close a pane exit or Ctrl-d
  • To detach from the session Ctrl-b d
  • To list all available commands Ctrl-b ? and Esc to come back
General setups:
  • git --version
  • git config --global user.name "xxx"
  • git config --global user.email "xxx@xxx.xxx"
  • git config --global core.editor "vim"
  • git credential-osxkeychain erase
    host=github.com
    protocol=https
    or git config --global credential.helper osxkeychain to erase credentials
Common commands:
  • To initiate a git repo:
    • git clone <url> or git clone -b <branchname> <url>
    • git init
  • Local commands:
    • revert unstaged changes to last committed state git checkout xxx.xx
    • revert changes in a file to a commit git checkout <commitid> - xxx.xx
    • revert commits git revert master~3..master or git revert B..D
    • add / delete / rename a file to staged git add / rm / mv xxx.xx
    • unstage changes git reset HEAD xxx.xx, counterpart of git add xxx.xx
    • add staged files to commited git commit, use -a to skip staging
    • use staged state to update latest commit git commit --amend, ONLY locally, before push!!!
    • a commit to cancel out previous commits git revert HEAD / <commitID>, not "undo"
    • squash commits git rebase -i master / HEAD~4 or git rebase -i <prevcommitid>, interactive rebase, pick the earliest commit and squash all else
    • delete the most recent commit, without destroying the work you've done git reset --soft HEAD~1, or delete the most recent commit and remove changes git reset --hard HEAD~1
  • Remote commands:
    • pull from remote git pull, equivalent to git fetch + git merge origin/master
    • list all branches git branch
    • create and switch to a branch git checkout -b <branchname>, equivalent to git branch <branchname> + git checkout <branchname>, or git checkout -b <branchname> origin/<branchname>
    • rename a branch git branch -m <newname> for current branch, or git branch -m <oldname> <newname> otherwise
    • add changes to the most recent commit git commit --amend --no-edit and git push -f
  • Steps to update remote:
    • 1st method:
      git push
      (fail, not synchronized) --->
      git pull
      (conflicts) --->
      git log --graph --oneline --all
      (history for all branches) ---> (edit files with conflicts, search for
      >>>>
      and
      <<<<
      ) --->
      git add xxx.xx
      --->
      git commit
      --->
      git push
    • 2nd method:
      git fetch
      --->
      git rebase origin/master
      ---> (edit files with conflicts, search for
      >>>>
      and
      <<<<
      ) --->
      git add xxx.xx
      --->
      git rebase --continue
      --->
      git push
  • Steps to bring a local folder into a remote git repo:
    git init
    --->
    git add .
    --->
    git commit -m "first commit"
    --->
    git remote add origin <remoterepoURL>
    --->
    git remote -v
    (just to verify) --->
    git push origin main
    (if origin/main exists, or
    git branch -m <branchname>
    to rename local branch and
    git push origin -u <branchname>
    to add and push to a new branch)
  • Steps to merge branch to
    master
    branch:
    git checkout master
    (go to
    master
    branch) --->
    git pull
    --->
    git checkout <branchname>
    (go to branch) --->
    git rebase master
    (rebase to
    master
    branch) --->
    git checkout master
    (go to
    master
    branch) --->
    git merge <branchname>
    (merge to master branch, conflicts) ---> (edit files with conflicts, search for
    >>>>
    and
    <<<<
    ) --->
    git merge --continue
    --->
    git push --delete origin <branchname>
    (delete remote branch) --->
    git branch -d <branchname>
    (delete local branch) --->
    git push
  • Steps to rebase a branch
    <branchname>
    on commit
    <baseid>
    in
    master
    branch:
    git checkout master
    (go to
    master
    branch) --->
    git pull
    --->
    git checkout <baseid>
    (detach to commit
    base
    ) --->
    git checkout -b <basebranch>
    (create base branch) --->
    git checkout <branchname>
    --->
    git merge <basebranch>
    --->
    git add .
    and
    git commit
    if any conflicts --->
    git push
  • Steps to rebase a commit
    <updateid>
    on commit
    <baseid>
    in
    master
    branch:
    git checkout master
    (go to
    master
    branch) --->
    git checkout <baseid>
    (detach to commit
    base
    ) --->
    git checkout -b <branchname>
    (create new branch) --->
    git cherry-pick <updateid>
  • Others:
    • git status
    • git branch -a to list all branches
    • show history git log --graph --oneline
    • HEAD stands for current checkout snapshot
    • origin stands for remote
All commands might need to add sudo in front.
General commands:
  • list the Docker version installed docker version
  • docker info
  • docker or docker help
Images-related commands (An image is a combination of a file system and parameters):
  • docker pull <REPOSITORY>:<TAG>, where :<TAG> could be ommited if latest
  • <REPOSITORY>:<TAG> is then equivalent to <ImageID>
  • list all images (or only Image ID's) docker images (-p)
  • list the details of an image docker inspect <REPOSITORY>:<TAG>
  • docker run <REPOSITORY>:<TAG>, or in interactive mode docker run -it <REPOSITORY>:<TAG> /bin/bash, or map the ports by docker run -p <port>:<port> <REPOSITORY>:<TAG>; this will pull the docker first if not yet
  • list all commands that were run with the image via a container docker history <ImageID>
  • remove an image docker rmi <ImageID>
Containers-related commands (Containers are instances of Docker images that can be run using the Docker run command):
  • <ContainerName> is equivalent to <ContainerID>
  • list all running (or all) containers docker ps (-a)
  • list top-level processes within the container docker top <ContainerID>
  • show the statistics (CPU and memory utilization) of a running container docker stats <ContainerID>
  • list the details of a container docker inspect <ContainerID>
  • docker attach <ContainerID> and docker exec -it <ContainerName> /bin/bash
  • docker start <ContainerID> and docker stop <ContainerID>
  • docker pause <ContainerID> and docker unpause <ContainerID>
  • docker kill <ContainerID> and docker rm <ContainerID>
Architectures of Virtual Machines vs. Dockers:
  • vs.
References:
There are two types of GitHub pages:
  • One type is "account page", and by definition, one GitHub account is allowed to have only one "account page". This page is auto-deployed by GitHub, and cannot be set private.

    The repo name of the "account page" has to be <username>.github.io, the files have to be under the master branch, and the link to this page will be https://<username>.github.io/.

  • The other type is "repo page", and each repo can have one "repo page", so each GitHub account is allowed to have as many "repo pages" as you like. These pages are not auto-deployed, and they can be set to private if you like.

    The repo name of a "repo page" could be anything, but the files have to be under the gh-pages branch (actually not really..) in order to be deployed, and the link to this page will be https://<username>.github.io/<reponame>/.