Oct 7, 2008

Code Complete 读书笔记 PART 7

Software Craftsmanship 软件工艺
Chapter 31. 布局与风格
Layout and Style
准确、一致、易读性、易维护性
Layout Fundamentals
好的布局凸显程序的逻辑结构。
人 != 计算机
经验和规矩是吻合的
Layout as Religion
Objectives of Good Layout
准确,始终如一地表现程序的逻辑结构;改善可读性;经得起修改
Layout Techniques
分组:空行,空格
空行:将不相关的语句隔开 8% ~ 16%
缩进:2 ~ 4 空格,显示逻辑
Layout Sytles
纯块结构:Basic
仿纯块结构:java
begin-end {}
行尾布局
Laying Out Control Structures
begin-end: 未缩进;两次缩进  ×
在程序中加入空行,有助于思考语句的从属
缩进策略应统一
goto:标号大写、上下空行;包含goto的语句单独为一行
Laying Out Individual Statements
空格:逻辑、数组引用、子程序参数
续行:续行需明显(“+ , && ||”);所有后续行按标准量缩进;
Using only one statement Per Line
易调试,易修改,能提供关于复杂度的正确印象,线性阅读
数据声明:一行一声明,靠近首次使用的位置,合理组织顺序
注释:缩进一致,注释前加空行
有约定比约定某个特定细节更重要
Laying Out Routines
用空格分隔程序各部分
参数按标准缩进
Laying Out Class
Class Interfaces: 头部注释(类及完整用法) 构造析构 public protected private
Class Implementations: 类文件内容 类数据 public protected private
子程序间:2~3行

Chapter 32. 自说明代码
Self-Documenting Code
好的注释才有价值
源码包含大部分关键信息,信息融入代码
好的代码本身是最好的说明
注释应用来说明代码无法说明的东西
注释应易维护
External Documentation
单元开发文件夹:UDF: uint-development folder  SDF: software-development folder
详细设计文档
Programming Styla as Documentation
良好结构、直率易懂的方法、有意义的名称、具名常量、清晰的布局、最低复杂度的控制流和数据结构
循环 -- 良好定义的子程序
尽可能采用问题领域的术语
To Comment or not to Comment
好注释 != (重复代码 or 解释代码)
注释困难 --> 代码差劲 or 没有彻底理解
代码复杂:改进代码 > 添加注释
Kinds of comments
repeat of code
×
explanation of code ×
marker in the code (fix before release?)
summary of code: good for other readers
description of the code's intent: 意图而非解决方法
information that cannot possibly be expressed by the code itself
Commenting Efficiently
采用不会被打断和易于修改的注释方法
用伪码编程法减少注释时间
1 comment per 10 lines
Commenting Techniques
行尾注释:代码块,数据声明
数据声明:数据单位、允许范围、编码含义、输入数据限制、位标志

Chapter 33. 个人性格
Personal Character
谦虚,求知欲,诚实,创造性,纪律,高明的偷懒
好性格 -->正确的习惯
软件开发:建造材料=个人才智;工具=自己,其实在研究人的智力、性格
20/80,10:1
Intelligence and Humility
理解一个程序,需要很强的吸取细节的能力并能同时消化
《The Humble Programmer》:大部分编程工作都是在弥补我们有限的智力。承认自己智力有限并通过学习来弥补。
减轻脑力负担:
系统分解,复查、详查、测试,程序尽量短小,尽量高层,规范
Curiosity
在开发过程中建立自我意识!
试验!学会制造错误-->收获;利用小程序
阅读解决问题的方法
在行动之前做分析和计划:分析<-->行动
学习成功项目的开发经验:Programming Pearls, The Mythical Man-Month
阅读文档,RTFM!^_^
向专业开发看齐:
入门级:某语言的基本功能,运用语言特性
中级:多中语言基本功能,熟练使用一种语言
熟练级:对语言和环境有专业技能
技术带头人级:人
Intellectual Honesty
了解代码,了解进度,如实反馈
Communication and Cooperation
代码可读性,编程首先是和人交流,其次才是计算机
Creativity and Discipline
在非关键之处设立规范,从而在更重要的地方发挥创造性
Form is liberating.
Laziness
拖延:逃避思考,实在懒
迅速完成:用最少时间做完不喜欢的工作。开明懒
编写某个工作完成不喜欢的任务:一劳永逸的懒
Characteristics that don't matter as much as you might think
persistence: 固执己见 or 坚韧不拔 知道何时放弃
experience: 软件开发行业的经验比书本知识价值要小,工作10年,是得到10年的经验还是1年经验的10次重复
Habits
精神品德,编程品德
态度端正,积极思考 --> 习惯
不能用没有习惯来代替坏习惯
Additional Resources
《The Humble Programmer》
Dijkstra:编程的本质任务就是驾驭计算机科学的极端复杂性,编程是唯一一个需要掌握从最底层到最高层9个数量级细节差异的人类活动。

Chapter 34. 软件工艺的话题
Themes in software Craftsmanship
编程的目的之一是管理复杂性
过程对产品有深远影响
团队:广泛沟通;单人:自我交流
编程应基于问题域而非解决方案
注意警告信息
迭代:软件质量
丰富的工具箱

Conquer Complexity
降低复杂度几乎和衡量程序员成果的最重要依据
方法:划分子系统,类、接口,保持接口抽象性,避免深层次的继承,避免深层的循环、条件判断,不用goto,不滥用异常(需以系统的观点使用),不让类过度膨胀,子程序短小,使用不言自明的变量,子程序参数尽量少,规范和约定
Pick Your Process
团队成员 --> Process --> 质量。
避免不成熟的优化
坏的过程损耗脑力
Write Programs for People First, Computer Secon
目标:算法精准,结构紧凑,性能好,注释清晰得体
Program into your Language, Not in It
要什么 --> 怎样用工具实现。
Fous Your Attention with the Help of Conventions
规范是一套管理复杂度的质量工具
规范能精确地传达重要的信息
规范能免除各种风险:禁止,要求 --> 防范
规范能增加对低层工作的可预见性
规范能弥补语言的不足之处
Program in Terms of the Problem Domain
尽可能工作于最高的软件层次
顶层代码:说明解决的问题
Separating a Program into Levels of Abstraction
Level 0: Operating-System Operations and Machine Instructions
Level 1: Programming-Language Structures and Tools
Level 2: Low level of implementation Structures 粘结层
Level 3: Low level Problem-Domain Terms 提供框架
Level 4: High level Problem-Domain Terms 基于问题域的术语
Watch for Falling Rocks
艺术  工艺(craft) 科学
良好的个人判断
玄机代码 maybe 差劲代码
设计的度量 反映 设计的质量
警告信息
重复,“不自在,不惬意”
不容易写注释,不易命名变量,不易将问题分解
难以理解,不安,猜测
找不到错误的原因仅仅因为是忽视
Iterate, Repeatedly, Again and Again
反复评估 --> 精确
开发:逐步精化,实证而非证明
迭代的代码调整
Thou Shalt Rend Software and Religion Asunder
software Oracles & Eclecticism
Experimentation
基于实验结果改变思路
“试图没有错误”是最大的错误
设计是仔细规划小错误以避免更大的错误
试验可用在很多层次上


Chapter 35. 更多信息

Software Construction
Pragmatic Programmer
Programming Pearls
Extreme Programming Explained: Embrace Change
Writing Solid Code
The Practise of Programming
Topic Beyond Construction
Facts and Fallacies of Software Engineer
Professional Software Development
The Psychology of Computer Programming
Software Engineering Overviews
Software Engineering: A Practitioner's Approach
Software Engineering 6th
Periodicals
Software Development www.sdmagazine.com
Dr.Dobb's Journal www.ddj.com
IEEE Software www.computer.org/software
Communications of the ACM www.acm.org/cacm/
A Software Developer's Reading Plan
Introductory Level
Conceptual Blockbusting: A Guide to Better Ideas
Programming Pearls
Facts and Fallacies of Software Engineering
Software Project Survival Guide
Code Complete
Practitioner Level
Software Configuration Management Patterns: Effective Teamwork, Practical Integration
UML Distilled: A Brief Guide to the Standard Object Modeling Language
Software Creativity
Applying UML and Patterns: An Introduction to Object-Oriented Analysis and Design and the Unified Process
Rapid Development
Software Requirements
Professional Level
Software Architecture in Practice
Refactoring: Improving the Design of Existing Code
Design Patterns
Principles of Software Engineering Management
Writing Solid Code
Object-Oriented Software Construction

Oct 6, 2008

blogger功能增强

昨天花了两个多小时给blogger加上了留言板、标签云和缩略显示。
blogger本身提供的功能较少,但提供了灵活的模板编辑功能,就好像blogger提供了一系列的数据接口,让用户选择所需要的数据进行显示,这比普通的Web开发来得更加省事,blogger的技巧很大程度上可以称为HACK,再加上blogger的广大用户群,所以一般的博客需求都可以方便地找到在blogbger上的解决方案。
留言板使用了cbox提供的服务,在网上找下就可以了。
标签云详见:Blogger V3.0 添加标签云
但是里面的javascript空行太多,影响阅读,使用正则表达式%[ ^t]++^p匹配多余的空行,删除就可以了。
缩略显示详见一下的文章:继续阅读懒人加强版

Oct 5, 2008

Learning python 读书笔记 PART 4

PART FOUR. FUNCTIONS
Chapter 12. Function Basics
calls:  myfunc(argv)
def, return, yield: def adder(a, b=1, *c): return a+b+c[0]
global:  def function(): global x; x = 'new'
lambda:  funcs = [lambda x: x**2, lambda x: x*3]
1. Coding Functions
def is a executable statement which create an object and assigns it to a name
arguments are passed by assignment
global declares module-level variables that are to be assigned
def <name> (arg1, arg2...):
    ...
    return <value>
def can executes at runtime
if test:
    def function():
else:
    def function():
2. Definitions and Calls
Polymorphism in Python: because python is a dynamically typed language, every operation is polymorphic in python
in python, code is not supposed to care about specific data types.

Chapter 13. Scopes and Arguments
1. Scope Rules
Name <--> Namespace
The enclosing module is a global scope
The global scope spans a single file only
Each call to a function is a new local scope
Assigned names are local, unless declared global
All other names are enclosing locals, globals, or built-ins
LEGB: local --> enclosing functions --> global --> built-in
the built-in scope
>>> import __builtin__
>>> dir(__builtin__)
zip <--> import __builtin__,  __builtin__.zip
2. The global Statements
3. Scope and Nested Functions
LEGB: statically nested scope
lambda: an expression that generates a new function to be called later, much like def statement
4. Passing Arguments
immutable arguments <--> C's "by value" mode
mutable arguments <--> C's "by pointer" mode
Avoiding mutable arguments change:
pass a copy or tuple
Simulating output parameters:
>>> def multiple(x,y):
    x = 2
    y = [3,4]  #change local names only
    return x,y #return new values in a tuple(not two values)
>>> x = 1
>>> y = [1,2]
>>> x,y = multiple(x,y)  #assign result to caller's names
>>> x,y
(2, [3, 4])
5. Special Argument Matching Modes
func(value)    : Normal argument: matched by position
func(name=value)    : Keyword argument: matched by name
self documention, more meaningful
def func(name)   
def func(name=value)    : default argument value, if not passed in the call
make some arguments optional
def func(*name)    : Matchs remaining positional args(in a tuple)
>>>def f(*args): print args
def func(**name)    : Matchs remaining keyword args(in a dict)
>>>def f(**args): print args
>>>f(a=1,b=2)
{'a':1, 'b':2}
Argument Matching
rules:
key arguments after non-keyargument
*name after normal argument
**name last
Matching steps:
non-key argus --> key word argus --> extra non-key argus --> extra key argus -->default values

Chapter 14. Advanced Function Topics
1. Anonymous Functions: lambda
lambda expression creates a function to be called later, but returns it instead of assigning it to a name
lambda argu1, argu2, argu3...arguN: expression using argus
lambda bodies are single expression, not a block of statements
example1:
L = [(lambda x: x**1),(lambda x: x**2), (lambda x: x**3)]
for f in L
    print f(2)
print L[0](2)
example2:
key = 'b'
{'a': (lambda f1),
  'b': (lambda f2),
}[b]()
is equivalent to
def f1():...
def f2():...
...
key = ...
{'a':f1, 'b':f2}[key]()
How(not) to obfuscate your python code
((a and b) or c) is roughly equivalent to:
if a: b else: c
(C's a?b:c)
2. Applying Functions to Arguments
The apply built-in
apply(func, argus) == func(argus)
argument list is passed by tuple
if <test>:
    action,args = func1, arguments_a
else
    action,args = func2, arguments_b
...
apply(action,args)
3. Functions Over Sequences
>>> counter = [1,2,3,4]
>>> def func(x): return x + 10
>>> map(func,counter)
[11, 12, 13, 14]
>>>map((lambda x: x + 3), counter)
[3,4,5,6]
map(func,[1,2,3],[4,5,6]) #[func(1,4),func(2,5),func(3,6)]
4. Functional Programing Tools
filter
>>>filter((lambda x: x>0), range(-5,5))
[1,2,3,4]
reduce
>>>reduce((lambda x, y: x+y), [1,2,3,4]) 
10
>>>import operator
>>>reduce(opetator.add, [1,2,3,4])
5. List Comperhensions
[x ** 2 for x in range(10)]
map((lambda x: x ** 2), range(10))
[x for x in range(5) if x%2 == 0]
filter((lambda x: x%2 == 0), range(5))
map((lambda x: x**2), filter((lambda x: x%2 == 0),range(10)))
the genaral structure of list comprehensions
[expression for target1 in sequence 1 [if condition]
                for target2 in sequence 2 [if condition]....
                for targetN in sequence N [if condition]]
list comperhension and map are faster than for loop.
6. Generators and Iterators
Generators yield a value rather than returning one. The yield statment suspends the function and sends a value back to the caller and allow the function to resume from where it left off.
>>> def gensqure(N):
    for i in range(N):
        yield i ** 2
>>>x=gensqure(10)
>>>x.next(), x.next()...
Iterators and built-in type: iter(L)
__iter__ method

Learning python 读书笔记 PART 3

PART THREE: Statements and Syntax
Chapter 8. Assignment, Expressions, and Print
program  are composed of  modules contains statements contain expressions create and process objects
1. Assignment Statements
a = 'a'
a, b = 'a', 'b'   #tuple assignment
[a,b] = ['a','b']    #List assignment
a = b = 'c'    #Mutiple-assignment
L = L + [3], L = L + [5,6]    #Concatenate(create a new object)
L.append(3), L.extend([4,5])    #Faster, but in-place(add at the and of memory)
L += [9,10]    #Mapped to L.extend([9,10]): the faster mothed
2. Expression Statements
3. Print Statements
print a,b,    #don't add newline at the end of text
print >>myfile a,b    #send data to myfile.write, not to sys.stdout.write
redirecting the Output Stream
import sys
sys.stdout = open('myfile', 'a')
print and stdout
class FileFaker:
    def write(self, string)  #do something with the string
import sys
    sys.stdout = FileFaker()

Chapter 9. if Tests
1. if stataments
if: elif: else:
if 1:
    print 'true'
else:
    print 'false'
switch & case:
*if choice = 'a':
    print 'aaa'
elif choice = 'b':
    print 'bbb'
else:
    print 'default'
choice = 'b'
*print {'a':'aaa','b':'bbb'}[choice]
*branch = {'a':'aaa','b':'bbb'}
  print branch.get('a', 'bad choice')
2. truth tests
2<3, 3<2   #Less-than: return 1 or 0
short circuit evaluation
2 or 3, 3 or 2   #(2,3) Return left operand if true. Else return right operand.
[] or 3   #3
[] or {}   #{}
2 and 3, 3 and 2   #(3,2) return left operand if false. Else return right operand.

Chapter 10. while and for Loops
1. while loops
while <test>:
     <statement1>
     if <test2>: break    #Exit loop now, skip now
     if <test2>: continue    #goto top of loop now   
else:
     <statement2>    #if we didn't hit break
breaks, continue, pass and the loop else
Emulating C while Loops

C assignments return the value assignment; Python assignments are just statements, not expressions
C: while ((x = next()) != NULL){process x...}
Python equivalent:
*while 1:
    x = next()
    if not x: break
    ...process...
x = 1
*while x:
    x = next()
    if x:
    ...process
2. for loops
for <target> in <object>:
    <statements>
else:
    <statements>  #if we didn't hit break
3. loop variations
range

Counter Loops
range(3)  #[0,1,2]
range(2,5) #[2,3,4]
range(0,10,2)  #[0,2,4,6,8]
*for item in X: print item
*i = 0
 while i < len(X)
     print x[i],; i += 1
*for i in range(len(x)): print X[i]
Nonexhaustive Traversals
S = 'abcdefghijk'
for i in range(0, len(s), 2) print S[i],  #manual for indexing
for i in S[::2]: print x
Changing Lists
for i in range(len(L)):
    L[i] += 1
zip and map
zip can enable us to visit multiple sequences in parallel
L1 = [1,2,3], L2 = [4,5,6]
zip(L1,L2)   #[(1,4),(2,5),[3,6]]
for (x,y) in zip(L1,L2):
    print x, y,
when argument lengths differ, zip choose the shortest length
map(None, L1, L2)
map choose the longest length and filled empty items with "None"
Dictionary Construction with zip
>>> keys = ['a','b','c']
>>> values = [1,2,3]
>>> zip(keys,values)
[('a', 1), ('b', 2), ('c', 3)]
>>> D = {}
>>> for(k,v)in zip(keys,values):
    D[k]= v   
>>> D
{'a': 1, 'c': 3, 'b': 2}
>>> D2 = dict(zip(keys,values))
>>> D2
{'a': 1, 'c': 3, 'b': 2}
File Scanners
file = open('test.txt', 'r')
while 1:
    line = file.readline()
    if not line: break
    print line
1. for line in open('test.txt').readlines(): print line
2. for line in open('test.txt').xreadlines(): print line
3. for line in open('test.txt'): print line
xreadlines loads lines on demand, "3" relies on iterators, is equivalent of xreadlines

Chapter 11. Documenting Python Code
1. the python document interlude

dir(): Lists of attributes  available on objects
__doc__: In-file documentation attached to objects
docstrings
User-defined docstrings: strings at the top of file, method and class
built-in docstring:
import sys
print sys.__doc__
print int.__doc__, print open.__doc__
pydoc
help(sys)
2. common coding gotthas
Don't forget the colons
Start in column 1
Blank lines matter at the interactive prompt:
mean the end of compound statement
Indent consistently
Don't coding C in Python:
don't embed assignment statements in while loop tests
Use simple for loop instead of while or range:
for loop is simple and fast
Don't expect results from functions that change objects in-place:
append(), sort(), append(), extend()
myList = myList.append(X)  #set myList to None
Always use parenthesis to call a function
Don't use extensions or paths in imports and reloads

Oct 4, 2008

Google docs + Google Gear + Blogger

这几天把其它地方的blog都挪到Blogger上了,和其它blog服务相比,blogger更加简洁,而且方便定制。但这两天在使用的过程中,也发现了一些问题,首先Blogger本身提供的文本格式化工具较弱,拍版普通的文字尚可,但如果文字有缩进之类的就相当麻烦,Tab是没用的,就算在“誊写”状态下使用空格,虽然在编辑视图中缩进正常,但是在发布后依然难以控制缩进的量。其次我习惯性将博客写在word中,然后粘帖到在线博客的编辑窗口,但doc中的样子在粘帖过程中很难不走样。

首先我想到的从word中导出Html,然后粘帖到blogger的html视图中,但即使将导出的html进行规整后,显示的效果依然极不理想。

接着我想到了像blogger这么大的用户群,应该有人会开发blogger for word的插件,结果还真让我给找着了,可实际结果是登录blogger帐号失败,分析下来的结果是用户名和密码的字符编码可能在中文win环境下有错,导致了不能登陆,在windows环境下,这类字符编码的问题很少发生,但发生了还真想不到解决的办法。

然后我又想到既然word和Google doc间的兼容性较好,而Google的产品间应该也有较好的兼容性,因此我想到了word-->Google doc-->Blogger这样的发布路线,但实际操作下来word-->Google doc这一步没有问题,但从Google doc 发布到blogger时仍然出现了问题,虽然现在Google doc支持将文档直接发布到Blogger,但是发布的效果和doc中的显示效果有较大的差别。其实原因很简单,Google doc默认使用的CSS和Blogger使用的CSS有些不同,但修改Blogger模板有点烦,一个个属性一个个值调下去太费时间。不过我觉得只要调整正文的P、ul、li、dvi这四个属性就能取得比较好的显示效果。

最后的结果是,现在我不用office了,直接使用Google docs,虽然功能少些,但是够用,也不要担心文章丢失之类的东西。想想Google docs推出这么些年,也该出个离线编辑功能了吧,找了下还果然发现了。

首先要在http://gears.google.com/下载Google Gear,Google的一个支持web apps离线操作的软件,下载后能自动套用到当前使用的浏览器。然后启动Google Docs,在“设置”中将语言设成English(现在还不支持中文版的Google Docs),然后重启下浏览器,Google docs的右上方就会出现:offline链接,搞定!

Learning python 读书笔记(6, 7章)

Chapter 6: Lists and Dictionaries
1. List
Methods: grow, sort, search, reverse, append, extend, append
del L[x:y], L[x:y]=[a,b,c]
range(x), xrange(x,y), L.pop()
2. List in Action
Slice assignment: delete + insert
L.append(x) < -- > L+[x]
3. Dictionaries
D.keys(), D.values(), D.items():
create a new list
D.copy(), D.get(k, default),
D2.update(D1): merges the keys and values of one directory into another, blindly overwriting values of the same key.
D.has_key(k), k in D
D = dict(zip(keyslist, valueslist))
4. Dictionaries in Action
sequence operation don’t work.
Assigning to new indexes adds entries.
keys need not always be strings.(can be other immutable object)
Using dictionaries to simulate flexible lists Using dictionaries for sparse data structures
Matrix = {}
Matrix[(2,3,4)] = 88: the number at position (2,3,4) is 88
Using dictionaries as “reconds”
Dictionary interfaces
import anydbm
file = anydbm.open(“filename”)
file [‘key’] = ‘data’ #store data by key
data = file[‘key’] #fetch data by key

Chapter 7: Tuples, Files, and Everything Else
1. Tuples

simple groups of objects, cannot change in place(immutable), don't support any method calls
>>> (1,2) + (3,4)
(1, 2, 3, 4)
>>> (1,2) * 3
(1, 2, 1, 2, 1, 2)
>>> T = ('1', '2', '3')
>>> tmp = list(T)
>>> tmp
['1', '2', '3']
>>> T2 = tuple(tmp)
>>> T2
('1', '2', '3')
>>> T = (1, [2,3], 4)
>>> T[1][0] = 5 #works
>>> T[0] = 0 #Fails
2. Files
input = open('path', 'r'), output = open ('path', 'w')  #mode: r, w, a
S = input.read(), S = input.read(N) # N bytes
S = input.readline(), S = input.readlines()
output.write(S), output.writelines(L), output.close()
seek: reset current position in file, flush: buffered output write into disk
3. Type Categories Revisited
Operator Overloading:

class MySquence:
    def __getitem__(self, index):
        #called on self[index]
    del __add__(self, other):
        #called on self + other
4. Object Generality
Lists, dictionaries, and tuples can: 1. hold any kind of object 2. arbitrarily nested
Lists and dictionaries can dynamically grow and shrink.
5. References Versus Copies
No reference to the same object:

A = L[:]    #instead of: A = L (or list(L))
B = D.copy()    #instead of: B = D
empty-limit slices and copy method only do a top-level copy!
nested copy:
import copy
X = copy.deepcopy(Y)
6. Comparisons, Equality, and Truth
L1 == L2, L1 is L2    #Equivalent? Same object?
But short string: S1 = 'spam', S2 = 'spam' # S1==S2: true, S1 is S2: true
Numbers are true if nonzero
Other objects are true if nonempty
None: much like NULL in C
L = [None] * 100
bool: True, False

Oct 3, 2008

Concept map 思维导图

接触思维导图是在《学习的革命》开始流行的那会,书中叫做“脑图”,兴许是名字太土,如今换成叫思维导图,听起来专业了些。也着实画了几张,后来新鲜劲过了也就没继续下去。昨天在抓虾上看到了《从优秀到卓越》的思维导图,发现看这图相比看书,比快餐还快餐,一下子就能知道个大概。接着试用了几款软件,MindMapper、Keystone和Inspriation。比较下来几款软件并无多少差异,可从作图的美观性和实例多少来看,MindMapper更为优秀。不过后来在Visio中找了下,发现也有类似的功能,即是所谓的灵感触发图。总的用下来Visio还是最好的,操作便捷且绘图标准大方。

在Visio中脑图一共有四种图形:主标题、标题、动态连接线和关联线。十分简单,而且够用。要花哨的话也提供了一些模板可以套用,使用上还是十分方便的。



http://picasaweb.google.com/xuyizun/LbltPF#
在网络相册中我放了一些搜集到的思维导图。

可我们真的需要脑图么?如果它真的有用,那么在工作中早就在应用了,而实际上直到现在,脑图依然处在个人的尝试中,我认为导致脑图并不流行的原因有以下几点:首先是脑图本身的局限性,它太简单而且太缺乏标准了,简单导致了灵活和杂乱,的确,脑图几乎可以表示任何结构的知识或思考;但由于没有标准的图例,一来导致了过于灵活,二来稍显杂乱。其次是中国的教育体制决定的,从小我们就被锻炼出了十分不错的记忆力,既然看完能较快地记住,脑图也就变得不那么重要了,因为脑图从本质上来讲就是为了帮助大家较好地建立一个思维体系。

下面用思维导图来表示思维导图的局限,算是练习咯!

Oct 2, 2008

Learning python 读书笔记(1--5章)

PART ONE: Getting Started
Chapter 1: A Python Q&A Session
Chapter 2: How python runs programs
1. Source(x.py) --> Byte Code(x.pyc) --> runtime(PVM)
2. CPython, Jython and Python.net
Psyco: Just-in-Time Compiler
3. Frozen Binaries: program + PVM = binary executable program.
Py2exe(for windows), Installer(Linux & Unix), freeze(original)
Chapter3: How you run programs
1. Unix executable scripts: start with #!/usr/local/bin/python
2. raw_input trick: pause the script
3. import and reload
imports are too expensive an operation to repeat, so when we use reload() instead.
4. Attributes: import xx & from xx import yy. yy are the attributes in the python file xx.
5. IDE: IDLE, Komodo, PythonWorks, PythonWin, Visual Python(plugin for VS).
6. text editor: see http://www.python.org/editors

PATR TWO: Types and Operations
Chapter4: Numbers
1. programs  modules  statements  expressions.
2. Numbers: Normal integers(C longs); Long integers(unlimited size); Floating-point(C doubles);Octal and hex literals; Complex number literals.
3. NumPy(Numeric Python).
4. When use a variable that has never been assigned, Pythons report an error rather than a default value.
5. Numeric representation:
>>>b/a #Auto echo output: more digits
>>>print b/a #print rounds off digits.
>>>repr(num) #Used by echos: as cod form
>>>str(num) #Used by print: user-friendly form
6. Division: Classic, Floor and True
x/y: Classic division
x//y: Floor devision
>>>from __future__import division
7. >>>import math
>>>math.pi, math.e
8. >>>int(‘0100’), int(‘0100’, 8), int(‘0x40’, 16) #100, 64, 64
>>>oct(64), hex(64) #’0100’, ‘0x40’
>>>eval(‘100’), eval(‘0100’), eval(‘0x40’) #100, 64, 64
9. >>>a=3 # a: Names (reference) 3: Object
10. >>>L1 = [2, 3, 4]
>>>L2 = L1
>>>L1 = 24 #L2 is not changed
>>>L1[0] = 24 #L2 = [24, 3, 4]
Chapter 5: Strings
1. >>> s = ‘a\nb\tc’
>>> s # output is the original sequence
>>> print s #output is translated sequence
>>>len(s) #5
2. If python doesn’t recognize the character after ‘\’, it simple keeps the backslash in the resulting string.
3. Raw stirng: r’xxxx’
4. u‘xxx’: Unicode string
5. >>> abc = 'abc'
>>> for i in abc:
print i
a
b
c
>>> for i in abc:
print i,
a b c
6. Index and slicing:
>>> num = '123456'
>>> num[1:3], num[5:], num[:-4]
('23', '6', '12')
>>> num[::2], num[::-1], num[0:-3:2]
('135', '654321', '13')
7. String conversion tools:
>>>int(“42”), str(42) #Convert from/to string
>>>string.atoi(“42”), ‘42’ #older techniques
8. You cannot change a string in place(by assigning an index).
9. String formatting
>>> "%s %d %s" %('I', 4, 'you')
'I 4 you'
%s: string
%r: s, but uses repr()
%c: character
%d: decimal (integer)
%i: integer
%u: unsigned integer
%o, %x, %X: Octal, Hex, Hex uppercase
%e, %E: floating-point exponent
%f: float point
%g, %G: floating-point e or f
%%: %
%[(names)][flag][width][.precision]code
>>> x = 1234
>>> res = "integers:...%d...%+d...%-6d...%06d" %(x, x, x, x)
>>> res
'integers:...1234...+1234...1234 ...001234'
10. String methods:
X.method(arguments) == string.method(X, arguments)
list(); join(); capitalize(); center(width)…

Sep 30, 2008

vmware联网

好久没在家里过十一了,今年老妈没给生活费,硬生生把俺逼回了家,也好,正好赶上大闸蟹上市。今儿上午去外婆家,成了玩笑的对象,很是热闹了一下,晚上爷爷奶奶又到我家,聚一起吃螃蟹,回家的第一天过得还是有声有色的。

空了还帮家里搞了下电脑,发现虽然学了四年的计算机,很多最基本的操作还是一窍不通。找了些基础的文章:
基本的DOS命令。
接着顺便在vmware中装了下Linux。选择host=windows guest=Linux这中方式也是十分无奈,上财的校园网通过H3C的802.1x拨号,在Linux下找不到合适的拨号软件,虽然网上也介绍了一些方法,但试下来无一成功。只好在windows下装了虚拟机。
vmware联网,host = win xp;guest = linux。
vmware联网类型:NAT,host-only and bridge。
最后我使用NAT方式联网成功,虚拟机中的IP设成通过DHCP自动获得就可以了。

Sep 25, 2008

开学第一周

国民经济核算,高等数理统计,投资学,高级微观经济学,社会主义经济理论,高级英语口语,马克思。七门课程,23个学时,忙忙碌碌。大学里逃了很多课,有些是当时就不该逃的,有些是当时只能逃但现在有些后悔的。后来考G,考研,找工,实习,才发现自己放弃了那么多本不该放弃的东西。现在只想静静地读书,再也不逃课,学好了课本再学其他的东西。简单生活。

上财来我还是蛮喜欢的。学校小小的,满满的,看着挺舒服;路上有很多漂亮的女孩子,就算每天走一样的路也不会觉得无聊;饭堂的伙食好出了华工很多;图书馆有满排崭新的计算机经典书。这些都是蛮让人开心的事儿。
STA + CS = data mining;
economic + math = STA.
从课程来讲,我也挺喜欢系里的安排,高微和高统打下了些经济和数学的基础,这对我而言是蛮重要的。
在网上也找了MIT的经济和数学课程,慢慢加强吧。
看了大学一个同学的简历,真的感觉差距很大,现在的我也许真不到他大三初的水平。回想自己的大学,实在是在七零八碎的地方花去了太多的时间。有很多基础的东西需要去补。
DB、Stastics、R、Regular Expressions。One by one!

Sep 24, 2008

通过u盘安装Linux

下了fedora9,无奈本本刻不了dvd,只能打算通过usb进行安装。
win的usb启动盘可以通过usboot制作,而linux的usb启动盘在win下制作比较麻烦。
幸好fedora有liveusb制作软件,链接如下:
https://fedorahosted.org/liveusb-creator

上财上网通过H3C的802.1x,linux下找到的拨号软件试了下都用不了,比较可行得是linux1x,可仍无法验证通过,可能是数据包加密的问题,也不知怎么解决。现在学unix大多在win下通过putty连到unix-center进行一些操作。