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
28 changes: 28 additions & 0 deletions burun/exercise_0000/add_number_to_avatar.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
#!/usr/bin/env python
# -*- encoding: utf-8 -*-
# Date: 22-02-15
# Author: Liang


from PIL import Image, ImageDraw, ImageFont


def add_number(image_path, number):
im = Image.open(image_path)
width, height = im.size

# get a drawing context
avatar_draw = ImageDraw.Draw(im)
# set the font of number to draw
font_size = int(height / 4)
number_font = ImageFont.truetype('microsoft_yahei.TTF', font_size)

# Draw the image with a number(xy, text, color, font)
avatar_draw.text(
(width - font_size, 0), str(number), (255, 0, 0), font=number_font)

im.save('./new_avatar.jpg')
im.show()


add_number('avatar.png', 3)
Binary file added burun/exercise_0000/avatar.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 burun/exercise_0000/microsoft_yahei.TTF
Binary file not shown.
1 change: 1 addition & 0 deletions burun/exercise_0000/requirements.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
pillow==2.7.0
15 changes: 15 additions & 0 deletions burun/exercise_0001/coupon_code_generator.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
#!/usr/bin/env python
# -*- encoding: utf-8 -*-
# Date: 23-02-15
# Author: Liang

import random
import string

coupon_number = 200
coupon_size = 12

for i in range(coupon_number):
coupon = ''.join(
random.sample(string.digits + string.ascii_uppercase, coupon_size))
print(coupon)
30 changes: 30 additions & 0 deletions burun/exercise_0004/count_words.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
#!/usr/bin/env python
# -*- encoding: utf-8 -*-
# Date: 10-03-15
# Author: Liang

import re
import operator

# Read the file
myfile = open('english_text.txt', 'r')
# Extract words from file excluding punctuation and /n
words = re.findall(r"[\w']+", myfile.read())

# Dictionary contains all the words and frequencies
words_dictionary = {}

# Count frequencies
for word in words:
if word not in words_dictionary:
# Put word in dictionary
words_dictionary[word] = 0
for item in words:
if item == word:
words_dictionary[word] += 1

# Sort the words by frequencies
sort_words_dictionary = sorted(
words_dictionary.items(), key=operator.itemgetter(1), reverse=True)

print(sort_words_dictionary)
3 changes: 3 additions & 0 deletions burun/exercise_0004/english_text.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
ClinicalTrials.gov provides a remarkable resource of information regarding drug development for AD and other disorders. Trends in AD drug development over time can be seen, and the movement of the drugs through the pipeline can be monitored. ClinicalTrials.gov has provided comprehensive information since 2007, when registration of clinical trials was required by the FDA. The analyses demonstrate that the number of clinical trials has been declining since the 2008 through 2009 period. The pharmaceutical industry sponsors most drug development for AD, whereas NIH accounts for a relatively small percentage of drug development. The United States has the largest number of clinical trials of any single country, but more clinical trials are conducted outside of the United States than inside of the United States.
Most trials address symptomatic agents intended to improve cognition, but disease-modifying small molecules and disease-modifying immunotherapies are also represented in the drug-development pipeline. More therapies address amyloid-beta targets than any other single target. Phase 2 trials are smaller and shorter than Phase 3 trials, and sponsors have relatively limited experience with most molecules when they enter Phase 3.
Most drugs entering the AD drug-development pipeline have failed; only one agent has been approved since 2004 (memantine). The failure rate since 2002 (excluding agents currently in Phase 3) is 99.6%. Currently, 108 trials of AD therapies represent 94 unique agents. This is a relatively small number of test compounds. The small number of agents in Phase 1 is particularly concerning, as it suggests that relatively few drugs are entering the AD drug-development process. Repurposed agents may enter the pipeline at later phases, but it is unlikely that a large number of repurposed agents will be assessed. The AD drug-development pipeline is relatively small, and the rate of success of AD clinical trials is limited. An urgent need exists to increase the number of agents entering the pipeline and progressing successfully toward new therapy for patients with AD.
Binary file added burun/exercise_0005/img/img1.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 burun/exercise_0005/img/img2.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 burun/exercise_0005/img/img3.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 burun/exercise_0005/img/img4.jpg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
39 changes: 39 additions & 0 deletions burun/exercise_0005/img_resizer.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,39 @@
#!/usr/bin/env python
# -*- encoding: utf-8 -*-
# Date: 11-03-15
# Author: Liang

import os
from PIL import Image

# Set input and output path
img_path = "img/"
new_img_path = "new_img/"
# list all the files in dir
dirs = os.listdir(img_path)

# iphone 5 resolution
iphone_width = 640
iphone_height = 1136


def resizer(img, iwidth, iheight):
im = Image.open(img_path + img)
width, height = im.size
# To decide the ratio to resize
if width > iwidth or height > iheight:
if width / iwidth > height / iheight:
ratio = width / iwidth
else:
ratio = height / iheight
resized_img = im.resize(
(int(width / ratio), int(height / ratio)), Image.ANTIALIAS)
else:
resized_img = im
print("The new size is: ", end=" ")
print(resized_img.size)
resized_img.save(new_img_path + img)


for img in dirs:
resizer(img, iphone_width, iphone_height)
Binary file added burun/exercise_0005/new_img/img1.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 burun/exercise_0005/new_img/img2.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 burun/exercise_0005/new_img/img3.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 burun/exercise_0005/new_img/img4.jpg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
1 change: 1 addition & 0 deletions burun/exercise_0005/requirements.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
pillow==2.7.0