Skip to content

Commit 4e7a12b

Browse files
committed
增加脚本、调整结构
1 parent 89f47de commit 4e7a12b

13 files changed

+465
-18
lines changed

.gitignore

+1
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,7 @@ wheels/
2424
.installed.cfg
2525
*.egg
2626
MANIFEST
27+
.DS_Store
2728

2829
# PyInstaller
2930
# Usually these files are written by a python script from a template

LICENSE

+19-18
Original file line numberDiff line numberDiff line change
@@ -1,21 +1,22 @@
1-
MIT License
1+
署名-非商业性使用-禁止演绎 4.0 国际 (CC BY-NC-ND 4.0)
22

33
Copyright (c) 2019 HelloGitHub
44

5-
Permission is hereby granted, free of charge, to any person obtaining a copy
6-
of this software and associated documentation files (the "Software"), to deal
7-
in the Software without restriction, including without limitation the rights
8-
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9-
copies of the Software, and to permit persons to whom the Software is
10-
furnished to do so, subject to the following conditions:
11-
12-
The above copyright notice and this permission notice shall be included in all
13-
copies or substantial portions of the Software.
14-
15-
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16-
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17-
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18-
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19-
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20-
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21-
SOFTWARE.
5+
## 您可以自由地:
6+
共享 — 在任何媒介以任何形式复制、发行本作品
7+
只要你遵守许可协议条款,许可人就无法收回你的这些权利。
8+
9+
## 惟须遵守下列条件:
10+
- 署名 — 您必须给出适当的署名,提供指向本许可协议的链接,同时标明是否(对原始作品)作了修改。您可以用任何合理的方式来署名,但是不得以任何方式暗示许可人为您或您的使用背书。
11+
12+
- 非商业性使用 — 您不得将本作品用于商业目的。
13+
14+
- 禁止演绎 — 如果您 再混合、转换、或者基于该作品创作,您不可以分发修改作品。
15+
16+
- 没有附加限制 — 您不得适用法律术语或者 技术措施 从而限制其他人做许可协议允许的事情。
17+
18+
## 声明:
19+
您不必因为公共领域的作品要素而遵守许可协议,或者您的使用被可适用的 例外或限制所允许。
20+
不提供担保。许可协议可能不会给与您意图使用的所必须的所有许可。例如,其他权利比如形象权、隐私权或人格权可能限制您如何使用作品。
21+
22+
更详细的说明:https://creativecommons.org/licenses/by-nc-nd/4.0/legalcode.zh-Hans

README.md

+2
Original file line numberDiff line numberDiff line change
@@ -1,2 +1,4 @@
11
# Script
22
基于 python3.7 的 GitHub 的脚本集合
3+
4+
详细介绍(待补充)

github/README.md

+1
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
待补充

github/__init__.py

+9
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
#!/usr/bin/env python
2+
# -*- coding: utf-8 -*-
3+
4+
"""
5+
6+
author: xue.sun
7+
date: 2019/12/31
8+
description:
9+
"""
File renamed without changes.

github/interview_github.py

+29
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,29 @@
1+
#!/usr/bin/env python
2+
# -*- coding:utf-8 -*-
3+
#
4+
# Author : XueWeiHan
5+
6+
# Date : 2019-12-28
7+
# Desc : 刷新本机 DNS 加速访问 GitHub 速度、解决图裂的问题
8+
import requests
9+
10+
11+
# content = requests.get('https://github.com/521xueweihan/HelloGitHub')
12+
# content
13+
14+
# import dns.resolver
15+
#
16+
# myResolver = dns.resolver.Resolver()
17+
# myResolver.nameservers = ['180.76.76.76', '223.6.6.6']
18+
# myAnswers = myResolver.query("github.githubassets.com", "A")
19+
# for rdata in myAnswers:
20+
# print(rdata)
21+
#
22+
import socket
23+
24+
def getip():
25+
sock = socket.create_connection(('ns1.dnspod.net', 6666), 20)
26+
ip = sock.recv(16)
27+
sock.close()
28+
return ip
29+
getip()
File renamed without changes.

mdn_tool/README.md

+1
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
待补充

mdn_tool/__init__.py

+9
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
#!/usr/bin/env python
2+
# -*- coding: utf-8 -*-
3+
4+
"""
5+
6+
author: xue.sun
7+
date: 2019/12/31
8+
description:
9+
"""

mdn_tool/http_code.py

+52
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,52 @@
1+
#!/usr/bin/env python
2+
# -*- coding:utf-8 -*-
3+
#
4+
# Author : XueWeiHan
5+
6+
# Date : 2019-12-31
7+
# Desc : 查询 HTTP code 解释
8+
import json
9+
import textwrap
10+
11+
import fire
12+
13+
14+
def read_file(file_name):
15+
with open(file_name, 'r', encoding='utf-8') as fb:
16+
file_data = fb.read()
17+
status_code_data = json.loads(file_data)
18+
return status_code_data
19+
20+
21+
STATUS_CODE = read_file('status_code.json')
22+
STATUS_CODE_TEMPLATE = """
23+
\x1b[1m\x1b[36m{code} {info}\x1b[0m\x1b[0m
24+
\x1b[32m{desc}\x1b[0m
25+
"""[1:]
26+
27+
28+
class StatusCode(object):
29+
def __init__(self, code=0, info=''):
30+
self.code = str(code)
31+
self.info = info.upper()
32+
33+
def message(self):
34+
info_list = STATUS_CODE.values()
35+
for info_item in info_list:
36+
data_list = info_item['item_list']
37+
for fi_data in data_list:
38+
desc = fi_data['description']
39+
desc = textwrap.fill(desc, 30)
40+
if self.code == fi_data['number'] or self.info == fi_data[
41+
'info']:
42+
result = STATUS_CODE_TEMPLATE.format(
43+
code=fi_data['number'], info=fi_data['info'],
44+
desc=desc)
45+
return result
46+
47+
else:
48+
return '\x1b[31m未查到 {} 对应信息。\x1b[0m'.format(self.code)
49+
50+
51+
if __name__ == '__main__':
52+
fire.Fire(StatusCode)

mdn_tool/requirements.txt

+1
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
fire

0 commit comments

Comments
 (0)