收集开发相关的技巧,比如中国需要的镜像服务等。
镜像服务🔗
Github🔗
Fastgit - Github 国内镜像
Download: https://download.fastgit.org/org/repo/xxx
Clone git clone https://github.com/org/repo
Clone with ssh git clone git@ssh.fastgit.org:theowenyoung/gatsby-theme-primer-wiki.git
Rust🔗
- rsproxy cn - rust 国内镜像
Docker🔗
- 阿里云公网:
https://registry.cn-hangzhou.aliyuncs.com腾讯云: https://mirror.ccs.tencentyun.comsudo vim /etc/docker/daemon.json
{ "registry-mirrors": ["https://mirror.ccs.tencentyun.com"] }sudo systemctl restart docker解决方案🔗
Bash Tips🔗
Get bash script parent dir absolute path🔗
workspace="$( cd -- "$( dirname -- "${BASH_SOURCE[0]}" )/../" &> /dev/null && pwd )"Get bash script dir path🔗
workspace="$( cd -- "$( dirname -- "${BASH_SOURCE[0]}" )" &> /dev/null && pwd )"Bash Dotenv🔗
导出.env 文件到当前执行环境
set -o allexport; source .env; set +o allexportDeno Tips🔗
Dirname🔗
const __dirname = new URL(".", import.meta.url).pathname;Docker Tips🔗
Docker compose exec bin🔗
docker-compose exec service-name /bin/shStop All contains and remove🔗
sudo docker stop $(sudo docker ps -a -q)sudo docker rm $(sudo docker ps -a -q)Clean all🔗
sudo docker system prune --volumessudo docker image prune -aGit Tips🔗
Generate ssh key🔗
Reference: Generating a new SSH key and adding it to the ssh-agent - GitHub Docs
ssh-keygen -t ed25519 -C "your_email@example.com"# Start the ssh-agent in the background.eval "$(ssh-agent -s)"# Add your SSH private key to the ssh-agentssh-add ~/.ssh/id_ed25519Add ssh key to Github:
cat .ssh/id_ed25519.pub获取首次提交时间🔗
提交消息的模版🔗
- Git Semantic Commit Messages - git 语义化提交消息模版
合并上游的时候不弹出确认框🔗
git pull upstream main --commit --no-edit对所有的冲突上游的更新🔗
git checkout --theirs .首次更新子 repo submodule🔗
git submodule update --init --recursiveLater
git submodule update --recursiveGitignore 忽略所有,除了文件夹🔗
folder/*!folder/.gitkeepGo Template Tips🔗
- Parent Variable,
{{$.XX}}URL encode, urlquery "https://test.com"开源许可证 License🔗
- Unlicense - 无版权许可证,公有领域许可证fsl -
Coopcycle - 商业不友好开源许可Prosperity Public License - 本许可证允许您免费将此软件用于非商业目的并分享,以及在商业目的下试用 30 天。By 如何选择开源许可证?
Linux Common Commands🔗
View current system info🔗
lsb_release -aOutput:
Distributor ID: DebianDescription: Debian GNU/Linux 10 (buster)Release: 10Codename: busterView all users🔗
cat /etc/passwd | grep -v nologin|grep -v halt|grep -v shutdown|awk -F":" '{ print $1"|"$3"|"$4 }'|moreGet Publish IP🔗
hostname -IChange user group🔗
usermod -g groupname usernameGet user group🔗
id -g -nRemove apt ppa🔗
sudo add-apt-repository --remove ppa:qbittorrent-team/qbittorrent-stableGet current shell🔗
echo "$SHELL"Get current cpu arch🔗
archor
dpkg --print-architectureUnzip tar.gz🔗
tar -xf x.tar.gzSee also here
Tar to specific directory
tar -xf x.tar.gz -C ./xxxUnzip .gz🔗
gzip -d file.gzStdout to File🔗
command &> fileOverwrite:
command >| file.txt 2>&1Download/Upload file by SSH SCP🔗
Download to local:
scp root@ip:/path ~/DownloadsRemove node_modules🔗
find . -name 'node_modules' -type d -prune -exec rm -rf '{}' +Remove target🔗
find . -name 'target' -type d -prune -exec rm -rf '{}' +Find and replace string🔗
sed -i 's/old-text/new-text/g' input.txtSoft Link🔗
ln -s source_file target_fileCreate User🔗
useradd -m USERNAMENote: with home directory
Get all shells🔗
cat /etc/shellsLast n lines in file🔗
tail -3 file.txtLinux find a biggest directory in ./🔗
sudo du -a ./ 2>/dev/null | sort -n -r | head -n 20Linux find a biggest file in ./🔗
find ./ -type f -printf '%s %p\n' | sort -nr | head -10Linux view systemctl log:🔗
sudo journalctl -f -u service-name.serviceSee who connect with Me🔗
See: here
ss -tun state connectedSort by ip connect with 443🔗
netstat -tn 2>/dev/null | grep -E '\s[0-9.]+:443\s' | awk '{print $5}' | cut -d : -f 1 | sort | uniq -c | sort -nrBan🔗
See here
sudo systemctl status firewalldsudo firewall-cmd --permanent --add-rich-rule="rule family='ipv4' source address='202.61.254.136' reject"sudo firewall-cmd --reloadsudo firewall-cmd --list-allKill tcp🔗
tcpkill host <ip>Nodejs Tips🔗
Delete node_modules folder recursively from a specified path using command line🔗
Delete node_modules folder recursively from a specified path using command line - Stack Overflow
find . -name 'node_modules' -type d -prune -exec rm -rf '{}' +Get NPM Token🔗
npm token createCheck NPM modules updates🔗
npx npm-check-updatesUpdate to the latest version:
npx npm-check-updates -uPostgresql Tips🔗
0. Enter psql🔗
psqlShow all databases🔗
\lEnter Database🔗
\c database_nameShow all Tables🔗
\dShow Table structure🔗
\d table_namePretty print table🔗
\x onAlter table🔗
See https://www.postgresql.org/docs/current/sql-altertable.html
Upsert🔗
Export Schema🔗
pg_dump database_name -s --no-owner > schema.sqlExport Only data🔗
pg_dump database_name -a --no-owner > data.sqlDelete or Drop or Remove Database🔗
psqldrop database database_name;Create Database🔗
psqlCREATE DATABASE name;Import Database🔗
psql database_name < data.sqlCSS🔗
Smart word break in CSS🔗
body { overflow-wrap: break-word; word-wrap: break-word; -ms-word-break: break-all; word-break: break-word; -ms-hyphens: auto; -moz-hyphens: auto; -webkit-hyphens: auto; hyphens: auto;}Vim Tips🔗
Resources🔗
- Vim online exercises - help you master vim with interactive exercises.
Tips🔗
Delete all words: 1,$d
Current line end: $
Replace all string: s/string/replace_string/g
VS Code Tips🔗
Open command palette: ⇧⌘P🔗
Select current line: cmd+L🔗
Quick Switch Windows🔗
Also see here
Added the following shortcut to keybindings.json
{ "key": "alt+tab", "command": "workbench.action.quickSwitchWindow"}Read more:🔗
- Visual Studio Code Tips and TricksGitHub - microsoft/vscode-tips-and-tricks: Collection of helpful tips and tricks for VS Code.
Robots.txt🔗
# https://www.robotstxt.org/robotstxt.htmlUser-agent: *Disallow: /Systemd🔗
stay active after your session is killed🔗
loginctl <userid> enable-linger
