Skip to content

Commit 5d2e108

Browse files
committed
preliminary solution for task 0004 added.
1 parent aac9f3e commit 5d2e108

4 files changed

Lines changed: 164 additions & 2 deletions

File tree

effy/0000/pillow_chesnut.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@
99
'''
1010
from PIL import Image, ImageDraw
1111
# open the base pic
12-
minion = Image.open("/Users/effy/Documents/python/effy/0000/zizi.gif").convert('RGBA')
12+
minion = Image.open("Your_Working_Directory_Path/python/effy/0000/zizi.gif").convert('RGBA')
1313
# new a transparent canvas for the annoying number :)
1414
annoying = Image.new('RGBA', minion.size, (255, 255, 255, 0))
1515
# get the drawing context , note that ImageDraw is the actionable module that will CREATE canvas on the base pic

effy/0002/0002.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,7 @@
2525
'''
2626
## activate echo option will print out actual SQL statement at each step, for debugging purposes
2727
## to connect to postgresql, create_engine('dialect://username:password@local:port/DBname')
28-
db = create_engine('postgresql://username:password@localhost:5432/dbname', echo=False)
28+
db = create_engine('postgresql://username:password@localhost:5432/DBname', echo=False)
2929

3030
'''
3131
Step 2:

effy/0004/0004_bad.py

Lines changed: 48 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,48 @@
1+
#!/usr/bin/env
2+
'''
3+
I HATE REGULAR EXPRESSION :(
4+
5+
So.. the following code is a very preliminary word processing,
6+
it won't split abbrevations, like "I'd", nor it won't split words
7+
concatenated with underscore, like "bad_game"
8+
'''
9+
import re
10+
def word_count(file_path):
11+
word_dict = {}
12+
with open(file_path) as txt:
13+
for line in txt:
14+
words = re.findall(r"\w+", line.strip())
15+
for word in words:
16+
word = word.lower()
17+
# dict.get() saves trouble of if/else block for checking
18+
# key existence.
19+
# some_dict.get(some_key, default_value) will return
20+
# default value is key is not in dict, while returns
21+
# actual value if key is present!
22+
word_dict[word] = word_dict.get(word,0) + 1
23+
return word_dict
24+
25+
result = word_count("Your_Working_Directory_Path/python/effy/0004/readme.txt")
26+
27+
###################################################################################
28+
29+
'''
30+
share a gain :)
31+
"How to "sort" a dict by its key/value"
32+
33+
Obviously, a dict can not be sorted, since it is orderless in nature.
34+
However, what we can do is to sort a representation(a list of tuples or a list of keys) of dict.
35+
Here is How:
36+
http://stackoverflow.com/questions/613183/sort-a-python-dictionary-by-value
37+
'''
38+
39+
import operator
40+
d = {"what": 3, "I": 19, "the":30}
41+
# to get a list of tuples with sorted items by the value
42+
sorted_d_by_value = sorted(d.items(), key=operator.itemgetter(1))
43+
# to get a list of tuples with sorted key
44+
sorted_d_by_key = sorted(d.items(), key=operator.itemgetter(0))
45+
print sorted_d_by_key
46+
47+
48+

effy/0004/readme.txt

Lines changed: 114 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,114 @@
1+
=== Plugin Name ===
2+
Contributors: (this should be a list of wordpress.org userid's)
3+
Donate link: http://example.com/
4+
Tags: comments, spam
5+
Requires at least: 3.0.1
6+
Tested up to: 3.4
7+
Stable tag: 4.3
8+
License: GPLv2 or later
9+
License URI: http://www.gnu.org/licenses/gpl-2.0.html
10+
11+
Here is a short description of the plugin. This should be no more than 150 characters. No markup here.
12+
13+
== Description ==
14+
15+
This is the long description. No limit, and you can use Markdown (as well as in the following sections).
16+
17+
For backwards compatibility, if this section is missing, the full length of the short description will be used, and
18+
Markdown parsed.
19+
20+
A few notes about the sections above:
21+
22+
* "Contributors" is a comma separated list of wp.org/wp-plugins.org usernames
23+
* "Tags" is a comma separated list of tags that apply to the plugin
24+
* "Requires at least" is the lowest version that the plugin will work on
25+
* "Tested up to" is the highest version that you've *successfully used to test the plugin*. Note that it might work on
26+
higher versions... this is just the highest one you've verified.
27+
* Stable tag should indicate the Subversion "tag" of the latest stable version, or "trunk," if you use `/trunk/` for
28+
stable.
29+
30+
Note that the `readme.txt` of the stable tag is the one that is considered the defining one for the plugin, so
31+
if the `/trunk/readme.txt` file says that the stable tag is `4.3`, then it is `/tags/4.3/readme.txt` that'll be used
32+
for displaying information about the plugin. In this situation, the only thing considered from the trunk `readme.txt`
33+
is the stable tag pointer. Thus, if you develop in trunk, you can update the trunk `readme.txt` to reflect changes in
34+
your in-development version, without having that information incorrectly disclosed about the current stable version
35+
that lacks those changes -- as long as the trunk's `readme.txt` points to the correct stable tag.
36+
37+
If no stable tag is provided, it is assumed that trunk is stable, but you should specify "trunk" if that's where
38+
you put the stable version, in order to eliminate any doubt.
39+
40+
== Installation ==
41+
42+
This section describes how to install the plugin and get it working.
43+
44+
e.g.
45+
46+
1. Upload `plugin-name.php` to the `/wp-content/plugins/` directory
47+
1. Activate the plugin through the 'Plugins' menu in WordPress
48+
1. Place `<?php do_action('plugin_name_hook'); ?>` in your templates
49+
50+
== Frequently Asked Questions ==
51+
52+
= A question that someone might have =
53+
54+
An answer to that question.
55+
56+
= What about foo bar? =
57+
58+
Answer to foo bar dilemma.
59+
60+
== Screenshots ==
61+
62+
1. This screen shot description corresponds to screenshot-1.(png|jpg|jpeg|gif). Note that the screenshot is taken from
63+
the /assets directory or the directory that contains the stable readme.txt (tags or trunk). Screenshots in the /assets
64+
directory take precedence. For example, `/assets/screenshot-1.png` would win over `/tags/4.3/screenshot-1.png`
65+
(or jpg, jpeg, gif).
66+
2. This is the second screen shot
67+
68+
== Changelog ==
69+
70+
= 1.0 =
71+
* A change since the previous version.
72+
* Another change.
73+
74+
= 0.5 =
75+
* List versions from most recent at top to oldest at bottom.
76+
77+
== Upgrade Notice ==
78+
79+
= 1.0 =
80+
Upgrade notices describe the reason a user should upgrade. No more than 300 characters.
81+
82+
= 0.5 =
83+
This version fixes a security related bug. Upgrade immediately.
84+
85+
== Arbitrary section ==
86+
87+
You may provide arbitrary sections, in the same format as the ones above. This may be of use for extremely complicated
88+
plugins where more information needs to be conveyed that doesn't fit into the categories of "description" or
89+
"installation." Arbitrary sections will be shown below the built-in sections outlined above.
90+
91+
== A brief Markdown Example ==
92+
93+
Ordered list:
94+
95+
1. Some feature
96+
1. Another feature
97+
1. Something else about the plugin
98+
99+
Unordered list:
100+
101+
* something
102+
* something else
103+
* third thing
104+
105+
Here's a link to [WordPress](http://wordpress.org/ "Your favorite software") and one to [Markdown's Syntax Documentation][markdown syntax].
106+
Titles are optional, naturally.
107+
108+
[markdown syntax]: http://daringfireball.net/projects/markdown/syntax
109+
"Markdown is what the parser uses to process much of the readme file"
110+
111+
Markdown uses email style notation for blockquotes and I've been told:
112+
> Asterisks for *emphasis*. Double it up for **strong**.
113+
114+
`<?php code(); // goes in backticks ?>`

0 commit comments

Comments
 (0)