Wednesday, September 17, 2025

Tách âm thanh và video

1. Tách video ra khỏi âm thanh

ffmpeg -i original_video.mp4 -c copy -an video_nosound.mp4 

2. Tách âm thanh ra khỏi video

dùng Audacity để mở file .mp4 sau đó lưu sound track lại dạng mp3

 

3. Tách vocal dùng web https://vocalremover.org

4. Ghép nhạch sau khi tách vào lại video no soundtrack

Dùng cho video dang không có soundtrack
ffmpeg -i peppa_video_nosound.mp4 -i soundtrack_music.mp3 -c:v copy -map 0:v:0 -map 1:a:0 -shortest output.mp4

Dùng cho video đang có sound track, sẽ ghép nhồi âm thanh
ffmpeg -i peppa_video_nosound.mp4 -i soundtrack_music.mp3 -filter_complex "[0:a][1:a]amix=inputs=2:duration=shortest[a]" -map 0:v -map "[a]" -c:v copy video_mixed.mp4
 

Thursday, August 21, 2025

Merge branch to main Git

 Merge full branch to main
git fetch --all --prune
# Tạo tag backup trỏ về remote main hiện tại (để có thể rollback)
git tag -a backup/main-override-$(date +%Y%m%d-%H%M%S) -m "backup before override main" rag-backend-remote/main
git switch main
git reset --hard chore/remove-old-translators
git push --force-with-lease rag-backend-remote main
# (tùy chọn) nếu bạn cũng dùng remote ssh cho main, đẩy lên cả remote đó:
# git push --force-with-lease rag-backend-ssh-remote main

Friday, August 15, 2025

Install infinispan on Linux

On user run infinispan:

wget https://github.com/infinispan/infinispan/releases/download/15.2.5.Final/infinispan-server-15.2.5.Final.zip

unzip infinispan-server-15.2.5.Final.zip

cd infinispan-server-15.2.5.Final/

bin/cli.sh user create admin -p 'your_password' -g admin 

done

Install JDK 21 on Linux

On <user_run_jdk>
wget https://github.com/adoptium/temurin21-binaries/releases/download/jdk-21.0.8%2B9/OpenJDK21U-jdk_x64_linux_hotspot_21.0.8_9.tar.gz

On root
update-alternatives --install /usr/bin/java java /home/<user_run_jdk>/jdk-21.0.8+9/bin/java 21
update-alternatives --install /usr/bin/javac javac /home/<user_run_jdk>/jdk-21.0.8+9/bin/javac 21

Wednesday, August 13, 2025

Backup và Restore Milvus Docker

Restore

Vào user, stop Milvus service

Vào root, xóa thư mục data của Milvus ở user

Vào user, tạo thư mục data/milvus

Copy file đã backup vào data/milvus

Giải nén file, start lại milvus


Add normal user to docker group to run docker compose file

groupadd docker 2>/dev/null || true

usermod -aG docker yournormaluser

newgrp docker 


out and ssh again

Install Docker on Debian 12

 apt install ca-certificates curl
install -m 0755 -d /etc/apt/keyrings

 curl -fsSL https://download.docker.com/linux/debian/gpg -o /etc/apt/keyrings/docker.asc
 chmod a+r /etc/apt/keyrings/docker.asc

echo "deb [arch=$(dpkg --print-architecture) signed-by=/etc/apt/keyrings/docker.asc] https://download.docker.com/linux/debian $(. /etc/os-release && echo "$VERSION_CODENAME") stable" | \
   tee /etc/apt/sources.list.d/docker.list > /dev/null
 apt update

apt-cache madison docker-ce | awk '{ print $3 }'

VERSION_STRING="5:26.1.3-1~debian.12~bookworm"
 apt-get install docker-ce=$VERSION_STRING docker-ce-cli=$VERSION_STRING containerd.io docker-buildx-plugin docker-compose-plugin


Monday, July 29, 2024

Add JMX monitor without authen and SSL

Add this line to java command, replace 10.68.55.37 with ip of local jmx server 

 -Dcom.sun.management.jmxremote -Djava.rmi.server.hostname=10.68.55.37 -Dcom.sun.management.jmxremote.local.only=false -Dcom.sun.management.jmxremote.port=9999 -Dcom.sun.management.jmxremote.authenticate=false -Dcom.sun.management.jmxremote.ssl=false

 


Saturday, August 12, 2023

Install kernel mainline

 

  • In Terminal, enter uname -mrs to determine the current kernel version.
  • Check and get any needed updates by entering sudo apt update && sudo apt upgrade.
  • Add the ppa for the kernels: sudo add-apt-repository ppa:cappelikan/ppa -y
  • Again, get the update list, now that the new repository has been added: sudo apt update
  • Install the latest mainline kernel: sudo apt install mainline -y
  • Reboot.

Dell 9310 fix suspend issue

 


BIOS, turn off Early Logo Display to OFF in the Sign of Life options

BIOS, disable Secure Boot

In the system, edit and configure in /etc/default/grub to add to the kernel options : mem_sleep_default=deep

My current kernel options are : GRUB_CMDLINE_LINUX_DEFAULT="quiet splash mitigations=off mem_sleep_default=deep"

(do NOT use mitigations=off unless you seriously know what you're doing)

Reboot. TO check if the deep sleep is on :

cat /sys/power/mem_sleep

Should return :

s2idle [deep]

The deep here confirms the deep sleep mode is turned on.

Saturday, June 10, 2023

Renew openvpn certificate

 cd /etc/openvpn/easy-rsa
#replace server_X79s9v1gWRTvLcGp with your server_yourcertificate
# name server_X79s9v1gWRTvLcGp can be found in /etc/openvpn
./easyrsa renew server_X79s9v1gWRTvLcGp nopass
cp pki/issued/server_X79s9v1gWRTvLcGp.crt  ../
cp pki/private/server_X79s9v1gWRTvLcGp.key ../
/etc/init.d/openvpn restart

 

Friday, April 21, 2023

Run DBeaver portable with jdk 17

 add to eclipse.ini config:


-XX:+IgnoreUnrecognizedVMOptions
--add-modules=ALL-SYSTEM
--add-opens=java.base/java.nio=ALL-UNNAMED
--add-opens=java.base/java.net=ALL-UNNAMED

Thursday, March 23, 2023

Setup relicate table Postgres

 

SHOW wal_level;

ALTER SYSTEM SET wal_level = logical;


On Publisher database:

--STEP 1: create publiccation named mypub, for table1,table2, table3
CREATE PUBLICATION mypub FOR TABLE newtable;

--check created publication
SELECT *
FROM pg_catalog.pg_publication

SELECT *
FROM pg_catalog.pg_publication_tables

--STEP 2: for each subscription, need to creating relication slot on publication node, 'pgoutput' is plugin
SELECT pg_create_logical_replication_slot('mysub', 'pgoutput');

--check replication slot
SELECT slot_name, slot_type, active FROM pg_replication_slots;

--in case to manual delete replication slot, run
SELECT * FROM pg_drop_replication_slot('slot_name');

 
On Subscriber database
 
--create subscription
CREATE SUBSCRIPTION mysub
CONNECTION 'host=192.168.56.20 port=5432 user=databaseuser password=passhere dbname=dbtest1'
PUBLICATION mypub
WITH (create_slot=false);

--check all subscription
SELECT *
FROM pg_subscription

-- drop subscription
ALTER SUBSCRIPTION mysub DISABLE;
ALTER SUBSCRIPTION mysub SET (slot_name=NONE);
DROP SUBSCRIPTION mysub

Friday, March 17, 2023

Fix Sequence Postgres

 SELECT
    'SELECT SETVAL(' ||
       quote_literal(quote_ident(sequence_namespace.nspname) || '.' || quote_ident(class_sequence.relname)) ||
       ', COALESCE(MAX(' ||quote_ident(pg_attribute.attname)|| '), 1) ) FROM ' ||
       quote_ident(table_namespace.nspname)|| '.'||quote_ident(class_table.relname)|| ';'
FROM pg_depend
    INNER JOIN pg_class AS class_sequence
        ON class_sequence.oid = pg_depend.objid
            AND class_sequence.relkind = 'S'
    INNER JOIN pg_class AS class_table
        ON class_table.oid = pg_depend.refobjid
    INNER JOIN pg_attribute
        ON pg_attribute.attrelid = class_table.oid
            AND pg_depend.refobjsubid = pg_attribute.attnum
    INNER JOIN pg_namespace as table_namespace
        ON table_namespace.oid = class_table.relnamespace
    INNER JOIN pg_namespace AS sequence_namespace
        ON sequence_namespace.oid = class_sequence.relnamespace
ORDER BY sequence_namespace.nspname, class_sequence.relname;

 

 

Ref: https://wiki.postgresql.org/wiki/Fixing_Sequences

 

Sunday, December 26, 2021

Fix lc_* message error when start postgres

 localedef -i en_US -c -f UTF-8 -A /usr/share/locale/locale.alias en_US.UTF-8

Saturday, June 19, 2021

Install nftables

apt update 

apt install make git autoconf autogen libtool bison flex asciidoc libgmp-dev libreadline-dev pkg-config 

echo "install libmnl 1.0.4"
git clone -b libmnl-1.0.4 git://git.netfilter.org/libmnl
cd libmnl
sh autogen.sh
./configure
make -j 4 install

echo "install libnftnl-1.2.0"
cd
git clone -b libnftnl-1.2.0 git://git.netfilter.org/libnftnl
cd libnftnl
sh autogen.sh
./configure --libdir=/lib/x86_64-linux-gnu/
make -j 4 install

 
echo "install nftables v0.9.9"
cd
git clone -b v0.9.9 git://git.netfilter.org/nftables
cd nftables
sh autogen.sh
./configure --libdir=/lib/x86_64-linux-gnu/
make -j 4 install

echo "add crontab on reboot"
echo "@reboot root    nft -f /etc/nftables.conf" >> /etc/crontab


 

Monday, June 7, 2021

Build mysql from Source

 apt build-dep mariadb-server


mkdir mariadb-build
cd mariadb-build
git clone -b 10.5 https://github.com/MariaDB/server.git
mkdir mariadb
cd mariadb
cmake ../server -DBUILD_CONFIG=mysql_release
make package

 

Wait about 30 min for build, it will export binary file tarball .tar.gz

Copy that file to home and extract it

cd mariadb-version

Create some directories for log, config...

mkdir log
mkdir tmp
mkdir database
mkdir binlog

Create my.cnf file and .sh files for simplified action

Copy shared libraries to portablelib, use generate_portablelib.sh



Sunday, June 6, 2021

Program open port 80 with normal user

sudo apt-get install libcap2-bin
sudo setcap 'cap_net_bind_service=+ep' /path/to/program