Python Development Environment Setup - an Excellent Way

Install pyenv to manage multiple python versions

This gist self-explains how to install pyenv and use it to manage multiple python versions on your machine

Manage virtual envs

A virtual env is where dependencies live without polluting the global space of the current python version, preventing dependency version conflicts between different projects on the same machine.
Install virtualenv package:

pip install virtualenv
virtualenv --version

It’s common that .gitignore file excludes virtual env directories named venv, env, .venv, .env, ENV in most python projects.
I prefer to use venv for the name of virtual envs. cd to the project directory and create a virtual env:

Setup Neovim with vim-plug on Windows 11

I love to use vim everywhere. Almost all the linux distros and macOS come with Vim pre-installed, but what about Windows? You can stick to the vim within the Windows Git Bash(you should know git because that’s what makes you a developer :D) with a Linux-like configuration, but you may notice that :w command lags for some reason.

So why not use Neovim(nvim) on Windows? Let’s get to it!

Open powershell and run the command below to install Neovim on your system. Different ways of installation can be found in the source repository.

Tmux Cheatsheet

I use linux terminal all day, and if you are like me, you should use tmux, which enables a number of terminals to be created, accessed, and controlled from a single screen, just to be more productive!
So, there’re some essential commands for tmux down below.

start a new session

tmux                              # session name will be 0,1,2, ... by default
tmux new -s <session name>        # you can set a custom session name

rename an existing session

tmux rename-session -t <old name> <new name>

detach current session

C-b d
C-b D

Automatic Https With Caddy - Extremely Easy

Today I had a chance to try Caddy for dev purpose, and you guess what, it was extremely easy and funny. Only two steps and boom, you got a secured website almost instantly.
Here are the steps I followed:

Install Caddy on Ubuntu/Debian

Check their documentation for another OS/installation method.

1
2
3
4
5
sudo apt install -y debian-keyring debian-archive-keyring apt-transport-https
curl -1sLf 'https://dl.cloudsmith.io/public/caddy/stable/gpg.key' | sudo gpg --dearmor -o /usr/share/keyrings/caddy-stable-archive-keyring.gpg
curl -1sLf 'https://dl.cloudsmith.io/public/caddy/stable/debian.deb.txt' | sudo tee /etc/apt/sources.list.d/caddy-stable.list
sudo apt update
sudo apt install caddy

Edit Caddyfile and restart the service

1
sudo vim /etc/caddy/Caddyfile
1
2
3
dev-api.your-domain.com

reverse_proxy 127.0.0.1:8000
1
2
3
sudo systemctl restart caddy
# or
sudo caddy reload

That’s it, you can now browse https://dev-api.your-domain.com.
In my case, a REST API service was running on port 8000 and I configured Caddy as a reverse proxy.
Configuring Caddy should be easy for other use cases as well, I’m pretty sure.

How to Deploy Next.js App to AWS EC2 in Production and Set up CI/CD with Github Actions

Yo!

In this article, we’ll be discussing how to deploy a Next.js app to AWS EC2 and set up continuous integration and deployment using Github Actions.

Before proceeding, you will need to have the infrastructure ready on AWS, which can be deployed manually or by using Terraform code. I’ll be skipping the infrastructure setup part for the purpose of this article.

First things first, we need to SSH into the EC2 instance. Once you’re logged in, run this script to install Node.js on the machine: