This file contains hidden or 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 | |
trap byefunc EXIT | |
byefunc() | |
{ | |
[[ "$NO_CPUINFO" == "1" ]] && return | |
lscpu | |
} |
This file contains hidden or 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 hidden or 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 hidden or 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 hidden or 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
#include <stdio.h> | |
#include <string.h> | |
#include <stdint.h> | |
#include <sys/time.h> | |
/*---------------------------------------------------------------------------*/ | |
/* CITT CRC16 polynomial ^16 + ^12 + ^5 + 1 */ | |
/*---------------------------------------------------------------------------*/ | |
unsigned short crc16_add(unsigned char b, unsigned short acc) | |
{ |
This file contains hidden or 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 hidden or 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 |
This file contains hidden or 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 hidden or 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 line: $LINENO command: $BASH_COMMAND && exit $?' ERR | |
lcnt=1 | |
nw_pref="192.168.10" | |
create_node() | |
{ | |
ns="$1"; shift; |
This file contains hidden or 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 |
OlderNewer