Blog

  • 好电影

    动作类

    谍影重重

    智商类

    记忆碎片
    禁闭岛
    廊桥遗梦
    少年pi
    猎鼠游戏

    秒速五厘米

    感情类

    天堂电影院
    不一样的天空
    佐贺的超级阿嬷
    聪明人,笨人,有钱人,穷人,过了五十岁,都一样是50岁
    只要能道声再见,就是幸福;如果能说声“改天见”,就更加幸福;要是能说“好久不见”,就更加更加幸福了

  • 遇到一切问题就想着用 python 来处理, 一段时间后你就是 py 程序员了

    遇到一切问题就想着用 python 来处理, 一段时间后你就是 py 程序员了

    看书就行了.
    往死里看, 然后上git往死里看源代码.
    最后在抄一次源代码.然后在自己编一下,基本上就成型了.

    必须有     大量    这个词作支撑

    心须搞     实用    价值的东西

    社区
    chinaunix
    github
    http://simple-is-better.com/news/953

  • python map函数对list转换

    results = [‘1’, ‘2’, ‘3’]
    变为
    results = [1, 2, 3]

    使用

    results = map(int, results)

    反过来转换使用

    results = map(str, results)
  • gitignore使用方法

    .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

  • linux使用inode笔记

    今天使用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