Created
April 4, 2022 12:53
-
-
Save yougg/55bfd0e1c464373733e3cd808d97bf41 to your computer and use it in GitHub Desktop.
Command Note
Windows
查看进程环境变量PowerShell
(Get-Process -id %PID%).StartInfo.EnvironmentVariables
挂载/卸载分区
:: 查看分区信息
mountvol /?
:: 卸载分区
mountvol D: /D
:: 挂载分区
mountvol D: \\?\Volume{e316bd82-2441-11e5-9656-d6d12ffbbef0}
MingW配置/etc/profile
export PS1='\e[35;40m[\w]\e[0m\$ '
alias clear=clsb
alias reset=clsb
alias ls='/bin/ls --color=auto'
alias l='ls -AlF'
alias vi=vim
创建服务
sc create xxxxx type= "own" start= "auto" error= "normal" binPath= "D:\xxxxx.exe" tag= "no" depend= "RpcSs" DisplayName= "xxxxx" obj= "LocalSystem"
sc delete xxxxx
编程语言
Go
单元测试
盖率报告
go test -cover -coverprofile=cover.out -covermode=count
go tool cover -html cover.out -o cover.html
测试包
# 测试当前包
go test .
# go test会在GOROOT和GOPATH下查找这个包并执行包的测试
go test fmt
# 测试整个包
go test github.com/yougg/pool/...
静态链接
引用了net
包的程序, 编译时默认会动态链接
CGO_ENABLED=0 go build -installsuffix cgo yourcode.go
# 首先需要静态链接标准库中的net包
go install -tags netgo -a -v std
# 然后再编译自己的程序
CGO_ENABLED=0 go build yourcode.go
使用gccgo
静态编译引用了cgo
代码的程序
# static cgo
go build --ldflags '-extldflags "-static"' yourcode.go
# gccgo
go build -compiler gccgo --gccgoflags "-static" yourcode.go
Python
域名解析
#!/usr/bin/env python
#coding=utf8
import socket
import traceback
def resolv(url):
try:
while True:
socket.getaddrinfo(url, 80, 0, socket.SOCK_STREAM)
s = socket.socket()
s.connect((url, 80))
s.close()
except Exception as e:
print "Exception: %s\n" % e
traceback.print_exc()
resolv("domain.example.com")
Tool/Software/Middleware
MySQL
启用用户远程连接权限
grant all privileges on *.* to ${username}@${IP} identified by '${pwd}' with grant option;
flush privileges;
超级权限
grant super on *.* to 'my_user'@'localhost';
revoke super on *.* from 'my_user'@'localhost';
连接数据库
mysql -h ${IP} -P ${Port} -D ${database} -u ${user} -p${pwd}
本地MySQL调试
docker run -d -p 3306:3306 -e MYSQL_ROOT_PASSWORD=pa55w0rd --name DB mysql
docker exec -it DB bash
mysql -u root -ppa55w0rd
Docker
从镜像复制文件到其他镜像
COPY --from=ochinchina/supervisord:latest /usr/local/bin/supervisord /usr/local/bin/supervisord
列出镜像ID、摘要
docker images -f=reference='registry.example.com/*/*' --format "table {{.Repository}}:{{.Tag}}\t{{.Digest}}\t{{.CreatedSince}}"
docker image ls --format "table {{.Repository}}:{{.Tag}}\t{{.Digest}}\t{{.CreatedSince}}" registry.example.com/group*/*
docker image ls --format "{{.Repository}}:{{.Tag}}" registry.example.com/group*/*
IDE/Editor
编译Webkit版本的LietIDE
sudo apt install qt4-qmake libqt4-dev libqtwebkit-dev
go get github.com/visualfc/gotools
cd ${SRC}/liteide/build/
chmod +x build_linux_qt4_webkit.sh
./build_linux_qt4_webkit.sh
cp -rf liteide ~/
Emacs Shortcut
Git
切换远程仓库路径
git remote set-url origin https://github.com/user/FORK.git
添加子模块
cd parent_project
git submodule add https://github.com/username/subproject.git external/src
git submodule update --init --recursive external/src
cd external/src
git checkout -b develop origin/develop
cd ..
git add .
git commit -m 'Add submodule'
git push
同步子模块
git submodule update --init --force --recursive
删除子模块
- Delete the relevant section from the
.gitmodules
file.
git config -f .gitmodules --remove-section submodule.src
Stage the .gitmodules
changes git add .gitmodules
- Delete the relevant section from
.git/config
.
git config --remove-section submodule.src
- Delete submodule and folder
git rm --cached path_to_submodule
rm -rf .git/modules/path_to_submodule
git commit -m "Removed submodule <name>"
- Delete the now untracked submodule files
rm -rf path_to_submodule
git克隆保存用户/密码
git clone http://username:[email protected]/user/project.git
git指定提交时的作者和邮箱
GIT_AUTHOR_NAME="some one" GIT_AUTHOR_EMAIL="[email protected]" GIT_COMMITTER_NAME="some one" GIT_COMMITTER_EMAIL="[email protected]" git commit -m 'message'
git push -f --set-upstream origin master
配置git diff使用vimdiff
git config --global diff.tool vimdiff
git config --global difftool.prompt false
git config --global alias.d difftool
使用方式
git difftool
git d
如果执行报错
Can't locate Error.pm in @inc ......
则执行如下方式后再操作
cpan Error.pm
或者
sudo perl -MCPAN -e 'install Error'
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Linux
查看进程环境变量
查看进程网络连接
生成随机复杂密码
生成数字序列
seq -f "%03.f" 9 12
强制关机
重设登陆失败重试次数
设置普通用户定时任务
查看网线连接状态
上传文件
禁止ssh连接超时
客户端修改
/etc/ssh/ssh_config
或者~/.ssh/config
服务端修改
/etc/ssh/sshd_config
重启ssh服务
重置只读变量
密钥格式pkcs8转换为pkcs1
压缩包加密
抓包网卡流量
查看shell所有颜色
shell显示循环滚动字符