Skip to content

Instantly share code, notes, and snippets.

View tranduydat's full-sized avatar
🦆
Run

Dat Tran tranduydat

🦆
Run
View GitHub Profile
@tranduydat
tranduydat / find_mv.sh
Created January 27, 2023 11:09
Find .txt and move to text_files directory
find . -name "*.txt" -exec mv {} text_files/ \;
@tranduydat
tranduydat / get-fastest-apt.sh
Created January 23, 2023 08:24
Get fastest apt
# https://askubuntu.com/questions/39922/how-do-you-select-the-fastest-mirror-from-the-command-line
curl -s http://mirrors.ubuntu.com/mirrors.txt | xargs -n1 -I {} sh -c 'echo `curl -r 0-102400 -s -w %{speed_download} -o /dev/null {}/ls-lR.gz` {}' |sort -g -r |head -1| awk '{ print $2 }'
@tranduydat
tranduydat / fix_mysqld_safe.sh
Created January 14, 2023 17:45
mysqld_safe Directory '/var/run/mysqld' for UNIX socket file don't exists
sudo mkdir -p /var/run/mysqld
sudo chown mysql:mysql /var/run/mysqld
@tranduydat
tranduydat / reset-mysql-8-password.sh
Created January 14, 2023 17:33
Reset MySQL 8 password
sudo systemctl stop mysql
sudo mysqld_safe --skip-grant-tables &
mysql -u root
UPDATE mysql.user SET authentication_string=null WHERE User='root';
flush_privileges;
ALTER USER 'root'@'localhost' IDENTIFIED WITH caching_sha2_password BY 'yourpasswd';
exit;
ps -fea | grep mysqld
sudo kill -9 [pid from previous command]
# Credit: https://stackoverflow.com/questions/50691977/how-to-reset-the-root-password-in-mysql-8-0-11 @Ulises Layera
@tranduydat
tranduydat / urlregex.py
Created January 13, 2023 16:54
URL Regex in Python
__URL_REGEX = re.compile(r'^https?://[^\s/$.?#].[^\s]*$', re.IGNORECASE)
@tranduydat
tranduydat / paste_it_on_address_bar.txt
Created January 8, 2023 03:13
quick note on web browser
data:text/html, <textarea style="font-size: 1.5em; width: 100%; height: 100%; border: none; outline: none" autofocus />
@tranduydat
tranduydat / pttt.json
Created November 8, 2022 13:20
Demo dữ liệu phần phương thức tuyển sinh
[
{
"ID": 1,
"ResourceGroupID": 2,
"Code": "200",
"CodeName": "highschoolacademicperformance_adme",
"Description": "Xét kết quả học tập cấp THPT (học bạ)",
"Note": null,
"CreatedAt": "2022-11-08 03:12:51.620",
"CreatedBy": "dattdhe140517@fpt.edu.vn",
@tranduydat
tranduydat / update-alternatives-java.sh
Created August 14, 2022 15:55
Update alternatives java
update-alternatives --install "/usr/bin/java" "java" "/usr/lib/jvm/zulu8.64.0.19-ca-jdk8.0.345-linux_x64/bin/java" 1
update-alternatives --install "/usr/bin/javac" "javac" "/usr/lib/jvm/zulu8.64.0.19-ca-jdk8.0.345-linux_x64/bin/javac" 1
update-alternatives --install "/usr/bin/jps" "jps" "/usr/lib/jvm/zulu8.64.0.19-ca-jdk8.0.345-linux_x64/bin/jps" 1
@tranduydat
tranduydat / auto-unsub.js
Created August 14, 2022 02:37
Auto unsubscribe all your Youtube channels
/**
* Youtube bulk unsubsribe fn.
* Wrapping this in an IIFE for browser compatibility.
*/
(async function iife() {
@tranduydat
tranduydat / auto-curl-logged-in.sh
Last active August 9, 2022 23:41
Auto run curl when a user logged in Linux
#!/bin/bash
# Append it in `/etc/bash.bashrc`
if [[ -n $SSH_CONNECTION ]] ; then
curl "https://HOST/message?token=XXX" -F "title=user:$USER logged -> $(cat /proc/sys/kernel/hostname)" -F "message=IP: $(who am i| awk -F'[()]' '{print $2}'), at: $(date)" -F "priority=9" > /dev/null
fi