-
Notifications
You must be signed in to change notification settings - Fork 0
/
atom.xml
662 lines (534 loc) · 50.5 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
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
<?xml version="1.0" encoding="utf-8"?>
<feed xmlns="http://www.w3.org/2005/Atom">
<title><![CDATA[流水笔记]]></title>
<link href="http://huangcd.github.com/atom.xml" rel="self"/>
<link href="http://huangcd.github.com/"/>
<updated>2012-07-27T13:54:33+08:00</updated>
<id>http://huangcd.github.com/</id>
<author>
<name><![CDATA[huangcd]]></name>
</author>
<generator uri="http://octopress.org/">Octopress</generator>
<entry>
<title type="html"><![CDATA[Sublime Text 2各种插件及使用方法]]></title>
<link href="http://huangcd.github.com/blog/2012/07/25/sublime-text-package-usage/"/>
<updated>2012-07-25T17:32:00+08:00</updated>
<id>http://huangcd.github.com/blog/2012/07/25/sublime-text-package-usage</id>
<content type="html"><![CDATA[<h2>SublimeCodeIntel</h2>
<p>支持N多语言的Intelligence。主要提供几个功能。</p>
<ul>
<li>定义跳转(光标在标示符上的时候按<code>ctrl+F3</code>或者<code>alt+鼠标左键</code></li>
<li>自动补全(写的时候会自动出来,如果没有自动出来可以按<code>ctrl+j</code>强制弹出(貌似没有效果))</li>
</ul>
<h3>配置</h3>
<p>可以配置外部库的路径,具体参考自带文档。。。</p>
<h2>Pylinter</h2>
<p>Python代码的动态检查(主要是语法和格式层面的),打开py文件就会自动运行。有错误/警告的地方会用方框框住,光标移到方框里面的时候会在状态栏支出错误/警告的内容。有几个快捷键<code>ctrl+alt+x</code>、<code>ctrl+alt+z</code>、<code>ctrl+alt+c</code>,不够实测都没什么用。。。</p>
<h3>配置</h3>
<p>Pylinter依赖python的pylint包,运行前需要修改目录下的Pylinter.sublime-settings的文件。设置pylint_path变量,指定pylint的位置。</p>
<h2>Sublime Alignment</h2>
]]></content>
</entry>
<entry>
<title type="html"><![CDATA[Scope学习笔记]]></title>
<link href="http://huangcd.github.com/blog/2012/07/25/scope-notes/"/>
<updated>2012-07-25T11:29:00+08:00</updated>
<id>http://huangcd.github.com/blog/2012/07/25/scope-notes</id>
<content type="html"><![CDATA[
]]></content>
</entry>
<entry>
<title type="html"><![CDATA[Awk 简单应用]]></title>
<link href="http://huangcd.github.com/blog/2012/07/25/awk-usage/"/>
<updated>2012-07-25T11:17:00+08:00</updated>
<id>http://huangcd.github.com/blog/2012/07/25/awk-usage</id>
<content type="html"><![CDATA[
<figure class='code'><figcaption><span>使用制表符\t来过滤第4列的元素 </span></figcaption>
<div class="highlight"><table><tr><td class="gutter"><pre class="line-numbers"><span class='line-number'>1</span>
</pre></td><td class='code'><pre><code class='awk'><span class='line'><span class="nx">awk</span> <span class="s1">'BEGIN {FS = "[\t]+" }; {print $1"\t"$2"\t"$3"\t"$5"\t"$6}'</span>
</span></code></pre></td></tr></table></div></figure>
]]></content>
</entry>
<entry>
<title type="html"><![CDATA[使用LINQ表达式来求素数]]></title>
<link href="http://huangcd.github.com/blog/2012/07/21/sieve-using-linq/"/>
<updated>2012-07-21T12:03:00+08:00</updated>
<id>http://huangcd.github.com/blog/2012/07/21/sieve-using-linq</id>
<content type="html"><![CDATA[<p>不得不说,这是相当无聊的问题,用LINQ来做Sieve,不仅效率低,而且可读性差,因此纯粹是练习LINQ。。</p>
<p>同样不得不说的是,Aggregate函数(也就是一般意义上的reduce函数)确实异常强大。。</p>
<figure class='code'><figcaption><span>sieve in LINQ </span></figcaption>
<div class="highlight"><table><tr><td class="gutter"><pre class="line-numbers"><span class='line-number'>1</span>
<span class='line-number'>2</span>
<span class='line-number'>3</span>
<span class='line-number'>4</span>
<span class='line-number'>5</span>
<span class='line-number'>6</span>
<span class='line-number'>7</span>
<span class='line-number'>8</span>
<span class='line-number'>9</span>
<span class='line-number'>10</span>
<span class='line-number'>11</span>
<span class='line-number'>12</span>
<span class='line-number'>13</span>
<span class='line-number'>14</span>
<span class='line-number'>15</span>
</pre></td><td class='code'><pre><code class='csharp'><span class='line'><span class="k">public</span> <span class="n">IEnumerable</span><span class="p"><</span><span class="kt">int</span><span class="p">></span> <span class="n">GetPrimesUsingLinq</span><span class="p">(</span><span class="kt">int</span> <span class="n">maxValue</span><span class="p">)</span>
</span><span class='line'><span class="p">{</span>
</span><span class='line'> <span class="k">return</span> <span class="n">Enumerable</span><span class="p">.</span><span class="n">Range</span><span class="p">(</span><span class="m">2</span><span class="p">,</span> <span class="n">maxValue</span> <span class="p">-</span> <span class="m">1</span><span class="p">).</span><span class="n">Aggregate</span><span class="p">(</span>
</span><span class='line'> <span class="n">Enumerable</span><span class="p">.</span><span class="n">Range</span><span class="p">(</span><span class="m">0</span><span class="p">,</span> <span class="n">maxValue</span> <span class="p">+</span> <span class="m">1</span><span class="p">).</span><span class="n">ToList</span><span class="p">(),</span>
</span><span class='line'> <span class="p">(</span><span class="n">sieve</span><span class="p">,</span> <span class="n">x</span><span class="p">)</span> <span class="p">=></span>
</span><span class='line'> <span class="p">{</span>
</span><span class='line'> <span class="k">if</span> <span class="p">(</span><span class="n">sieve</span><span class="p">[</span><span class="n">x</span><span class="p">]</span> <span class="p">></span> <span class="m">0</span><span class="p">)</span>
</span><span class='line'> <span class="p">{</span>
</span><span class='line'> <span class="n">Enumerable</span><span class="p">.</span><span class="n">Range</span><span class="p">(</span><span class="m">2</span><span class="p">,</span> <span class="n">maxValue</span> <span class="p">/</span> <span class="n">x</span> <span class="p">-</span> <span class="m">1</span><span class="p">).</span><span class="n">Select</span><span class="p">(</span><span class="n">i</span> <span class="p">=></span> <span class="n">i</span> <span class="p">*</span> <span class="n">x</span><span class="p">).</span><span class="n">Aggregate</span><span class="p">(</span><span class="n">sieve</span><span class="p">,</span> <span class="p">(</span><span class="n">s</span><span class="p">,</span> <span class="n">i</span><span class="p">)</span> <span class="p">=></span> <span class="p">{</span> <span class="n">s</span><span class="p">[</span><span class="n">i</span><span class="p">]</span> <span class="p">=</span> <span class="m">0</span><span class="p">;</span> <span class="k">return</span> <span class="n">s</span><span class="p">;</span> <span class="p">});</span>
</span><span class='line'> <span class="p">}</span>
</span><span class='line'> <span class="k">return</span> <span class="n">sieve</span><span class="p">;</span>
</span><span class='line'> <span class="p">},</span>
</span><span class='line'> <span class="n">x</span> <span class="p">=></span> <span class="n">x</span><span class="p">.</span><span class="n">Where</span><span class="p">(</span><span class="n">i</span> <span class="p">=></span> <span class="n">i</span> <span class="p">></span> <span class="m">1</span><span class="p">)</span>
</span><span class='line'> <span class="p">);</span>
</span><span class='line'><span class="p">}</span>
</span></code></pre></td></tr></table></div></figure>
]]></content>
</entry>
<entry>
<title type="html"><![CDATA[使用Octopress在github搭建博客]]></title>
<link href="http://huangcd.github.com/blog/2012/07/19/shi-yong-octopresszai-githubda-jian-bo-ke/"/>
<updated>2012-07-19T16:48:00+08:00</updated>
<id>http://huangcd.github.com/blog/2012/07/19/shi-yong-octopresszai-githubda-jian-bo-ke</id>
<content type="html"><![CDATA[<ul>
<li>使用<a href="http://rubyforge.org/frs/download.php/75127/rubyinstaller-1.9.2-p290.exe">rubyInstaller</a>安装ruby1.9.2</li>
<li>使用<a href="http://code.google.com/p/msysgit/downloads/list">msysgit</a>安装git</li>
<li>按照<a href="https://github.com/oneclick/rubyinstaller/wiki/development-kit">教程</a>安装<a href="https://github.com/downloads/oneclick/rubyinstaller/DevKit-tdm-32-4.5.2-20111229-1559-sfx.exe">development-kit</a></li>
<li>在命令行下执行下面代码</li>
</ul>
<figure class='code'><figcaption><span>gem install </span></figcaption>
<div class="highlight"><table><tr><td class="gutter"><pre class="line-numbers"><span class='line-number'>1</span>
<span class='line-number'>2</span>
<span class='line-number'>3</span>
<span class='line-number'>4</span>
</pre></td><td class='code'><pre><code class='sh'><span class='line'>git clone git://github.com/imathis/octopress.git octopress
</span><span class='line'><span class="nb">cd </span>octopress
</span><span class='line'>gem install bundler
</span><span class='line'>bundle install
</span></code></pre></td></tr></table></div></figure>
<p>安装过程中可能会遇到一些问题,自行google之。</p>
<figure class='code'><figcaption><span>gem source </span></figcaption>
<div class="highlight"><table><tr><td class="gutter"><pre class="line-numbers"><span class='line-number'>1</span>
<span class='line-number'>2</span>
</pre></td><td class='code'><pre><code class='sh'><span class='line'>gem sources --remove http://rubygems.org/
</span><span class='line'>gem sources -a http://ruby.taobao.org/
</span></code></pre></td></tr></table></div></figure>
<p>如果gem install的速度比较慢,可以把gem的源换成taobao的。</p>
<ul>
<li>在github创建一个名字为[userName].github.com的项目,然后根据<a href="https://help.github.com/">help</a>的内容进行配置。</li>
<li>执行下面代码</li>
</ul>
<figure class='code'><figcaption><span>setup and deploy </span></figcaption>
<div class="highlight"><table><tr><td class="gutter"><pre class="line-numbers"><span class='line-number'>1</span>
<span class='line-number'>2</span>
<span class='line-number'>3</span>
</pre></td><td class='code'><pre><code class=''><span class='line'>rake setup_github_pages
</span><span class='line'>rake generate
</span><span class='line'>rake deploy</span></code></pre></td></tr></table></div></figure>
]]></content>
</entry>
<entry>
<title type="html"><![CDATA[函数式C#的尝试]]></title>
<link href="http://huangcd.github.com/blog/2012/07/18/functional-c-number/"/>
<updated>2012-07-18T07:20:00+08:00</updated>
<id>http://huangcd.github.com/blog/2012/07/18/functional-c-number</id>
<content type="html"><![CDATA[<p>由于工作的需要,最近需要大量使用MS系的产品,Visual Studio和C#首当其冲(吐槽一下,Visual Studio的快捷键和Intelligence太弱了,好不容易有个ReSharper还是收费的。。。)</p>
<p>不得不说,几年不见,C#跟以前长得都不一样了。我印象中的C#基本上是Java的翻版,现在一看,我勒个去,各种lambda、LINQ满天飞。。。</p>
<!--more-->
<p>lambda是我喜欢的,作为一个低级的Haskell爱好者和Python的中度用户,lambda表达式为链式处理带来的快捷体验是无可比拟的,Python的map、reduce、filter这些函数式方法以及Generator Expression是谁用谁知道啊。</p>
<p>粗略看了一下C#,发现居然没有map、reduce、filter几个函数,深感无力,决定自己轮子一下:</p>
<figure class='code'><figcaption><span>functional C# </span></figcaption>
<div class="highlight"><table><tr><td class="gutter"><pre class="line-numbers"><span class='line-number'>1</span>
<span class='line-number'>2</span>
<span class='line-number'>3</span>
<span class='line-number'>4</span>
<span class='line-number'>5</span>
<span class='line-number'>6</span>
<span class='line-number'>7</span>
<span class='line-number'>8</span>
<span class='line-number'>9</span>
<span class='line-number'>10</span>
<span class='line-number'>11</span>
<span class='line-number'>12</span>
<span class='line-number'>13</span>
<span class='line-number'>14</span>
<span class='line-number'>15</span>
<span class='line-number'>16</span>
<span class='line-number'>17</span>
<span class='line-number'>18</span>
<span class='line-number'>19</span>
<span class='line-number'>20</span>
<span class='line-number'>21</span>
<span class='line-number'>22</span>
<span class='line-number'>23</span>
<span class='line-number'>24</span>
<span class='line-number'>25</span>
<span class='line-number'>26</span>
<span class='line-number'>27</span>
<span class='line-number'>28</span>
<span class='line-number'>29</span>
<span class='line-number'>30</span>
<span class='line-number'>31</span>
<span class='line-number'>32</span>
<span class='line-number'>33</span>
<span class='line-number'>34</span>
</pre></td><td class='code'><pre><code class='csharp'><span class='line'><span class="k">public</span> <span class="k">static</span> <span class="n">IEnumerable</span><span class="p"><</span><span class="n">TResult</span><span class="p">></span> <span class="n">Map</span><span class="p"><</span><span class="n">TSource</span><span class="p">,</span> <span class="n">TResult</span><span class="p">></span>
</span><span class='line'> <span class="p">(</span><span class="n">IEnumerable</span><span class="p"><</span><span class="n">TSource</span><span class="p">></span> <span class="n">sources</span><span class="p">,</span> <span class="n">Converter</span><span class="p"><</span><span class="n">TSource</span><span class="p">,</span> <span class="n">TResult</span><span class="p">></span> <span class="n">converter</span><span class="p">)</span>
</span><span class='line'><span class="p">{</span>
</span><span class='line'> <span class="k">foreach</span> <span class="p">(</span><span class="kt">var</span> <span class="n">source</span> <span class="k">in</span> <span class="n">sources</span><span class="p">)</span>
</span><span class='line'> <span class="p">{</span>
</span><span class='line'> <span class="k">yield</span> <span class="k">return</span> <span class="nf">converter</span><span class="p">(</span><span class="n">source</span><span class="p">);</span>
</span><span class='line'> <span class="p">}</span>
</span><span class='line'><span class="p">}</span>
</span><span class='line'>
</span><span class='line'><span class="k">public</span> <span class="k">static</span> <span class="n">IEnumerable</span><span class="p"><</span><span class="n">TItem</span><span class="p">></span> <span class="n">Filter</span><span class="p"><</span><span class="n">TItem</span><span class="p">></span>
</span><span class='line'> <span class="p">(</span><span class="n">IEnumerable</span><span class="p"><</span><span class="n">TItem</span><span class="p">></span> <span class="n">sources</span><span class="p">,</span> <span class="n">Predicate</span><span class="p"><</span><span class="n">TItem</span><span class="p">></span> <span class="n">predicater</span><span class="p">)</span>
</span><span class='line'><span class="p">{</span>
</span><span class='line'> <span class="k">foreach</span> <span class="p">(</span><span class="kt">var</span> <span class="n">item</span> <span class="k">in</span> <span class="n">sources</span><span class="p">)</span>
</span><span class='line'> <span class="p">{</span>
</span><span class='line'> <span class="k">if</span> <span class="p">(</span><span class="n">predicater</span><span class="p">(</span><span class="n">item</span><span class="p">))</span>
</span><span class='line'> <span class="p">{</span>
</span><span class='line'> <span class="k">yield</span> <span class="k">return</span> <span class="n">item</span><span class="p">;</span>
</span><span class='line'> <span class="p">}</span>
</span><span class='line'> <span class="p">}</span>
</span><span class='line'><span class="p">}</span>
</span><span class='line'>
</span><span class='line'><span class="k">public</span> <span class="k">delegate</span> <span class="n">TResult</span> <span class="n">Accumulator</span><span class="p"><</span><span class="k">in</span> <span class="n">TSource</span><span class="p">,</span> <span class="n">TResult</span><span class="p">></span>
</span><span class='line'> <span class="p">(</span><span class="n">TSource</span> <span class="n">source</span><span class="p">,</span> <span class="n">TResult</span> <span class="n">result</span><span class="p">);</span>
</span><span class='line'>
</span><span class='line'><span class="k">public</span> <span class="k">static</span> <span class="n">TResult</span> <span class="n">Reduce</span><span class="p"><</span><span class="n">TSource</span><span class="p">,</span> <span class="n">TResult</span><span class="p">></span>
</span><span class='line'> <span class="p">(</span><span class="n">IEnumerable</span><span class="p"><</span><span class="n">TSource</span><span class="p">></span> <span class="n">sources</span><span class="p">,</span> <span class="n">TResult</span> <span class="n">initValue</span><span class="p">,</span>
</span><span class='line'> <span class="n">Accumulator</span><span class="p"><</span><span class="n">TSource</span><span class="p">,</span> <span class="n">TResult</span><span class="p">></span> <span class="n">accumulator</span><span class="p">)</span>
</span><span class='line'><span class="p">{</span>
</span><span class='line'> <span class="k">foreach</span> <span class="p">(</span><span class="kt">var</span> <span class="n">source</span> <span class="k">in</span> <span class="n">sources</span><span class="p">)</span>
</span><span class='line'> <span class="p">{</span>
</span><span class='line'> <span class="n">initValue</span> <span class="p">=</span> <span class="n">accumulator</span><span class="p">(</span><span class="n">source</span><span class="p">,</span> <span class="n">initValue</span><span class="p">);</span>
</span><span class='line'> <span class="p">}</span>
</span><span class='line'> <span class="k">return</span> <span class="n">initValue</span><span class="p">;</span>
</span><span class='line'><span class="p">}</span>
</span></code></pre></td></tr></table></div></figure>
<p>写完之后就深深地被自己的函数式功底折服了~尤其是这Reduce函数,还可以生成Filter和Map两个函数,实在是太给力了。。。</p>
<p>然后开始看LINQ,看着看着觉得不怎么妥。。咦,Filter不就是where嘛,Map不就是Select嘛。。。原来我想要的,别人早就想好了,不过还好Reduce这么高阶的函数是LINQ做不到的,想来又深以为然~</p>
<p>然后装了ReSharper(插播一下,ReSharper真的可以让Visual Studio好用一万倍啊一万倍),猛然又发现,ReShaper函数上直接提示说这个可以换成LINQ表达式!我勒个去,Ctrl+Enter之后果然把Reduce函数变成了这个样子:</p>
<figure class='code'> <div class="highlight"><table><tr><td class="gutter"><pre class="line-numbers"><span class='line-number'>1</span>
</pre></td><td class='code'><pre><code class='csharp'><span class='line'><span class="k">return</span> <span class="n">sources</span><span class="p">.</span><span class="n">Aggregate</span><span class="p">(</span><span class="n">initValue</span><span class="p">,</span> <span class="p">(</span><span class="n">current</span><span class="p">,</span> <span class="n">source</span><span class="p">)</span> <span class="p">=></span> <span class="n">accumulator</span><span class="p">(</span><span class="n">source</span><span class="p">,</span> <span class="n">current</span><span class="p">));</span>
</span></code></pre></td></tr></table></div></figure>
<p>于是我就不能忍了,直接上.NET Reflector看源码,发现Aggregate、Select、Where几个函数长得基本和我写得差不多,总算舒服一点。。。</p>
<p>总的来说,C#还是不错的,从语言的层面上来说已经完全超越Java了,除了各种库少一点,用的人少一点之外基本上没什么问题了。</p>
]]></content>
</entry>
<entry>
<title type="html"><![CDATA[依然是今天的事情]]></title>
<link href="http://huangcd.github.com/blog/2010/12/29/yi-ran-shi-jin-tian-de-shi-qing/"/>
<updated>2010-12-29T00:00:00+08:00</updated>
<id>http://huangcd.github.com/blog/2010/12/29/yi-ran-shi-jin-tian-de-shi-qing</id>
<content type="html"><![CDATA[<p>宋老师说William做事很快,果然是很快。今天看了一个工具以后把我的看法给他发过去,顺便提了一下等价性证明无从下手的问题。过了不大一会他就打电话过来详细了解了Lego小车的模型,然后指出了现在的系统实际上应该是有两层的控制器在工作,high level是我写的pid控制器,low level是Lego本身的一个控制系统,就像卫星一样(说得好像很高级的样子,赞~),我们之前的验证其实都是在high level上面做的,low level里面的事情还没说清楚。所以我最好能把这个事情给弄明白。</p>
<p>然后下午又开始搬出尘封已久的Lego小车。试了一下,发现代码几个月不用,大概是生锈了,跑起来各种不给力,效果很不好,还原因不明。想想还是先专心看看low level实现比较靠谱,看了一下Motor那块,发现其实真没做什么事情,无非就是把速度等比例转换成马达的功率,然后稍微做了点调整。。。</p>
<p>忘了说个号外,今天看到一个很给力的哥们,用Lego和纸杯了个留声机。<a href="http://www.josepino.com/lego/ntx-gramophone">这里</a>可以围观。亮点是最后一句的粗体。。。</p>
]]></content>
</entry>
<entry>
<title type="html"><![CDATA[tools]]></title>
<link href="http://huangcd.github.com/blog/2010/12/29/tools/"/>
<updated>2010-12-29T00:00:00+08:00</updated>
<id>http://huangcd.github.com/blog/2010/12/29/tools</id>
<content type="html"><![CDATA[<p>SPIN: I haven’t tried it. I read the manual and find out that SPIN use its own language Promela, so I have to change the C code. And the manual also says that “Spin is a tool for analyzing the logical consistency of concurrent systems, specifically of data communication protocols”. So I think it’s not suitable.
(http://spinroot.com/spin/sitemap.html)</p>
<p>MAGIC: I haven’t tried it either. However after I read the introduction and tutorial, I think it might be a very good tools for us. It’s used to verify an implementation in C code conforms to its specification.
(http://www.cs.cmu.edu/~chaki/magic/)</p>
<p>CBMC: I’ve tried this tool. It’s a Bounded Model Checker for ANSI-C programs. It allows verifying array bounds, pointer safety and user-specified assertions. It’s kind of useful, but not performs well with loops in C code.
(http://www-2.cs.cmu.edu/~modelcheck/cbmc/)</p>
<p>VeriSoft: I an unable to download the software. It seems to be useful, but I am not sure if it can deal with multiplication.
(http://cm.bell-labs.com/who/god/verisoft/files.html)</p>
<p>BANDERA: for model checking concurrent Java software. not for me.
(http://bandera.projects.cis.ksu.edu/)</p>
<p>FSP notation: might be useful
(http://www.doc.ic.ac.uk/~jnm/LTSdocumention/FSP-notation.html)</p>
]]></content>
</entry>
<entry>
<title type="html"><![CDATA[还是今天的事情]]></title>
<link href="http://huangcd.github.com/blog/2010/12/28/huan-shi-jin-tian-de-shi-qing/"/>
<updated>2010-12-28T00:00:00+08:00</updated>
<id>http://huangcd.github.com/blog/2010/12/28/huan-shi-jin-tian-de-shi-qing</id>
<content type="html"><![CDATA[<p>早上看了一下那篇所谓的Model Checking on python和eXplode,发现是挂着Model checking的狗头卖autoamted-testing的羊肉。跟我要做的东西完全不沾边。。。不过eXplode里面有提到几个implementation-level model checking的文章,主要是Java和C的。估计看看能有点收获。</p>
<p>中午跟William通了个电话。他也是觉得裸写BLAST Algorithm工作量确实有点大,所以最好还是能够再找找其他工具看看能不能凑活一下,他提了几个,我也找了几个,计有SLAM、CBMC、SPIN等等,明天逐一试试看看靠不靠谱。今天先简单试了一下,SPIN貌似不是针对C的,估计不行;CBMC挺好,但是循环处理很不给力;SLAM微软出品,不抱什么希望。。。</p>
<p>抛开这些东西不说吧,其实回到最根本的问题,William想证的是python code和数学方程的等价性,这个就是我一直不知道怎么证的。说可以写invariant来保证,但invariant怎么写呢?真是一大堆头疼的问题。</p>
<p>总的来说今天很不给力。</p>
]]></content>
</entry>
<entry>
<title type="html"><![CDATA[又是今天的事情]]></title>
<link href="http://huangcd.github.com/blog/2010/12/27/you-shi-jin-tian-de-shi-qing/"/>
<updated>2010-12-27T00:00:00+08:00</updated>
<id>http://huangcd.github.com/blog/2010/12/27/you-shi-jin-tian-de-shi-qing</id>
<content type="html"><![CDATA[<p>先说昨天的,开了一上午会,干了一下午活,然后晚上开了一个晚上的会。昨天是星期天!!!早上自己啃面包,中午一小撮人吃饺子,晚上一大坨人吃汉堡,总的来说没一顿好的,饺子很难吃。麦当劳的汉堡,不能说难吃,就是吃完之后觉得不太舒服。。。</p>
<p>今天上午干了几件事情:办了新的学生卡(居然要30块工本费。。。),洗了最近积攒的衣服,剪了个鸟头,不过我喜欢。。。晚上洗澡回来头发终于不结冰了。</p>
<p>下午主要工作就是给William发了封邮件,说了一下我想做的事情,大概就是想在python上面做model checking,思路是python code转CFG转BLAST Algorithm,发完邮件之后仔细看了看,想了想。发现虽然原来想着就不简单,但实际应该更难。Pypy出来的CFG有限制,CPython出来的CFG没看过,不过网上有人说很麻烦,估计最后如果要做的话可能还要自己写转换。突然想起三年前其实就是做着类似的事情,只不过是在PHP code上检查infeasible branch,实际上做的事情都很类似。想想真是可悲,研究所换来换去,导师换来换去,最后还是在做同样的东西,早知道这样还不如当初直截了当地跟宇哥混了,虽然谨慎觉得可能也很悲惨,但至少不至于三年什么都干不出来,而且那边至少有口头上承诺的好处。</p>
<p>伤心的往事掠过不提了,转换出CFG以后BLAST Algorithm也不好弄,不过至少如果William觉得靠谱的话可以奋起一搏。</p>
<p>另外今天认识了一个很可爱的人,恩。</p>
]]></content>
</entry>
<entry>
<title type="html"><![CDATA[今天的事情]]></title>
<link href="http://huangcd.github.com/blog/2010/12/24/jin-tian-de-shi-qing/"/>
<updated>2010-12-24T00:00:00+08:00</updated>
<id>http://huangcd.github.com/blog/2010/12/24/jin-tian-de-shi-qing</id>
<content type="html"><![CDATA[<p>首先是实验室里面的,最近两个老师都回来了,然后我的座位正好背对着两位老师,因此时常觉得压力很大。。。想悄悄干点坏事都不行。</p>
<p>然后上周隔壁组试图结题,挤压了n久的工作要赶着做完。毫无意外地,我被拉去帮忙赶工了。。。发来布置任务的邮件写的很牛的样子,让我觉得压力很大,不过和负责coding的师弟了解了一下以后发现是个很简单的东西。</p>
<p>第二天早上一大早赶过去试图开工,正在准备软件的时候老大赶过来说有个小任务。。。于是就开始优先做小任务了,确实挺小的,十分钟搞定,不过由于要求要弄成exe,然后我是用python写的,所以就开始尝试转换了,试了一下py2exe,很好很强大,一下子就转过去了,转到纯洁无瑕的虚拟机下面一试,发现丫说这是不明真相的exe不能执行。网上搜了一下,发现是python2.6用的是VS2008编译的,py2exe之后各种不能用,尝试了一些解决方案发现没效果。心里默念“python2.6傻X一万遍,VS2008傻X一千遍”以后果断开始尝试pyinstall,惊奇的发现pyinstall纯爷们,直接来一句我们支持2.5、2.7及各种3.+版本,但是不支持您用的2.6。心里再次默念python2.6傻X一万遍以后开始在纯洁无瑕的虚拟机下面装python2.5.4(顺便发现corsair挂了),装完以后果然pyinstall就可以用了。而且很好很强大的是它还可以把所有需要的文件打包成一个大exe,如果忽略那个长得巨难看无比的图标的话简直就太完美了。</p>
<p>吃完饭回来开始做隔壁组的任务,吭哧吭哧捣鼓了一个下午总算完成了,n久不用Java,难得用一次还是在不给力的netbeans上面,而且还要写界面,十分痛苦。而且最后发现写的东西无非是师弟原有代码的简化版。。。不过事不关己,完成任务就好</p>
<p>晚上打球,这学期第一次打六点场,一开始很不给力,跑了两下觉得晚饭都要跳出喉咙了。。。不过后来越打越舒服,更舒服的是打完以后还能去北区澡堂洗澡,不用去东区将就。</p>
<p>然后就没有然后了,恩</p>
]]></content>
</entry>
<entry>
<title type="html"><![CDATA[交了定金]]></title>
<link href="http://huangcd.github.com/blog/2010/12/19/jiao-le-ding-jin/"/>
<updated>2010-12-19T00:00:00+08:00</updated>
<id>http://huangcd.github.com/blog/2010/12/19/jiao-le-ding-jin</id>
<content type="html"><![CDATA[<p>恩,元旦爸妈过来办理最后的手续,然后这事就算完了。</p>
<p>家里人都很高兴,毕竟也算是有着落了。</p>
<p>突然觉得压力很大。。。</p>
]]></content>
</entry>
<entry>
<title type="html"><![CDATA[家里的好吃的]]></title>
<link href="http://huangcd.github.com/blog/2010/12/16/jia-li-de-hao-chi-de/"/>
<updated>2010-12-16T00:00:00+08:00</updated>
<id>http://huangcd.github.com/blog/2010/12/16/jia-li-de-hao-chi-de</id>
<content type="html"><![CDATA[<p>海产品、河产品:</p>
<p>跳跳鱼(tiao[四转轻声]仔):煲汤很甜。不过最好吃还是豆豉煎焖一下,肉很嫩,煎完以后皮又稍微有点脆,一口一条,不用吐骨头,最爽的是端着满满一大盘,边吃边看球,可惜在家里不喝啤酒,不然就完美了。</p>
<p>牡蛎(蠔):吃过最好吃的一次是在海边直接开出来,马上拿到外婆家煮粥,清甜。稍差一点的就是拿回家里带壳煮,也很好吃,不过差点新鲜。其他的就只能说好吃了,说不上特别。</p>
<p>皮皮虾(虾婆):有膏的话香甜,没有的话凑活,不过剥皮太费劲了。。。</p>
<p>蟹:好吃的蟹有两种,软壳的和有膏的,软壳的可以连壳一起吃,口感特别好;有膏的就不用说了。蟹的品种有很多,不过总的来说我喜欢大的。。。</p>
<p>虾:是个虾就好吃</p>
<p>花螺:一般要蘸辣椒酱或者醋吃,不过广东的辣椒酱像番茄酱多一点。说不上特别好吃,不过因为贵(一百多一斤,大概十个不到的样子,而且一斤花螺至少8两是壳),所以吃的比较少,每次吃起来都觉得意犹未尽。</p>
<p>鲮鱼松:鲮鱼去骨以后和萝卜一起剁碎之后清蒸,能多吃一碗饭</p>
<p>鱼头:是个鱼头就好吃,不过在家里想吃鱼头比较艰难。。。大家都想吃</p>
<p>夜水咸鱼:其实不是咸鱼。。。一般是一种叫“刀里”(金线鱼)的开肚去内脏以后用粗盐埋一夜,然后拿出来或蒸或煎,既有鲜鱼的甜味,鱼肉又比一般的结实,还有一股香味。有个不怎么好听的名字,叫“一夜情”。。。</p>
<p>北极贝刺生:是好吃,比其他刺生都要好吃,不过忒贵了</p>
<p>各种汤:</p>
<p>老鸭汤:老火老鸭汤,很甜,鸭肉煲软了之后也特别好吃</p>
<p>羊肉煲:羊肉加枸杞党参姜片之类的煲到水变成汁一样,为了吃羊肉可以无限量吃饭。比北京这边的羊肉好吃一百倍。。。</p>
<p>鱼头煲:好吃不解释,阿爸做的特别好吃</p>
<p>藕汤:精华不在藕,而在于藕汤里面的肉特别好吃,不管瘦肉肥肉。。。</p>
<p>各种菜:</p>
<p>南瓜花:很甜</p>
<p>薯苗:貌似是专门用来吃的品种,口感很特别,纤维比较粗,不过很好吃</p>
<p>秘制鱼干:阿公阿婆造。。。各种鱼开肚去内脏以后晒干,专门用于早上喝粥。鱼有大有小,大的一小块能下几碗粥,小的一勺能舀几十条。</p>
<p>本地系列:所谓本地,并不是指在附近养,而是指不用饲料,纯放养的。典型的是本地鸡,特点是肉比较有韧性,吃起来比一般的要香。</p>
<p>香菇蒸鸡:阿妈做得特别好吃,不过这个比起好吃来说,更重要的是香,真的是十里飘香,三楼饭厅我在六楼房间就能闻到。</p>
<p>飘香牛骨头:所谓的秘制牛骨头,要专门开车到山里面某个偏僻的角落的某家小店吃,不过吃完之后总是觉得不枉此行。熬的火候特别好,恰好能咬开里面的肉,又不至于太烂。而且确实是飘香,不过不是闻起来香,是吃起来香。</p>
<p>烧鹅:一般是外面买回来的,正好楼下有个烧鹅店。烧鹅肉一般般,好吃的是烧鹅皮,所谓皮脆多汁,一口咬下,满嘴留香(比西门烤翅要好吃。。。)</p>
<p>水果系列:</p>
<p>马水桔:产于阳春马水,只有春节才能吃到,而且多半不是正宗的,特别甜,能吃的欲罢不能。。。</p>
<p>荔枝龙眼:每年夏天总有很多,不是特别喜欢,不过量大,无聊就吃,无聊就吃。。。</p>
<p>火龙果:家里有种,几个姑姑家里也有种,所以经常能吃到,很滑很嫩,冰冻效果尤佳</p>
<p>菠萝蜜:其实挺好吃的,不过不喜欢,据说很容易上火。菠萝蜜很牛的一点是所有东西几乎都能吃。。。</p>
<p>早茶夜宵系列:</p>
<p>这个太多了,写不下。。。羊杂、牛杂、蛋挞、干蒸、小馒头、白切牛、核桃包、雪蛤挞等等等等</p>
]]></content>
</entry>
<entry>
<title type="html"><![CDATA[位运算版的n皇后问题]]></title>
<link href="http://huangcd.github.com/blog/2010/12/15/wei-yun-suan-ban-de-n-huang-hou-wen-ti/"/>
<updated>2010-12-15T00:00:00+08:00</updated>
<id>http://huangcd.github.com/blog/2010/12/15/wei-yun-suan-ban-de-n-huang-hou-wen-ti</id>
<content type="html"><![CDATA[
<figure class='code'> <div class="highlight"><table><tr><td class="gutter"><pre class="line-numbers"><span class='line-number'>1</span>
<span class='line-number'>2</span>
<span class='line-number'>3</span>
<span class='line-number'>4</span>
<span class='line-number'>5</span>
<span class='line-number'>6</span>
<span class='line-number'>7</span>
<span class='line-number'>8</span>
<span class='line-number'>9</span>
<span class='line-number'>10</span>
<span class='line-number'>11</span>
<span class='line-number'>12</span>
<span class='line-number'>13</span>
<span class='line-number'>14</span>
<span class='line-number'>15</span>
<span class='line-number'>16</span>
<span class='line-number'>17</span>
<span class='line-number'>18</span>
<span class='line-number'>19</span>
<span class='line-number'>20</span>
<span class='line-number'>21</span>
<span class='line-number'>22</span>
<span class='line-number'>23</span>
<span class='line-number'>24</span>
<span class='line-number'>25</span>
<span class='line-number'>26</span>
<span class='line-number'>27</span>
<span class='line-number'>28</span>
<span class='line-number'>29</span>
</pre></td><td class='code'><pre><code class='python'><span class='line'><span class="c"># -*- coding: utf-8 -*-</span>
</span><span class='line'><span class="sd">"""</span>
</span><span class='line'><span class="sd">n皇后问题位运算版</span>
</span><span class='line'><span class="sd">Created on Wed Dec 15 08:39:27 2010</span>
</span><span class='line'><span class="sd">@author: HUANGCD</span>
</span><span class='line'><span class="sd">"""</span>
</span><span class='line'><span class="k">def</span> <span class="nf">queen</span><span class="p">(</span><span class="n">row</span><span class="p">,</span> <span class="n">ld</span><span class="p">,</span> <span class="n">rd</span><span class="p">,</span> <span class="n">upper_limit</span><span class="p">,</span> <span class="n">result</span><span class="p">):</span>
</span><span class='line'><span class="sd">'''</span>
</span><span class='line'><span class="sd">@param row 列上的限制,0为允许,1为不允许</span>
</span><span class='line'><span class="sd">@param ld 左上到右下的对角线限制</span>
</span><span class='line'><span class="sd">@param rd 右上到左下的对角线限制</span>
</span><span class='line'><span class="sd">@param upper_limit n (设定的值为(1 << n) - 1)</span>
</span><span class='line'><span class="sd">@param result 返回的结果</span>
</span><span class='line'><span class="sd">'''</span>
</span><span class='line'> <span class="k">if</span> <span class="n">row</span> <span class="o">^</span> <span class="n">upper_limit</span><span class="p">:</span>
</span><span class='line'> <span class="n">pos</span> <span class="o">=</span> <span class="n">upper_limit</span> <span class="o">&</span> <span class="o">~</span><span class="p">(</span><span class="n">row</span> <span class="o">|</span> <span class="n">ld</span> <span class="o">|</span> <span class="n">rd</span><span class="p">)</span>
</span><span class='line'> <span class="k">while</span> <span class="n">pos</span><span class="p">:</span>
</span><span class='line'> <span class="n">p</span> <span class="o">=</span> <span class="n">pos</span> <span class="o">&</span> <span class="p">(</span><span class="o">-</span><span class="n">pos</span><span class="p">)</span>
</span><span class='line'> <span class="n">pos</span> <span class="o">=</span> <span class="n">pos</span> <span class="o">-</span> <span class="n">p</span>
</span><span class='line'> <span class="n">result</span> <span class="o">=</span> <span class="n">queen</span><span class="p">(</span><span class="n">row</span> <span class="o">|</span> <span class="n">p</span><span class="p">,</span> <span class="p">(</span><span class="n">ld</span> <span class="o">|</span> <span class="n">p</span><span class="p">)</span> <span class="o"><></span> <span class="mi">1</span><span class="p">,</span> <span class="n">upper_limit</span><span class="p">,</span> <span class="n">result</span><span class="p">)</span>
</span><span class='line'> <span class="k">else</span><span class="p">:</span>
</span><span class='line'> <span class="n">result</span> <span class="o">+=</span> <span class="mi">1</span>
</span><span class='line'> <span class="k">return</span> <span class="n">result</span>
</span><span class='line'>
</span><span class='line'><span class="k">if</span> <span class="n">__name__</span> <span class="o">==</span> <span class="s">'__main__'</span><span class="p">:</span>
</span><span class='line'> <span class="kn">import</span> <span class="nn">time</span>
</span><span class='line'> <span class="n">time</span><span class="o">.</span><span class="n">clock</span><span class="p">()</span>
</span><span class='line'> <span class="k">print</span> <span class="n">queen</span><span class="p">(</span><span class="mi">0</span><span class="p">,</span> <span class="mi">0</span><span class="p">,</span> <span class="mi">0</span><span class="p">,</span> <span class="p">(</span><span class="mi">1</span> <span class="o"><<</span> <span class="mi">13</span><span class="p">)</span> <span class="o">-</span> <span class="mi">1</span><span class="p">,</span> <span class="mi">0</span><span class="p">)</span>
</span><span class='line'> <span class="k">print</span> <span class="n">time</span><span class="o">.</span><span class="n">clock</span><span class="p">()</span>
</span></code></pre></td></tr></table></div></figure>
]]></content>
</entry>
<entry>
<title type="html"><![CDATA[计算一个32位整数的二进制表示末尾0的个数]]></title>
<link href="http://huangcd.github.com/blog/2010/12/15/ji-suan-yi-ge-32-wei-zheng-shu-de-er-jin-zhi-biao-shi-mo-wei-0-de-ge-shu/"/>
<updated>2010-12-15T00:00:00+08:00</updated>
<id>http://huangcd.github.com/blog/2010/12/15/ji-suan-yi-ge-32-wei-zheng-shu-de-er-jin-zhi-biao-shi-mo-wei-0-de-ge-shu</id>
<content type="html"><![CDATA[
<figure class='code'> <div class="highlight"><table><tr><td class="gutter"><pre class="line-numbers"><span class='line-number'>1</span>
<span class='line-number'>2</span>
<span class='line-number'>3</span>
<span class='line-number'>4</span>
<span class='line-number'>5</span>
<span class='line-number'>6</span>
<span class='line-number'>7</span>
<span class='line-number'>8</span>
<span class='line-number'>9</span>
<span class='line-number'>10</span>
<span class='line-number'>11</span>
<span class='line-number'>12</span>
<span class='line-number'>13</span>
<span class='line-number'>14</span>
<span class='line-number'>15</span>
</pre></td><td class='code'><pre><code class='python'><span class='line'><span class="c"># -*- coding: utf-8 -*-</span>
</span><span class='line'><span class="sd">"""</span>
</span><span class='line'><span class="sd">计算一个32位整数的二进制表示末尾0的个数</span>
</span><span class='line'><span class="sd">Created on Wed Dec 15 09:18:27 2010</span>
</span><span class='line'><span class="sd">@author: HUANGCD</span>
</span><span class='line'><span class="sd">"""</span>
</span><span class='line'><span class="n">multiply_De_Bruijn_position</span> <span class="o">=</span> <span class="p">[</span>
</span><span class='line'> <span class="mi">0</span><span class="p">,</span> <span class="mi">1</span><span class="p">,</span> <span class="mi">28</span><span class="p">,</span> <span class="mi">2</span><span class="p">,</span> <span class="mi">29</span><span class="p">,</span> <span class="mi">14</span><span class="p">,</span> <span class="mi">24</span><span class="p">,</span> <span class="mi">3</span><span class="p">,</span> <span class="mi">30</span><span class="p">,</span> <span class="mi">22</span><span class="p">,</span> <span class="mi">20</span><span class="p">,</span> <span class="mi">15</span><span class="p">,</span> <span class="mi">25</span><span class="p">,</span> <span class="mi">17</span><span class="p">,</span> <span class="mi">4</span><span class="p">,</span> <span class="mi">8</span><span class="p">,</span>
</span><span class='line'> <span class="mi">31</span><span class="p">,</span> <span class="mi">27</span><span class="p">,</span> <span class="mi">13</span><span class="p">,</span> <span class="mi">23</span><span class="p">,</span> <span class="mi">21</span><span class="p">,</span> <span class="mi">19</span><span class="p">,</span> <span class="mi">16</span><span class="p">,</span> <span class="mi">7</span><span class="p">,</span> <span class="mi">26</span><span class="p">,</span> <span class="mi">12</span><span class="p">,</span> <span class="mi">18</span><span class="p">,</span> <span class="mi">6</span><span class="p">,</span> <span class="mi">11</span><span class="p">,</span> <span class="mi">5</span><span class="p">,</span> <span class="mi">10</span><span class="p">,</span> <span class="mi">9</span><span class="p">]</span>
</span><span class='line'>
</span><span class='line'><span class="k">def</span> <span class="nf">tail_zero_count</span><span class="p">(</span><span class="n">num</span><span class="p">):</span>
</span><span class='line'> <span class="k">return</span> <span class="n">multiply_De_Bruijn_position</span><span class="p">[(((</span><span class="n">num</span> <span class="o">&</span> <span class="p">(</span><span class="o">-</span><span class="n">num</span><span class="p">))</span> <span class="o">*</span> <span class="mh">0x077CB531</span><span class="p">)</span> <span class="o">>></span> <span class="mi">27</span><span class="p">)</span> <span class="o">&</span> <span class="mi">31</span><span class="p">]</span>
</span><span class='line'>
</span><span class='line'><span class="k">if</span> <span class="n">__name__</span> <span class="o">==</span> <span class="s">'__main__'</span><span class="p">:</span>
</span><span class='line'> <span class="k">print</span> <span class="n">tail_zero_count</span><span class="p">(</span><span class="mh">0x110000000</span><span class="p">)</span>
</span></code></pre></td></tr></table></div></figure>
<p><a href="http://graphics.stanford.edu/~seander/bithacks.html" target="_blank">这里</a>可以围观到各种位运算的技巧</p>
]]></content>
</entry>
<entry>
<title type="html"><![CDATA[再一次情何以堪]]></title>
<link href="http://huangcd.github.com/blog/2010/12/10/zai-yi-ci-qing-he-yi-kan/"/>
<updated>2010-12-10T00:00:00+08:00</updated>
<id>http://huangcd.github.com/blog/2010/12/10/zai-yi-ci-qing-he-yi-kan</id>
<content type="html"><![CDATA[<p>据说某次错误的算法作业在小朋友中间广为流传,情何以堪。。。
昨天打了一个下午和半个晚上的羽毛球,现在腰酸背痛腿抽筋,还没有思达舒胶囊。导致今天中午辗转反侧了一个下午,愣是睡不着。。。
改编个冷笑话:
“丞相!丞相~~~~奉孝昨日在西门吃了几串烤翅,晚上腹泻不止,已经。。。去啦~~~”</p>
]]></content>
</entry>
<entry>
<title type="html"><![CDATA[情何以堪。。。]]></title>
<link href="http://huangcd.github.com/blog/2010/12/04/qing-he-yi-kan-/"/>
<updated>2010-12-04T00:00:00+08:00</updated>
<id>http://huangcd.github.com/blog/2010/12/04/qing-he-yi-kan-</id>
<content type="html"><![CDATA[<p>以前打电话回家无非就是谈谈人生谈谈理想,说说工作说说学习,聊聊八卦聊聊新闻,非常和谐。最近口风突然变了,大家都开始关心我的感情问题了,时不时就来一句“有女朋友没啊”、“真的没有女朋友啊”、“有女朋友不要不说啊”之类的,这个还好,呵呵笑一下就算过去了。不料今天跟我爸打电话的时候他老人家突然来了一句“要抓紧,这是近期工作的重点,要放到科研和找工作同等重要的地位”。我就o(╯□╰)o了,好像也不至于啊,真是让我情何以堪。。。</p>
]]></content>
</entry>
<entry>
<title type="html"><![CDATA[流水笔记]]></title>
<link href="http://huangcd.github.com/blog/2010/11/28/liu-shui-bi-ji/"/>
<updated>2010-11-28T00:00:00+08:00</updated>
<id>http://huangcd.github.com/blog/2010/11/28/liu-shui-bi-ji</id>
<content type="html"><![CDATA[<p>半夜翻被子的时候把水杯弄翻了,床单衣服全湿了。只见我不慌不忙翻起来拿面纸把水吸个半干,换件衣服,卷着被子到另一边继续睡。早上起来发现床单居然已经干了,怀疑是在做梦,又摸了一下衣服,发现是湿的,于是淡定地起床。。。</p>
]]></content>
</entry>
<entry>
<title type="html"><![CDATA[看了Inception]]></title>
<link href="http://huangcd.github.com/blog/2010/11/28/kan-le-inception/"/>
<updated>2010-11-28T00:00:00+08:00</updated>
<id>http://huangcd.github.com/blog/2010/11/28/kan-le-inception</id>
<content type="html"><![CDATA[<p>可能是之前已经被剧透了不少,比如梦是有层次的之类,所以感觉不怎么给力。
看到一半的时候心里想不会到最后发现原来Codd是在梦里面,然后Mal是清醒的吧。结果到最后发现果然Codd似乎就是在梦里,不过倒没说Mal是不是清醒的。
另外翻译是《盗梦空间》,不过似乎实际上是在植梦,跟盗梦貌似关系不大。
Codd同学十几年前说:“You jump, I jump”,现在成了“I’m not jumping with you”o(╯□╰)o。
总的来说场景很有想象力,不过内容没有想象中给力。</p>
]]></content>
</entry>
<entry>
<title type="html"><![CDATA[贴段代码]]></title>
<link href="http://huangcd.github.com/blog/2010/11/24/tie-duan-dai-ma/"/>
<updated>2010-11-24T00:00:00+08:00</updated>
<id>http://huangcd.github.com/blog/2010/11/24/tie-duan-dai-ma</id>
<content type="html"><![CDATA[<p>python的修饰器版singleton模式</p>
<figure class='code'><div class="highlight"><table><tr><td class="gutter"><pre class="line-numbers"><span class='line-number'>1</span>
<span class='line-number'>2</span>
<span class='line-number'>3</span>
<span class='line-number'>4</span>
<span class='line-number'>5</span>
<span class='line-number'>6</span>
<span class='line-number'>7</span>
<span class='line-number'>8</span>
<span class='line-number'>9</span>
<span class='line-number'>10</span>
<span class='line-number'>11</span>
<span class='line-number'>12</span>
<span class='line-number'>13</span>
<span class='line-number'>14</span>
<span class='line-number'>15</span>
<span class='line-number'>16</span>
<span class='line-number'>17</span>
<span class='line-number'>18</span>
<span class='line-number'>19</span>
<span class='line-number'>20</span>
<span class='line-number'>21</span>
</pre></td><td class='code'><pre><code class=''><span class='line'>#!/usr/bin/env python
</span><span class='line'># -*- coding: UTF-8 -*-
</span><span class='line'>def singleton(cls):
</span><span class='line'> '''
</span><span class='line'> singleton 模式的修饰器,保留第一次初始化的值
</span><span class='line'> 例:
</span><span class='line'> @singleton
</span><span class='line'> class Class:
</span><span class='line'> def __init__(self, v):
</span><span class='line'> self.val = v
</span><span class='line'> a = Class('a')
</span><span class='line'> b = Class('b')
</span><span class='line'> 则b.val == 'a'
</span><span class='line'> a is b返回True
</span><span class='line'> '''
</span><span class='line'> instance_container = []
</span><span class='line'> def get_instance(*arg, **args):
</span><span class='line'> if not len(instance_container):
</span><span class='line'> instance_container.append(cls(*arg, **args))
</span><span class='line'> return instance_container[0]
</span><span class='line'> return get_instance</span></code></pre></td></tr></table></div></figure>
]]></content>
</entry>
</feed>