Skip to content

Instantly share code, notes, and snippets.

View zhangchenchen's full-sized avatar

pekingzcc zhangchenchen

View GitHub Profile
## remote forward ##
iptables -t nat -A PREROUTING -d LocalIP -p tcp --dport PortNumber -j DNAT --to-destination DestinationIP:Port
iptables -t nat -A POSTROUTING -d estinationIP -p tcp --dport PortNumber -j SNAT --to-source LocalIP
## local forward ##
iptables -t nat -A PREROUTING -p tcp --dport 80 -j REDIRECT --to-ports 8080
@zhangchenchen
zhangchenchen / salt command to ssh login with private key
Last active June 14, 2017 04:28
salt command to ssh login with private key
salt '*' cmd.run 'mkdir ~/.ssh && chmod 700 ~/.ssh'
salt-cp '*' ~/.ssh/id_rsa.pub ~/.ssh/temp.pub
salt '*' cmd.run 'cat ~/.ssh/temp.pub >> ~/.ssh/authorized_keys && rm -f ~/.ssh/temp.pub'
@zhangchenchen
zhangchenchen / tmux-cheatsheet.markdown
Last active June 15, 2017 08:48 — forked from MohamedAlaa/tmux-cheatsheet.markdown
tmux shortcuts & cheatsheet

tmux shortcuts & cheatsheet

start new:

tmux

start new with session name:

tmux new -s myname
@zhangchenchen
zhangchenchen / substitute with vim
Created November 8, 2016 09:09
substitute with vim
:s/vivian/sky/ 替换当前行第一个 vivian 为 sky
  :s/vivian/sky/g 替换当前行所有 vivian 为 sky
  :n,$s/vivian/sky/ 替换第 n 行开始到最后一行中每一行的第一个 vivian 为 sky
  :n,$s/vivian/sky/g 替换第 n 行开始到最后一行中每一行所有 vivian 为 sky
  n 为数字,若 n 为 .,表示从当前行开始到最后一行
@zhangchenchen
zhangchenchen / linux substitute string in all files
Last active November 8, 2016 01:54
substitute string in all files in linux
sed -i "s/oldString/newString/g" `grep oldString -rl /etc`
# -i substitute in place
@zhangchenchen
zhangchenchen / find all files containing specific text on Linux
Created November 8, 2016 01:12
find all files containing specific text on Linux
grep -rnw '/path/to/somewhere/' -e "pattern"
-r or -R is recursive,
-n is line number, and
-w stands match the whole word.
-l (lower-case L) can be added to just give the file name of matching files.
Along with these, --exclude or --include parameter could be used for efficient searching. Something like below:
grep --include=\*.{c,h} -rnw '/path/to/somewhere/' -e "pattern"
This will only search through the files which have .c or .h extensions.
@zhangchenchen
zhangchenchen / download & upload file with scp
Created October 13, 2016 02:07
download/upload file with scp
download file: scp test.py user@192.168.0.231:/e:/
download dir: scp -r /opt/test user@192.168.0.231:/e:/
upload file: scp user@192.168.0.231:/e:/test.py /opt/test
upload dir: scp -r user@192.168.0.231:/e:/test/ /opt/test
@zhangchenchen
zhangchenchen / python
Created August 29, 2016 10:13 — forked from 582033/python
多线程获取并验证代理
#!/usr/bin/env python
# -*- coding: utf-8 -*-
import sys, re
import requests
import Queue
import threading
class Proxy():
def __init__(self, proxy_url, target_url, ver_keyword, timeout):