Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
23 changes: 23 additions & 0 deletions evan69/0000/0000.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
# coding=utf-8
from PIL import Image,ImageFont,ImageDraw
import sys
def add_number(filename,number):
mystr = str(min(99,number))
al = 0.4
if number > 99:
mystr += '+'
al = 0.25
print mystr
img = Image.open(filename)
fontsize = min(img.size[0],img.size[1])
print img.size
fontsize = int(fontsize * al)
font = ImageFont.truetype('Arial.ttf',size = fontsize)
position = img.size[0] - font.getsize(mystr)[0]
dr = ImageDraw.Draw(img)
dr.text((position,0),mystr,font = font,fill = (255,0,0,255))
return img

filename = sys.argv[1]
num = sys.argv[2]
add_number(filename,int(num)).save(num + '_' + filename)
Binary file added evan69/0000/1.jpg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added evan69/0000/2.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added evan69/0000/Arial.ttf
Binary file not shown.
20 changes: 20 additions & 0 deletions evan69/0001/0001.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
# -*- coding: utf-8 -*-
# 做为 Apple Store App 独立开发者,你要搞限时促销,为你的应用生成激活码(或者优惠券),使用 Python 如何生成 200 个激活码(或者优惠券)?

import uuid

def produce_str(num = 200):
str_list = []
i = 0
while True:
i = i + 1
if i > num:
break
mystr = str(uuid.uuid1()).replace('-','')
if mystr not in str_list:
str_list.append(mystr)
return str_list


a = produce_str()
print a
18 changes: 18 additions & 0 deletions evan69/0004/0004.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
import collections,re
import sys
def cal(filename = 'in.txt'):
print 'now processing:' + filename + '......'
f = open(filename,'r')
data = f.read()
dic = collections.defaultdict(lambda :0)
data = re.sub(r'[\W\d]',' ',data)
data = data.lower()
datalist = data.split(' ')
for item in datalist:
dic[item] += 1
del dic['']
return dic
try:
print sorted(cal().items())
except:
print 'no input file'
32 changes: 32 additions & 0 deletions evan69/0004/in.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
If you are looking for someone you can pour out your love to, let me suggest the empowered woman. The empowered woman knows what she wants, knows how to get it, knows how to live fully, and she knows how to love you back without needing anyone’s approval or recognition. An empowered woman is unarguably one of the most magnificent beings you will ever come in contact with. Read on and find 10 reason why you should absolutely love and embrace the empowered women in your life! .

1. She knows how to love you in return
It is difficult to give what you don’t have. It is impossible to love someone and feel fulfilled when they can’t love you in return because they don’t love themselves. This will never happen to you when you love an empowered woman. She loves herself (not in a narcissistic manner). In turn, she appreciates who you are and loves you in return. She will love you just like you deserve to be loved.

2. She will inspire you
When life puts you down and you are at the end of your rope, the empowered woman will be there to see you through. Her drive, enthusiasm and (at times) hopeless optimism will inspire you to carry on despite the obstacles you face.

3. She is not afraid of failure
While many out there are thoroughly terrified of failure, the empowered woman understands that failures are simply stepping stones in life. How can you not love someone that is thoroughly unafraid to try, fail, and give it a shot all over again?!

4. She is all about the legacy
While most people are focused on the car, the house, the job, and corner office; the empowered woman is focused on leaving a legacy that will inspire others and change the world. The empowered woman is focused on empowering others to maximize their potential and fulfill their purpose. She is all about inspiring others to look beyond themselves and live a life of service to others.

5. She can laugh at her mistakes…
…and learn from them as well! She understands mistakes are part of the journey. The empowered woman can laugh and learn from her mistakes to ensure they never happen again.

6. She can be vulnerable
The empowered woman understands there is no debt in relationships without vulnerability. Although she is emotionally strong, she is willing to laugh and cry with you because all of these emotions are an essential part of life.

7. She can speak her mind
While everyone else is too concerned with what others may think or say, the empowered woman is not afraid to speak her mind. She understands that her value comes from within, not from what others say or think about her.

8. She knows when to remain quiet
She lives by Abe Lincoln’s words, “Better to remain silent and be thought a fool, than to speak out and remove all doubt.”

9. She knows how to have fun
Whether it is at the symphony or at a ball game, the empowered woman understands life is made up of experiences with people – not the places you go. She is able to live in the moment and enjoy it fully without being concerned for the future. After all, who’s got a guaranteed future?

10. She is not afraid of change
While most people rather continue on living unfulfilled lives as long as their comfort zone remains intact, the empowered woman is all about embracing change. She understands growth cannot happen without change. She understands that change is the gift life offers you to choose your destiny. Therefore, she is not afraid of change because it is her stepping stone towards success.

37 changes: 37 additions & 0 deletions evan69/0007/0007.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
#coding:utf8
import sys,os,re

def cal(path):
filelist = os.listdir(path)
#print filelist
filelist = (item for item in filelist if item.endswith('.py'))
ret = [0,0,0]
for item in filelist:
res = calfile(path,item)
for i in (0,1,2):
ret[i] += res[i]
return tuple(ret)

def calfile(path,filename):
totline = 0
blankline = 0
commentline = 0
fileobj = open(path + filename,'r')
linelist = fileobj.readlines()
totline = len(linelist)
for line in linelist:
pattern = re.compile(r'(\s*)#')
pattern1 = re.compile(r'(\s*)$')
if pattern.match(line):
commentline += 1
if pattern1.match(line):
blankline += 1
fileobj.close()
return totline,blankline,commentline

#path = r'/home/evan/Desktop/py/python/evan69/0007/'
path = sys.argv[1]
data = cal(path)
dic = dict(zip(['total line','blank line','comment line'],list(data)))
print dic