This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
parse_git_branch() { | |
git branch 2> /dev/null | sed -e '/^[^*]/d' -e 's/* \(.*\)/ (\1)/' | |
} | |
netns_name() { | |
str=`ip netns identify $$` | |
[[ "$str" != "" ]] && echo "\033[1;35m[$str]\033[0m " && return | |
} | |
export PS1="$(netns_name)\u@\h:\[\033[32m\]\w\[\033[33m\]\$(parse_git_branch)\[\033[00m\]\$ " |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
ssh -L 4000:192.168.56.102:80 127.0.0.1 | |
# 4000 = Remote port | |
# 192.168.50.102 = Remote IP | |
# 80 = Local port | |
# 127.0.0.1 = Local IP | |
What this means? | |
Whatever packets come to 127.0.0.1:80 forward it to 192.168.56.102:4000 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/bash | |
OUTFILE=perf_out.txt | |
rm perf*.txt | |
for((i=0;i<4;i++)); do | |
#timeout -s SIGINT 12 perf stat -e dTLB-loads -e cs,cycles,instructions -D 2000 -a -o perf$i.txt | |
#timeout -s SIGINT 12 perf stat -e dTLB-stores -e cs,cycles,instructions -D 2000 -a -o perf$i.txt | |
#timeout -s SIGINT 12 perf stat -e dTLB-load-misses,dTLB-store-misses -e cs,cycles,instructions -D 2000 -a -o perf$i.txt | |
timeout -s SIGINT 12 perf stat -e cs,cycles,instructions -D 2000 -a -o perf$i.txt |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
usage() | |
{ | |
echo "Usage: $0 <options>" | |
} | |
parse_cmdargs() | |
{ | |
# -s | --server is the short and long option to be parsed | |
# Remember to specify : in cases where argument is nessary both in short and long options | |
OPTS=`getopt -o s: --long server:xyz: -n 'parse-options' -- "$@"` |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/bash | |
set -E | |
trap 'echo Failed at $lineno COMMAND: $BASH_COMMAND && exit 1' ERR | |
SRV_IP="192.168.106.2" | |
SP_IP="192.168.105.2" | |
echo 1 > /proc/sys/net/ipv4/ip_forward | |
iptables -F |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/bash | |
[[ "`whoami`" != "root" ]] && echo "Got to be root. Use sudo." && exit | |
export LOG_LEVEL=DBG | |
export OVERRIDE_IP=192.168.100.100 | |
./server_proxy & | |
sleep 1 | |
sysctl -w net.ipv4.ip_forward=1 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Verifying my Blockstack ID is secured with the address 1FhDaxSAbL7yf78wAgtZshqvt7EJsC4mfx https://explorer.blockstack.org/address/1FhDaxSAbL7yf78wAgtZshqvt7EJsC4mfx |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
--- | |
Language: Cpp | |
# BasedOnStyle: LLVM-Modified-by-RJ | |
AccessModifierOffset: -2 | |
AlignAfterOpenBracket: DontAlign | |
AlignConsecutiveAssignments: true | |
AlignConsecutiveDeclarations: false | |
AlignEscapedNewlines: Right | |
AlignOperands: true | |
AlignTrailingComments: true |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Iptables ip/port range spec: | |
Multiple individual ports: | |
iptables -t mangle -A OUTPUT -p udp --match multiport --dports 110,143,993,955 -j MARK --set-mark 13 | |
Port Range: | |
iptables -t mangle -A OUTPUT -p udp --match multiport --dports 1024:3000 -j MARK --set-mark 13 | |
Multiple Port ranges: | |
iptables -t mangle -A OUTPUT -p udp --match multiport --dports 1000:2000,3000:4000 -j MARK --set-mark 13 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/bash | |
#socat examples: | |
#recv msgs on udp port 60K and print to stdout. recv input on stdin and sendto connected socket. | |
socat - UDP4-LISTEN:60000 | |
socat - UDP4-SENDTO:192.168.106.2:60000 | |
# send contents of t.c to multiple TCP4 servers | |
socat GOPEN:t.c - | tee >(socat - tcp4:127.0.0.1:12345) >(socat - tcp4:127.0.0.1:33455) > /dev/null |
OlderNewer