Skip to content

Commit 81e5ec1

Browse files
authored
Merge pull request Show-Me-the-Code#233 from PatchLion/master
patchlion 的练习
2 parents aca2fea + 81d68e5 commit 81e5ec1

File tree

11 files changed

+379
-0
lines changed

11 files changed

+379
-0
lines changed

patchlion/0000/DrawHeadImage.py

Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,28 @@
1+
# -*- coding: utf-8 -*-
2+
__author__ = 'PatchLion'
3+
4+
from PIL import Image, ImageDraw,ImageFont
5+
6+
def drawNumberOnIcon(imgpath, number):
7+
img = Image.open(imgpath)
8+
if (None == img):
9+
print('打开图片失败')
10+
return
11+
12+
img = img.resize((160, 160))
13+
14+
print(imgpath, "->", img.format, img.size, img.mode)
15+
draw = ImageDraw.Draw(img)
16+
img_size = img.size
17+
18+
font = ImageFont.truetype("Varela-Regular.otf", size=int(img_size[1]/4))
19+
text_size = font.getsize(str(number))
20+
21+
draw.text((img_size[0]-text_size[0], 0), str(number), font=font, fill=(255, 0, 0))
22+
23+
img.save('icon_withnumber.jpg')
24+
25+
print('生成图片成功')
26+
27+
28+
drawNumberOnIcon("icon.jpg", 21)

patchlion/0000/Varela-Regular.otf

131 KB
Binary file not shown.

patchlion/0000/icon.JPG

571 KB
Loading

patchlion/0000/icon_withnumber.jpg

6.82 KB
Loading

patchlion/0001/CreateSN.py

Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
1+
# -*- coding: utf-8 -*-
2+
__author__ = 'PatchLion'
3+
import uuid
4+
5+
def createSN(count):
6+
if count <= 0:
7+
return
8+
9+
10+
sns=[]
11+
12+
for i in range(count):
13+
sns.append(uuid.uuid4().hex.upper())
14+
15+
return sns
16+
17+
def createSNAndSaveToFile(count, filepath):
18+
sns = createSN(count)
19+
20+
with open(filepath, 'wt') as f:
21+
for sn in sns:
22+
f.write(sn+"\n");
23+
24+
print(createSN(200))
25+
createSNAndSaveToFile(200, 'sns.txt')

patchlion/0001/sns.txt

Lines changed: 200 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,200 @@
1+
D6E7BE4F8DBB400DBCADFC71D0397C95
2+
E3C83441DCBD4916A4E921CF7E69BEEF
3+
6DEB7C95E46B443FB464203C3239CAC9
4+
D9FCB5F316A743AB914E46074D813F08
5+
53896AC8D6EC4781AFE08D7A41FDD62A
6+
A454638CA4F841698CD8443328053B8A
7+
F1BD39FDDF6E488A96ED03ACE0880989
8+
7A18B38339AB42F0A29F96A13A65277C
9+
92E8E5957A93425283CD8F9A5C7AC6A9
10+
1682747B4AC14B6BB854220C7795C351
11+
40584A6C19AB462FA0EDFEBCBA200317
12+
3B38874AD4E14D0384898C3F71570EA2
13+
6B3570EF96B343D2BA66D667202B7999
14+
756269BE448C46E989CEB279F4E6A0AC
15+
8857CD736ECD45579A0E5BF365DFE303
16+
2DF003F62F8B4FD78C3582B2336FECD9
17+
0120A4D066C044C3BF4B3F283AC93F1C
18+
685CBE0E5EC34384B435DFE05549E264
19+
EAECEAF83D214376937410867FFF813F
20+
08EC93DB931E455099F207D64B2EF7BA
21+
C27E8749C60443FAA1C9D332D8056E7D
22+
BF2AF04E1BEB47E2808BB9F89CE48A57
23+
35806F99395D48CE95F3B20DB2C72877
24+
98C4CD32A09C47FCA792984144E34789
25+
69913A451CE943AC8F46E373C260E76F
26+
88783C30A1A5418C9852CE1C11D66FC5
27+
251DFA24C113427DB1A4F84AD4A0A16B
28+
A631E2EC4F804195A65C47EA3EC7BFE2
29+
DAF81DCA20374B50A4C2E5901FAFFE4C
30+
E2705D418FD6428AA6F89232A03D1DF1
31+
2C09E4830228428B8683EF48662FD533
32+
B59451DA98094A439467E55A36BD1015
33+
54DA1A69C6994A96A2E3DD3F52AB47EB
34+
298EACA4ED254F22AA577BF3F070F21D
35+
6D3B63EE76E4440289ED91E9EAA2374B
36+
2FDCEEC57F2F4D0E83C312DAE6404E0E
37+
10C1BE2B6EE74AEEA798FD4F76D16F27
38+
4E73A1BAA99741B2B484DCDAD5541D97
39+
4CB1C9F16AA74FC996786497A034CF7A
40+
1E5F42316AAF44B48F06F72C5DCADC96
41+
D97FFA9C38A74848AD4FFDC0BCDFE397
42+
D527818259154E03AFD63714A59D6CCF
43+
5DDA33ADDA7A4C7380A7DFE5DAF429A5
44+
93B40E7017124F0083C13F2244DD58CB
45+
FD657708028A462D9BFC2143B0E7F847
46+
B30EEFE0D52843DC9A7F71C5A2108A60
47+
BCA196A6BBE44AADAC7B1C421A7ED832
48+
2C7191D0AB0F4E1AA45CBC8756E6987F
49+
BF15546D4BD84E02964D76165E9022D4
50+
C9DDD80402594334A5C4828C04832D60
51+
FA6532A3000C45478862A0156AD3E373
52+
F16CB5B1C76743379DE2104683CB840E
53+
2B5C6D0A188D462A8F3D7930ACB112D3
54+
F3EA1DF6A64146D592FA562C18BF4DD2
55+
4C52BFA77E654E178E4F096DB33C3D5B
56+
5DC2FD42388D48E7A95723E59BE1C259
57+
D291D238B3934F4FBF50E34452CFD557
58+
42C0AD39833949AD9BE90DA9444AD1D1
59+
4E8F59CF678445C494F34B5DA27D05B6
60+
7DBB506CB74D4C5AA7BC71A8C9F9846E
61+
4DFDB7E3E0DD4C4A9E08CFE4053692F1
62+
7B322AE2926B4FD69080BB9012447437
63+
302D9BD6D5CB4B88B1A3213057C5CC45
64+
7D09EEAC14B648C39C92088DDCCC8B7E
65+
6B3ED4C47E334791AE1CED843DAE4899
66+
CEA81BDA91A8439FB3018BEFB646F019
67+
315DBE136DB34FCA903D631286B1A662
68+
4B017A55EA7D410AAA790D2333C61594
69+
966549CCFA5C4B03BE79CFD916DC6269
70+
583AB01B84EA47CDA5A5C53AA27F06AA
71+
8E6DFAF297584D0AAB6ACFA339830A83
72+
A65F7467EFA34D61B2D20C1195841148
73+
06F4F523DCD94696906F2E2A56B46AC1
74+
5A6A59EE44E34E42AD58933B65227E05
75+
FA83E66777134C51BA4DA9E94956C6CD
76+
B64A713D76B941539628EA92B50A02D8
77+
9DCEA293DBCB45B2B560F6ECCEFCBF7B
78+
E55AF3850F6A4F07BB28E47065D8A238
79+
3B58A064F9174242829B8E0ADF8BA09B
80+
97A8300DD587458A92823F65DEFFFBB8
81+
F3A78DC166E94581A281533065F17311
82+
2D581CC2F7A2474B966C456559FAE3DA
83+
4536F8162A2041F68CB07E86BD2F46C2
84+
5153184E53234ACC8874EE00EF6FDA0E
85+
D57EB677DA234B629A24C056CB72BE00
86+
91901A4D1E1241448A6FD6C2413E818F
87+
93BB457333444545B4CB7A18F1934FDF
88+
9674B8DA0F2A405BB7E236DD40EDC7F1
89+
8207517B57AB484CB47DE54CBA20C893
90+
47A22567975746D2B42B822E5CBA4392
91+
C6BA941DCA8B409990A24BF64C9E06AA
92+
4421081C06EE48218C5B1D173D29804A
93+
367C39E7266A454E95D7888C9CE78F1C
94+
05E590CB231A40F3B8CA9F9FEAD869D9
95+
FCE6EC0EF03A4103BE4247525DCF7B79
96+
EBCC771A7DE74ADD989A81D586170E6B
97+
9C6060D6ECCF4A39BD08ABD50620D8EB
98+
EBD26DD692964D14BFBA5A7E3B934338
99+
D7575BEF63CB4A779FF25E9CBC864EC4
100+
7B41987358D24CDCA157FFF855B3420D
101+
D2A7DDC6BACC4A98B8239438CDACB3EE
102+
C4316AB1F8584178B0E06A263F9DBCA8
103+
A0FE533D1D0B43398109ADB210CD0404
104+
E68EAF900E9A410B8FDB13F32ECAFEC2
105+
55617EA7008A44D1AD5E8016410E1107
106+
FB952D010F9F4F32AC2364BA13475B17
107+
24980F4C2248479BA54A3FCD35D8C1A9
108+
58AD60569A774F16B1D551E097E9454F
109+
F9766715F95C416891A658475839AE7D
110+
F670ECA0929149FFA1D5AA272EACF1AD
111+
05F0A37684534FA282815093E7413D6A
112+
EFA810265E5F4D80BA80BC3E0F36ECFD
113+
96C9599153014A088DFCFE93E183C3F6
114+
C1762FCD8A9F4682ACA98D4CACCE24D0
115+
E4C8F0053414449294F74D190DD291E4
116+
199689A96CD041EB85CAE8C57BC6310E
117+
048927803E8D40E3AFF100314A163DC8
118+
B9818ADDA4E54AD7B0BDE413849F42D3
119+
E83CC52FFD6C481D9526C0E890D12723
120+
47E26674DCA54DA2B0A6D1BAB5854CF3
121+
102D42B66DA74A25923E5FE663FB7D82
122+
CD8438F4F88E419FB70BD6AD461C8BAD
123+
873FEA3FCB044970B15937CCFCC1AA13
124+
4025E874E046480BA91291D25D838E30
125+
B70D2D7AD78740F8979B9042E1E67B0A
126+
2DE11879D52848128C2E3378E45E8C54
127+
99D680CCBB3A45AF8B0ABFBF32E57FF1
128+
4B3A7DE5BF6A488B8339910416E8C611
129+
4E5AD5924441485E932DD7120284E93E
130+
D3C60168186244B2AA3FA579513A12D6
131+
75A9BD60F766410391861B8F6B958204
132+
7D3AB7509B1F4BF3B582446B759D16F9
133+
5A931FC10B1747FCA968B36A94DA6372
134+
1127110D4E66430C8A05128A87CF9BF5
135+
2E3391B7DCAB47FCBA4121925EE72616
136+
D585934B00364D22A44DC6F8A170BABA
137+
F3375085D86347B8A9346EEB05D85EFE
138+
6C98A9EB8CE5402A8008BC06E57FB72B
139+
9C8528B3090E448DA64DE005811834CB
140+
6394A70E285F4BADBC4D0C866DA3F8C7
141+
9DED2AC8E5914DFF8299309527764ADE
142+
8CE5DA9D7B57476FBC00AC7AD1B9CE03
143+
0D6C8D235E694E429FA84D3380FF4F26
144+
B7232772ECC54307B5C3834B2C3952E2
145+
A94A3B61F994447F9B3171D8078F0475
146+
B726C16CB4D04E7590221B40197BC76C
147+
A3C917BC085443558E87C352A9EDCD4E
148+
17622D7067D941B6BB505AF0E4F27B6D
149+
23218F4A89A549CAA2B30A992A37C639
150+
126DCC5794D44B4C8FE63CA36ECCDB5E
151+
B5EA3D5D1A88464C8E5EBB1BB287E972
152+
7A8BEB2465C8408DA00201C1F7B4AA10
153+
F3AF716F58654B02B97433A27846C7E7
154+
A87AE973D49D4154AC9D3BD4D7081436
155+
F44F33C608F6454F997D497B26FB3BBA
156+
969C4D7030C74661BCE12F793068D9D4
157+
D4DB2913A8D64F2BA98FEEB16028ECD3
158+
A4AE0465CCDC442FB3A793757CCB28A3
159+
8102CF06BAD24BBD8BEC48828AAC7D21
160+
CCD9B4EC7A67422D9447600ADDBE14EA
161+
4A138CC7A4924CE99E0B22A838AD5B17
162+
04C5741D3D594A1EBDE6A9C44A3AEB2E
163+
F3E98C2A7E0E4CDCB77BBE53BFC9CB20
164+
9983125A3B544AAE8F3FAEEE67780D43
165+
C92790AA97A54BCE9BC99210482722D0
166+
4124C0BE33024CD68CE0CB81289DBABA
167+
D31F84B4EBA54F9EA1A63377DA620B02
168+
56ABB33312C14F6D95EF9B7E939355FD
169+
A00C5FCC2A46473F8FBB9571C68925D0
170+
7DF5ABC4D6C841DDB65646C2101CDF75
171+
7DFB1BE67C1141CCA708EF1B0A2039D2
172+
77B726FD00DA4F42B8DE56B77B363FF8
173+
BC821284EE9D4EF99599A254301B7A9B
174+
0FAA403A28DF4396B3E020FEB7EA79DF
175+
F568103AA32E4985B544DF03CF6EB513
176+
8F8493CA9DC545CEB05A2BC09A0F2E5A
177+
682F0A441022424D89EE3F17DC6F4BD9
178+
FA74F790D66E4DAA9AA842EF0030FD24
179+
B984010789BB4B74AC0F4C8635C3912B
180+
AA6D2CBA27C643D48A8DB81A4EB16299
181+
9438EF86D80B4438948B8D593D90C91A
182+
59C16C42EF514F78835521931A03D9B5
183+
8189E4E9B8AD4092BFBF24DC76D92C5C
184+
AE5386C5809347D4A899218C86B0D10A
185+
A450A51757EA4CD0B47528D2FD4E9A5F
186+
DADFE9DE21A545F881F96D31ED817BB5
187+
CAAABF11539A49A5A7E5E055E18C5262
188+
B793CACDF5AE464F86ABC432966F3853
189+
D9B0417D1560454AADF1D87ECD98967A
190+
2262EE1EA75C4FDF8674EE2271D23FD8
191+
91380450B6474EA69C4D3A1DE3280A23
192+
2B67B8C203C648FCA5F6C0A0B085837F
193+
49AAAB2A48C645B5B0E2A3EA94143EB4
194+
AEC612FF401E4F448C9B5B5F32CA3F95
195+
BB651687308E420E84C2BF2475F1BBFC
196+
6BAFD6CE048644E6AF4C83B445A44167
197+
94775518A9CE40F3892427E4C0F9AA28
198+
27BE68E1B727408499DB50CDED3042F3
199+
212F1919D1FD44EDA80652FC1BB9B5D7
200+
4898E391F2704A81BA13D664A9ED433D

patchlion/0002/SaveSNsToMySQL.py

Lines changed: 35 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,35 @@
1+
# -*- coding: utf-8 -*-
2+
__author__ = 'PatchLion'
3+
4+
import pymysql
5+
6+
sns = []
7+
8+
with open('../0001/sns.txt', 'rt') as f:
9+
for line in f.readlines():
10+
sn = line.strip()
11+
sns.append(sn)
12+
13+
print(sns)
14+
15+
def insertToDB(sns):
16+
if(len(sns) == 0):
17+
return
18+
19+
conn = pymysql.connect(host='127.0.0.1', port=3306,user='root',password='root', db='python')
20+
cur = conn.cursor()
21+
try:
22+
cur.execute('DELETE FROM sns')
23+
conn.commit()
24+
25+
for sn in sns:
26+
cur.execute('INSERT INTO sns VALUE ("%s")' % sn)
27+
conn.commit()
28+
conn.close()
29+
30+
print('Done!')
31+
except:
32+
conn.rollback()
33+
34+
35+
insertToDB(sns)

patchlion/0004/CountChar.py

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
# -*- coding: utf-8 -*-
2+
__author__ = 'PatchLion'
3+
4+
result = {}
5+
6+
def doCount(c):
7+
if c in result.keys():
8+
result[c] = result[c]+1
9+
else:
10+
result[c]=1
11+
12+
def countChar(file_path):
13+
with open(file_path, 'rt') as f:
14+
txt = f.read()
15+
f.close()
16+
list(map(doCount, txt))
17+
18+
countChar('PrivacyPolicy.txt')
19+
20+
print(result)
21+
print(len(result))

patchlion/0004/PrivacyPolicy.txt

Lines changed: 37 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,37 @@
1+
Privacy Policy
2+
Last Updated: July 13, 2015
3+
=========================
4+
Your privacy is important to xxxxx. Our Privacy Policy covers how we collect, use, disclose, transfer, and store your information. We hope our policy is straightforward and easy-to-understand. Please take a minute to review the details of our privacy practices below.
5+
6+
Collection and Use of Non-Personal Information
7+
We may collect non-personal information, such as data that does not allow direct association with any specific individual. Non-personal data is collected, used, transferred, and disclosed for a number of purposes. These purposes include the use of cookies and other technologies that give us a better understanding of our users' needs. A "cookie" is a small data file that is stored on your device. Most Internet browsers automatically accept cookies. We use information collected from cookies to improve users' experience and the overall quality of our services.
8+
9+
Collection and Use of Personal Information / Content
10+
Personal information may be collected in a number of ways when you use any of the products or services offered by xxxxx. We may prompt you to voluntarily provide information, including personal information. For example, we may ask to collect your name, email address, user name, telephone number and credit card number whenever you register for an account, purchase our products, or contact us via email.
11+
12+
From time-to-time we may also collect personal information you provide in connection with your participation in surveys, sweepstakes, contests, promotional offers, and other activities on the site.
13+
14+
When you use our email support services, we collect your correspondence in order to build up a public knowledge base, which will be available to all users of the site. Your correspondence will most likely not be used verbatim, but paraphrased in an FAQ format.
15+
16+
We use the information collected through xxxxx products: (I) to communicate with you; (II) to process your requests and transactions; (III) to improve the site; (IV) to customize the services and/or products we provide to you; (V) to assist with our product and service development; (VI) to perform marketing analysis; and (VII) for other purposes related to our business.
17+
18+
The images you upload to xxxxx for editing will not be stored unless your request a link to revisit your works or you actually request a xxxxx service that requires storage of this image (e.g. to temporarily save the unfinished works under your xxxxx account).
19+
20+
If you are using xxxxx Market Service to share / sell your photo works, refer to clause "3 xxxxx's Use" of the "xxxxx Market Terms" in the "Terms of Services" for detailed information on how we handle these images.
21+
22+
Transparency and Choice
23+
You may configure your browser to block cookies, including cookies associated with our services. However, many of our services may not function correctly with cookies disabled. You can also control which social websites you upload images to.
24+
25+
Third party accounts
26+
xxxxx does not store your Facebook, Twitter, or Flickr passwords. Your account information is not disclosed to xxxxx and you are free to cancel any of your social networking website connections with xxxxx at any time.
27+
28+
Enforcement
29+
We regularly review our own compliance with our Privacy Policy. If you submit a formal written complaint, we will contact you and try our best to resolve the issue.
30+
31+
Changes
32+
Our Privacy Policy may change occasionally. We will not reduce your rights under this Privacy Policy without providing explicit, advanced notice. We will post any privacy policy changes on this page and, in the event of significant changes, we will provide a more prominent notice (such as an email notification). We will also archive prior versions of this Privacy Policy for your review.
33+
34+
35+
If you have any questions regarding this Privacy Policy, please feel free to contact us(Support@xxxxx.com).
36+
37+
Lines changed: 33 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,33 @@
1+
# -*- coding: utf-8 -*-
2+
__author__ = 'PatchLion'
3+
4+
from PIL import Image, ImageDraw, ImageFont, ImageFilter
5+
import random
6+
7+
def randChar():
8+
#65-90 A-Z
9+
return chr(random.randint(65, 90))
10+
11+
def randColor():
12+
return (random.randint(0, 255), random.randint(0, 255), random.randint(0, 255))
13+
14+
def createIdentifyingCode(size, charcount=4):
15+
width=size*charcount
16+
height=size
17+
18+
img = Image.new('RGB', (width, height), (255, 255, 255))
19+
draw = ImageDraw.Draw(img)
20+
for x in range(width):
21+
for y in range(height):
22+
draw.point((x, y), fill=randColor())
23+
24+
font = ImageFont.truetype("../0000/Varela-Regular.otf", size=size)
25+
#draw.text((0, 0), randChar(), fill=randColor())
26+
for i in range(charcount):
27+
draw.text((i*size + 10, -10), randChar(), fill=randColor(), font=font)
28+
29+
img = img.filter(ImageFilter.BLUR)
30+
img.save('ic.jpg', 'jpeg')
31+
32+
createIdentifyingCode(60)
33+

0 commit comments

Comments
 (0)