diff --git a/chapters/append/cheatsheets.qmd b/chapters/append/cheatsheets.qmd index a060d1ac..587f66ee 100644 --- a/chapters/append/cheatsheets.qmd +++ b/chapters/append/cheatsheets.qmd @@ -4,49 +4,49 @@ ### Checking library + repository status -+-------------------------+---------------+----------------------+ -| **Step** | R Command | Python Command | -+-------------------------+---------------+----------------------+ -| Check whether library | `re | None | -| is in sync with | nv::status()` | | -| lockfile. | | | -+-------------------------+---------------+----------------------+ ++-------------------------+------------------+----------------------+ +| **Step** | R Command. | Python Command | ++-------------------------+------------------+----------------------+ +| Check whether library | `renv::status()` | None | +| is in sync with | | | +| lockfile. | | | ++-------------------------+------------------+----------------------+ ### Creating and using a standalone project library Make sure you're in a standalone project library. -+------------------+--------------------+----------------------+ -| **Step** | R Command | Python Command | -+------------------+--------------------+----------------------+ -| Create a | `renv::init()` | `p | -| standalone | | ython -m venv ` | -| library. | Tip: get `{renv}` | | -| | w/ | Convention: use | -| | `install | `.venv` for `` | -| | .packages("renv")` | | -| | | Tip: `{venv}` | -| | | included w/ Python | -| | | 3.5+ | -+------------------+--------------------+----------------------+ -| Activate project | ` | `source | -| library. | renv ::activate()` | /bin/activate` | -| | | | -| | Happens | | -| | automatically if | | -| | in RStudio | | -| | project. | | -+------------------+--------------------+----------------------+ -| Install packages | `install. | `python - | -| as normal. | packages("")` | m pip install ` | -+------------------+--------------------+----------------------+ -| Snapshot package | `renv::snapshot()` | `pip freeze | -| state. | | > requirements.txt` | -+------------------+--------------------+----------------------+ -| Exit project | Leave R project or | `deactivate` | -| environment. | `r | | -| | env::deactivate()` | | -+------------------+--------------------+----------------------+ ++------------------+----------------------------+----------------------+ +| **Step** | R Command | Python Command | ++------------------+----------------------------+----------------------+ +| Create a | `renv::init()` | `python | +| standalone | | -m venv ` | +| library. | Tip: get `{renv}` | | +| | w/ | Convention: use | +| | `install.packages("renv")` | `.venv` for `` | +| | | | +| | | Tip: `{venv}` | +| | | included w/ Python | +| | | 3.5+ | ++------------------+----------------------------+----------------------+ +| Activate project | ` | `source | +| library. | renv::activate()` | /bin/activate` | +| | | | +| | Happens | | +| | automatically if | | +| | in RStudio | | +| | project. | | ++------------------+----------------------------+----------------------+ +| Install packages | ` | `python -m | +| as normal. | install.packages("")` | pip install ` | ++------------------+----------------------------+----------------------+ +| Snapshot package | `renv::snapshot()` | `pip freeze | +| state. | | > requirements.txt` | ++------------------+----------------------------+----------------------+ +| Exit project | Leave R project or | `deactivate` | +| environment. | `renv::deactivate()` | | +| | | | ++------------------+----------------------------+----------------------+ ### Collaborating on someone else's project @@ -60,8 +60,8 @@ Start by downloading the project into a directory on your machine. | directory. | Or open project in | | | | RStudio. | | +-------------+--------------------------+----------------------+ -| Create | `renv::init()` | `p | -| project | | ython -m venv ` | +| Create | `renv::init()` | `python | +| project | | -m venv ` | | e | | | | nvironment. | | Recommend: use | | | | `.venv` for `` | @@ -126,73 +126,73 @@ Here's are some of those used most frequently. | ` | Commit staging area. | | commit -m ` | | +----------------------+----------------------------------------+ -| `p | Push to a remote. | -| ush origin ` | | +| `push | Push to a remote. | +| origin ` | | +----------------------+----------------------------------------+ -| `p | Pull from a remote. | -| ull origin ` | | +| `pull | Pull from a remote. | +| origin ` | | +----------------------+----------------------------------------+ -| `che | Checkout a branch. | -| ckout ` | | +| `checkout | Checkout a branch. | +| ` | | +----------------------+----------------------------------------+ -| `check o | Create and checkout a branch. | -| ut -b ` | | +| `checkout | Create and checkout a branch. | +| -b ` | | +----------------------+----------------------------------------+ -| `bran | Delete a branch. | -| ch -d ` | | +| `branch | Delete a branch. | +| -d ` | | +----------------------+----------------------------------------+ ## Docker {#cheat-docker} ### Docker CLI commands -+------------+------------+------------+---------------------+ -| **Stage** | **Command | **What it | **Notes and helpful | -| | (prefix w/ | does** | options** | -| | ` | | | -| | docker`)** | | | -+------------+------------+------------+---------------------+ -| Build | `build ` | -| | irectory>` | directory | provides a name to | -| | | into an | the container. | -| | | image. | | -| | | | `tag` is optional, | -| | | | defaults to | -| | | | `latest`. | -+------------+------------+------------+---------------------+ -| Move | `pus | Push a | | -| | h ` | container | | -| | | to a | | -| | | registry. | | -+------------+------------+------------+---------------------+ -| Move | `pul | Pull a | Rarely needed | -| | l ` | container | because `run` pulls | -| | | from a | the container if | -| | | registry. | needed. | -+------------+------------+------------+---------------------+ -| Run | `ru | Run a | See flags in next | -| | n ` | container. | table. | -+------------+------------+------------+---------------------+ -| Run | `stop ` | running | be used if `stop` | -| | | container. | fails. | -+------------+------------+------------+---------------------+ -| Run | `ps` | List | Useful to get | -| | | running | container `id` to | -| | | c | do things to it. | -| | | ontainers. | | -+------------+------------+------------+---------------------+ -| Run | `exec | command | used to open a | -| | ` | inside a | shell with | -| | | running | ` | -| | | container. | docker exec -it /bin/bash` | -+------------+------------+------------+---------------------+ -| Run | `logs ` | for a | | -| | | container. | | -+------------+------------+------------+---------------------+ ++------------+--------------+------------+---------------------+ +| **Stage** | **Command | **What it | **Notes and helpful | +| | (prefix w/ | does** | options** | +| | ` | | | +| | docker`)** | | | ++------------+--------------+------------+---------------------+ +| Build | `build | Builds a | `-t ` | +| | ` | directory | provides a name to | +| | | into an | the container. | +| | | image. | | +| | | | `tag` is optional, | +| | | | defaults to | +| | | | `latest`. | ++------------+--------------+------------+---------------------+ +| Move | `push | Push a | | +| | ` | container | | +| | | to a | | +| | | registry. | | ++------------+--------------+------------+---------------------+ +| Move | `pull | Pull a | Rarely needed | +| | ` | container | because `run` pulls | +| | | from a | the container if | +| | | registry. | needed. | ++------------+--------------+------------+---------------------+ +| Run | `run | Run a | See flags in next | +| | ` | container. | table. | ++------------+--------------+------------+---------------------+ +| Run | `stop | Stop a | `docker kill` can | +| | ` | running | be used if `stop` | +| | | container. | fails. | ++------------+--------------+------------+---------------------+ +| Run | `ps` | List | Useful to get | +| | | running | container `id` to | +| | | c | do things to it. | +| | | ontainers. | | ++------------+--------------+------------+---------------------+ +| Run | `exec | Run a | Basically always | +| | | command | used to open a | +| | ` | inside a | shell with | +| | | running | `docker exec -it | +| | | container. | | +| | | | /bin/bash` | ++------------+--------------+------------+---------------------+ +| Run | `logs | Views logs | | +| | ` | for a | | +| | | container. | | ++------------+--------------+------------+---------------------+ ### Flags for `docker run` @@ -213,8 +213,8 @@ Here's are some of those used most frequently. | | (don't block the | in production. | | | terminal). | | +------------------+------------------+----------------------+ -| `- | Publish port | Needed if you want | -| p :` | from inside | to access an app or | +| `-p | Publish port | Needed if you want | +| :` | from inside | to access an app or | | | running | API inside the | | | container to | container. | | | outside. | | @@ -233,8 +233,8 @@ These are the commands that go in a Dockerfile when you're building it. +-----------------+--------------------+------------------------+ | Command | Purpose | Example | +-----------------+--------------------+------------------------+ -| `FROM` | Indicate base | `F R | -| | container. | OM rocker/r-ver:4.1.0` | +| `FROM` | Indicate base | `FROM | +| | container. | rocker/r-ver:4.1.0` | +-----------------+--------------------+------------------------+ | `RUN` | Run a command when | `RUN apt-get update` | | | building. | | @@ -378,15 +378,15 @@ These are the commands that go in a Dockerfile when you're building it. | | | permanent!** | +---------------+----------------+-------------------------------+ | `cp | Copy. | | -| ` | | | +| ` | | | +---------------+----------------+-------------------------------+ | `mv | Move. | | -| ` | | | +| ` | | | +---------------+----------------+-------------------------------+ | `*` | Wildcard. | | +---------------+----------------+-------------------------------+ -| `m | Make/remove | `-p` - create any parts of | -| kdir`/`rmdir` | directory. | path that dont exist | +| `mkdir` | Make/remove | `-p` - create any parts of | +| /`rmdir` | directory. | path that dont exist | +---------------+----------------+-------------------------------+ ### Move things to/from server @@ -478,8 +478,8 @@ ssh @ | **Command** | **What it does** | **Helpful | | | | options + notes** | +---------------+--------------------------+-------------------+ -| `s | Change to be a different | | -| u ` | user. | | +| `su | Change to be a different | | +| ` | user. | | +---------------+--------------------------+-------------------+ | `whoami` | Get username of current | | | | user. | | @@ -491,8 +491,8 @@ ssh @ +---------------+--------------------------+-------------------+ | `useradd` | Add a new user. | | +---------------+--------------------------+-------------------+ -| `usermo | Modify user `username`. | `-aG ` | -| d ` | | adds to a group | +| `usermod | Modify user `username`. | `-aG ` | +| ` | | adds to a group | | | | (e.g.,`sudo`) | +---------------+--------------------------+-------------------+ @@ -502,9 +502,9 @@ ssh @ | Command | What it does | Helpful options + | | | | notes | +====================+===================+=====================+ -| `chmod ` | permissions on a | permissions for | -| | file or | user, group, | +| `chmod | Modifies | Number indicates | +| | permissions on a | permissions for | +| ` | file or | user, group, | | | directory. | others: add `4` for | | | | read, `2` for | | | | write, `1` for | @@ -512,9 +512,9 @@ ssh @ | | | nothing, | | | | e.g.,`644`. | +--------------------+-------------------+---------------------+ -| `chown ` | of a file or | user or group, | -| | directory. | e.g.,`:my-group`. | +| `chown | Change the owner | Can be used for | +| : | of a file or | user or group, | +| ` | directory. | e.g.,`:my-group`. | +--------------------+-------------------+---------------------+ | `sudo ` | Adopt root | | | | permissions for | | @@ -527,8 +527,8 @@ ssh @ +----------------------------+-----------------------------------+ | **Command** | **What it does** | +----------------------------+-----------------------------------+ -| `apt -get upd | Fetch and install upgrades to | -| ate && apt-get upgrade -y` | system packages | +| `apt-get update | Fetch and install upgrades to | +| && apt-get upgrade -y`. | system packages | +----------------------------+-----------------------------------+ | ` | Install a system package. | | apt-get install ` | | @@ -572,34 +572,34 @@ ssh @ ### Networking -+---------------+----------------------+-----------------------+ -| **Command** | **What it does** | **Helpful Options** | -+---------------+----------------------+-----------------------+ -| `netstat` | See ports and | Usually used with | -| | services using them. | `-tlp`, for tcp | -| | | listening | -| | | applications, | -| | | including `pid`. | -+---------------+----------------------+-----------------------+ -| `ssh -L | Port forwards a | Remote `ip` is | -| ::< | remote port on | usually `localhost`. | -| port>:` | remote host to | | -| | local. | Choose local port to | -| | | match remote port. | -+---------------+----------------------+-----------------------+ ++----------------------------+----------------------+-----------------------+ +| **Command** | **What it does** | **Helpful Options** | ++----------------------------+----------------------+-----------------------+ +| `netstat` | See ports and | Usually used with | +| | services using them. | `-tlp`, for tcp | +| | | listening | +| | | applications, | +| | | including `pid`. | ++----------------------------+----------------------+-----------------------+ +| `ssh -L | Port forwards a | Remote `ip` is | +| :::` | remote port on | usually `localhost`. | +| | remote host to | | +| | local. | Choose local port to | +| | | match remote port. | ++----------------------------+----------------------+-----------------------+ ### The path -+------------------+---------------------------------------------+ -| **Command** | **What it does** | -+------------------+---------------------------------------------+ -| ` | Finds the location of the binary that runs | -| which ` | when you run `command`. | -+------------------+---------------------------------------------+ -| `ln -s :` | `where to put symlink`. | -+------------------+---------------------------------------------+ ++-------------------------+---------------------------------------------+ +| **Command** | **What it does** | ++-------------------------+---------------------------------------------+ +| ` | Finds the location of the binary that runs | +| which ` | when you run `command`. | ++-------------------------+---------------------------------------------+ +| `ln -s | Creates a symlink from file/directory at | +| | `linked location` to | +| ` | `where to put symlink`. | ++-------------------------+---------------------------------------------+ ### `systemd`