linux:
openssl passwd -crypt 12345will generate different output every time but how to check the12345send from client whether is same as the server.xargsconvert stdout to argsls |xargs echo- press
c-vin vim enter visual block then do the multi select - linux redirect link1,link2,link3,link4
- use
who,lastto get all logined user curl -s https://raw.githubusercontent.com/sivel/speedtest-cli/master/speedtest.py | python -for testing network speedman -korapropostail -n 20 /var/log/nginx/error.logto find nginx problem.cat ~/.ssh/id_rsa.pub | ssh username@hostname ' mkdir -p .ssh && cat >>.ssh/authorized_keys'copy public key to serverauthorized_key.sudo chown -R group:user folderchange the folder user group.docker update --restart=no my-containerto update the running container flaggrep --color -R --exclude-dir=node_modules '\.js"\to findcurl -v -H "Accept: application/json" https://httpbin.org/getwill see the request header and bodycurl -s -I -v http://www.baidu.comsimple get request and response headerfind / -type d -name "*Chrome.app"find chromenpm-check -uto check npm package healthcurl http://www.vdberg.org/~richard/tcpping -o tcppingto download tcppingcat foo.c | sed '/^\s*#/d;/^\s*$/d' | wc -lto count-non-blank-lines-of-code-in-bashstty -ixonto enable XON/XOFF flow control then you can usectrl-sto reverse-reverse-i-searchfind . -type f -name '*.gz' -exec rm {} +to remove all file type endwith gzcurl cli.fyi/helpa++is unarysetw -g mode-keys vifor tmuxexport http_proxy='http://proxyServerSddress:proxyPort'finallyunset http_proxyecho 050100 | xxd -p -r | netcat -o out.txt {server} {port}test socks5 proxysocat tcp-l:7654,fork,reuseaddr tcp:27.122.57.247:7654 &socat UDP-LISTEN:7654,fork,reuseaddr dup:27.122.57.247:7654 &for port forwardcp /home/sample.txt{,-old}=>cp /home/sample.txt /home/sample.txt-oldxapropos "list directory"to recall commandcurl -o /dev/null -s -w 'Establish Connection: %{time_connect}s\nTTFB: %{time_starttransfer}s\nTotal: %{time_total}s\n' https://www.google.commtr='PATH=/usr/local/sbin:$PATH sudo mtr'export PATH=/opt/local/bin:/usr/local/Cellar/mtr/0.92/sbin/:$PATHenable mtr at mac..who | grep -v 'via mosh' | grep -oP '(?<=mosh \[)(\d+)(?=\])' | xargs killorkill pidof mosh-serverkill the mosh session belong to youps aux | grep "[f]nord"orps aux | grep -v grep | grep "fnord"orless -r output.txtto view termnial-style txtsudo du -a / 2>/dev/null | sort -n -r | head -n 20find big filesiptables-save |vi -to check the rule scriptiptables -A INPUT -s 192.168.1.100 -p icmp -j DROPoriptables -A INPUT -p icmp -j DROPwireshark -k -i <( ssh -l root IP-of-probe /usr/bin/tshark -i eth0 -w - port 53 )capture remote ssh network packagefind -type f -print0 2>/dev/null | xargs -0 -n 10 grep -i searchstring 2>/dev/nullRedirect standard error to /dev/nulldu -h -d 1 | sort -hrsee folder sizesh -x script [arg1 ...]bash -x script [arg1 ...]set -xset +xdebug script- you need confirm your
.sshfolder is accessible by user(you will get a key failed auth).chown -r owner-user:owner-group .sshfor change to file owner - replace str
grep -rl matchstring somedir/ | xargs sed -i 's/string1/string2/g'in OSXsed -i "" 's/str1/str2/g' cat 0021500492.json | python -m json.tool |lessfor view large json file.sudo add-apt-repository universethensudo apt-get install netcat-traditionalthensudo update-alternatives --config ncfinallySelect the option /bin/nc.traditionalcurl -s -v -X HEAD http://foo.com/bar/baz.pdf 2>&1 | grep '^< Last-Modified:'for query website upgrade timesocat tcp-l:4431,fork,reuseaddr tcp:152.32.191.48:4431 & socat UDP-LISTEN:4431,fork,reuseaddr dup:152.32.191.48:4431 &proxyiftop -n -N -f "host 112.64.175.162"filter the specified network trafficgrep -e "search_word" -rn foldershow the line number of fined fileecho $SHELLorps -p $$to determine current shell.ls -l node_modules/* | egrep "^l"output the softlinkfind / -name art 2>/dev/nullto skip the error output.curl ip.sb,curl ident.me,curl ip.cn%s/phrase to delete//gcdelete word in vim.apt-cache search keyword. ubuntunpm list --depth=0 2> >(grep -v "extraneous")npm list -signore error message.find ./ -type d -name "node_modules" -exec rm -r {} \;.docker build . -t application_name -f path_to_dockerfilegit ls-files | grep '\.py' | xargs wc -llist number of code line.find . -name '*.php' | xargs wc -l,wc -l **/*.tsx.npm view webpack versions --jsonls -l -sh,du -hfor file human readable sizesALL_PROXY=socks5://host:port brew updatebrew upgrade --cask chromedrivergrep " install " /var/log/dpkg.log*installed packages with installation datesshd -T | grep -E 'gatewayports|allowtcpforwarding'Trouble enabling GatewayPorts for Remote Port Forwarding over SSH- Debug iptables
uptime,last reboot,log show --predicate 'eventMessage contains "reboot"' --last 1htroubleshoot mac reboot issue.
iptables -t raw -A PREROUTING -p tcp --destination 192.168.0.0/24 --dport 80 -j TRACE
iptables -t raw -A OUTPUT -p tcp --destination 192.168.0.0/24 --dport 80 -j TRACE
cat /var/log/kern.log | grep 'TRACE:' crontab -l,crontab -ecat /proc/meminfo,free -gto check memory infosudo chown --reference ${DEST_DIR} -R ${DEST_DIR}/copied_dir,chmod --reference=file1 file2ssh -L local_port:remote_host:remote_port ssh_hostmake remote resource accessible in client.ssh -D local_port [email protected]as socks5 proxy provider.- list files size
du -sh * | sort -h|tail -n 20 - copy exclude
cp -rls -A |grep -E -v "@storybook|@nx|typescript|.cache|.bin|@nrwl|@babel|@jest"desition_folder - do the same above
rsync -av --progress sourcefolder /destinationfolder --exclude thefoldertoexclude --exclude anotherfoldertoexclude
git:
1. git show head~1:/path/to/file
2. git rev-list --all --remotes --pretty=oneline -- src/views/trade/other.vue get the file commit log in all history.
3. git config --system -l to check system check. Then git config --system --unset credential.helper to forget the credential . git config --global credential.helper store enable credentials storage git config --global core.ignorecase true.
4. git ls-files -z | xargs -0 -n1 -I{} -- git log -1 --format="%ai {}" {} | sort retrieve the last date of all files.
5. git diff origin/master > patch,git apply --check xxx.patch,git apply --status xxx.patch, git apply --revers patch to update branch.
6. git reset --hard HEAD^ or git reset --soft HEAD^ to undo a local commit .git revert HEAD then git push origin for remote update.
7. git config credential.helper cache for temporary cache your account infor git config --system --unset credential.helper.
8. git diff ..origin/dev|git apply apply the diff between remote dev to local current head in stage
9. git log --all --decorate --simplify-by-decoration --graph --all --date=relative try to figure the relationship between branch
10. git branch --contains --all $branchName show all branch(include remote) which contain current branch
11. git config --global core.fileMode false ignore.
12. git config --global alias.lg "log --color --graph --pretty=format:'%Cred%h%Creset -%C(yellow)%d%Creset %s %Cgreen(%cr) %C(bold blue)<%an>%Creset' --abbrev-commit".
13. git log origin/release..HEAD --graph --decorate --oneline show the different commit between branch.
14. gitk --all file will show the all history of the file git checkout -p give you a change to checkout each hun individually
15. unable to access 'https://github.com/xxxx/xxx.git': Failed to connect to 127.0.0.1 port 8087: Connection refused may related to system http proxy env|grep -i proxy.
16. git show-ref --abbrev=7 --tags show tag commit id.
17. cat .git/refs/tags/* show git tag.
18. npm outdated -g npm ls --depth=1 npm la npm show package version npm search npm completion >> ~/.bashrc
19. use git patch cherry pick only one file git diff <branch>..<other-branch> --<fileName> |git apply
20. git show branch:file git merge branch --no-commit --no-ff to ignore no-diff merge .
21. git ignore case default.
22. git apply --3way patchFile.patch Typical fail case applies as much of the patch as it can, and leaves you with conflicts to work out in git however you normally do so.
23. git push --follow-tags only push tag created by git tag -a <tagname> -m '<message>',git push origin tagname push the specified tag.
24. git diff --name-only release-1.1.19..release-1.1.31 -- '*.tsx' -- '*.ts' -- '*.less' show the different between two commit.
25. git fetch --prune --prune-tags origin synchron remote tag with local
26. git push origin branchA:branchB push the nickname.
27. git checkout master and git merge <commit hash> .
28. git log head..origin/master --name-only --no-merges .
29. git merge --no-comit --no-ff branch & git merge --abort to test the merge status.
30. git stash push --keep-index -u stash un-staged,untracked. git stash save --patch.
31. fast-forward.
32. git reset move back the history, git revert add a commit.
33. git add --interactive.
34. git log -u -L <upperLimit>,<lowerLimit>:<path_to_filename> specific the line number
35. git log --all --diff-filter=D --sumary. show the deleted file. git checkout <SHA>^ -- /path/to/file. restore te file
36. git branch --sort=-committerdate descend, git brand --sort=committerdate asecend. git branch -vv.
37. git rebase -i --ignore-date update the date to current time.
38. git config --global core.editor "vim"
39. git log --pretty=format:"%h%x09%an%x09%ad%x09%s" --graph --all --decorate --date=relative --abbrev-commit %h:hash, %x09:tab,%an:author_name,%ad:author_date,%s:subject
40. git merge --no-commit --no-ff $BRANCH test before merge than git merge --continue
VSC:
1. ctrl+D add current selection to match . Ctrl+Shift+D + add all selection .
2. ctrl+shirft+O show symbols (quick variable,method quick goto).
3. ctrl+option+P show next problem.
VIM:
1. ma set mark a, 'a,`a jump to mark a. :marks show the mark list.
2. ctr+z to put vim background, bring it back by fg
mis:
http authcontainsbasic auth,digest auth.return401when auth fail.- simple http get request
GET / HTTP/1.1/r/nHost: www.baidu.com/r/n/r/n,blog - tcp allows for retransimmsion of lst packets gitbook
- get script error when cors fundebug
- image error do not trigger window.onerror, you have to listen for them specifically mdn
- Triggering built-in events
- Synchronous JavaScript pauses parsing of the DOM delay the fired of DOMContentLoaded mdn
thisis different when use in onClick and addEventListener('click') mdn- use
db.things.find( { ln : { $exists : true } } );to select by the given key nedb - use
https://api.weixin.qq.com/cgi-bin/token?grant_type=client_credential&appid=APPID&secret=APPSECRETto get weixin apiaccess_tokenblog - 30-seconds-of-code了解下git
- Greedy
/.+/match as many as possible and lazy/.+?/as few as possible tutorial encodeURIComponentwill encode=,so encodevaluenotkey=valuewhen encode path- server return
304when requestIf-Modified-Since<= responseLast-Modifiedand requestIf-None-Match==responseETag Promise.reject(1).then(console.log).catch(console.error).then(3=>console.info(3))- X-Forwarded-For, IP Transparency with nginx
- [os x locale is not set UTF-8]
localeexport LC_ALL=en_US.UTF-8 export LANG=en_US.UTF-8or add~/.bash_profilethensource ~/.bash_profile w !sudo tee %:w #write a file!sudo #call shell sudo commandtee # the output of vi/vim% #trigger the use of current fielname- set up a clean utf8 linux
- override
pushStateand listener for onPopState can watch the url history change. url echo 0 >/proc/sys/net/ipv4/icmp_echo_ignore_allfor temp allow or appendnet.ipv4.icmp_echo_ignore_all=1to/etc/sysctl.conffor save to disk- Data URLS, URLs prefixed with the
data:scheme,allow content creators to embed small files inline in documents. mdn require,the path is relative to that source file(NOT root directory),fs,the pat is relative toprocess.cwd()(NOT that source file) .You should usepath.resolve(__dirname,'../other/module.js')- If the request method is
GETorHEAD,XMLHttpRequestwill ignore request body . requirevsimportlink204 No Contentis meant to say there is no body to returncache:http://www.baidu.comto see the website cached by google in chrome- babel-plugin-component to require on demand for optimizing code size.
Accept-Language: fr-CH, fr;q=0.9, en;q=0.8, de;q=0.7, *;q=0.5// Multiple types, weighted with the quality value syntax:- The old-style backquotes ` ` do treat backslashes and nesting a bit different. The new-style $() interprets everything in between ( ) as a command.
python -m SimpleHTTPServer <port_number>python3 -m http.serverrsync -av --delete source_folder destination_foldergit fetch --prune --prune-tags,git log --oneline --name-status --grep='Searched phrase'git log commit-id-before commit-id --statshow the lines added/changed/deleted. (git diff --numstat HEAD~).SELECT db_name()get current database name.curl -k -O -L https://npmjs.org/install.shsh install.shinstall nodejs.^x.y.zstands for version betweenx.y.zand next major .~x.y.zmeans betweenx.y.zand next minor.kill $(lsof -ti:3000,3001)kill ports in mac.time nmap -p 22 portquiz.nettest specified port.time nmap portquiz.netpopular port.time nmap -p- portquiz.net | grep -i openall outgoing port.(Very slow).rectangle,alttab,Xnip,keyCastrtool in mac.- mute the soud of
tabin window terminal - remote send c when double click.
- (fix dock always cover the bottom of application)[https://appuals.com/how-to-fix-mac-dock-getting-stuck/] just
killall Dock. open -e ~/.bashrcmac.npx kill-port 8080kill portArray.from(Array(2), () => new Array(4))create multi dimension arraypm2 startupto setup auto restart strategy.'ThisIsASlug'.replace(/(\w)(?=[/A-Z])/g,'$1 ')split camelCase.sudo dscacheutil -flushcache; sudo killall -HUP mDNSResponderclean mac DNS cache.-scheme:chrome-extension -scheme:dataorscheme:httpsto filter out extension request in chronium based browser-scheme:chrome-extension -scheme:dataorscheme:httpsto filter noise request in chrome network tabgit commit --fixup=HEADandGIT_SEQUENCE_EDITOR=true git rebase -i --autosquash HEAD~2aftergit addto quick fixup the commit.lpstat -sshow mac printer IP- Route different traffic through different network interfaces in windows
route add 10.183.148.0 mask 255.255.255.0 10.57.175.79 declare -f funcandtype functo describe and find the terminal function
kube:
kubectl logs -l app=elasticsearch -n namespaceget all pods log from namspacedocker kill $(docker ps -q)stop all docker containers.docker exec -ti container_name /bin/bashordocker exec -ti container_name shdocker container ls|grep "yarn start"|awk '{print $1}'|xargs docker container stopkubectl get pods -n $namespaceshow all running pod under namespace.kubectl exec --stdin --tty $podname -n $namespace -- /bin/bashrun the shell environment.helm search repo $name,helm list -n $namespacedocker container ls -a |grep docker-entry|awk '{print $1}'|xargs docker container rmdocker rmi $(docker images --filter "dangling=true" -q --no-trunckubectl describe ingress $container,kubectl describe configmap $containerkubectl exec --stdin --tty $pod -n $namespace -- /bin/shkubectl logs podkubectl config get-contexts,kubectl config use-context $context,kubectl config set-context --current --namespace=$namespacekubectl port-forward pod 80:127.0.0.1:8888docker ps -aq --filter "ancestor=postgres:15"|xargs -r docker stop