Some tips and code snippets

Tổng hợp một số tips và code snippets có vẻ hữa ích
Skype
1. Italic - Bold - Stride
_italic_ *bold* ~stride~
2. Code
This will be {code}monospaced{code}
or Block Code
!! this is
code import
Google slide show
Thêm present
vào url để hiện slide show ở tab mới
Ví dụ: https://docs.google.com/presentation/d/<slide-id>/present
Ubuntu
1. Unzip Shift JS encode
unzip -O shift-jis <filename.zip>
2. Unclock root status file/folder
sudo chmod 777 <file-name>
sudo chmod -R 777 <folder-name>
3. Sửa lỗi Read-only khi Ubuntu truy cập vào phân vùng của Windows
Đây là do Windows 10. Windows 10 mặc định sẽ Hibernate khi Shutdown. Để tránh việc Hibernate:
- Restart thay vì Shutdown
- Cài đặt lại mặc định là Shutdown thay vì Hibernate, uncheck
Turn on fast startup
trongControl panel
->Power options
->Choose what the power buttons do
4. Cài đặt *.deb
package
sudo sudo dpkg -i <file_name.deb>
5. Wireguard-BPN
First edit .conf
file to use 1.1.1.1
host
sudo gedit /etc/wireguard/wg0.conf
Start wireguard
sudo wg-quick up wg0
View wireguard status
sudo wg
Stop wireguard
sudo wg-quick down wg0
Web dev
Nhấn Ctrl + F5
thay vì F5
để tải lại hết nội dung của trang web.
FFMPEG
1. GIF to WEBM
ffmpeg -f gif -i input_file.gif input_file.webm
2. Remove audio from video
ffmpeg -i input_file.webm -c copy -an output_file.webm
3. Resize video
ffmpeg -i input_file.webm -s 720x480 -c:a copy output_file.webm
Docker
1. Save-Load image
Save image to *.tar
file
sudo docker save -o <path-to-save.tar> <image_name>
Load image from *.tar
file
sudo docker load -i <path-to-save.tar>
2. Remove image
sudo docker rmi <ID_image>
3. Remove stopped container
sudo docker rm $(sudo docker ps -a -f status=exited -q)
4. Update docker image
sudo docker commit <container_name> <image:tag>
Git
1. Pull and Commit current local branch
Step-1. Stash your local changes:
git stash save "<Message>"
Step-2. Update the branch to the latest code
git pull
Step-3. List all saved stash
git stash list
Step-4. Merge your local changes into the latest code
git stash apply
or
git stash apply stash@{<stash_number>}
Step-5. Finally, commit and push your changes
git add
git commit
git push
Elastic Search
1. Start ElasticSearch
sudo systemctl start elasticsearch
2. Stop ElasticSearch
sudo systemctl stop elasticsearch
3. Show all index
curl -XGET 'localhost:9200/_cat/indices?v&pretty'
4. Delete index
curl -XDELETE 'localhost:9200/<index_name>?pretty'