OAuth

教程

概念

token 令牌

  • 和密码类似
  • 有有效时长
  • 可以被主动撤销
  • 可以设置权限范围 scope

    • 密码是所有权限

角色

  • 客户端
  • 资源所有者

GnuPG ---- GNU Privacy Guard

QEMU notes

创建磁盘

  • qemu-image

    1
    2
    3
    
    qemu-img create ubuntu.img 20G
    
    qemu-img create -f qcow2 ubuntu.qcow2 20G

启动和安装

  • 安装
 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
qemu-system-x86_64 \

    # 磁盘路径
    -hda ubuntu.img \

    # 启动顺序
    -boot d \

    # 安装iso文件路径
    -cdrom /path/to/install_iso_file \

    # 内存大小,默认单位MiB
    -m 640
  • -boot: 启动数序

decorator ---- python decorator 装饰器

类装饰器,修饰类的装饰器 class decorator

  • 参考:

  • 例子

     1
     2
     3
     4
     5
     6
     7
     8
     9
    10
    11
    12
    13
    14
    15
    16
    17
    18
    19
    20
    21
    22
    23
    24
    25
    26
    27
    28
    29
    30
    31
    32
    33
    34
    35
    36
    37
    
    from functools import wraps
    
    def debug(func):
        """decorator for debugging passed function
        """
            @wraps(func)
        def wrapper(*args, **kwargs):
            print("Full name of this method:", func.__qualname__)
            return func(*args, **kwargs)
        return wrapper
    
    
    # 类装饰器
    def debugmethods(cls):
        '''class decorator make use of debug decorator
        to debug class methods '''
    
        # check in class dictionary for any callable(method)
        # if exist, replace it with debugged version
        for key, val in vars(cls).items():
            if callable(val):
                setattr(cls, key, debug(val))
        return cls
    
    # sample class
    @debugmethods
    class Calc:
        def add(self, x, y):
            return x+y
        def mul(self, x, y):
            return x*y
        def div(self, x, y):
            return x/y
    
    mycal = Calc()
    print(mycal.add(2, 3))
    print(mycal.mul(5, 2))