Posts

Showing posts with the label Python

Changing the Default Terminal to Terminator on Ubuntu

Image
Terminator is a powerful tool for developers, allowing you to manage multiple terminal sessions in a single window. Features like splitting panes, tabs, and simultaneous input can significantly boost your productivity. Step 1: Install Terminator First, install Terminator using the apt package manager. sudo apt update sudo apt install terminator -y The -y option automatically answers 'yes' to any prompts during the installation process, streamlining the setup. Step 2: Set as the System Default Ubuntu uses a utility called update-alternatives to manage default applications. We'll use this tool to change the default terminal emulator ( x-terminal-emulator ) to Terminator. Run the Configuration Command Enter the following command in your terminal. A list of available terminals will appear. sudo update-alternatives --config x-terminal-emulator Select Terminator From the resulting list, enter the selection number corresponding to terminator and press Enter. ...

Pydantic v2, A Practical Guide from FastAPI to v1 Migration

Image
In the modern Python ecosystem, it's impossible to discuss data validation and settings management without mentioning Pydantic . It has become the de-facto standard, empowering countless developers to increase productivity by clearly defining data structures with type hints and enforcing them at runtime. This article will serve as your practical guide to mastering Pydantic v2. We will explore its core use cases with hands-on examples, from API development with FastAPI to settings management. Most importantly, we provide a detailed v1-to-v2 migration checklist to help you upgrade your codebase with confidence. 1. API Development (Web API Development) This is one of Pydantic's most well-known and powerful use cases. It plays a core role, especially when used with the FastAPI framework. Request Validation : It automatically checks if the data sent from a client (like a web browser or mobile app) to the server has the correct format and values. For example, it can val...

Managing FastAPI Projects with Poetry: A Step-by-Step Guide

Image
This guide will walk you through how to use Poetry to manage dependencies and structure your project in FastAPI . It includes detailed explanations of Poetry's core concepts and commands to help prevent issues that can arise during team collaboration and deployment. 1. What is Poetry? Poetry is a dependency management and packaging tool for Python. It goes beyond simply installing libraries by allowing you to clearly declare the dependencies your project needs and ensuring that all developers on the project have the same library versions. Clarity in Dependency Management : Explicitly manage your project's basic information and required libraries through the pyproject.toml file. Reproducible Builds : By locking all dependency versions in the poetry.lock file, it fundamentally prevents "it works on my machine" problems. Integrated Development Environment : It automatically creates and manages isolated virtual environments for each project and handles mo...

A Guide to Automating Connections with SecureCRT Logon Scripts

Image
Developers and system administrators often repeat the daily process of connecting to multiple servers via SSH or Telnet. SecureCRT's "Logon Actions" (or "Logon Scripts") feature is a useful tool that automates these repetitive connection procedures, reducing wasted time and significantly improving work efficiency. I personally used this feature because I found the process of connecting to a PostgreSQL database to be tedious every time. In addition to database connections, this feature is also very useful when you need to connect to a final destination server through an intermediary server, often for security reasons. For example, the true value of this feature becomes apparent in a "jump server" environment, where you must first log into Server A via SSH and then, from there, initiate another Telnet or SSH connection to Server B. Step 1: Create the Python Script File Create a python code file with a .py extension. It's recommended to creat...