Skip to content

Instantly share code, notes, and snippets.

View ziritrion's full-sized avatar

Alvaro Navas ziritrion

View GitHub Profile
@ziritrion
ziritrion / dezoomcamp-vm.md
Last active May 18, 2023 20:51
Quick guide to easily create a VM instance in GCP and set up SSH access with Gcloud SDK

Install and setup Gcloud SDK

  1. Download Gcloud SDK from this link and install it according to the instructions for your OS.
  2. Initialize the SDK following these instructions.
    1. Run gcloud init from a terminal and follow the instructions.
    2. Make sure that your project is selected with the command gcloud config list

Creating a VM instance

  1. From your project's dashboard, go to Cloud Compute > VM instance
@ziritrion
ziritrion / vm_containers.md
Last active April 21, 2024 19:28
Cheatsheet for various container and VM thingies

Docker

Terminology

  • Container: environment that runs an applications that is not dependent on the OS. Kind of like a lightweight VM. Containers are stateless; if you need to update the components inside, create another container instead.
  • Image: template to create a container. Its components are defined by a Dockerfile.
  • Volume: storage area detached from the container for maintaining state.
  • Foreground/interactive vs background/detached: a detached container runs in the background whereas an interactive container will usually have a terminal of some sort for interacting with.

Commands

@ziritrion
ziritrion / pythondata.md
Last active April 27, 2024 16:22
Python and libraries cheat sheet

Python

Lists

  • [1, 2, 3, 4, 5]

Power operator (2^5)

  • 2 ** 5

Square root (power operator trick)

  • 9 ** 0.5
@ziritrion
ziritrion / pythonenvs.md
Last active April 21, 2024 19:16
Cheatsheet for Conda, Pipenv

Conda

  1. Create a virtual environment
    • conda create --name my_env_name python=3.8 or whatever Python version you may need.
  2. List available envs (2 different ways
    • conda env list
    • conda info --envs
  3. Activate virtual env
    • conda activate my_env_name
  4. Deactivate current environment
@ziritrion
ziritrion / ssh_background_process.md
Created September 7, 2021 18:27
SSH quick reference for running processes in the background
  1. SSH with local X (any X window should be run locally rather than remotely)
    • ssh -X user@instance
  2. Leave a process running even when you leave the SSH session
    • Make your script executable with chmod +x main.py
    • 2 possible instructions:
      • If console output does not matter (console output is still available in nohup.out but only if execution is finished successfully):
        • nohup python main.py &
      • If output must be saved even if you interrupt the execution:
        • (bash) nohup python -u main.py > output.log &
  • (zsh) nohup python -u main.py > output.log &!
@ziritrion
ziritrion / gcloud.md
Created September 7, 2021 18:21
Gcloud quick reference
  1. Start your instance from Cgloud console
  2. (Local terminal) Change to your project
    1. gcloud projects list
    2. gcloud config set project my-project
  3. Create the ssh blob for easier connection
    • gcloud compute config-ssh
  4. Inside ~/ssh/ a new config file should appear with the necessary info to connect. The host name should be enough to connect via SSH
    • ssh instance.zone.project
  5. In VSCode, with the Remote SSH extension, use the same instruction to add the necessary info in order to log into the instance. The passphrase will be asked.
@ziritrion
ziritrion / git.md
Last active April 8, 2024 08:27
git cheatsheet

Basic git

  1. Make sure your local copy of the selected branch is updated.
    1. Without overwriting anything
      • git fetch
    2. If you already fetched or you are ready to overwrite your local copy, then pull
      • git pull
  2. Check your repo branches
    1. Local branches
  • git branch

Keybase proof

I hereby claim:

  • I am ziritrion on github.
  • I am alvaronp (https://keybase.io/alvaronp) on keybase.
  • I have a public key whose fingerprint is 994B DE62 2EC6 1B1D 6B09 CADF 4DA5 4041 B876 23F8

To claim this, I am signing this object: