Skip to content

Instantly share code, notes, and snippets.

View zhengxiaowai's full-sized avatar
🎯
Focusing

zxy zhengxiaowai

🎯
Focusing
View GitHub Profile
@zhengxiaowai
zhengxiaowai / vimrc
Created September 7, 2016 14:43
vim configure
set nu
set tabstop=4
set shiftwidth=4
set softtabstop=4
set autoindent
set nowrap
set expandtab
set fileencodings=utf-8,ucs-bom,gb18030,gbk,gb2312,cp936
set termencoding=utf-8
@zhengxiaowai
zhengxiaowai / sublime
Created September 7, 2016 14:44
sublime configure
{
"always_show_minimap_viewport": true,
"bold_folder_labels": true,
"draw_minimap_border": true,
"font_face": "monaco",
"font_size": 14,
"highlight_line": true,
"ignored_packages":
[
"Vintage"
@zhengxiaowai
zhengxiaowai / source.sh
Created September 7, 2016 14:45
配置软件源
#!/bin/bash
#########################################
#Function: update source
#Usage: bash update_source.sh
#Author: Customer service department
#Company: Alibaba Cloud Computing
#Version: 5.0
#########################################
check_os_release()
@zhengxiaowai
zhengxiaowai / tests.py
Created October 14, 2016 10:33
tornado AsyncHTTPSTestCase example
#!/usr/bin/env python
# -*- coding:utf-8 -*-
from hsdo import make_app
from tornado.testing import AsyncHTTPSTestCase
from tornado.escape import json_encode
class BaseAsyncHTTPSTestCase(AsyncHTTPSTestCase):
def get_app(self):
@zhengxiaowai
zhengxiaowai / zip_dir.py
Created November 15, 2016 12:24
压缩一个文件夹,没有文件目录
def zip_dir(zipfile_path, zip_dir_path, file_tyle='*'):
with zipfile.ZipFile(zipfile_path, 'w') as z:
glob_file = glob.glob(os.path.join(zip_dir_path, file_tyle))
for filepath in glob_file:
z.write(filepath, os.path.basename(filepath))
@zhengxiaowai
zhengxiaowai / mysql57_config_utf8.cnf
Last active December 27, 2016 09:42
mysql5.7 配置 utf8
# /etc/mysql/mysql.conf.d/mysqld.cnf
[mysqld]
character-set-server=utf8
collation-server=utf8_general_ci
@zhengxiaowai
zhengxiaowai / add_user.sh
Created November 26, 2016 04:03
root 添加用户,自动添加用户目录
#!/bin/bash
username=$1
useradd -m -s /bin/bash $username
usermod -aG sudo $username
@zhengxiaowai
zhengxiaowai / scan_port.py
Last active December 4, 2016 05:58
扫描已经使用的端口
#!/usr/bin/env python
# -*- coding: utf-8 -*-
import sys
import socket
def scan_port(port_num, host):
s = socket.socket()
socket.setdefaulttimeout(2)
try:
@zhengxiaowai
zhengxiaowai / algin-center-left.css
Created December 6, 2016 07:20
短文本居中,长文本左对其
li {
text-align: center;
}
p {display: inline-block;text-align: left;}
#!/usr/bin/env python
# -*- coding: utf-8 -*-
'''
nginx 的日志在存 json 的时候会把 “ 转义成 \x22
此脚本实现类似于 Unix tail -f 但是会还原原始 json 数据
可以单独执行不依赖于第三方 package
Python2.+ | Python3.+
'''