linux curl 命令

curl get

1
curl $URL

阅读全文

防火墙设置

SUSE

1
2
3
4
5
6
SuSEfirewall2 stop   #停止firewall

chkconfig SuSEfirewall2_setup off #禁止firewall开机启动1
chkconfig SuSEfirewall2_init off #禁止firewall开机启动2

chkconfig --list|grep fire #查看防火墙状态

阅读全文

selenium python

介绍

启动

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
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
#!/usr/bin/env python3
# coding:utf-8

import os
import sys

try:
# 配置目录
from conf.selenium_config import RESPATH
os.path.exists(RESPATH)
except:
# 本机目录,末尾不加 “/”
RESPATH = 'D:/IDE/Test/res'
if os.path.exists(RESPATH) is False:
print(RESPATH, ' is not find')
quit()

from selenium import webdriver
from selenium.webdriver.common.desired_capabilities import DesiredCapabilities
from selenium.webdriver.firefox.firefox_binary import FirefoxBinary


def chromeDriver():
driverPath = RESPATH + "/chromedriver2.31.exe"
# chrome.exe地址
chromePath = RESPATH + "/Chrome60/chrome.exe"
# chrome启动选项
options = webdriver.ChromeOptions()
# options.add_argument("--user-data-dir=" + chromeoptionPath))
options.add_argument("--start-maximized")
options.add_argument("--test-type")
options.add_argument("allow-running-insecure-content")
if os.path.isfile(chromePath):
options.binary_location = chromePath
# 带参数启动driver
dr = webdriver.Chrome(
chrome_options=options, executable_path=driverPath, port=9515)
dr.implicitly_wait(10) # 隐性等待,最长等10秒
print('driver started')
return dr


def firefoxDriver():
# 获取当前文件夹的绝对路径#driver地址
ffpath = RESPATH + "/Mozilla Firefox46/firefox.exe"
binary = FirefoxBinary(ffpath)
# 带参数启动driver
# profile = webdriver.FirefoxProfile(xx)
if os.path.isfile(ffpath):
dr = webdriver.Firefox(firefox_binary=binary)
else:
dr = webdriver.Firefox()
# 将浏览器最大化
dr.maximize_window()
# 隐性等待,最长等10秒
dr.implicitly_wait(10)
print('driver started')
return dr


def ieDriver():
# 修改配置信息
DesiredCapabilities.INTERNETEXPLORER['ignoreProtectedModeSettings'] = True
# 获取当前文件夹的绝对路径+driver地址
driverPath = RESPATH + "/IEDriverServer_x64_2.53.1.exe"
dr = webdriver.Ie(executable_path=driverPath)
# 将浏览器最大化
dr.maximize_window()
# 隐性等待,最长等10秒
dr.implicitly_wait(10)
print('driver started')
return dr


if __name__ == '__main__':
# chromeDriver()
# firefoxDriver()
ieDriver()

阅读全文

python3随机生成手机号

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
38
39
40
#!/usr/bin/env python3
# coding:utf-8
'''
获取随机手机号方法
'''
import random
import time
'''
MDN号码的结构如下:CC + MAC + H0 H1 H2 H3 + ABCD:
【CC】:国家码,中国使用86。
【MAC】:移动接入码,本网采用网号方案,为133。
【H0H1H2H3】:HLR识别码,由运营商统一分配。
【ABCD】:移动用户号,由各HLR自行分配。
'''
# 号段列表
macid_list = [
'133', '149', '153', '173', '177', '180', '181', '189', '199', '130',
'131', '132', '145', '155', '156', '166', '171', '175', '176', '185',
'186', '166', '134', '135', '136', '137', '138', '139', '147', '150',
'151', '152', '157', '158', '159', '172', '178', '182', '183', '184',
'187', '188', '198'
]


# 获取随机手机号
# return int
def get_phone(macid=None):
if macid is None:
macid = macid_list[random.randint(0, len(macid_list) - 1)]
# 地区4位,取本机月日
H0H1H2H3 = time.strftime("%m").zfill(2) + time.strftime("%d").zfill(2)
# a_list = range(1, 10)
# 随机4位数,zfill方法使高位补0
ABCD = str(random.randint(0, 9999)).zfill(4)
phone = str(macid) + H0H1H2H3 + ABCD
return int(phone)


if __name__ == "__main__":
get_phone()

阅读全文

python3随机生成银行卡号

做一个声明,这个只用于内部测试!

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
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
#!/usr/bin/env python3
# coding:utf-8
'''
随机银行卡
'''
import copy
import json
import math
import random

import requests

# 维萨卡(VISACARD)
VISA_PREFIX_LIST = [
"4539", "4556", "4916", "4532", "4929", "40240071", "4485", "4716", "4"
]
# 万事达卡(MasterCard)
MASTERCARD_PREFIX_LIST = ["51", "52", "53", "54", "55"]
# 美国运通卡(AmericanExpressCard)
AMEX_PREFIX_LIST = ["34", "37"]
# 发现卡(Discover Card)
DISCOVER_PREFIX_LIST = ["6011"]
# 大莱卡(DinersCard)
DINERS_PREFIX_LIST = ["300", "301", "302", "303", "36", "38"]
# enRoute(credit card issued by Air Canada until 1992)
ENROUTE_PREFIX_LIST = ["2014", "2149"]
# JCB卡(JAPANCREDITBUREAUCARD)
JCB_PREFIX_LIST = ["35"]
# Voyager Credit Card
VOYAGER_PREFIX_LIST = ["8699"]
# 中国银联
China_UnionPay_PREFIX_LIST = ["62"]
# 常用
CUP_PREFIX_LIST = {
'622220': '中国工商银行',
'622258': '中国交通银行',
'622707': '中国建设银行',
'622580': '中国招商银行',
'622150': '中国邮政储蓄银行',
'622273': '中国银行',
'623058': '平安银行'
}
BANK_CODE_LIST = {
'CCB': '中国建设银行',
'ABC': '中国农业银行',
'ICBC': '中国工商银行',
'CDB': '国家开发银行',
'BCCB': '北京市商业银行',
'HSBC': '汇丰银行',
'PBC': '中国人民银行',
'BOC': '中国银行',
'CMBC': '中国民生银行',
'CMB': '招商银行',
'CIB': '兴业银行',
'BCM': '交通银行',
'CEB': '中国光大银行',
'GDB': '广东发展银行',
'SPABANK': '平安银行'
}
CARD_TYPE_LIST = {'DC': "储蓄卡", 'CC': "信用卡", 'SCC': "准贷记卡", 'PC': "预付费卡"}


def completed_number(ccnumber, length):
# generate digits
while len(ccnumber) < (length - 1):
digit = str(random.randint(0, 9))
ccnumber = ccnumber + digit
# Calculate sum
sum = 0
pos = 0
reversed_ccnumber = []
reversed_ccnumber.extend(ccnumber)
reversed_ccnumber.reverse()
while pos < length - 1:
# 卡号从右往左看,偶数位数乘以2
odd = int(reversed_ccnumber[pos]) * 2
# 如果乘以2后的数为两位数(值大于9)则减去9
if odd > 9:
odd -= 9
# 然后将所有的位数进行累加
sum += odd
if pos != (length - 2):
sum += int(reversed_ccnumber[pos + 1])
# 偶数位从0开始,加2循环
pos += 2
# Calculate check digit
# 最后一位当做是校验位,用来补齐到能够整除10
# TODO
# t = 10 - sum % 10
# ccnumber += str(0 if t == 10 else t)
# math.floor 向下取整
checkdigit = int(((math.floor(sum / 10) + 1) * 10 - sum) % 10)
ccnumber = str(ccnumber) + str(checkdigit)
# TODO end
return ccnumber


def get_bank_number(prefixList=None, length=None):
if prefixList is None:
prefixList = list(CUP_PREFIX_LIST.keys())
if length is None:
length = 16
ccnumber = copy.copy(random.choice(prefixList))
ccnumber = '622707'
bank_number = completed_number(ccnumber, length)
return bank_number


def is_bank_number(bank_number):
try:
url = 'https://ccdcapi.alipay.com/validateAndCacheCardInfo.json?\
_input_charset=utf-8&cardNo=%s&cardBinCheck=true' % bank_number
r = requests.get(url)
data = r.text
data = json.loads(data)
# print(data)
validated = data['validated']
cardType = None
bank = None
if validated is True:
cardType = CARD_TYPE_LIST[data['cardType']]
bank = BANK_CODE_LIST[data['bank']]
print(cardType, bank)
return validated, cardType, bank
except Exception as e:
if isinstance(bank_number, int):
bank_number = str(bank_number)
mod10Count = 0
reversed_ccnumber = list(reversed(bank_number))

for i in range(0, len(bank_number) - 1):
augend = reversed_ccnumber[i]
if ((i + 1) % 2) == 0:
productString = str(augend * 2)
augend = 0
for j in range(0, len(productString)):
augend += int(productString[j])
mod10Count += int(augend)
digits = [int(x) for x in reversed(str(bank_number))]
check_sum = sum(digits[::2]) + sum(
(dig // 10 + dig % 10) for dig in [2 * el for el in digits[1::2]])
print(check_sum, mod10Count)
return (mod10Count % 10) == 0


if __name__ == "__main__":
bank_number = '6217000010104124329'
bank_number = get_bank_number()
print(bank_number)
print(is_bank_number(bank_number))

阅读全文

Git


生成公钥

1
ssh-keygen -t rsa -C "shineniefei@qq.com"

阅读全文

vim

写在前面

内容来自网络总结

状态模式

阅读全文

vimium

command       | en                                               | cn

:—————–: | :———————————————– | :—————————
Navigating the page | — | —
j, <c-e> | Scroll down | 向下移动(CTRL+e)
k, <c-y> | Scroll up | 向上移动(CTRL+y)
gg | Scroll to the top of the page | 跳到页面顶部
G | Scroll to the bottom of the page | 跳到页面底部
d | Scroll a half page down | 向下翻页
u | Scroll a half page up | 向上翻页
h | Scroll left | 向左移动
l | Scroll right | 向右移动
zH | Scroll all the way to the left | 移动到最左
zL | Scroll all the way to the right | 移动到最右
r | Reload the page | 刷新页面
yy | Copy the current URL to the clipboard | 拷贝当前页面的URL到剪贴板
p | Open the clipboard’s URL in the current tab | 在当前页打开剪贴板的地址
P | Open the clipboard’s URL in a new tab | 在新页面打开剪贴板的地址
gu | Go up the URL hierarchy | 跳转到父页面(url往上一个/)
gU | Go to root of current URL hierarchy | 跳转到根页面(url的hosts一级)
i | Enter insert mode | 插入模式
v | Enter visual mode | 可视模式
V | Enter visual line mode | 行可视模式
gi | Focus the first text input on the page | 到第一个文本框插入
f | Open a link in the current tab | Hint模式,在本页面打开待选择的链接
F | Open a link in a new tab | Hint模式,在新页面打开待选择的链接
<a-f> | Open multiple links in a new tab | Hint模式,在新页面打开待选择的多个链接(ALT+f)
yf | Copy a link URL to the clipboard | 拷贝某一个URL到剪贴板(y拷f选择,选择后生效)
[[ | Follow the link labeled previous or < | 转到当前页之前标记的链接
]] | Follow the link labeled next or > | 转到当前页之后标记的链接
gf | Select the next frame on the page | 到当前页面的下一层框架
gF | Select the page’s main/top frame | 到当前页面的最上层框架
m | Create a new mark | 创建一个标记(按下后,接一个字母)
| Go to a mark | 跳到一个标记(按下后,接用m标记过的字母)

阅读全文

Windows 在apache中使用mod_wsgi部署flask

  1. 下载mod_wsgi Python的插件,选择 mod_wsgi-4.5.24+ap24vc14-cp37-cp37m-win_amd64.whl,

    1
    2
    3
    http://www.lfd.uci.edu/~gohlke/pythonlibs/#mod_wsgi

    https://download.lfd.uci.edu/pythonlibs/h2ufg7oq/mod_wsgi-4.5.24+ap24vc14-cp37-cp37m-win_amd64.whl

阅读全文

win10 下 安装 mysql 8

  1. 首先去官网下载安装包

    1
    https://dev.mysql.com/downloads/mysql/

阅读全文