## # You should look at the following URL's in order to grasp a solid understanding # of Nginx configuration files in order to fully unleash the power of Nginx. # https://www.nginx.com/resources/wiki/start/ # https://www.nginx.com/resources/wiki/start/topics/tutorials/config_pitfalls/ # https://wiki.debian.org/Nginx/DirectoryStructure # # In most cases, administrators will remove this file from sites-enabled/ and # leave it as reference inside of sites-available where it will continue to be # updated by the nginx packaging team. # # This file will automatically load configuration files provided by other # applications, such as Drupal or Wordpress. These applications will be made # available underneath a path with that package name, such as /drupal8. # # Please see /usr/share/doc/nginx-doc/examples/ for more detailed examples. ##
# Default server configuration # server { listen 80 default_server; listen [::]:80 default_server;
# SSL configuration # # listen 443 ssl default_server; # listen [::]:443 ssl default_server; # # Note: You should disable gzip for SSL traffic. # See: https://bugs.debian.org/773332 # # Read up on ssl_ciphers to ensure a secure configuration. # See: https://bugs.debian.org/765782 # # Self signed certs generated by the ssl-cert package # Don't use them in a production server! # # include snippets/snakeoil.conf;
root /var/www/html;
# Add index.php to the list if you are using PHP index index.html index.htm index.nginx-debian.html;
server_name _;
location / { # First attempt to serve request as file, then # as directory, then fall back to displaying a 404. try_files $uri $uri/ =404; }
# pass PHP scripts to FastCGI server # #location ~ \.php$ { # include snippets/fastcgi-php.conf; # # # With php-fpm (or other unix sockets): # fastcgi_pass unix:/var/run/php/php7.0-fpm.sock; # # With php-cgi (or other tcp sockets): # fastcgi_pass 127.0.0.1:9000; #}
# deny access to .htaccess files, if Apache's document root # concurs with nginx's one # #location ~ /\.ht { # deny all; #} }
# Virtual Host configuration for example.com # # You can move that to a different file under sites-available/ and symlink that # to sites-enabled/ to enable it. # #server { # listen 80; # listen [::]:80; # # server_name example.com; # # root /var/www/example.com; # index index.html; # # location / { # try_files $uri $uri/ =404; # } #}
#asan 链接sys set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -fsanitize=address") SET(CMAKE_C_FLAGS_ASAN "-O2 -g -fsanitize=address -fno-omit-frame-pointer" CACHE STRING "Flags used by the C compiler during asan builds." FORCE) SET(CMAKE_C_FLAGS "-O2 -g -fsanitize=address -fno-omit-frame-pointer -lstdc++ -lasan" CACHE STRING "Flags used by the C compiler during asan builds." FORCE)
==1867==ERROR: AddressSanitizer: heap-use-after-free on address 0x7f69c0e59823 at pc 0x000001f1f50c bp 0x7f69c02624e0 sp 0x7f69c02624d0 ... 0x7f69c0e59823 is located 35 bytes inside of 8388608-byte region [0x7f69c0e59800,0x7f69c1659800) freed by thread T14 here: ... previously allocated by thread T14 here: ... SUMMARY: AddressSanitizer: heap-use-after-free /data/zhenkai.sun/ranker/cmake-build-debug/CMakeUnzipPackages/mongo-c-driver-1.19.1/src/libbson/src/bson/bson.c:1993 in bson_init_static Shadow bytes around the buggy address: 0x0fedb81c32b0: fa fa fa fa fa fa fa fa fa fa fa fa fa fa fa fa 0x0fedb81c32c0: fa fa fa fa fa fa fa fa fa fa fa fa fa fa fa fa 0x0fedb81c32d0: fa fa fa fa fa fa fa fa fa fa fa fa fa fa fa fa 0x0fedb81c32e0: fa fa fa fa fa fa fa fa fa fa fa fa fa fa fa fa 0x0fedb81c32f0: fa fa fa fa fa fa fa fa fa fa fa fa fa fa fa fa =>0x0fedb81c3300: fd fd fd fd[fd]fd fd fd fd fd fd fd fd fd fd fd 0x0fedb81c3310: fd fd fd fd fd fd fd fd fd fd fd fd fd fd fd fd 0x0fedb81c3320: fd fd fd fd fd fd fd fd fd fd fd fd fd fd fd fd 0x0fedb81c3330: fd fd fd fd fd fd fd fd fd fd fd fd fd fd fd fd 0x0fedb81c3340: fd fd fd fd fd fd fd fd fd fd fd fd fd fd fd fd 0x0fedb81c3350: fd fd fd fd fd fd fd fd fd fd fd fd fd fd fd fd Shadow byte legend (one shadow byte represents 8 application bytes): Addressable: 00 Partially addressable: 01 02 03 04 05 06 07 Heap left redzone: fa Freed heap region: fd Stack left redzone: f1 Stack mid redzone: f2 Stack right redzone: f3 Stack after return: f5 Stack use after scope: f8 Global redzone: f9 Global init order: f6 Poisoned by user: f7 Container overflow: fc Array cookie: ac Intra object redzone: bb ASan internal: fe Left alloca redzone: ca Right alloca redzone: cb ==1867==ABORTING
A template parameter pack is a template parameter that accepts zero or more template arguments (non-types, types, or templates). A function parameter pack is a function parameter that accepts zero or more function arguments.
A template with at least one parameter pack is called a variadic template.
/** * @param port network port for listening * @param wd working directory, files will be saved into this folder */ publicFileTransferServer(int port, String wd) { this.port = port; this.wd = wd; }
# 定义数组 ARR=(a b c) # ARR[@]: 数组转换为字符串 echo "${ARR[@]}" a b c # ARR[*] echo "${ARR[*]}" a b c # 数组赋值 ANOTHER=("${ARR[@]}") # 长度 echo ${#ARR[@]} 3 # 序号 for idx in "${!ARR[@]}"; do echo "$idx" done
[@] VS [*]
数组的 [@] 和 [*] 都是取所有元素,但是有所差别。
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16
# 定义 $ ARR=(a b c) $ A=("${ARR[@]}") $ B=("${ARR[*]}") # A $ echo${#A[@]} 3 $ echo${A[@]} a b c # B $ echo${#B[@]} 1 $ echo${B[@]} a b c
布尔
1 2 3 4
FLAG=true if [[ $FLAG == true ]]; then # do something fi
IFS=';' read -ra ADDR <<< "$IN" # 按 ; 分割 for i in "${ADDR[@]}"; do # process "$i" done
替换
1
echo ${LINE//{old}/{new}}
循环
while
语法
1 2 3 4
while command do Statement(s) to be executed if command is true done
示例
1 2 3 4 5 6 7 8 9
a=0 while [ $a -lt 10 ] do echo $a a=`expr $a + 1` done # 等待 port while ! lsof -i:8080; do echo "wait for server ready"; sleep 1; done
数组
1 2 3 4 5 6 7 8 9 10
# 命令行 $ countries=(china us); for country in${countries[@]}; echo$country china us # 脚本 countries=(china us) for country in ${countries[@]}; do echo $country done
范围
1 2 3 4 5 6 7 8 9 10 11 12 13
$ foridin {1..3}; echo$id# 1 2 3 # 脚本 for id in {1..3}; do echo $id done # seq [首数] [增量] 尾数 $ seq 1 3 # [1, 3] $ seq 3 # [1, 3] $ seq 1 2 5 # 1, 3, 5 $ for i in `seq 3`; doecho$i; done# 1 2 3
case…esac
1 2 3 4 5 6 7 8 9 10 11 12
word=a case $word in a) echo "a $word" ;; b) echo "b $word" ;; *) echo "* $word" ;; esac
getopts
参数
1 2 3 4 5 6
# opts :前缀 忽略错误 :后缀 参数后必须有值 # example :abc:de: 忽略参数错误,-c、-e后必须有值
while getopts ":ab:Bc:" opt; do case $opt in a) echo "found -a" ; a="hello" ;; b) echo "found -b and value is: $OPTARG" ;; c) echo "found -c and value is: $OPTARG" ;; *) usage ;; esac done