1. 圆的定义 https://zh.wikipedia.org/zh-hans/%E5%9C%86
    2. 圆周率 https://zh.wikipedia.org/zh-hans/%E5%9C%93%E5%91%A8%E7%8E%87
    3. 圆的面积 https://zh.wikipedia.org/zh-hans/%E5%9C%86%E7%9A%84%E9%9D%A2%E7%A7%AF
  1. 圆的面积计算
    1. 逼近
      1. 上下界(这个方向研究者主要是优化逼近的速度)
        1. 割圆法
          1. 阿基米德
          2. 威理博·斯涅尔(Cyclometricus,1962年[来源请求])
          3. 惠更斯(De Circuli Magnitudine Inventa,1654年)
      2. 无限逼近
        1. 高斯格点
        2. 数值逼近(最容易操作的方法)
          1. 蒙特卡罗(掷飞镖:如果随机样本一致地散布于一个包含圆的正方形中,样本击中圆的比例趋近于圆和正方形的面积比)
    2. 拼图
      1. 圆分为很大但有限块然后重拼成一个相同面积的正方形
    3. 微积分
      1. 积分&无穷级数展开
  2. 参考文章:
    1. https://zh.m.wikihow.com/%E8%AE%A1%E7%AE%97%E5%9C%86%E5%91%A8%E7%8E%87-Pi
    2. π论 https://web.math.sinica.edu.tw/math_media/d282/28208.pdf

1)废弃oss批量删除bucket文件

对于非空的oss后台没有比较便捷的方式直接删除只能删除全部item然后再删除bucket

ossutil config 配置完成之后

    ./ossutil ls oss://bucketname/ | awk ‘{print $8}’ | xargs -I {} ./ossutil rm {}
参考资料:
     https://help.aliyun.com/document_detail/50452.html?spm=5176.87240.585413.1.KlUVHk
 2)用sslfofree 免费快速实现 slb https
https://www.sslforfree.com/ 提供免费的90天的证书,快过期renew需要重新申请一个新的证书。
申请完成后
格式转换
openssl x509 -in ca_bundle.crt -out ca_bundle.pem
openssl x509 -in certificate.crt -out certificate.pem
openssl rsa -in private.key -out private.key.pem
slb 创建服务器证书
证书内容: certificate.pem + “\n” + ca_bundle.pem
私钥: private.key.pem
然后添加监听 433接口即可

如果header头定义两个变量,
需要优先采取header1 均衡到后端服务器
如果header2存在就用header2均衡到后端服务器

主要应用场景在websocket的链接分发

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
#map section
map $http_header2 $selectone {
~_    $http_header2;     #header2 内容是***_***匹配是否有内容
''    $http_header1;        #header2 没有内容用header1
default $http_header1;
}
#split section
split_clients "$selectone" $bkservice {
50% webserv1;
*  webserv2;
}

server {
listen 80;
server_name www.test.com;

.......

location ~ ^/balanceservice {
proxy_pass http://$bkservice;
}
......

}

两个模块前后顺序没有关系,不影响最终使用(map 指令。这些不与处理阶段相关联的配置指令基本上都是“声明性的”(declarative),即不直接产生某种动作或者过程。Nginx 的作者 Igor Sysoev 在公开场合曾不止一次地强调,Nginx 配置文件所使用的语言本质上是“声明性的”,而非“过程性的”(procedural)。)
nginx/1.15.0 的代码和实际调试运行来看 只有真正使用变量的时候才会去调用具体的变量解析逻辑。

参考资料:
agentzh的nginx教程
nginx开发从入门到精通
nginx源码分析 3张图看懂
map模块详解
split_client 模块

当我们在 shell 的 bash 里操作多行内容的字符串,我们往往会想到 普通的字符串处理办法 例如:

1
2
string="Hello linux"
echo $string

其实 bash 提供了一个非常好的解决办法,就是 “Multi-line”
变量的基本使用
e.g. 包含变量

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
cat > myfile.txt <<EOF
this file has $variable $names $inside
EOF


# 注入文档到 myfile.txt
cat myfile.txt
#输入:
#this file has

variable="ONE"
names="TWO"
inside="expanded variables"

cat > myfile.txt <<EOF
this file has $variable $names $inside
EOF


#print out the content of myfile.txt
cat myfile.txt
#输入:
#this file has ONE TWO expanded variables

无变量

1
2
3
4
5
6
7
8
9
cat > myfile.txt <<"EOF"
this file has $variable $dollar $name $inside
EOF

cat myfile.txt
#得到
#this file has $variable $dollar $name $inside

#PS:引用符号 "EOF" 决定是否需要输入变量

无变量 – 例子 2

1
2
3
4
5
6
7
8
9
cat > myfile.txt <<EOF
this file has $variable \$dollar \$name \$inside
EOF


cat myfile.txt
# 得到
# this file has $variable $dollar $name $inside

#转义 dollar "$" 符号,bash将取消变量的解析

将一个多行文本赋值到变量里面
例1:

1
2
3
4
5
6
7
8
read -d '' stringvar <<-"_EOF_"

all the leading dollars in the $variable $name are $retained

_EOF_
# 输入变量
echo $stringvar;
# all the leading dollars in the $variable $name are $retained

例2:

1
2
3
4
5
6
read -d '' help <<- "_EOF_"
  usage: up [--level <n>| -n <levels>][--help][--version]

  Report bugs to:
  up home page:
_EOF_

例3:

1
2
3
4
5
6
VARIABLE1="<?xml version="1.0" encoding='UTF-8'?>
<report>
  <img src="a-vs-b.jpg"/>
  <caption>Thus is a future post on Multi Line Strings in bash
  <date>1511</date>-<date>1512</date>.</caption>
</report>"

例4:

1
2
3
4
5
6
7
8
9
VARIABLE2=$(cat <<EOF
<?xml version="1.0" encoding='UTF-8'?>
<report>
  <img src="a-vs-b.jpg"/>
  <caption>Thus is a future post on Multi Line Strings in bash
  <date>1511</date>-<date>1512</date>.</caption>
</report>
EOF
)

例5:

1
2
3
4
5
6
7
8
VARABLE3=`cat <<EOF
<?xml version="1.0" encoding='UTF-8'?>
<report>
  <img src="a-vs-b.jpg"/>
  <caption>Thus is a future post on Multi Line Strings in bash
  <date>1511</date>-<date>1512</date>.</caption>
</report>
EOF`

例6 (直接写入文件):

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
cat > heredocfile.txt <<_EOF_
I am line 1
I am line 2
I'm the last line
_EOF_

# 测试
cat heredocfile.txt
# I am line 1
# I am line 2
# I'm the last line

# and then, change your echo statement to include the '-e' option
# which will turn on escape sequence processing:
echo -e $USAGE >&2

例7:

1
2
3
4
5
6
7
sudo cat > /aaaa.txt <<_EOF_
I am line 1
I am line 2
I'm the last line
_EOF_

# sudo and >>: permission denied

例8:

1
2
3
4
# create
sudo tee /aaa.txt << EOF
  echo "Hello World 20314"
EOF

例9(可向文本文件追加):

1
2
3
4
# Append to Sudo
sudo tee -a  /aaa.txt << EOF
 echo "This Line is appended"
EOF

例如10:

1
2
3
4
5
6
sudo sh -c "cat > /aaa.txt" <<"EOT"
this text gets saved as sudo - $10 - ten dollars ...
EOT

cat /aaa.txt
#this text gets saved as sudo - $10 - ten dollars ...

例11:

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
cat << "EOF" | sudo tee /aaa.txt
let's count
$one
two
$three
four

EOF

cat /aaa.txt
#let's count
#$one
#two
#$three
#four

关于 tee
> tee –help
Usage: tee [OPTION]… [FILE]…
Copy standard input to each FILE, and also to standard output.

-a, –append append to the given FILEs, do not overwrite
-i, –ignore-interrupts ignore interrupt signals
–help display this help and exit
–version output version information and exit

If a FILE is -, copy again to standard output.

Report tee bugs to bug-coreutils@gnu.org
GNU coreutils home page:
General help using GNU software:
For complete documentation, run: info coreutils ‘tee invocation’

参考:
1. Heredoc Quoting – Credit to Ignacio Vazquez-Abrams: http://serverfault.com/questions/399428/how-do-you-escape-characters-in-heredoc
2. eredoc Quoting – Credit to Dennis Williamson: http://stackoverflow.com/questions/3731513/how-do-you-type-a-tab-in-a-bash-here-document
3. http://serverfault.com/questions/72476/clean-way-to-write-complex-multi-line-string-to-a-variable
4. http://arstechnica.com/civis/viewtopic.php?p=21091503
5. http://superuser.com/questions/201829/sudo-permission-denied
6. http://stackoverflow.com/questions/4937792/using-variables-inside-a-bash-heredoc
7. http://stackoverflow.com/questions/2600783/how-does-the-vim-write-with-sudo-trick-work
8. http://www.unix.com/shell-programming-scripting/187477-variables-heredoc.html

来源:http://www.woola.net/detail/2016-09-05-bash-multi-line-text.html