Useful stuffs
Useful Websites
Website SEO
Pagespeed Insight (https://pagespeed.web.dev/): Tool đánh giá chỉ ra vấn đề website đang gặp phải.
Google Search Console (https://search.google.com/): Tool theo dõi performance và ranking website. Xem các url nào đã được đánh index.
Study
Libgen (https://www.libgen.is/): Download sách free
Scihub (https://www.sci-hub.se/): Download paper và article free
Utility
Google Contacts (https://contacts.google.com/): Quản lý danh bạ Google, sync contact giữa các thiết bị.
Google Calendar (https://calendar.google.com/): Quản lý lịch. Có thể bật gợi nhắc ngày sinh nhật từ Google Contacts.
Codebeautify highlighter (https://codebeautify.org/code-highlighter): Online syntax highlighter
DBDiagram (https://dbdiagram.io/): Giúp drawn database. Có thể import file MySQL và export lệnh tạo MySQL. Mình dùng để vẽ database tự động khi import file MySQL và sửa lại lệnh tạo table khi thay đổi cấu trúc database.
Google Gemini (https://gemini.google.com/app): Google Chatbot. Trả lời khá OK. Có thể đưa nhiều link đọc tham khảo.
Jira Atlassian (https://www.atlassian.com/software/jira): Kanban Board. Mình dùng để note việc cần làm theo queue.
Useful commands
Script cài MySQL
sudo wget https://repo.mysql.com/mysql-apt-config_0.8.29-1_all.deb
sudo dpkg -i mysql-apt-config_0.8.29-1_all.deb
sudo apt-get update
sudo apt-get install mysql-server -y
sudo rm mysql-apt-config_0.8.29-1_all.debDump MySQL databases
mysqldump -u root -p --all-databases > all_data.sqlLoad MySQL databases
mysql -u root -p < all_data.sqlTạo ssh key
ssh-keygenRemove known key from IP SSH
ssh-keygen -R <host>Liệt kê các service đang chạy Linux
systemctl --type=service --state=runningLiệt kê toàn bộ process đang chạy Linux
ps -ATạo cert thủ công certbot
certbot certonly --manual --preferred-challenges=dnsFirewallcmd Command
firewall-cmd --list-all
firewall-cmd --zone=public --add-port=80/tcp --permanent
firewall-cmd --reload
firewall-cmd --zone=public --remove-port=80/tcp --permanent
firewall-cmd --list-portsGit Command
git checkout -b <branch-name>
git push origin -u <branch-name>SSH Port forwarding
ssh -L <local-port>:<remote-host>:<remote-port> <user-name>@<host-name>Tar command
tar -cvf <archive-name.tar> folder-name/ #c - create, v - verbose, f - fileMongoDB Command
mongosh "mongodb://<user-name>:<password>@localhost:27017" # Connect to DB
use <db-name> # Use DB
db.<collection-name>.find() # Show all data in collection
db.<collection-name>.drop() # Drop collection
use admin
db.auth("username", "password") # Authenticate
db.<collection-name>.find({<field-name>: <value>}) # Show data with condition
db.<collection-name>.insertOne({<field-name>: <value>}) # Insert data
db.<collection-name>.updateOne({<field-name>: <value>}, {$set: {<field-name>: <value>}}) # Update data
db.<collection-name>.deleteOne({<field-name>: <value>}) # Delete data
mongodump --db <db-name> --username <user-name> --password <password> --authenticationDatabase=admin # Backup DB
mongorestore --db <db-name> --username <user-name> --password <password> --authenticationDatabase=admin <path-to-backup> # Restore DBImport CSV to MongoDB
Prepare Your CSV File
The CSV file have headers, for example:
name,age,city
Alice,25,New York
Bob,30,San Francisco
Charlie,28,Los AngelesLet's assume the file is named data.csv.
Import Data with mongoimport
Run the command:
mongoimport --uri="mongodb://localhost:27017" --db mydatabase --collection users --type csv --file data.csv --headerlineExplanation:
--uri="mongodb://localhost:27017": Connects to MongoDB locally.--db mydatabase: Specifies the database.--collection users: Defines the collection to import into.--type csv: Specifies the file type.--file data.csv: Points to the CSV file.--headerline: Uses the first line as field names (headers).
Verify the Import
Open MongoDB shell:
mongoshCheck your imported data:
use mydatabase
db.users.find().pretty()Curl Flags
| Flag | Description |
|---|---|
-X / --request | Specify the HTTP method (e.g., GET, POST, PUT, DELETE). |
-d / --data | Send data in a POST request. |
-H / --header | Pass custom headers with the request. |
-o / --output | Save the response to a file. |
-O | Save the response to a file using the remote name. |
-L / --location | Follow redirects. |
-i / --include | Include HTTP response headers in the output. |
-I | Fetch the headers only (like a HEAD request). |
-s / --silent | Silent mode (no progress bar or error messages). |
-S / --show-error | Show error messages when -s is used. |
-f / --fail | Fail silently (no output) on HTTP errors. |
-u / --user | Specify user credentials for authentication. |
-k / --insecure | Allow connections to SSL sites without certificates. |
Utility Script
readlink <pod-name> # follow the symbolic link and see where it point
> <file-name> # Delete all content of a file
wc -l <file-name> # Count number of lines in a file
md5sum $<file-name> # Checksum of a file on Linux
certutil -hashfile <file-name> MD5 # Checksum of a file on WindowsMost Used App
Terminus (https://termius.com/): SSH Terminal. Hỗ trợ nhiều OS
Tính năng:- Nhóm server lại quản lý
- SSH theo user
- Split screen
- Drag item từ các server với nhau
- Thay key ssh nếu thấy host thay đổi
Visual Studio Code (https://code.visualstudio.com): IDE phổ biến nhất
Telegram (https://desktop.telegram.org): App nhắn tin
Useful Keyboard Combination MacOS
Ctrl A : Về đầu dòng
Ctrl Space ~ : Đổi input source
Click 3 lần: Bôi đen dòng
Ctrl Click dùng 1 ngón : Right click (Không dùng được khi chạy 1 số chương trình)
Click dùng 2 ngón : Right click
Microsoft Word
Ctrl + : Insert equation
Ctrl I : In nghiêng phần text trong trường hợp đang bôi đen text, bật tắt in nghiêng trong trường hợp không bôi đen
Vscode
Ctrl Shift ~ : Tạo terminal mới
Command P : Mở file
Command Shift P : Mở Command Palette
Command Shift N : Mở cửa sổ VSCode mới
Command P : Tìm file
Command W : Đóng file đang mở
Option ↑ : Di chuyển code giữa các dòng
Command ← : Về đầu dòng
Command \ : Split Terminal
Check diff giữa 2 file- Chuột phải vào tên file1, chọn Select for Compare
- Chuột phải vào tên file2, chọn Compare with Selected
Nano text editor
Ctrl W : Text search
Vi text editor
Basic movement
h→ Move leftl→ Move rightj→ Move downk→ Move up0→ Move to the beginning of the line^→ Move to the first non-blank character of the line$→ Move to the end of the linew→ Move to the beginning of the next worde→ Move to the end of the current/next wordb→ Move to the beginning of the previous wordgg→ Move to the beginning of the fileG→ Move to the end of the file:n→ Move to linen(e.g.,:10goes to line 10)
Search and Replace
/pattern→ Search forpatternforward?pattern→ Search forpatternbackwardn→ Repeat the last search forwardN→ Repeat the last search backward:%s/old/new/g→ Replace all occurrences ofoldwithnewin the file:s/old/new/→ Replace the first occurrence ofoldwithnewin the current line
File Operations
:w→ Save (write) the file:wqorZZ→ Save and quit:q→ Quit (fails if unsaved changes):q!→ Quit without saving changes:e filename→ Openfilename:r filename→ Read the contents offilenameinto the current file:n→ Open the next file in the argument list:prev→ Open the previous file in the argument list
Miscellaneous
.→ Repeat the last command:%!cmd→ Run the file through an external command (e.g.,:%!sortto sort the file)Ctrl-g→ Show the file name and current line/column information:set number→ Show line numbers:set nonumber→ Hide line numbers:x,y→ Delete from line x to line y (including y)