Skip to content

Instantly share code, notes, and snippets.

View ziritrion's full-sized avatar

Alvaro Navas ziritrion

View GitHub Profile
@ziritrion
ziritrion / readme.md
Created July 10, 2024 14:12 — forked from erikvullings/readme.md
Add SSH site to Windows Terminal

Source.

You can use a commandline field in your profile configuration to initiate an SSH connection on tab creation.

Step-by-step guide:

  1. Open Settings (Ctrl+,)
  2. Find the "list" array in the "profiles" object
  3. Duplicate a Command Prompt profile ("commandline": "cmd.exe")
  4. Change the commandline value to: ssh me@my-server -p 22 -i ~/.ssh/id_rsa (use your own connection command).
@ziritrion
ziritrion / ssh_keys.md
Last active November 21, 2024 10:08
SSH keys for Github and logging in to servers
@ziritrion
ziritrion / dezoomcamp-vm.md
Last active July 13, 2024 10:48
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 February 26, 2025 16:53
Docker, containers and VMs

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. There are 4 types:
    • Volumes: managed by Docker itself, they're stored in a separate part of the host filesystem (on Linux by default this would be var/lib/docker/volumes). Useful for production deployments.
    • Bind mounts: mount a specific directory or file from the host to the container, such as a project folder. Useful for development.
  • Tmpfs mounts: mount a temporary file system in the container, which is stored in the host system's memory only, not on disk. Useful for sensitive information that should not be persisted between container restarts or for performance reaso
@ziritrion
ziritrion / pythondata.md
Last active October 8, 2024 05:13
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 February 12, 2025 16:24
Python package managers and environments

uv

Experimental but very promising pip replacement that handles package managing as well as virtual environments and Python version management.

uv comes included with uvx, an alias for uv tool run. uvx allos you to install and execute command-line tools on an ephemeral environment.

Python versions

Note that you don't have to actively install a Python version! uv will automatically fetch the required Python version for your project.

@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 February 19, 2025 10:38
git cheatsheet

Basic git

  1. Clone a repo!
    • git clone [email protected]/path/to/repo.git > for SSH checkout (recommended for extended use)
    • git clone https://somedomain.com/path/to/repo.git > for HTTPS checkout (easier for experimenting)
    • If you are cloning from GitHub, you can also use the GitHub CLI
      • gh repo clone path/to/repo
    • Check this section for more info on SSH vs HTTPS
  2. Make sure your local copy of the selected branch is updated.
    1. Without overwriting anything, but update the status on all branches.

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: