/
atom.xml
245 lines (191 loc) · 7.41 KB
/
atom.xml
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
<?xml version="1.0" encoding="utf-8"?>
<feed xmlns="http://www.w3.org/2005/Atom">
<title><![CDATA[Mike Tech]]></title>
<link href="http://mikegao.github.com/atom.xml" rel="self"/>
<link href="http://mikegao.github.com/"/>
<updated>2013-01-29T17:36:28+08:00</updated>
<id>http://mikegao.github.com/</id>
<author>
<name><![CDATA[Mike Gao]]></name>
<email><![CDATA[mike.gao0611@gmail.com]]></email>
</author>
<generator uri="http://octopress.org/">Octopress</generator>
<entry>
<title type="html"><![CDATA[五分钟冥想法]]></title>
<link href="http://mikegao.github.com/blog/five-minutes-of-meditation/"/>
<updated>2013-01-29T17:20:00+08:00</updated>
<id>http://mikegao.github.com/blog/five-minutes-of-meditation</id>
<content type="html"><![CDATA[<ol>
<li><p>原地不动,安静做好
坐在椅子上,双脚平放在地上,或盘腿坐在垫子上,背挺直,双手放在膝盖上,冥想时一定不要烦躁,这是自控力的基本保证,如果你想挠痒的话,可以调整一下胳膊的位置,腿交叉或伸直,看自己是否有冲动但能克制,简单的静坐对于意志力的冥想训练至关重要,你将学会,不再屈服于大脑和身体产生的冲动。</p></li>
<li><p>注意你的呼吸
闭上眼睛,要是怕睡着,你可以盯着某处看,比如盯着一面白墙,但不要看家庭购物频道,注意你的呼吸,吸气时在脑海中默念“吸”,呼气时再脑海中默念“呼”,当你发现自己有点走神的时候,重新将注意力集中到呼吸上,这种反复的注意力训练,能让前额皮质开启高速模式,让大脑中处理压力和冲动的区域更加稳定。</p></li>
<li><p>感受呼吸,弄清自己是怎么走神的
几分钟后,你就可以不再默念“呼”,“吸”了。试着专注于呼吸本身,你会注意到空气从鼻子和嘴巴进入和呼出的感觉,感觉到吸气时胸腹部的扩张和呼气时胸腹部的收缩。不再默念“呼”,“吸”后,你可能更容易走神,像之前一样,当你发现自己在想别的事情时,重新将注意力集中到呼吸上,如果你觉得很难重新集中注意力,就在心里默念几遍“呼”和“吸”,这部分的训练能锻炼你的自我意识和自控能力。</p></li>
</ol>
<p><em>刚开始的时候,你每天锻炼5分钟就行,习惯成自然之后,请试着每天做10-15分钟,如果你觉得有负担,那就减到5分钟。每天做比较短的训练,也比把比较长的训练拖到明天好。这样,你每天都会有一段固定的时间冥想,比如早晨洗澡之前,如果你做不到,可以对时间进行适当的调整。</em></p>
]]></content>
</entry>
<entry>
<title type="html"><![CDATA[Beginner_Of_Python]]></title>
<link href="http://mikegao.github.com/blog/beginner-of-python/"/>
<updated>2013-01-29T10:42:00+08:00</updated>
<id>http://mikegao.github.com/blog/beginner-of-python</id>
<content type="html"><![CDATA[<h4>变量交换</h4>
<pre><code>x = 6
y = 5
x, y = y, x
print x
>>> 5
print y
>>> 6
</code></pre>
<h4>if 语句再行内</h4>
<pre><code>print "Hello" if True else "World"
>>> Hello
</code></pre>
<h4>连接</h4>
<p> 下面的最后一种方式在绑定两个不同类型的对象时显得很cool</p>
<pre><code>nfc = ["Packers", "49ers"]
afc = ["Ravens", "Patriots"]
print nfc + afc
>>> ['Packers', '49ers', 'Ravens', 'Patriots']
print str(1) + " world"
>>> 1 world
pring 1, "world"
>>> 1 world
print nfc, 1
>>> ['Packers', '49ers'] 1
</code></pre>
<h4>数字技巧</h4>
<pre><code># 除后向下取整
print 5.0//2
>>> 2
# 2的5次方
print 2**5
>>> 32
</code></pre>
<h4>注意浮点数的除法</h4>
<pre><code>print .3/.1
>>> 2.9999999999999996
print .3//.1
>>> 2.0
</code></pre>
<h4>数值比较</h4>
<pre><code>x = 2
if 3 > x > 1:
print x
>>> 2
if 1 < x > 0:
print x
>>> 2
</code></pre>
<h4>同时迭代两个列表</h4>
<pre><code>nfc = ['Packers', '49ers']
afc = ['Ravens', 'Patriots']
for teama, teamb in zip(nfc, afc)
print teama + " vs. " + teamb
>>> Packers vs. Ravens
>>> 49ers vs. Patriots
</code></pre>
<h4>带索引的列表迭代</h4>
<pre><code>teams = ["Packers", "49ers", "Ravens", "Patriots"]
for index, team in enumerate(teams):
print index, team
>>> 0 Packers
>>> 1 49ers
>>> 2 Ravens
>>> 3 Patriots
</code></pre>
<h4>列表推导式</h4>
<p> 已知一个列表,我们可以刷选出偶数列表方法</p>
<pre><code>numbers = [1,2,3,4,5]
even = [number for number in numbers if number%2 == 0]
</code></pre>
<h4>字典推导</h4>
<p> 和列表推导类似</p>
<pre><code>teams = ['Packers', '49ers', 'Ravens', 'Patriots']
print {key: value for value, key in enumerate(teams)}
>>> {'49ers': 1, 'Ravens': 2, 'Patriots': 3, 'Packers': 0}
</code></pre>
<h4>初始化列表的值</h4>
<pre><code>items = [0]*3
print items
>>> [0, 0, 0]
</code></pre>
<h4>列表转换为字符串</h4>
<pre><code>teams = ['Packers', '49ers', 'Ravens', 'Patriots']
print ", ".join(teams)
>>> 'Packers, 49ers, Ravens, Patriots'
</code></pre>
<h4>从字典中获取元素</h4>
<pre><code>data = {'user': 1, 'name': 'Max', 'three': 4}
try:
is_admin = data['admin']
except KeyError:
is_admin = False
</code></pre>
<p> 替换成这样:</p>
<pre><code>data = {'user': 1, 'name': 'Max', 'three': 4}
is_admin = data.get('admin', False)
</code></pre>
<h4>获取列表的子集</h4>
<pre><code>x= [1,2,3,4,5]
# 前3个
print x[:3]
>>> [1, 2, 3]
# 中间4个
print x[1:5]
>>> [2, 3, 4, 5]
# 最后3个
print x[3:]
>>> [4, 5, 6]
# 奇数项
print x[::2]
>> [1, 3, 5]
# 偶数项
print x[1::2]
>> [2, 4, 6]
</code></pre>
<h4>60个字符解决FizzBuzz</h4>
<p> 写一个程序,打印数字1到100,3的倍数打印“Fizz”来替换这个数,5的倍数打印“Buzz”,对于既是3的倍数又是5的倍数的数字打印“FizzBuzz”</p>
<pre><code>for x in range(101):print'fizz'[x%3*4::]+'buzz'[x%5*4::]or x
</code></pre>
<h4>集合</h4>
<pre><code>from collections import Counter
print Counter("hello")
>>> Counter({'1': 2, 'h': 1, 'e': 1, 'o': 1})
</code></pre>
<h4>迭代工具</h4>
<p> 和collections库一样,还有一个库叫itertools,对某些问题真能高效地解决。其中一个用例是查找所有组合,他能告诉你在一个组中元素的所有不能的组合方式</p>
<pre><code>from itertools import combinations
teams = ["Packers", "49ers", "Ravens", "Patriots"]
for game in combinations(teams, 2):
print game
>>> ('Packers', '49ers')
>>> ('Packers', 'Ravens')
>>> ('Packers', 'Patriots')
>>> ('49ers', 'Ravens')
>>> ('49ers', 'Patriots')
>>> ('Ravens', 'Patriots')
</code></pre>
<h4>False == True</h4>
<pre><code>False = True
if False:
print "Hello"
else:
print "World"
>>> Hello
</code></pre>
]]></content>
</entry>
<entry>
<title type="html"><![CDATA[Hello World]]></title>
<link href="http://mikegao.github.com/blog/hello-world/"/>
<updated>2013-01-29T10:23:00+08:00</updated>
<id>http://mikegao.github.com/blog/hello-world</id>
<content type="html"><![CDATA[<p> 终于搞好了OctPress On Git Page!
继续Blog之旅</p>
]]></content>
</entry>
</feed>