├── crontab.md ├── docker.md └── README.md /crontab.md: -------------------------------------------------------------------------------- 1 | ## Cron Jobs Cheat Sheet 2 | 3 | ### Commands 4 | 5 | ``` sh 6 | # display current user's crontab 7 | crontab -l 8 | 9 | # edit current user's crontab 10 | crontab -e 11 | 12 | # delete current user's crontab 13 | crontab -r 14 | 15 | # display 's crontab 16 | crontab -l -u 17 | 18 | # edit 's crontab 19 | crontab -e -u 20 | 21 | # delete 's crontab 22 | crontab -r -u 23 | 24 | # populate crontab from file contents 25 | crontab -l -u | cat - | crontab -u - 26 | ``` 27 | -------------------------------------------------------------------------------- /docker.md: -------------------------------------------------------------------------------- 1 | ## Docker Cheatsheet 2 | 1. [Docker Commands](#docker-commands) 3 | 2. [Dockerfile Tips](#dockerfile-tips) 4 | 3. [Docker Compose Commands](#docker-compose-commands) 5 | 4. [Docker Compose File Tips](#docker-compose-file-tips) 6 | 7 | ### Docker Commands 8 | #### List Images / Containers 9 | ```sh 10 | # list all images 11 | docker images 12 | 13 | # list all images (including intermediate) 14 | docker images -a 15 | 16 | # list running containers 17 | docker container ls 18 | docker ps 19 | 20 | # list all containers 21 | docker container ls -a 22 | docker ps -a 23 | 24 | # inspect a container 25 | docker inspect 26 | 27 | # get container IP address 28 | docker inspect -f '{{range .NetworkSettings.Networks}}{{.IPAddress}}{{end}}' 29 | 30 | # access sh/bash on running container 31 | docker exec -it /bin/sh 32 | ``` 33 | 34 | #### Build Image 35 | ```sh 36 | # build a docker image from the local files in 37 | docker build --tag=/: 38 | 39 | # tag an already built image 40 | docker tag /: 41 | ``` 42 | 43 | #### Run Image 44 | **`docker run`** *will attempt to fetch the image from public registry if it's not found in local machine.* 45 | ```sh 46 | # map the in Dockerfile to that the app will be served 47 | docker run -p : 48 | 49 | # run image in detached mode 50 | docker run -d -p : 51 | 52 | # mount the volume 'my-vol' into '/app/' in the container 53 | docker run -d \ 54 | --mount source=my-vol,target=/app \ 55 | -p : 56 | 57 | # same as above, but mounts the volume as read-only 58 | docker run -d \ 59 | --mount source=my-vol,target=/app,readonly \ 60 | -p : 61 | 62 | # run image in interactive mode, open up a shell, and remove container on exit 63 | docker run --rm -ti /bin/bash 64 | ``` 65 | 66 | #### Stop Container 67 | ```sh 68 | # gracefully stop container 69 | docker container stop 70 | 71 | # force shutdown 72 | docker container kill 73 | ``` 74 | 75 | #### Remove Images / Containers / Networks / Volumes 76 | ```sh 77 | # remove container from machine 78 | docker container rm 79 | 80 | # delete all stopped containers 81 | docker rm $(docker ps -a -q) 82 | 83 | # remove image from machine 84 | docker image rm 85 | 86 | # remove all stopped containers, all dangling images and all unused networks 87 | docker system prune 88 | 89 | # same as above, plus remove all unused volumes 90 | docker system prune --volumes 91 | ``` 92 | 93 | #### Volumes 94 | ```sh 95 | # create a volume named 'my-vol' 96 | docker volume create my-vol 97 | 98 | # list volumes 99 | docker volume ls 100 | 101 | # inspect the 'my-vol' volume 102 | docker volume inspect my-vol 103 | 104 | # remove the 'my-vol' volume 105 | docker volume rm my-vol 106 | 107 | # remove all unused volumes 108 | docker volume prune 109 | ``` 110 | 111 | #### Remote Registry 112 | ```sh 113 | # login to public registry 114 | docker login 115 | 116 | # logout from public registry 117 | docker logout 118 | 119 | # login to private registry 120 | docker login : 121 | 122 | # logout from private registry 123 | docker logout : 124 | 125 | # upload image to registry 126 | docker push /: 127 | 128 | # list all images in registry 129 | curl :/v2/_catalog 130 | 131 | # list all tags for an image in registry 132 | curl :/v2//tags/list 133 | ``` 134 | 135 | ### Dockerfile Tips 136 | #### `.dockerignore` Exceptions 137 | Lines starting with `!` can be used to make exceptions to exclusions. The following is an example `.dockerignore` file that uses this mechanism: 138 | ``` sh 139 | # all markdown files except `README.md` are excluded from the context. 140 | *.md 141 | !README.md 142 | ``` 143 | 144 | #### Notes on Instructions 145 | * **`ARG`** - An `ARG` declared before a `FROM` is outside of a build stage, so it can’t be used in any instruction after a `FROM`. 146 | 147 | * **`RUN`** - The `` in a `RUN ` instruction is run in a shell, which by default is `/bin/sh -c`. You can explicitly choose a shell using the *exec* form: 148 | ``` dockerfile 149 | RUN ["/bin/bash", "-c", ""] 150 | ``` 151 | 152 | * **`EXPOSE`** - The `EXPOSE` instruction does not actually publish the port. It functions as a type of documentation between the person who builds the image and the person who runs the container, about which ports are intended to be published. To actually publish the port when running the container, use the `-p` flag on docker run to publish and map one or more ports. 153 | 154 | #### Minimize the Number of Intermediate Steps 155 | Instead of installing packages one by one like this: 156 | ``` dockerfile 157 | FROM alpine:3.4 158 | 159 | RUN apk update 160 | RUN apk add curl 161 | RUN apk add vim 162 | RUN apk add git 163 | ``` 164 | 165 | combine these steps like this: 166 | ``` dockerfile 167 | FROM alpine:3.4 168 | 169 | RUN apk update && \ 170 | apk add curl && \ 171 | apk add vim && \ 172 | apk add git 173 | ``` 174 | 175 | #### Adding Packages 176 | It’s always advisable to put `apt-get update` and `apt-get install` commands on the same line because of [this](https://docs.docker.com/develop/develop-images/dockerfile_best-practices/#apt-get). 177 | 178 | #### Upgrading Packages 179 | Avoid `RUN apt-get upgrade` and `dist-upgrade`, as many of the "essential" packages from the parent images cannot upgrade inside an [unprivileged container](https://docs.docker.com/engine/reference/run/#security-configuration). If a package contained in the parent image is out-of-date, contact its maintainers. If you know there is a particular package, foo, that needs to be updated, use `apt-get update && apt-get install -y foo` to update automatically. 180 | 181 | 182 | #### Build Workflow 183 | 1. Pick the right base image. 184 | 2. Go into shell and build your environment step by step using: 185 | ``` sh 186 | # use /bin/sh on Alpine 187 | docker run --rm -ti /bin/bash 188 | ``` 189 | 3. Add verified steps into the Dockerfile. 190 | 4. Repeat steps 2 and 3 until complete. 191 | 192 | ### Docker Compose Commands 193 | #### Docker Compose 194 | ```sh 195 | # build images 196 | docker-compose build 197 | 198 | # build missing images & run containers 199 | docker-compose up 200 | 201 | # re-build images if Dockerfile or image files have changed 202 | docker-compose up --build 203 | 204 | # start in detached mode 205 | docker-compose up -d 206 | 207 | # stop containers 208 | docker-compose down 209 | 210 | # list containers 211 | docker-compose ps 212 | 213 | # access all container logs 214 | docker-compose logs 215 | 216 | # push images to registry 217 | docker-compose push 218 | 219 | # pull images into a new machine 220 | docker-compose pull 221 | ``` 222 | 223 | ### Docker Compose File Tips 224 | #### `build` 225 | `build` can be specified either as a string containing a path to the build context: 226 | ``` yml 227 | version: "3" 228 | services: 229 | webapp: 230 | # dockerfile path of the image 231 | build: 232 | ``` 233 | 234 | ``` yml 235 | version: "3" 236 | services: 237 | webapp: 238 | build: 239 | # dockerfile path of the image 240 | context: 241 | # environment variables accessible only during the build process 242 | args: 243 | buildno: 244 | gitcommithash: 245 | ``` 246 | 247 | #### `image` 248 | If the image does not exist, Compose attempts to pull it, unless you have also specified build, in which case it builds it using the specified options and tags it with the specified tag. 249 | ``` yml 250 | version: "3" 251 | services: 252 | redis: 253 | # attempt to pull 'redis' if it does not exist 254 | image: redis 255 | ``` 256 | ``` yml 257 | version: "3" 258 | services: 259 | webapp: 260 | build: 261 | # tag the built image 262 | image: /: 263 | ``` 264 | 265 | #### `command` 266 | ``` yml 267 | services: 268 | some-service: 269 | # overrides the default CMD in Dockerfile 270 | command: 271 | ``` 272 | 273 | #### `container_name` 274 | ``` yml 275 | services: 276 | some-service: 277 | # specify a custom container name, rather than a generated default name 278 | container_name: 279 | ``` 280 | 281 | #### `depends_on` 282 | * `docker-compose up` starts services in dependency order. In the following example, `db` and `redis` are started before web. 283 | 284 | * `docker-compose up SERVICE` automatically includes `SERVICE`’s dependencies. In the following example, `docker-compose up web` also creates and starts `db` and `redis` 285 | 286 | ``` yml 287 | version: "3" 288 | services: 289 | web: 290 | build: . 291 | depends_on: 292 | - db 293 | - redis 294 | redis: 295 | image: redis 296 | db: 297 | image: postgres 298 | ``` 299 | 300 | #### `entrypoint` 301 | ``` yml 302 | services: 303 | some-service: 304 | # overrides the default ENTRYPOINT and ignores the CMD instruction in dockerfile 305 | entrypoint: 306 | ``` 307 | 308 | #### `env_file` 309 | Add environment variables from a file. Can be a single value or a list: 310 | ``` yml 311 | services: 312 | some-service: 313 | env_file: 314 | ``` 315 | ``` yml 316 | services: 317 | some-service: 318 | env_file: 319 | - 320 | - 321 | - 322 | ``` 323 | 324 | Compose expects each line in an env file to be in `VAR=VAL` format. Lines beginning with `#` are treated as comments and are ignored. Blank lines are also ignored: 325 | ``` sh 326 | # Set Rails/Rack environment 327 | RACK_ENV=development 328 | ``` 329 | 330 | #### `environment` 331 | Add environment variables. You can use either an array or a dictionary. Any boolean values; `true`, `false`, `yes`, `no`, need to be enclosed in quotes to ensure they are not converted to `True` or `False` by the YML parser. 332 | 333 | Environment variables with only a key are resolved to their values on the machine Compose is running on, which can be helpful for secret or host-specific values. 334 | ``` yml 335 | services: 336 | some-service: 337 | environment: 338 | RACK_ENV: development 339 | SHOW: 'true' 340 | SESSION_SECRET: 341 | ``` 342 | 343 | #### `expose` 344 | Expose ports without publishing them to the host machine - they’ll only be accessible to linked services. Only the internal port can be specified. 345 | ``` yml 346 | services: 347 | some-service: 348 | expose: 349 | - "3000" 350 | - "8000" 351 | ``` 352 | 353 | #### `networks` 354 | Networks to join, referencing entries under the top-level `networks` key: 355 | ``` yml 356 | services: 357 | some-service: 358 | networks: 359 | - some-network 360 | - other-network 361 | ``` 362 | 363 | 364 | #### `ports` 365 | Either specify both ports `(HOST:CONTAINER)` 366 | ``` yml 367 | ports: 368 | - "8000:8000" 369 | - "49100:22" 370 | ``` 371 | 372 | #### `volumes` 373 | You can mount a host path as part of a definition for a single service, and there is no need to define it in the top level `volumes` key. 374 | But, if you want to reuse a volume across multiple services, then define a named volume in the top-level `volumes` key. 375 | ``` yml 376 | version: "3" 377 | services: 378 | web: 379 | image: nginx:alpine 380 | # long syntax 381 | volumes: 382 | - type: volume 383 | source: mydata 384 | target: /data 385 | volume: 386 | nocopy: true 387 | - type: bind 388 | source: ./static 389 | target: /opt/app/static 390 | 391 | db: 392 | image: postgres:latest 393 | # short syntax 394 | volumes: 395 | - "/var/run/postgres/postgres.sock:/var/run/postgres/postgres.sock" 396 | - "dbdata:/var/lib/postgresql/data" 397 | 398 | # named volumes must be listed here 399 | volumes: 400 | mydata: 401 | dbdata: 402 | ``` 403 | 404 | **Short Syntax:** 405 | ``` yml 406 | volumes: 407 | # Just specify a path and let the Engine create a volume 408 | - /var/lib/mysql 409 | 410 | # Specify an absolute path mapping 411 | - /opt/data:/var/lib/mysql 412 | 413 | # Path on the host, relative to the Compose file 414 | - ./cache:/tmp/cache 415 | 416 | # User-relative path 417 | - ~/configs:/etc/configs/:ro 418 | 419 | # Named volume 420 | - datavolume:/var/lib/mysql 421 | ``` 422 | 423 | **Long Syntax:** 424 | 425 | The long form syntax allows the configuration of additional fields that can’t be expressed in the short form. 426 | 427 | | key | description | 428 | |:----------|:------------| 429 | | type | mount type `volume`, `bind` or `tmpfs` | 430 | | source | source of the mount, or the name of a volume defined in the top-level `volumes` key | 431 | | target | path in the container where the volume is mounted | 432 | | read_only | flag to set the volume as read-only | 433 | | volume | configure additional volume options | 434 | | nocopy | flag to disable copying of data from a container when a volume is created | 435 | 436 | Here’s an example of a two-service setup where a database’s data directory is shared with another service as a volume so that it can be periodically backed up: 437 | ``` yml 438 | version: "3" 439 | 440 | services: 441 | db: 442 | image: db 443 | volumes: 444 | - data-volume:/var/lib/db 445 | backup: 446 | image: backup-service 447 | volumes: 448 | - data-volume:/var/lib/backup/data 449 | 450 | volumes: 451 | data-volume: 452 | ``` 453 | 454 | #### `external` 455 | If set to true, specifies that this volume has been created outside of Compose. `docker-compose up` does not attempt to create it, and raises an error if it doesn’t exist. 456 | 457 | In the example below, instead of attempting to create a volume called `[projectname]_data`, Compose looks for an existing volume simply called `data` and mount it into the `db` service’s containers. 458 | ``` yml 459 | version: "3" 460 | 461 | services: 462 | db: 463 | image: postgres 464 | volumes: 465 | - data:/var/lib/postgresql/data 466 | 467 | volumes: 468 | data: 469 | external: true 470 | ``` 471 | 472 | 473 | #### `network_mode` 474 | ``` yml 475 | services: 476 | some-service:: 477 | # network_mode: host -> do not use isolated network 478 | network_mode: 479 | ``` 480 | 481 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | # Ubuntu on Steroids 2 | ### Table of Contents 3 | 1. [Common Dependencies](#common-dependencies) 4 | 2. [Common Tools & Drivers](#common-tools--drivers) 5 | 3. [Git & Github](#git--github) 6 | 4. [Theme](#theme) 7 | 5. [Neovim](#neovim) 8 | 6. [Terminal & Shell](#terminal--shell) 9 | 7. [Python](#python) 10 | 8. [Go](#go) 11 | 9. [Rust](#rust) 12 | 10. [Node.js](#nodejs) 13 | 11. [Laravel](#laravel) 14 | 12. [Visual Studio Code](#visual-studio-code) 15 | 13. [Other Tools](#other-tools) 16 | 14. [Docker](#docker) 17 | 15. [MySQL](#mysql) 18 | 16. [DigitalOcean](#digitalocean) 19 | 20 | ### Common Dependencies 21 | * `sudo apt install net-tools` 22 | * `sudo apt install curl` 23 | * `sudo apt install python3-pip` 24 |
25 | 26 | ### Common Tools & Drivers 27 | #### Nvidia Driver 28 | > *Software & Updates > Additional Drivers* 29 | 30 | #### KeePass 31 | ``` sh 32 | sudo apt install keepass2 33 | ``` 34 | 35 | #### OBS 36 | ``` sh 37 | sudo add-apt-repository ppa:obsproject/obs-studio 38 | sudo apt install obs-studio 39 | ``` 40 | 41 | #### Ubuntu Software 42 | * Dropbox 43 | * Spotify 44 | * GIMP 45 | 46 |
47 | 48 | ### Git & Github 49 | #### Install Git & Configure SSH 50 | 1. `sudo apt install git` 51 | 2. [Generate SSH Key](https://help.github.com/articles/generating-a-new-ssh-key-and-adding-it-to-the-ssh-agent/) (or reuse an existing key) 52 | 3. [Add SSH Key to Github Account](https://help.github.com/articles/adding-a-new-ssh-key-to-your-github-account/) (skip if reusing an existing key) 53 | 54 | ``` sh 55 | # tip: get lines of code in a particular language within a Git repository 56 | git ls-files | grep '\.py$' | xargs wc -l 57 | ``` 58 | 59 | ### Theme 60 | #### Fonts 61 | 1. [Hack](https://github.com/source-foundry/Hack/releases/download/v3.003/Hack-v3.003-ttf.zip) 62 | 2. [Courier Prime Code](https://www.fontsquirrel.com/fonts/courier-prime-code) 63 | 3. [Input](http://input.fontbureau.com/download/index.html?size=15&language=python&theme=monokai&family=InputMono&width=300&weight=400&line-height=1.3&a=ss&g=ss&i=serifs_round&l=serifs_round&zero=slash&asterisk=height&braces=0&preset=default&customize=please) 64 | 4. Fira Code 65 | ``` sh 66 | sudo apt install fonts-firacode 67 | ``` 68 | 5. Source Code Pro 69 | ``` sh 70 | git clone --depth 1 --branch release https://github.com/adobe-fonts/source-code-pro.git ~/.fonts/adobe-fonts/source-code-pro 71 | fc-cache -f -v ~/.fonts/adobe-fonts/source-code-pro 72 | ``` 73 | 74 | #### Gnome Theme 75 | * `sudo add-apt-repository -u ppa:snwh/ppa` 76 | * `sudo apt update` 77 | * `sudo apt install paper-icon-theme` 78 | * `sudo apt install gnome-tweak-tool` 79 | * *Tweaks > Appearance > Applications > Adwaita-dark* 80 | * *Tweaks > Appearance > Icons > Paper* 81 | * *Tweaks > Fonts > [your_favourite_font]* 82 | 83 | #### Desktop Slideshow 84 | > *Shotwell Photo Manager > Select Pictures > File > Set as Desktop Slideshow* 85 |
86 | 87 | ### Neovim 88 | 89 | [Install Neovim](https://github.com/neovim/neovim) 90 | > `sudo apt install neovim` 91 | 92 |
93 | 94 | ### Terminal & Shell 95 | #### [Tilix](https://github.com/gnunn1/tilix) 96 | 1. Install Tilix 97 | > `sudo apt install tilix` 98 | 2. Install Dracula Theme 99 | ```sh 100 | curl -o ~/.config/tilix/schemes/Dracula.json --create-dirs https://raw.githubusercontent.com/dracula/tilix/master/Dracula.json 101 | ``` 102 | 3. Customize Tilix Appearance 103 | * *Preferences > Appearance > Window Style > Disable CSD && hide toolbar* 104 | * *Preferences > Appearance > Terminal Title Style > None* 105 | * *Preferences > Profile > Color > Color scheme > Dracula* 106 | 4. Configure Tilix Keyboard Shortcuts 107 | * *Preferences > Shortcuts > Replace **`Switch to next session`** shortcut with **`Alt+Right`*** 108 | * *Preferences > Shortcuts > Replace **`Switch to previous session`** shortcut with **`Alt+Left`*** 109 | * *Preferences > Shortcuts > Replace **`Paste`** shortcut with **`Ctrl+V`*** 110 | * *Preferences > Shortcuts > Replace **`Resize the terminal down`** shortcut with **`Shift+Ctrl+Down`*** 111 | * *Preferences > Shortcuts > Replace **`Resize the terminal up`** shortcut with **`Shift+Ctrl+Up`*** 112 | * *Preferences > Shortcuts > Replace **`Resize the terminal right`** shortcut with **`Shift+Ctrl+Right`*** 113 | * *Preferences > Shortcuts > Replace **`Resize the terminal left`** shortcut with **`Shift+Ctrl+Left`*** 114 | 5. Configure System Keyboard Shortcuts 115 | * *Keyboard Shortcuts > Remove Default Action for **`Ctrl+Alt+T`*** 116 | * *Keyboard Shortcuts > Bind **`Ctrl+Alt+T`** to Custom Shortcut for Launching Tilix* 117 | * *Keyboard Shortcuts > Disable Shortcut for **`Hide all normal windows`*** 118 | 119 | #### [Zsh](https://github.com/robbyrussell/oh-my-zsh/wiki/Installing-ZSH) 120 | 1. Install Zsh 121 | * `sudo apt install zsh` 122 | * `chsh -s $(which zsh)` 123 | * `gnome-session-quit` 124 | * *Login* 125 | * `echo $SHELL` 126 | 2. [Oh My Zsh](https://github.com/robbyrussell/oh-my-zsh) 127 | * `sh -c "$(curl -fsSL https://raw.githubusercontent.com/robbyrussell/oh-my-zsh/master/tools/install.sh)"` 128 | 3. [Spaceship Prompt](https://github.com/denysdovhan/spaceship-prompt) 129 | * `git clone https://github.com/denysdovhan/spaceship-prompt.git "$ZSH_CUSTOM/themes/spaceship-prompt"` 130 | * `ln -s "$ZSH_CUSTOM/themes/spaceship-prompt/spaceship.zsh-theme" "$ZSH_CUSTOM/themes/spaceship.zsh-theme"` 131 | 4. [Zsh Autosuggestions](https://github.com/zsh-users/zsh-autosuggestions) 132 | * `git clone https://github.com/zsh-users/zsh-autosuggestions ${ZSH_CUSTOM:-~/.oh-my-zsh/custom}/plugins/zsh-autosuggestions` 133 | * `echo "bindkey '^ ' autosuggest-accept" >> $ZSH_CUSTOM/autosuggestion-settings.zsh` 134 | * `source $ZSH_CUSTOM/autosuggestion-settings.zsh` 135 | 5. [Zsh Syntax Highlighting](https://github.com/zsh-users/zsh-syntax-highlighting) 136 | * `git clone https://github.com/zsh-users/zsh-syntax-highlighting.git ${ZSH_CUSTOM:-~/.oh-my-zsh/custom}/plugins/zsh-syntax-highlighting` 137 |
138 | 139 | ### Python 140 | #### Install Pyenv 141 | ```sh 142 | curl https://pyenv.run | bash 143 | ``` 144 | 145 | #### Install Build Dependencies 146 | ```sh 147 | sudo apt update && sudo apt install -y make build-essential libssl-dev zlib1g-dev \ 148 | libbz2-dev libreadline-dev libsqlite3-dev wget curl llvm libncurses5-dev \ 149 | libncursesw5-dev xz-utils tk-dev libffi-dev liblzma-dev python-openssl git 150 | ``` 151 | 152 | #### Install Desired Releases 153 | ```sh 154 | pyenv install 3.8.3 155 | pyenv install 3.7.7 156 | pyenv local 3.8.3 3.7.7 157 | ``` 158 | 159 | #### Install Poetry 160 | ```sh 161 | curl -sSL https://raw.githubusercontent.com/python-poetry/poetry/master/get-poetry.py | python 162 | source ~/.poetry/env 163 | 164 | # new project 165 | poetry init --no-interaction 166 | poetry install 167 | 168 | # run a Python session inside the virtual environment 169 | poetry run python 170 | 171 | # add & update a dependency 172 | poetry add google-api-python-client 173 | poetry update google-api-python-client 174 | poetry add google-api-python-client^2.0 # upgrade to major release 175 | ``` 176 | 177 | ### Go 178 | ```sh 179 | sudo add-apt-repository ppa:longsleep/golang-backports 180 | sudo apt update 181 | sudo apt install golang-go 182 | ``` 183 | 184 | ### Rust 185 | ```sh 186 | curl https://sh.rustup.rs -sSf | sh 187 | source $HOME/.cargo/env 188 | ``` 189 | 190 | ### Node.js 191 | #### Install NVM 192 | Note that the version number may differ: 193 | ``` sh 194 | # you might want to change the version 195 | curl -o- https://raw.githubusercontent.com/nvm-sh/nvm/v0.37.2/install.sh | bash 196 | ``` 197 | 198 | #### Install Node.js 199 | ```sh 200 | # list available versions 201 | nvm ls-remote 202 | 203 | # install desired version(s) 204 | nvm install x.y.z 205 | 206 | # use desired node version 207 | nvm use x.y.z 208 | 209 | # update npm 210 | npm install npm@latest -g 211 | ``` 212 | 213 | #### Configure 214 | ``` sh 215 | npm config set init.author.name 216 | npm config set init.author.email 217 | ``` 218 |
219 | 220 | ### Laravel 221 | #### Install PHP 7.3 222 | ```sh 223 | sudo apt update 224 | sudo apt install software-properties-common 225 | sudo add-apt-repository ppa:ondrej/php 226 | sudo apt install \ 227 | php7.3 \ 228 | php7.3-common \ 229 | php7.3-mysql \ 230 | php7.3-xml \ 231 | php7.3-xmlrpc \ 232 | php7.3-curl \ 233 | php7.3-gd \ 234 | php7.3-imagick \ 235 | php7.3-cli \ 236 | php7.3-dev \ 237 | php7.3-imap \ 238 | php7.3-mbstring \ 239 | php7.3-opcache \ 240 | php7.3-soap \ 241 | php7.3-zip \ 242 | php7.3-gmp \ 243 | php7.3-intl -y 244 | ``` 245 | 246 | #### Install Composer 247 | ``` sh 248 | php -r "copy('https://getcomposer.org/installer', 'composer-setup.php');" 249 | php composer-setup.php --install-dir=/home/utku/.local/bin --filename=composer 250 | ``` 251 | 252 | #### Install Laravel 253 | ``` sh 254 | composer global require "laravel/installer" 255 | ``` 256 | 257 | #### Install XDebug 258 | 1. Clone the [XDebug repo.](https://github.com/xdebug/xdebug) 259 | 2. From within the repo dir, run the following commands: 260 | ``` sh 261 | phpize 262 | ./configure --enable-xdebug 263 | make clean 264 | make 265 | sudo make install 266 | ``` 267 | 3. Add the following lines into your `php.ini`. (You can locate your `php.ini` by running the `php --ini` command) 268 | ``` sh 269 | zend_extension="xdebug.so" 270 | 271 | [XDebug] 272 | xdebug.remote_enable = 1 273 | xdebug.remote_autostart = 1 274 | ``` 275 | 4. Verify that XDebug is successfuly installed by running the following command (it should match): 276 | ``` sh 277 | php -v | grep "Xdebug" 278 | ``` 279 | 280 | ### Visual Studio Code 281 | 1. [Download the .deb package](https://code.visualstudio.com/docs/?dv=linux64_deb) 282 | 2. Download Extensions 283 | - Appearance 284 | * Overnight (Slumber) *or* Night Owl 285 | * Material Icon Theme 286 | - Editor 287 | * Vim 288 | * TabNine 289 | * EditorConfig for VS Code 290 | - Remote Development 291 | * Remote - SSH 292 | * Remote - SSH: Editing Configuration Files 293 | * Remote - SSH: Explorer 294 | - Web Development 295 | * REST Client 296 | * Auto Rename Tag 297 | * Live Server 298 | * GraphQL 299 | - Git 300 | * GitLens 301 | - JavaScript & TypeScript 302 | * Prettier 303 | * ESLint (`npm install -g eslint`) 304 | * ES7 React/Redux/GraphQL/React-Native snippets 305 | * vscode-sql-template-literal 306 | - PHP 307 | * PHP Debug 308 | * PHP DocBlocker 309 | * PHP Intelephense 310 | * php cs fixer 311 | * Larevel Blade Snippets 312 | - Go 313 | * Go 314 | - Python 315 | * Python 316 | * AREPL for python 317 | * autoDocstring 318 | - Rust 319 | * Rust 320 | - Other 321 | * Docker 322 | * Create Files & Folders: On The Go 323 | 3. Copy the [settings file](vscode.settings.json) contents into `settings.json` 324 | 4. Copy the [keybindings file](vscode.keybindings.json) contents into `keybindings.json` 325 |
326 | 327 | ### Other Tools 328 | * [Peek](https://github.com/phw/peek) 329 | ```sh 330 | sudo add-apt-repository ppa:peek-developers/stable 331 | sudo apt install peek 332 | ``` 333 | * [ag](https://github.com/ggreer/the_silver_searcher) & [sack](https://github.com/sampson-chen/sack) 334 | ``` sh 335 | # 1. install ag 336 | sudo apt install silversearcher-ag 337 | 338 | # 2. install sack 339 | git clone https://github.com/sampson-chen/sack.git && \ 340 | cd sack && \ 341 | chmod +x install_sack.sh && \ 342 | ./install_sack.sh && \ 343 | cd .. && \ 344 | rm -rf sack 345 | ``` 346 | * [fd](https://github.com/sharkdp/fd)  —  `sudo apt install fd-find` 347 | * [bat](https://github.com/sharkdp/bat)  —  `sudo apt install bat` 348 | * [exa](https://github.com/ogham/exa)  —  `cargo install exa` 349 | * [icdiff](https://www.jefftk.com/icdiff)  —  `sudo apt install icdiff` 350 |
351 | 352 | ### Docker 353 | ``` sh 354 | # 1. remove any older versions 355 | sudo apt purge docker lxc-docker docker-engine docker.io 356 | 357 | # 2. install prerequisites 358 | sudo apt install apt-transport-https ca-certificates software-properties-common 359 | 360 | # 3. import official GPG key & verify signature 361 | curl -fsSL https://download.docker.com/linux/ubuntu/gpg | sudo apt-key add 362 | 363 | # 4. add docker respository 364 | sudo add-apt-repository \ 365 | "deb [arch=amd64] https://download.docker.com/linux/ubuntu $(lsb_release -cs) stable" 366 | 367 | # 5. install docker 368 | sudo apt install docker-ce 369 | 370 | # 6. verify service status 371 | sudo systemctl status docker 372 | 373 | # 7. create docker group & add your user 374 | sudo groupadd docker 375 | sudo usermod -aG docker $USER 376 | ``` 377 | 378 | > Log out and login back. 379 | 380 | ``` sh 381 | # 8. verify that you can run this command without 'sudo' 382 | docker run hello-world 383 | 384 | # 9. install docker-compose 1.24.0 (better check newer versions) 385 | sudo curl -L "https://github.com/docker/compose/releases/download/1.27.4/docker-compose-$(uname -s)-$(uname -m)" -o /usr/local/bin/docker-compose 386 | 387 | 388 | # 10. apply executable permission 389 | sudo chmod +x /usr/local/bin/docker-compose 390 | ``` 391 | 392 | See [cheatsheet](./docker.md) for more info. 393 | 394 |
395 | 396 | ### MySQL 397 | #### Download MySQL Docker Image 398 | ```sh 399 | docker pull mysql: 400 | ``` 401 | 402 | #### Start MySQL Container 403 | ``` sh 404 | # publish default port, provide a root password and start mysql 405 | docker run --name -p 3306:3306 -e MYSQL_ROOT_PASSWORD= mysql: 406 | 407 | # you can provide optional config params like max-allowed-packet 408 | docker run --name -p 3306:3306 -it -e MYSQL_ROOT_PASSWORD= mysql: --max-allowed-packet=67108864 409 | ``` 410 | 411 | #### Connect to MySQL Server from within the Container 412 | 1. **Run the MySQL Client** 413 | ``` sh 414 | # check randomly generated password 415 | docker logs 2>&1 | grep GENERATED 416 | 417 | # run the MySQL client within the MySQL Server container 418 | docker exec -it mysql -uroot -p 419 | ``` 420 | When prompted, paste the generated password obtained from the previous step. 421 | 422 | 2. **Reset Root Password** 423 | ``` sh 424 | ALTER USER 'root'@'localhost' IDENTIFIED BY ''; 425 | ``` 426 | 427 | #### Connect via Client 428 | ``` sh 429 | # install client 430 | sudo apt install mysql-client 431 | 432 | # connect 433 | mysql -h HOST -P PORT_NUMBER -u USERNAME -p 434 | ``` 435 | 436 | #### Backup & Restore 437 | Backup & restore a particular database while MySQL container is running: 438 | ``` sh 439 | # backup 440 | docker exec mysqldump \ 441 | -u --password= > .sql 442 | 443 | # restore 444 | cat .sql | docker exec -i mysql \ 445 | -u --password= 446 | 447 | # backup & compress 448 | docker exec mysqldump \ 449 | -u --password= | gzip -c > .sql.gz 450 | 451 | # decompress & restore 452 | gzip -d -c .sql.gz | docker exec -i mysql \ 453 | -u --password= 454 | ``` 455 | 456 | See [cheatsheet](https://gist.github.com/bradtraversy/c831baaad44343cc945e76c2e30927b3) for more info. 457 |
458 | 459 | ### DigitalOcean 460 | 1. Follow the [Initial Server Setup](https://www.digitalocean.com/community/tutorials/initial-server-setup-with-ubuntu-18-04) guide. 461 | 2. Append public SSH keys of each client machine into the `~/.ssh/authorized_keys` file in droplet. 462 | --------------------------------------------------------------------------------