results = [‘1’, ‘2’, ‘3’]
变为
results = [1, 2, 3]
使用
results = map(int, results)
反过来转换使用
results = map(str, results)
results = [‘1’, ‘2’, ‘3’]
变为
results = [1, 2, 3]
使用
results = map(int, results)
反过来转换使用
results = map(str, results)
.gitignore里写明了一些故意不想存在于版本库里的文件
lib-cov *.seed *.log *.csv *.dat *.out *.pid *.gz pids logs results npm-debug.log .DS_Store node_modules .idea *.iml *.sqlite3
参考:
https://github.com/github/gitignore/blob/master/Node.gitignore
https://raw.githubusercontent.com/github/gitignore/master/Node.gitignore
今天使用ansible生成文件时,提示目标文件有 hard 硬链接,执行失败。
想要查到到底有哪些硬链,那么可以找到这些文件
find . -type f -links +1
要找到文件的inode, 使用 ls -li, 显示如下,第一列为inode number
6160399 -rw-r--r--. 3 root root 72 5月 6 2014 ifcfg-eth0
再找到都有哪些文件硬链到这个文件,使用find命令
find / -follow -inum 6160399
另一个例子,有时候shell下会生成一些乱码或touch ‘~’,这样删除挺麻烦的,即然是文件就有inode number,结合上面的命令,先找到inode number
rm `find . -follow -inum 1192387`
查看cpu个数,核心数,型号,频率
实际cpu个数: cat /proc/cpuinfo | grep ‘physical id’ | uniq -c
4 physical id : 0 4 physical id : 1 4 physical id : 0 4 physical id : 1
实际cpu核心数及型号频率
[root@puppet124 ~]# cat /proc/cpuinfo | grep name | cut -d: -f2 | uniq -c 16 Intel(R) Xeon(R) CPU L5520 @ 2.27GHz
查看内存条数及大小
dmidecode | grep -P -A 5 “Memory Device” | grep Size | grep -v Range | grep -v No
查看物理网卡及MAC地址
ifconfig -a | grep HWaddr | awk ‘{print $5}’
查看网卡支持的速度及当前工作的状态
# ethtool eth0
脚本:
cpu and Mem:
cpu物理个数
physical cpu count: `cat /proc/cpuinfo | grep 'physical id' | uniq -c | wc -l`
cpu核心个数型号频率
processor core count: `cat /proc/cpuinfo | grep name | cut -d: -f2 | uniq -c | awk '{print $1}'`
processor model: `cat /proc/cpuinfo | grep name | cut -d':' -f 2 | uniq`
memory sock count:`dmidecode | grep -P -A 5 "Memory Device" | grep Size | grep -v Range`
total memory:`dmidecode | grep -P -A 5 "Memory Device" | grep "Range Size"`
查看序列号:
dmidecode -s system-serial-number
经典爱情句子
1) I love you not because of who you are, but because of who I am when I am with you.
我爱你,不是因为你是一个怎样的人,而是因为我喜欢与你在一起时的感觉。
2) No man or woman is worth your tears, and the one who is, won‘t make you cry.
没有人值得你流泪,值得让你这么做的人不会让你哭泣。
3) The worst way to miss someone is to be sitting right beside them knowing you can‘t have them.
失去某人,最糟糕的莫过于,他近在身旁,却犹如远在天边。
4) Never frown, even when you are sad, because you never know who is falling in love with your smile.
纵然伤心,也不要愁眉不展,因为你不知是谁会爱上你的笑容。
5) To the world you may be one person, but to one person you may be the world.
对于世界而言,你是一个人;但是对于某个人,你是他的整个世界。
6) Don‘t waste your time on a man/woman, who isn‘t willing to waste their time on you.
不要为那些不愿在你身上花费时间的人而浪费你的时间。
7) Just because someone doesn‘t love you the way you want them to, doesn‘t mean they don‘t love you with all they have.
爱你的人如果没有按你所希望的方式来爱你,那并不代表他们没有全心全意地爱你。
8) Don‘t try so hard, the best things come when you least expect them to.
不要着急,最好的总会在最不经意的时候出现。
9) Maybe God wants us to meet a few wrong people before meeting the right one, so that when we finally meet the person, we will know how to be grateful.
在遇到梦中人之前,上天也许会安排我们先遇到别的人;在我们终于遇见心仪的人时,便应当心存感激。
10) Don‘t cry because it is over, smile because it happened.
不要因为结束而哭泣,微笑吧,为你的曾经拥有。
11).Life is a pure flame,and we live by an invisible sun within us.
生命是一束纯净的火焰,我们依靠自己内心看不见的太阳而存在。
12).Make yourself a better person and know who you are before you try and know someone else and expect them to know you.
在你尝试了解他人和盼望他人了解你之前,先把你变成一个更好的人和了解自己的人。
13).Atrue friend is some one who reaches for your hand and touches your heart.
一个真正的朋友是向你伸出手,触动你心灵的人。
在j2中可以很方便的使用 ansible setup 模块中的变量
如以下是一个bind的配置文件
{% if ansible_bond0.ipv4.address %}
bind {{ ansible_bond0.ipv4.address }}
{% elif ansible_eth0.ipv4.address %}
bind {{ ansible_eth0.ipv4.address }}
{% else %}
bind 0.0.0.0
{% endif %}
以下是一个snmp磁盘分区的设定
{% for i in ansible_mounts %}
{% if i['mount'] != '/boot' %}
disk {{ i['mount'] }} 10%
{% endif %}
{% endfor %}