Category: Life

  • 2015读书清单

    目标30本书

    开始时间 技术书 非技术书 教学视频
    2015-01-01 数学之美
    2015-01-19 乱时候,穷时候
    2015-05-17 图解HTTP
    2015-11-4 pro git
  • paste命令

    要把

    a
    b
    c
    d
    e

    变成

    a b c d e

    使用 paste 命令

    paste -s -d' ' filename

    paste 可以将多个文件整合,按列整合

    文件1  file1

    a

    b

    文件2 file2

    1

    2

      ~ paste file1 file2

    a 1

    b 2

      ~ paste -d’ ‘ file1 file2

    a 1

    b 2

    也可以变成

      ~ paste -s file1 file2

    a b

    1 2

    如果想把 奇偶行 拼接成一行,文件为

    1 foo
    2 bar
    3 foo
    4 bar
    5 foo
    6 bar
    7 foo
    8 bar
    

    命令为

    cat filename | paste -d, - -
    1 foo,2 bar
    3 foo,4 bar
    5 foo,6 bar
    7 foo,8 bar

    如果把三行并成一行

    cat filename | paste -d, - - -
  • mac dd 命令将制作 centos7 iso usb启动盘

    查看所有的 disk

    diskutil list
    /dev/disk1
     #: TYPE NAME SIZE IDENTIFIER
     0: FDisk_partition_scheme *7.7 GB disk1
     1: Windows_NTFS 未命名 7.7 GB disk1s1

    解除其挂载

    diskutil unmountDisk /dev/disk2

    用 dd 命令将 iso 写入

    sudo dd if=/Users/jpuyy/Downloads/CentOS-7.0-1406-x86_64-Minimal.iso of=/dev/disk2 bs=1m
  • python ftp测试脚本

    配置 vsftp ,用 python 测试 ftp 很方便

     

    #!/usr/bin/env python
    #-*- coding:utf-8 -*-
    #author: jpuyy.com date
    #modified by xx at date
    
    from ftplib import FTP
    
    def ftp_list(file = "group_xitong"):
        ftp=FTP()
        ftp.set_debuglevel(2)                                                                                                       
        #ftp.connect('106.186.23.161','21')
        ftp.connect('119.28.3.73','4413')
        ftp.login('ftpuser1','QAXjAHd7pAziK8')
        print ftp.getwelcome()
        ftp.cwd('/')
        ftp.retrlines('LIST')
        ftp.quit()
    
    ftp_list()
    
  • arping

    arping 192.168.1.100 可 ping 出当前 ip 对应的 mac 地址。

  • python iso8601转为本地时间

     

     

    #!/usr/bin/env python
    #-*- coding:utf-8 -*-
    #author: jpuyy.com date
    #modified by xx at date
    #import time
    #from dateutil import tz
    
    from datetime import datetime, timedelta, tzinfo
    
    class GMT8(tzinfo):
        delta = timedelta(hours=8)
        def utcoffset(self, dt):
            return self.delta
        def tzname(self, dt):
            return "GMT+8"
        def dst(self, dt):
            return self.delta
    
    class GMT(tzinfo):
        delta = timedelta(0)
        def utcoffset(self, dt):
            return self.delta
        def tzname(self, dt):
            return "GMT+0"
        def dst(self, dt):
            return self.delta
    
    a = "2014-12-13T10:42:28.000Z"
    from_tzinfo = GMT()
    local_tzinfo = GMT8()
    
    gmt_time = datetime.strptime(a, '%Y-%m-%dT%H:%M:%S.%fZ')
    gmt_time = gmt_time.replace(tzinfo=from_tzinfo)
    local_time = gmt_time.astimezone(local_tzinfo)
    
    print gmt_time
    print local_time