Save
Saving
  • G
    guluting

    Python集合处理常见的有添加,删除,交集与并集操作。
    以下是集合操作的常见符号:

    数学符号 Python符号 含义
    - - 差集
    & 交集
    并集

    集合创建

    [输入]set("ghostds")
    [输出]set(['d', 'g', 'h', 'o', 's', 't'])
    

    交集

    [输入]a = set("abc")
    [输入]b = set("cdef")
    [输入]a & b
    [输出]set(['c'])
    

    并集

    [输入]a = set("abc")
    [输入]b = set("cdef")
    [输入]a | b
    [输出]set(['a', 'c', 'b', 'e', 'd', 'f'])
    

    差集

    [输入]a = set("abc")
    [输入]b = set("cdef")
    [输入]a - b
    [输出]set(['a', 'b'])
    

    posted in GuaiK实验室 read more
  • G
    guluting

    openssl genrsa -out private_key.pem 1024
    
    openssl req -new -key private_key.pem -out rsaCertReq.csr
    
    openssl x509 -req -days 3650 -in rsaCertReq.csr -signkey private_key.pem -out rsaCert.crt
    
    openssl x509 -outform der -in rsaCert.crt -out public_key.der               // Create public_key.der For IOS
    
    openssl pkcs12 -export -out private_key.p12 -inkey private_key.pem -in rsaCert.crt  // Create private_key.p12 For IOS. 这一步,请记住你输入的密码,IOS代码里会用到
    
    openssl rsa -in private_key.pem -out rsa_public_key.pem -pubout             // Create rsa_public_key.pem For Java
     
    openssl pkcs8 -topk8 -in private_key.pem -out pkcs8_private_key.pem -nocrypt     // Create pkcs8_private_key.pem For Java
    
    pyrsa-priv2pub -i myprivatekey.pem -o mypublickey.pem
    

    posted in GuaiK实验室 read more
  • G
    guluting

    以下代码先通过时间段检索数据,将检索出数据中的tags分解成多条数据,之后通过group对tags进行分组统计,然后使用sort对数据进行倒序排序,随后返回100条记录。

    db.doc.aggregate([
        {"$match":{"date":{"$gte":from_date,"$lt":to_date}}},
        {"$unwind": "$tags"},
        {"$group":{"_id":"$tags","tag_total":{"$sum":1}}},
        {"$sort": {"tag_total": -1}},
        {"$limit":100}
    ])
    

    posted in GuaiK实验室 read more
  • G
    guluting

    alt

    运行如下安装指令

    yum install postgresql  
    yum install postgresql-server  
    yum install postgresql-contrib  
    yum update  
    postgresql-setup initdb  
    systemctl enable postgresql.service  
    systemctl start postgresql.service
    

    修改数据库登录密码

    sudo su - postgres  
    psql   
    alter user postgres with password 'xxxx';  
    

    允许远程访问【危险操作】

    vi /var/lib/pgsql/data/pg_hba.conf  
    host	all	all	0.0.0.0/0	trust 
    
    vi /var/lib/pgsql/data/postgresql.conf  
    listen_address = '*'
    
    systemctl restart postgresql.service
    

    配置防火墙

    firewall-cmd --permanent --zone=public --add-port=5432/tcp    增加规则  
    firewall-cmd --permanent --zone=public --remove-port=5432/tcp  删除规则  
    firewall-cmd --reload
    

    posted in GuaiK机房 read more
  • G
    guluting

    alt

    配置centos上网

    cd /etc/sysconfig/network-scripts/  
    vi ifcfg-enoxxxxxxxxx  
    将最后一行的ONBOOT=no改为ONBOOT=yes  
    service network restart  
    yum install net-tools  
    

    GCC安装
    yum install gcc-c++


    一键安装开发工具集合
    yum groupinstall "Development Tools"


    EPEL仓库安装
    yum install epel-release


    安装GDB

    yum install ncurses-devel  
    wget http://ftp.gnu.org/gnu/gdb/gdb-7.6.1.tar.gz  
    tar -zxvf gdb-7.6.1.tar.gz  
    ./configure  
    make  
    sudo make install  
    cp gdb-7.6.1/gdb/gdb /usr/bin/gdb   
    gdb -v  
    

    OPEN SSL 安装
    yum install openssl-devel


    iconv 下载安装

    wget http://ftp.gnu.org/pub/gnu/libiconv/libiconv-1.14.tar.gz  
    tar -zxvf libiconv-1.14.tar.gz   
    cd cd srclib/  
    sed -i -e '/gets is a security/d' ./stdio.in.h  
    
    ./configure --prefix=/usr/local  
    make  
    make install
    

    mysqlclient安装
    yum install mysql-devel


    CURL安装

    wget http://curl.haxx.se/download/curl-7.39.0.tar.gz
    tar -xzvf curl-7.39.0.tar.gz
    cd curl-7.39.0
    ./configure --with-ssl
    make
    make install
    

    BOOST安装

    yum install boost    
    yum install boost-devel    
    yum install boost-doc
    

    libevent安装
    yum install libevent-devel


    安装PIL图像处理模块
    yum install python-imaging

    posted in GuaiK机房 read more
  • G
    guluting

    alt


    第一步 添加mongodb源
    vi /etc/yum.repos.d/mongodb-org-3.2.repo


    输入如下内容:

    [mongodb-org-3.2]
    name=MongoDB Repository
    baseurl=https://repo.mongodb.org/yum/redhat/$releasever/mongodb-org/3.2/x86_64/
    gpgcheck=1
    enabled=1
    gpgkey=https://www.mongodb.org/static/pgp/server-3.2.asc
    

    第二步 开始安装
    yum -y install mongodb-org

    posted in GuaiK机房 read more
  • G
    guluting

    # -*- coding:utf-8 -*-
    import json
    import base64
    from Crypto.Signature import PKCS1_v1_5
    from Crypto.Hash import SHA
    from Crypto.PublicKey import RSA
    
    def sign_data(data):
        """ 将交易参数转换成签名用的字符串格式 """
        complex_keys = []
        for key, value in data.items():
            if isinstance(value, dict):
                complex_keys.append(key)
        # 将字典类型的数据单独排序
        for key in complex_keys:
            data[key] = json.dumps(data[key], sort_keys=True).replace(" ", "")
        return "&".join("{}={}".format(k, v) for k, v in sorted([(k, v) for k, v in data.items()]))
    
    def sha1_with_rsa(private_key, unsigned_string):
        """ 支付宝用的签名加密 """
        pkey_template = """-----BEGIN PRIVATE KEY-----
        {}
        -----END PRIVATE KEY-----"""
        # 开始计算签名
        key = RSA.importKey(pkey_template.format(private_key))
        signer = PKCS1_v1_5.new(key)
        signature = signer.sign(SHA.new(unsigned_string.encode("utf8")))
        # base64 编码,转换为unicode表示并移除回车
        sign = base64.b64encode(signature).decode("utf8").replace("\n", "")
        return sign
    

    posted in GuaiK实验室 read more
  • G
    guluting

    创建Docker组
    sudo groupadd docker

    将用户加入Docker组
    sudo gpasswd -a [username] docker

    重启Docker服务
    sudo systemctl restart docker

    posted in GuaiK机房 read more
  • G
    guluting

    修改sshd服务配置:
    vi /etc/ssh/sshd_config

    修改下面两项:
    GSSAPIAuthentication no UseDNS no

    重启sshd服务:
    systemctl restart sshd

    posted in GuaiK机房 read more
  • G
    guluting

    第一步备份原始文件,然后打开源

    sudo cp /etc/apt/sources.list /etc/apt/sources.list.bak  #备份为 sources.list.bak
    sudo nano /etc/apt/sources.list     #编辑sources.list  文件
    

    写入一下数据

    deb http://mirrors.aliyun.com/raspbian/raspbian/ wheezy main non-free contrib
    deb-src http://mirrors.aliyun.com/raspbian/raspbian/ wheezy main non-free contrib
    

    然后使用 Ctrl+O 回车后保存文件,Ctrl+X 退出编辑器。

    执行一下指令:

    sudo apt-get update       #更新系统软件
    sudo apt-get upgrade      #更新已安装的包
    

    posted in GuaiK实验室 read more