Blog

  • 经典爱情句子

    经典爱情句子
    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.
    一个真正的朋友是向你伸出手,触动你心灵的人。

  • ansible jinja2模板使用

    在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 %}
  • 从事IT最重要的是什么

    最近一直在思考这个问题,因为从我第一次上网开始,接触互联网已经10年了。

    做IT什么是最重要的

    以前花很多时间在硬件设备,挂QQ,下片子,下mp3,注册邮箱,注册域名,折腾虚拟主机,装系统,写小脚本,配vpn…

    回想起来很傻X,一直在折腾IT的外围的东西,设备域名用什么软件根本不是那么重要。最后也没搞出什么名堂来。

    现在在做运维的职业和一些开发工作,本身也是很外围的东西,为开发和业务服务。遇到运维问题之后打算做点东西,首先需要有编程的知识,然后想尽办法做一个别人会用的到东西。

    需要长时间的学习,才能渐渐接进互联网最重要的 — 产品和业务。

    在互联网做事的方法上,快速迭代验证想法十分重要,一个自认为很好的想法只有在快速迭代的验证下才变得有意义。只有小的想法都难证过了,才会找到最真实客观,而又简单美丽的东西。

    那么除了工作,我的人生什么是最重要的

    罗素说过:三种简单而又极度强烈的情感支配着我的一生:对爱情的渴望、对知识的追求和对人类苦难的深切同情。

    追求感情,追求知识,追求能有一份事业,人不能浪费自己的时间,心有多宽,能做的事,能获取的知识就有多宽,幸福就有多满。当前我还处于很低的位置,因为我有很多问题无法克服,物质困扰着我,自信不够强烈,求知不够耐心,不够虚心,工作不够专心,急功近利。应无视这些阻力和恐惧,始终保持自己无知的态度,容纳更多知识及涵养,到达每一个阶段都当做新的起点。追求人性和自然的本源。

  • python print颜色

    定义一个class

    class bcolors:
        HEADER = '\033[95m'           # 粉色
        OKBLUE = '\033[94m'           # 蓝色
        OKGREEN = '\033[92m'          # 绿色
        WARNING = '\033[93m'          # 黄色
        FAIL = '\033[91m'             # 红色
        BOLD = '\033[1m'              # 粗体
        ENDC = '\033[0m'              # 结束
    

    不管显示哪种颜色,最后都需要用end结束,不然会一直渲染。

    print bcolors.WARNING + "Warning: No active frommets remain. Continue?" + bcolors.ENDC

    参考:
    http://stackoverflow.com/questions/287871/print-in-terminal-with-colors-using-python

    其他颜色可以参考

    #!/usr/bin/perl
    print "0\t\033[0m coloured! \033[m\n";
    print "1\t\033[1m coloured! \033[m\n";
    print "4\t\033[4m coloured! \033[m\n";
    print "7\t\033[7m coloured! \033[m\n";
    print "31\t\033[31m coloured! \033[m\n";
    print "32\t\033[32m coloured! \033[m\n";
    print "33\t\033[33m coloured! \033[m\n";
    print "34\t\033[34m coloured! \033[m\n";
    print "35\t\033[35m coloured! \033[m\n";
    print "36\t\033[36m coloured! \033[m\n";
    print "37\t\033[37m coloured! \033[m\n";
    print "38\t\033[38m coloured! \033[m\n";
    print "39\t\033[39m coloured! \033[m\n";
    print "40\t\033[40m coloured! \033[m\n";
    print "41\t\033[41m coloured! \033[m\n";
    print "42\t\033[42m coloured! \033[m\n";
    print "43\t\033[43m coloured! \033[m\n";
    print "44\t\033[44m coloured! \033[m\n";
    print "45\t\033[45m coloured! \033[m\n";
    print "46\t\033[46m coloured! \033[m\n";
    print "47\t\033[47m coloured! \033[m\n";
    print "90\t\033[90m coloured! \033[m\n";
    print "91\t\033[91m coloured! \033[m\n";
    print "92\t\033[92m coloured! \033[m\n";
    print "93\t\033[93m coloured! \033[m\n";
    print "94\t\033[94m coloured! \033[m\n";
    print "95\t\033[95m coloured! \033[m\n";
    print "96\t\033[96m coloured! \033[m\n";
    print "97\t\033[97m coloured! \033[m\n";
    print "98\t\033[98m coloured! \033[m\n";
    print "99\t\033[99m coloured! \033[m\n";
    print "100\t\033[100m coloured! \033[m\n";
    print "101\t\033[101m coloured! \033[m\n";
    print "102\t\033[102m coloured! \033[m\n";
    print "103\t\033[103m coloured! \033[m\n";
    print "104\t\033[104m coloured! \033[m\n";
    print "105\t\033[105m coloured! \033[m\n";
    print "106\t\033[106m coloured! \033[m\n";
    print "107\t\033[107m coloured! \033[m\n";
    print "108\t\033[108m coloured! \033[m\n";
    
  • strace分析apache php进程执行

    看了外国人制作的排查apache网页很慢的视频顿时学习到了很多,应该多看国外的视频,链接http://www.youtube.com/watch?v=eF-p–AH37E

    这个例子介绍了有一个网页打开比其他网页要慢,telnet去测试GET请求,我这里用nginx做测试

    ➜   telnet jpuyy.com 80
    Trying 114.215.158.48...
    Connected to jpuyy.com.
    Escape character is '^]'.
    GET / HTTP/1.1
    Host: jpuyy.com
    

    这时回车一次,这样与服务器keep-alive。
    另打开一个窗口,,用pidof nginx找到此进程的pid,用lsof -p查看此pid都打开了哪些文件,同时也能看到tcp ESTABLISHED及打开的端口,这里就能确定是哪个nginx进程来处理用户请求。

    for i in `pidof nginx`; do lsof -n -p $i|grep ESTABLISHED; done
    nginx   28170 nginx   14u  IPv4            8920667      0t0     TCP 114.215.158.48:http->91.200.12.90:61110 (ESTABLISHED)
    

    在服务器上结合top,按下shift+u,输入nginx过滤只有nginx用户的进程。

    找到pid之后,用strace -p pid分析请求到底都做了什么。这里是要找网页变慢的因素,加上-r参数显示时间过程,用于查看是哪一步变慢的,-o 跟filename将输出重定向到文件中,以下是完整命令。

    strace -o file -r -p 28170

    接下来打开可以查看worker是如何工作的,打开文件,运行命令,调用系统文件,调用php。因为加了-r参数,可以看到每一步运行的时间。可以直接用awk或cut结合sort找出运行时间最长的一步,查看它是因为dns原因,还是php运行函数导致。

  • ThinkPad X200 Windows7 花屏处理

    经不起ie9的诱惑 把自己本本从xp升级成了win7 旗舰版 发现花屏 分析应该是本本内存 2G+1G 导致的 于是  开机按住F1进BIOS程序, 找到CPU设置项, 设置Intel VT-d 为 DISABLED,保存,关机