推导式?什么东西?我还真头一回听说这名词,以为是链表、二叉树之类的问题,面试官这样问,只能摇头不解。
回来查下推导式,原来就是常用的list的for in for,有点想笑,这么简单的列表创建问题问得让我摸不着头脑,有些术语听起来很深奥,其实就是常用的表达式,这好比你去问别人设计模式,你用过什么设计模式,什么工是工厂模式?什么是单例模式等等,虽然对术语可能一知半解或者解释不清,其实就是常常在用的。
newlist = [i for i in range(1, 100) if i%3==0]
276篇 Default中的文章
推导式?什么东西?我还真头一回听说这名词,以为是链表、二叉树之类的问题,面试官这样问,只能摇头不解。
回来查下推导式,原来就是常用的list的for in for,有点想笑,这么简单的列表创建问题问得让我摸不着头脑,有些术语听起来很深奥,其实就是常用的表达式,这好比你去问别人设计模式,你用过什么设计模式,什么工是工厂模式?什么是单例模式等等,虽然对术语可能一知半解或者解释不清,其实就是常常在用的。
newlist = [i for i in range(1, 100) if i%3==0]
名称 | DNS 服务器 IP 地址 | 备用 |
---|---|---|
114 DNS | 114.114.114.114 | 114.114.115.115 |
阿里 AliDNS | 223.5.5.5 | 223.6.6.6 |
百度 BaiduDNS | 180.76.76.76 | |
DNSPod DNS+ | 119.29.29.29 | 182.254.116.116 |
CNNIC SDNS | 1.2.4.8 | 210.2.4.8 |
oneDNS | 117.50.11.11 | 52.80.66.66 |
DNS派 电信/移动/铁通 | 101.226.4.6 | 218.30.118.6 |
DNS派 联通 | 123.125.81.6 | 140.207.198.6 |
Cloudflare DNS | 1.1.1.1 | 1.0.0.1 |
Google DNS | 8.8.8.8 | 8.8.4.4 |
IBM Quad9 | 9.9.9.9 | |
OpenDNS | 208.67.222.222 | 208.67.220.220 |
V2EX DNS | 199.91.73.222 | 178.79.131.110 |
话说本地用docker-compose搭了个wordpress的站点,设置里site url和home都是本地地址http://localhost:8300 ,然后上线的数据库数据是导出后导入进来。
用nginx反向代理wordpress的容器地址,浏览器卡住半天自动跳转到www.xxx.com:8300, 这很诡异啊,一直在怀疑是不是nginx配错了,proxy_redirect是off的。 即使重新安装nigix也无济无事。 curl -i 看看响应头确实301跳转了
There is no docker untag command, so, the answer is find the repository which using the image and execute
docker rmi <REPOSITORY>:<TAG>
There are the commands we executed before to tag a new image with an image id
docker tag <image id> hkccr.ccs.tencentyun.com/xxx/fff:v0.1.4
And remove the tagged image
docker rmi hkccr.ccs.tencentyun.com/xxx/fff:v0.1.4
Linux的定时功能crontab同样在macos上也可以用。
起因是之前检查过有尿结石,最近小腹疼,还尿出血,感觉又有结石了,所以还是要多喝水,所以写个定时提醒来时刻提醒自己。
先写段shell脚本来设置提醒内容
文件命令为 drink.sh
title="日常提醒"
content="常喝水,常排尿,远离疾病, 爱你的亲"
subtitle="记得喝水"
sound="Pon"
cmd=$(printf 'display notification "%s" with title "%s" subtitle "%s" sound name "%s"' "$content" "$title" "$subtitle" "$sound")
osascript -e "$cmd"
say -v Ting-ting $content
需要用的工具:
osascript在macos上可以执行AppleScript, JavaScript等.
这里介绍AppleScript两个常用命令: display, say.
这个命令可以在mac上发送系统通知,macos 会在侧边栏显示这个通知消息。
AppleStript这样写 display notification "hello world!"
为了执行这条命令需要用到osascript, 并且需要-e参数,后面跟的单引号字符引用的命令
执行发送这条通知:
osascript -e 'display notification "hello world!"'
这条通知显示在屏幕右上角,3秒后消失。
事情是这样的,一个表单,我想把get和post请求放到一个方法里,但是get和post的路由不一样。
@app.route('/markdown', methods=['GET'])
@app.route('/page_create', methods=['POST'])
def create():
form = PageForm()
context = {
'form': form
}
...
<!--more-->
按理说可以这样搞,但是我希望是不同的路由进来。
@app.route('/markdown', methods=['GET', 'POST'])
def create():
form = PageForm()
context = {
'form': form
}
...
那么view里可以这样生成链接,其实就是url_for 多个参数,指定用的method
<form method="post" action="{{ url_for('markdown.create', _method='POST') }}">
但事后觉得这样写太乱了,所以最好还是将get和post请求分不同的方法来写。
第一种方法:
rds = redis.StrictRedis(host='localhost', port=6379, password='123456')
第二种方法:
redis_config = {
'host': os.getenv('REDIS_HOST', '127.0.0.1'),
'port': os.getenv('REDIS_PORT', 6379),
'password': os.getenv('REDIS_PWD', '123456')
}
redis_uri = 'redis://:{password}@{host}:{port}/0'.format(**redis_config)
redis = Redis.from_url(redis_uri)
With -X you can add some libraries only on the alpine edge branch. Here is and example for zbar or libzbar
apk add --no-cache -X http://dl-cdn.alpinelinux.org/alpine/edge/testing zbar
vi /usr/local/etc/redis.conf
Add the line:
requirepass <your password>
And restart your redis service with brew services restart redis
.