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
Binary file removed .DS_Store
Binary file not shown.
Binary file added tongqi/0000/0000-out.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 tongqi/0000/0000.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
10 changes: 10 additions & 0 deletions tongqi/0000/0000.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
from PIL import Image, ImageFont, ImageDraw

text = "555"
img = Image.open("0000.png")
w_img, h_img=img.size
draw = ImageDraw.Draw(img)
font = ImageFont.truetype("msyh.ttf", 10)
w_font, h_font = draw.textsize(text, font)
draw.text((w_img-w_font, 0), text, fill="red", font=font)
img.save('0000-out.png')
Binary file added tongqi/0000/msyh.ttf
Binary file not shown.
3 changes: 3 additions & 0 deletions tongqi/0001/0001.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
import uuid

print [str(uuid.uuid1()) for i in range(200)]
4 changes: 4 additions & 0 deletions tongqi/0004/0004.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
import re

with open("english.txt") as f:
print len(re.findall("\w+", f.read()))
3 changes: 3 additions & 0 deletions tongqi/0004/english.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
Corporate Development, aka corp dev, is the group within companies that buys other companies. If you're talking to someone from corp dev, that's why, whether you realize it yet or not.

It's usually a mistake to talk to corp dev unless (a) you want to sell your company right now and (b) you're sufficiently likely to get an offer at an acceptable price. In practice that means startups should only talk to corp dev when they're either doing really well or really badly. If you're doing really badly, meaning the company is about to die, you may as well talk to them, because you have nothing to lose. And if you're doing really well, you can safely talk to them, because you both know the price will have to be high, and if they show the slightest sign of wasting your time, you'll be confident enough to tell them to get lost.
23 changes: 23 additions & 0 deletions tongqi/0005/0005.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
import os
from PIL import Image

def get_filepaths(directory):
file_paths = []
for root, directories, files in os.walk(directory):
for filename in files:
filepath = os.path.join(root, filename)
file_paths.append(filepath)

return file_paths

r_w, r_h = (1136, 640)

for infile in get_filepaths('dist'):
try:
im = Image.open(infile)
w, h = im.size
if w > r_w or h > r_h:
im.thumbnail((r_w, r_h), Image.ANTIALIAS)
im.save(infile)
except IOError:
print "cannot create thumbnail for '%s'" % infile
22 changes: 22 additions & 0 deletions tongqi/0006/0006.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
import os
import re
from collections import Counter

def get_filepaths(directory):
file_paths = []
for root, directories, files in os.walk(directory):
for filename in files:
filepath = os.path.join(root, filename)
file_paths.append(filepath)

return file_paths

def counter_more_words(li):
words_dict = Counter(li)
return [i[0] for i in words_dict.most_common()[:10]]

for diaryfile in get_filepaths('diaries'):
with open(diaryfile) as f:
word_li = re.findall("\w+", f.read())
print " ".join(counter_more_words(word_li))

3 changes: 3 additions & 0 deletions tongqi/0006/diaries/1.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
Corporate Development, aka corp dev, is the group within companies that buys other companies. If you're talking to someone from corp dev, that's why, whether you realize it yet or not.

It's usually a mistake to talk to corp dev unless (a) you want to sell your company right now and (b) you're sufficiently likely to get an offer at an acceptable price. In practice that means startups should only talk to corp dev when they're either doing really well or really badly. If you're doing really badly, meaning the company is about to die, you may as well talk to them, because you have nothing to lose. And if you're doing really well, you can safely talk to them, because you both know the price will have to be high, and if they show the slightest sign of wasting your time, you'll be confident enough to tell them to get lost.
3 changes: 3 additions & 0 deletions tongqi/0006/diaries/2.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
It's usually a mistake to talk to corp dev unless (a) you want to sell your company right now and (b) you're sufficiently likely to get an offer at an acceptable price. In practice that means startups should only talk to corp dev when they're either doing really well or really badly. If you're doing really badly, meaning the company is about to die, you may as well talk to them, because you have nothing to lose. And if you're doing really well, you can safely talk to them, because you both know the price will have to be high, and if they show the slightest sign of wasting your time, you'll be confident enough to tell them to get lost.

The danger is to companies in the middle. Particularly to young companies that are growing fast, but haven't been doing it for long enough to have grown big yet. It's usually a mistake for a promising company less than a year old even to talk to corp dev.
3 changes: 3 additions & 0 deletions tongqi/0006/diaries/3.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
The danger is to companies in the middle. Particularly to young companies that are growing fast, but haven't been doing it for long enough to have grown big yet. It's usually a mistake for a promising company less than a year old even to talk to corp dev.

But it's a mistake founders constantly make. When someone from corp dev wants to meet, the founders tell themselves they should at least find out what they want. Besides, they don't want to offend Big Company by refusing to meet.