Posts

Showing posts from April, 2025

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...

How to Keep Ubuntu 24.04 Laptop Running with Lid Closed

Image
By default, Ubuntu suspends your laptop when you close the lid. However, in some use cases, such as downloading files overnight, using external displays, or running services, you may want your laptop to stay awake. Here’s how to configure your system so it continues running even with the lid closed. Step 1: Edit the logind.conf File Open a terminal and run the following command to edit the systemd logind configuration file: sudo vi /etc/systemd/logind.conf Find the following lines (they may be commented out) and modify them as shown below: HandleLidSwitch=ignore HandleLidSwitchExternalPower=ignore HandleLidSwitchDocked=ignore If any of these lines are commented out with # , be sure to remove the comment symbol. HandleLidSwitch=ignore : Prevents the system from suspending when the laptop lid is closed, regardless of whether it's on battery or AC power. HandleLidSwitchExternalPower=ignore : Specifically ensures the system does not suspend when the lid is closed a...

How to enable ssh server and client on Ubuntu

Image
Introduction SSH (Secure Shell) is a network protocol used to securely communicate between two computers and transfer data. One of the main features of SSH is that it works well on insecure networks, as the communication channel is encrypted. The most widely-used SSH implementation is the OpenSSH suite, which includes the following tools: Remote operations: ssh, scp, sftp Key management: ssh-add, ssh-keysign, ssh-keyscan, ssh-keygen Service-side tools: sshd, sftp-server, ssh-agent Environment $ lsb_release -a No LSB modules are available. Distributor ID: Ubuntu Description: Ubuntu 22.04.4 LTS Release: 22.04 Codename: jammy $ uname -r 6.8.0-57-generic Install OpenSSH Server and Client OpenSSH client is usually pre-installed on Ubuntu. To accept SSH connections, install the server component: $ sudo apt update $ sudo apt install openssh-server openssh-client Verify installation: $ ssh -V OpenSSH_8.9p1 Ubuntu-3ubuntu0.13, OpenSSL 3.0.2 15 Mar 20...

Synology DS916+] How to Set Up SSH Key-Based Login from Windows 11 to Synology NAS (DSM 7.1)

Image
This step-by-step guide explains how to generate an SSH key on Windows 11 using Git Bash and configure key-based authentication on Synology NAS running DSM 7.1 . This lets you securely log in without typing a password every time. Although clients like SecureCRT offer features to remember your password after one login, setting up SSH key authentication is a more secure and reliable method—especially for automation, scripting, or accessing your NAS from multiple devices. Step 1: Enable User Home Service on DSM 7.1 Go to: Control Panel → User & Group → Advanced Enable User Home Service Step 2: Enable SSH Service on DSM 7.1 Navigate to: Control Panel → Terminal & SNMP → Terminal Enable SSH service Make sure Port 22 is allowed in your NAS firewall settings Step 3: Set Permissions for .ssh Directory C:\Users\jason>ssh -p 22 abc.i234.me jason@abc.i234.me's password: Synology strongly advises you not to run commands as the root user, who has the hi...

SecureCRT] How to Back Up and Restore SecureCRT Settings on Windows

Image
If you're a frequent user of SecureCRT , backing up your session settings and restoring them later is crucial—especially when migrating to a new PC or recovering from a crash. In this guide, you’ll learn how to manually back up and restore SecureCRT settings on Windows , ensuring you never lose your configurations again. Does SecureCRT Have a Built-in Export/Import Feature? Yes, SecureCRT provides built-in export and import features in the Tools menu. However, these features may not capture all configuration details such as: Backup scripts Custom login scripts Certain session-specific files Therefore, if you want to completely clone your SecureCRT environment—including every session and customization—the safest option is to manually back up the entire Config folder. What Is the SecureCRT Config Folder? SecureCRT stores your personal settings (sessions, host keys, global options, etc.) in a folder located at: C:\Users\<Your username>\AppData\Roaming\VanDyke\Config Th...

How to Find and Kill a Process Using a Specific Port on Linux (lsof & netstat)

Introduction When executing a process, it may fail to start if the port it needs is already occupied by another process. In such cases, you need to find out which process is using that port and either terminate it or modify its configuration. Using lsof lsof (List Open Files) is a command in Linux-like systems that displays a list of all open files and the processes that opened them. Option explanation: -i : Display the listing of files whose Internet address matches the specified address or protocol. Example: Check if port 22 is in use lsof -i TCP:22 Output: COMMAND PID USER FD TYPE DEVICE SIZE/OFF NODE NAME sshd 1116 root 5u IPv4 33907 0t0 TCP *:ssh (LISTEN) sshd 1116 root 7u IPv6 33909 0t0 TCP *:ssh (LISTEN) Using netstat netstat is a utility that prints network connections, routing tables, interface statistics, masquerade connections, and multicast memberships. Common options: -l : Display listening sockets -n : Displa...

FFmpeg] How to Batch Trim MP3 Files Using FFmpeg on Windows

Introduction: Why Batch Trimming MP3s with FFmpeg Saves Time If you only need to trim one or two MP3 files—like cutting out an intro or logo sound— online audio trimmers are good enough. However, if you need to crop dozens or hundreds of MP3 files , using an online tool becomes extremely time-consuming. That’s where FFmpeg , a free and open-source command-line tool for processing audio and video, comes in. It’s fast, efficient, and works on all major platforms. Environment OS: Windows 10 Pro x64 Tool: FFmpeg full build (version 2022-07-04) FFmpeg Basics: How to Crop a Single MP3 File Parameters explained: -i : Input file path -ss : Start time (can include milliseconds) -t : Duration (in seconds) -acodec copy : Copy audio codec (no re-encoding = faster) Example 1: Trim from 10.123 seconds to end ffmpeg -i input.mp3 -ss 00:00:10.123 -acodec copy output.mp3 Example 2: Trim from 5 seconds for 5 minutes ffmpeg -i input.mp3 -ss 00:00:05 -t 300 -acodec...

What is TCP? Segment Structure, Handshake, Control Bits Explained

Image
1. What is Transmission Control Protocol (TCP) protocol? The TCP/IP protocol has been discussed and standardized in the IETF. RFC 793 is the based standard for TCP, but it doesn't include all the details about modern TCP operations. TCP is a transport layer protocol that provides all the features that a general process requires for reliable data transmission through an unstable and unreliable network. It provides addressing for a process (application) in the form of TCP ports and allows devices to use these ports for the purpose of establishing connections between them. It is the most significant feature as a transport layer. When a connection is established between devices, they can exchange data between the devices with flow control and error control mechanisms simultaneously. Finally, a process can send data bytes to TCP as a simple stream, and TCP deals with packaging and sending the data as segments. 2. TCP Segment Structure and Header Format TCP messages are called se...

Synology DS916+] How to SU to root via SSH

Image
1. Enable SSH / Telnet service DSM → Control Panel → Connectivity → Terminal & SNMP 2. Login to your account via SSH 3. "sudo -i" or "sudo --login" and type root password Synology strongly advises you not to run commands as the root user, who has the highest privileges on the system. Doing so may cause major damages to the system. Please note that if you choose to proceed, all consequences are at your own risk. abcd@xyx:~$ sudo -i Password: root@xyx:~#

SecureCRT] How to Set Up a Serial Console Connection

Image
The below setting values are used for HP DL380, DL580 (Red Hat Linux) or HP server (HP-UX) .  Setting Value Description Port COM3 The serial port number on your laptop. COM3 is an example — use the actual COM port assigned to your serial-to-USB adapter or internal port. Baud rate 9600 The speed of communication in bits per second (bps). 9600 is the default baud rate for most servers. Data bits 8 Number of data bits per character. 8 bits is standard for ASCII data transmission. Parity None Parity is used for error checking. "None" means no parity bit is used — common and standard for most connections. Stop bits 1 Number of bits used to signal the end of a data packet. 1 stop bit is the most common setting. Flow control XON/XOFF Software...

FFmpeg] How to Merge Two Audio Files into a Stereo Track

Image
If you have two separate audio recordings — one for Speaker A and one for Speaker B — and both speakers were recorded at the same time , you might want to combine them into a single stereo audio file. This is useful in many scenarios: Dual-microphone recordings Interview capture Podcast editing Voice separation testing Audio analysis workflows The key idea is to place one speaker’s voice in the left channel and the other speaker’s voice in the right channel. This way, both voices are preserved in a synchronized and clean format, perfect for further processing or listening. You can use  ffmpeg , a powerful open-source audio and video processing tool, to merge two mono audio files (e.g., interviews or podcasts) into a single stereo track. FFmpeg Command ffmpeg -i speakerA.wav -i speakerB.wav -filter_complex "[0:a][1:a]amerge=inputs=2[stereo]" -map "[stereo]" -ac 2 merged_stereo.wav Options Option ...

How to Set Up Vaultwarden (Bitwarden) on Synology NAS (Best Free Alternative to LastPass)

Image
Have you ever felt overwhelmed managing passwords for all your websites? I used to use the same password across multiple sites , which wasn’t secure. To manage them better, I started using LastPass for years. However, in 2019, they changed their pricing policy — now it’s free only for one device for 30 days, and you have to pay to use it across multiple devices . If you're looking for a powerful and free password manager, Vaultwarden is one of the best alternatives to LastPass. What is Vaultwarden? Vaultwarden (formerly known as Bitwarden_RS) is a lightweight, open-source implementation of the Bitwarden server API written in Rust . It is fully compatible with official Bitwarden clients and is ideal for low-resource environments. Example: On a Synology DS916+, Vaultwarden uses 0% CPU and only 64MB of memory while running. My Setup NAS Model : Synology DS916+ DSM Version : DSM 7.1-42661 Update 1 Docker Image : vaultwarden/server Ins...

OSI 7 Layers Table with Protocols and Devices

The OSI model divides computer networking into seven logical layers. Each layer has a unique purpose, related protocols, and network devices. The table below summarizes the OSI 7 layers with clear examples of protocols, PDUs, and devices used at each level. OSI 7 Layers Explained with Protocols, PDU, and Devices Layer Description Protocol PDU Devices Application - Interacts between user and network application. - API - set of routines that make up part of a software application HTTP, FTP, IMAP, SNMP, POP3, SMTP Data Chrome, Firefox, Skype Presentation - Formats the data of application/network to be presented for the destination to be sent. - It can be viewed as the data translator between the application and network. - Character set translation - Data conversion - Data compression - Data encryption or decryption (if ...

How to Add Syntax Highlighting to Blogger Using Prism.js

Image
There are many great platforms these days for starting a technical blog, but most are either paid or require a bit of setup. That’s why I chose Blogger — it's free, simple, and easy to get started. However, as a technical blogger, I often need to share things like Linux commands , source code snippets , or terminal outputs — and unfortunately, Blogger doesn't support code blocks natively. To resolve this, I added a syntax highlighting library called Prism.js to my Blogger theme so that code in my posts looks clean and readable. How to Set Up Prism.js for Syntax Highlighting in Blogger Step 1: Open the Blogger Theme Editor Log in to your Blogger account On the left menu, click “Theme” Click the "▼ arrow" next to the current theme and select "Edit HTML" Step 2: Add Prism.js to the <head> section In the HTML editor, find the <head> tag near the top of the code. Add the following lines inside the <head> tag: ...

Disable Wi-Fi Power Saving on Ubuntu for fast access to SSH, Telnet, and FTP

Image
If you've noticed that SSH connections become very slow or unresponsive after your Ubuntu laptop has been idle for a while. This often happens because your Wi-Fi card enters power-saving mode, reducing network activity until it's manually "woken up." Here's how to check and disable Wi-Fi power management to ensure fast access to services like SSH, Telnet, and FTP. Step 1: Identify Your Network Interface Run the following command to find your WiFi network interface: $ iw dev phy#0 Interface wlp3s0 ifindex 3 wdev 0x1 addr d4:d2:52:96:ff:6e ssid ABCD1234 Here, wlp3s0 is your Wi-Fi interface name. You'll use this in the following steps. Step 2: Check Power Management Status Use iwconfig to check if power saving is enabled: $ iwconfig wlp3s0 wlp3s0 IEEE 802.11 ESSID:"ABCD1234" Mode:Managed Frequency:5.26 GHz Access Point: 38:06:E6:28:76:75 Tx-Power=22 dB...

How to Set a Static IP Address for WiFi on Ubuntu 22.04 using Netplan

When I use WiFi on my test laptop, its IP address sometimes changes. Because of this, I have to update the IP address on other client devices or change the settings of the application running on the test laptop. It would be easier to set a fixed IP address for the test laptop directly on the router, but I can't do that because of security policies. So, I decided to set a static IP address on the test laptop itself. Check Ubuntu version $ lsb_release -a No LSB modules are available. Distributor ID: Ubuntu Description: Ubuntu 22.04.4 LTS Release: 22.04 Codename: jammy 1. Check Your WiFi Interface Name $ ip address | grep 192 inet 192.168.1.95/24 brd 192.168.1.255 scope global wlp3s0 2. Locate the Netplan Configuration File $ cd /etc/netplan /etc/netplan$ ls 01-network-manager-all.yaml 3. Back Up the Original File $ sudo cp 01-network-manager-all.yaml 01-network-manager-all.org 4. Edit the Netplan YAML File $ sudo vim 01-network-manager-all.yaml ...