Skip to content

Instantly share code, notes, and snippets.

View codedeep79's full-sized avatar

Nguyễn Trung Hậu codedeep79

View GitHub Profile
@codedeep79
codedeep79 / SqliteProfilerUltimate.py
Last active August 22, 2025 04:21
SQLite Workload Profiler
#!/usr/bin/env python3
# Yêu cầu: Python3, rich, subprocess, perf
import subprocess, sys, os, time, sqlite3
from rich.console import Console
from rich.table import Table
from rich.panel import Panel
from rich.live import Live
from rich.prompt import Prompt
@codedeep79
codedeep79 / gen_scylla_yaml.py
Created August 10, 2025 06:17
Tạo mẫu file scylla.yaml tối ưu dựa trên input phần cứng (CPU core, RAM, NVMe, NUMA).
def generate_scylla_yaml(n_cpu, ram_gb, n_nvme, numa_nodes, use_row_cache=True):
ram_mb = ram_gb * 1024
memory = int(ram_mb * 0.7)
memtable_heap = int(memory * 0.25)
row_cache = 8192 if use_row_cache else 0
num_io_queues = n_nvme * numa_nodes
compaction_throughput = 256
yaml = f"""\
# Generated ScyllaDB configuration sample
@codedeep79
codedeep79 / scylla_scheduler_test.sh
Last active August 10, 2025 03:00
Script này được thiết kế để kiểm tra và tối ưu I/O Scheduler cho ScyllaDB trên hệ thống Debian hoặc các hệ điều hành Linux tương tự, chạy được cả trên môi trường bare metal lẫn trên các nền tảng đám mây phổ biến như AWS, GCP, Azure, VMware, OpenStack...
#!/bin/bash
set -e
DATA_PATH="${1:-/var/lib/scylla}"
echo "=== [1/6] Phát hiện thiết bị chứa dữ liệu ScyllaDB ($DATA_PATH) ==="
DEVICE=$(df "$DATA_PATH" | tail -1 | awk '{print $1}' | sed 's/[0-9]*$//')
DEVICE_NAME=$(basename "$DEVICE")
if [ -z "$DEVICE" ]; then
@codedeep79
codedeep79 / regex_training.md
Last active August 9, 2025 04:57
File dữ liệu test “đa vũ trụ” để luyện hết các pattern trong bộ Regex Hard Mode Training Pack. Dành cho trang web http://www.maxmind.io.vn/2025/08/regex-nang-cao-trong-notepad-bo-training-pack-voi-lookahead-recursion-and-parsing-phuc-tap.html
====================[ LOG SAMPLE ]====================
2025-08-08 15:32:55 [INFO] Server started at http://localhost:8080
2025-08-08 15:33:10 [ERROR] syntax error at line 23
2025-08-08 15:33:12 [WARN] Deprecated API usage
192.168.1.10 GET /index.html 200
8.8.8.8 GET /malicious.php?id=19 404
172.20.0.5 POST /api/data 500
http://example.com?param=1234567890123456789012345678901234567890
@codedeep79
codedeep79 / The current Visual Studio version does not support targeting .NET 8.0. Either target .NET 7.0 or lower, or use Visual Studio version 17.8 or higher.md
Last active January 6, 2025 05:21
The current Visual Studio version does not support targeting .NET 8.0. Either target .NET 7.0 or lower, or use Visual Studio version 17.8 or higher

The error message NETSDK1209 indicates that your current version of Visual Studio does not support targeting .NET 8.0:

  • Update the .csproj file to target a supported version of .NET, such as .NET 7.0.
    • Open the .csproj file.

    • Find the <TargetFramework> element.

    • Change the value to net7.0 or a lower version.

      <TargetFramework>net7.0</TargetFramework>
#!/bin/bash
sudo apt-get install -y \
apt-transport-https \
ca-certificates \
curl \
software-properties-common
curl -fsSL https://download.docker.com/linux/ubuntu/gpg | sudo apt-key add -
sudo apt-key fingerprint 0EBFCD88
sudo add-apt-repository \
"deb [arch=amd64] https://download.docker.com/linux/ubuntu \
@codedeep79
codedeep79 / Lỗi: TypeError: kwargs_from_env() got an unexpected keyword argument 'ssl_version'.md
Last active June 29, 2024 08:05
Lỗi: TypeError: kwargs_from_env() got an unexpected keyword argument 'ssl_version'

Lỗi TypeError: kwargs_from_env() got an unexpected keyword argument 'ssl_version' xảy ra khi truyền một tham số không hợp lệ (ssl_version) vào hàm kwargs_from_env() trong thư viện Docker Python.

image

Docker compose version 1 không hoạt động với Docker SDK for Python 7.0.0+ hiện có trên hệ thống, chỉ hoạt động đến version 6.x.y. Nên có 2 cách giải quyết vấn đề này:

  • Gỡ cài đặt thư viện Docker SDK 7.0.0+ trong hệ thống và cài lại phiên bản < 7.0.0:

    pip uninstall docker
    pip install docker==6.1.3
    
@codedeep79
codedeep79 / Lỗi: docker.errors.DockerException: Error while fetching server API version: HTTPConnection.request() got an unexpected keyword argument 'chunked.md
Last active June 29, 2024 07:38
Lỗi: docker.errors.DockerException: Error while fetching server API version: HTTPConnection.request() got an unexpected keyword argument 'chunked

Lỗi DockerException với thông báo Error while fetching server API version: HTTPConnection.request() got an unexpected keyword argument 'chunked' thường xuất hiện khi có sự không tương thích giữa các phiên bản Docker library và Library HTTP mà Docker sử dụng.

image

Để khắc phục vấn đề này, có thể thử các bước sau:

  • Cập nhật Thư viện Docker: Đảm bảo rằng sử dụng phiên bản mới nhất của thư viện Docker Python. Có thể cập nhật nó bằng cách chạy: pip install --upgrade docker
  • Cập nhật Thư viện urllib3: Lỗi này có thể liên quan đến thư viện urllib3 mà thư viện Docker sử dụng để thực hiện các yêu cầu HTTP. Cập nhật urllib3 lên phiên bản mới nhất: pip install --upgrade urllib3
@codedeep79
codedeep79 / Viber Not Working on Ubuntu 24.04.md
Last active June 15, 2024 06:33
Viber Not Working on Ubuntu 24.04

This worked for me on Ubuntu 24.04:

  • Download libssl1.0.0_1.0.2n-1ubuntu5.13_amd64.deb on Openssl 1.0

    sudo dpkg -i libssl1.0.0_1.0.2n-1ubuntu5.13_amd64.deb

  • Install Flatpak:

    sudo apt install flatpak
    

sudo apt install gnome-software-plugin-flatpak

@codedeep79
codedeep79 / Update text data in files according to specific versions of files with the same name in Minio.md
Created October 12, 2023 09:32
Update text data in files according to specific versions of files with the same name in Minio

To update text data in files according to specific versions of files with the same name in Minio using Python, you can use the Minio Python library to interact with your Minio server. The following steps outline the process:

  1. Install the Minio Python library:
pip install minio
  1. Import the necessary libraries and set up your Minio client: