Skip to content

Instantly share code, notes, and snippets.

View PoplarYang's full-sized avatar
🦖
Focusing

PoplarYang

🦖
Focusing
View GitHub Profile
# centos7 ansible 2.8.2+
"ansible_distribution": "CentOS",
"ansible_distribution_file_parsed": true,
"ansible_distribution_file_path": "/etc/redhat-release",
"ansible_distribution_file_variety": "RedHat",
"ansible_distribution_major_version": "7",
"ansible_distribution_release": "Core",
"ansible_distribution_version": "7.5

方式一

exec <FILE 
while read line 
do 
    cmd 
done

方式二(推荐)

[vars:hosts]
{% for id, host in (groups.hosts | infos(hostvars)).iteritems() %}
phenix_zone{{ id }}={{ host | join(',') }}
{% endfor %}
import SimpleHTTPServer
import SocketServer
PORT = 8000
Handler = SimpleHTTPServer.SimpleHTTPRequestHandler
httpd = SocketServer.TCPServer(("", PORT), Handler)
print "serving at port", PORT
#定义变量
GOPROXY=https://goproxy.io
GO111MODULE=on
#GOTHIRDPKG=${HOME}/gopkg/third
VERSION=$(shell git describe --abbrev=0 --tags)
COMMIT=$(shell git rev-parse --short HEAD)
#project:game prize pusher socket
#type:api srv web
touch abc.c
open abc.c
cc -c abc.c
cc abc.o
./a.out
#!/usr/bin/env python
# coding:utf-8
import redis
from redis.sentinel import Sentinel
# 连接哨兵服务器(主机名也可以用域名)
sentinel = Sentinel([
('172.31.0.2', 5001),
('172.31.0.3', 5001),
('172.31.0.4', 5001),
print 从 python2 到 python3
python2 不打印换行,在 print 的行尾加",",在 python2 体验python3 print,可以使用:
from __future__ import print_function
python3 print
print("a", "b", sep=" ", end="\n")
#!/usr/bin/env python
import os
for root,dirs,files in os.walk('/tmp'):
for name in files:
print(os.path.join(root,name))