UUBlog

UUBlog

插图大小

宽: 1200px

字体

描述大小: 18px
标题大小: 32px
字体: Source Code Pro

颜色

用途 颜色
背景色
#EEEEEE
文字颜色1
#EEEEEE
文字颜色2
#333333
组件颜色 - Sinbad
#66CCCC
组件颜色 - Sinbad Light
#99CCCC
组件颜色 - Golden Sand
#FFCC66
组件颜色 - Golden Sand Light
#FFCC99
组件颜色 - Gray
#555555
组件颜色 - Gray Light
#888888
组件颜色 - Sweet Pink
#FF6666
组件颜色 - Sweet Pink Light
#FF9999

高饱和度: https://flatuicolors.com/palette/se

参考资料

关注公众号 尹安灿

1
2
3
4
5
6
yum -y install yum-utils
yum-config-manager --enable rhui-REGION-rhel-server-extras rhui-REGION-rhel-server-optional
yum install -y python2-certbot-nginx
pip install -U pip
pip install --upgrade --force-reinstall 'requests==2.6.0' urllib3
ln -s /usr/local/nginx/conf /etc/nginx

配置证书 certbot --nginx 根据提示生成证书

配置定时续约证书

crontab -e

1
0 0,12 * * * python -c 'import random; import time; time.sleep(random.random() * 3600)' && certbot renew 

好了没了,就这么简单

Read more »

关注公众号 尹安灿

因为最近换了jenkins地址,之前CI环节依赖的gitee webhook。但是之前webhook的URL写的是ip。所以需要批量修改。

然而仓库上百个,头皮发麻。不过好在看到gitee有提供了API,虽然没找到sdk,但是也好很多了。

简单写了一个,放上来存档。

Read more »

关注公众号 尹安灿

漏洞成因

微擎米波现场插件存在任意修改密码漏洞。

  • meepo_xianchang/inc/web/account_manage.inc.php

143-193行,普通用户登录后,修改密码功能,ac_uid是可以外部传入的。只要传入其它用户的UID,即可修改掉其它用户的密码。

Read more »

关注公众号 尹安灿

环境: Python 3.6

Python异常处理和很多语言异常处理都差不多。

常见异常捕捉

  1. try … except … finally

索性把一些极端的处理句式给出给来 举一反三。依然是如果有异常,异常如果没有被捕捉,中断执行,finally是不会被执行的。

另外值得一提的是,python2中 except语句使用有区别于python3 。

python2: exception ErrType, ErrInfo
python3: exception ErrType as ErrInfo

一个用半角逗号隔开,一个用as隔开。后者更像其它的语言的异常处理。

1
2
3
4
5
6
7
8
9
10
11
try:
do_sth
except ErrorType as e:
handle_expcept_1
print("ErrorMessage:",e)
except ErrorType2 as e:
handle_expcept_2
else:
handle_other_error
finally:
colse_object
  1. with … as

对于支持该语句的对象来说,用这个语句比用try...finally更能保证对象在异常中得到期望的释放。

而支持该语句的对象必须内部实现两个方法 __enter__()__exit__().而在刚执行with语句时会触发 enter方法,离开with语句代码块后触发exit。所以,对象只要把释放资源的代码写在__exit__()函数中就行了。

1
2
with open('test.txt') as f:
f.readlines()
  1. Exception 万能异常

如其名,可以用try…except Exception 捕获所有的异常

Read more »

关注公众号 尹安灿

个人觉得装饰器就是Python对闭包的一种的语法糖。

可以灵活抽离出一些雷同代码,通过装饰器方便地调用,使得程序更加简单专注于逻辑的处理。

例子:

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
def check_data(func):
def check(*args, **kwargs):
print('in decorator')
print(args)
print(kwargs)
func(*args, **kwargs)
return check


@check_data
def echo_name(name):
print(name)


echo_name(name='jack')
print('--------')
echo_name(name='bob')

结果

1
2
3
4
5
6
7
8
9
in decorator
()
{'name': 'jack'}
jack
--------
in decorator
('bob',)
{}
bob
Read more »

关注公众号 尹安灿

用<Centos7配置LNMP nginx10+mariadb+php5.6>安装nginx后,

是没有nginx-upsync-module的.如此一来可能还不如直接编译安装,

但是这样安装好处在于,可以方便使用systemtl来管理nginx,不需要自己去添加服务,懒人必备.

然后再找同样版本的nginx,编译安装一遍,加进自己的模块.

  • 安装编译工具全家桶 yum groupinstall 'Development Tools'

  • 下载源码

1
2
3
4
wget http://nginx.org/download/nginx-1.12.1.tar.gz
tar -zxvf nginx-1.12.1.tar.gz
git clone https://github.com/onecer/nginx-upsync-module.git
#git clone https://github.com/weibocom/nginx-upsync-module.git
  • 安装编译依赖组件yum install -y zlib zlib-devel openssl openssl-devel pcre pcre-devel

  • 编译nginx

添加模块 --add-module=../nginx-upsync-module 其它模块有需要的自己加

1
2
3
cd nginx-1.12.1
./configure --with-http_stub_status_module --with-http_ssl_module --with-http_v2_module --with-http_gzip_static_module --with-http_gunzip_module --with-stream --with-stream_ssl_module --with-http_sub_module --with-http_flv_module --with-http_addition_module --with-http_realip_module --with-http_mp4_module --with-stream --with-stream_ssl_module --add-module=../nginx-upsync-module
make && make install
Read more »

关注公众号 尹安灿

问题描述

在这篇文章《Docker Swarm Mode中部署SpringCloud微服务》之后

遇到了点新问题。

在运行时指定自己网络的时候,容器里面多个网络,多个IP,但是注册的不是固定注册某个网卡的IP作为服务IP。

这就导致有时候注册的IP不是属于overlay网络的IP。服务访问就会出现问题。

Read more »

关注公众号 尹安灿

有同志容器的日志写到了自己容器里面。但是出问题后,一直写,导致磁盘写满。

以上是问题出现的前奏。

我接着清理下无用的容器,先快速释放部分空间出来。

1
docker system prune -a

紧接着我就出去帮忙别的东西了。

过一会被告知,Jenkins构建失败,而不止一个项目。每个项目出错如下:

Read more »

关注公众号 尹安灿

根据给定日期,生成 5*7的日历。自动补齐前面的日期。

含计算日期,计算星期几等函数。生生复习了一遍闰年和星期几计算。记录下留档。

Read more »

关注公众号 尹安灿

0%