Sunday, 30 October 2016

程序员修炼之道读书笔记 41


Test Your Software, or Your Users will.
测试你的软件,否则你的用户要测。
No one should produce code they don’t fully understand.
不要写你不完全理解的代码。
Perfection is achieved, not when there is nothing left to add, but when there is nothing left to take away….

完美不是通过无以复加而是通过无以可减来实现的。

Saturday, 29 October 2016

程序员修炼之道读书笔记 40


There's no better way to fix errors than by avoiding them in the first place. 
防患于未然。
上医知病治无病,中医知病治有病,下医治病不知病。

程序员也是一样, 高明的程序员通晓架构,精通编程,写优质近乎无bug的代码(当然不可能完全没有bug),通常在需求或设计阶段就已经把问题消灭。中等的程序员也知道一些架构,善于编程,但是还是要花一些时间改bug,因为他们做不到完美的设计和精确的实现。劣质的程序员,根本不知道什么是架构设计,只见树木不见森林,写一行代码返工三号代码,总是靠模仿写程序,没有懂得软件实现的来龙去脉,疲于应付和救火自己之前埋下的“代码地雷”。

Tuesday, 25 October 2016

vim hangs or got stuck when press ctrl+s

91. What should you do when you get stuck by accidiently pressed ctrl+s in vim?
You can:
press ctrl + q to quit.
Or:
To disable this feature you need the following in either ~/.bash_profile or ~/.bashrc:
stty -ixon


stackexchange link:
http://unix.stackexchange.com/questions/72086/ctrl-s-hang-terminal-emulator

accepted
This feature is called Software Flow Control (XON/XOFF flow control)
When one end of the data link (in this case the terminal emulator) can't receive any more data (because the buffer is full or nearing full or the user sends C-s) it will send an "XOFF" to tell the sending end of the data link to pause until the "XON" signal is received.
What is happening under the hood is the "XOFF" is telling the TTY driver in the kernel to put the process that is sending data into a sleep state (like pausing a movie) until the TTY driver is sent an "XON" to tell the kernel to resume the process as if it were never stopped in the first place.
C-s enables terminal scroll lock. Which prevents your terminal from scrolling (By sending an "XOFF" signal to pause the output of the software).
C-q disables the scroll lock. Resuming terminal scrolling (By sending an "XON" signal to resume the output of the software).
This feature is legacy (back from the 80's when terminals were very slow and did not allow scrolling) and is enabled by default.
To disable this feature you need the following in either ~/.bash_profile or ~/.bashrc:
stty -ixon

Sunday, 23 October 2016

程序员修炼之道读书笔记 39

It's unlikely that you'll spend much time during your career writing sort routines. The ones in the libraries available to you will probably outperform anything you may write without substantial effort.  现在的程序开发已经到了,完善高效库函数触手可及的地步,你的职业生涯你不需要自己写排序算法,即使你写,不花上洪荒之力的努力,你不太可能写出比库函数更优秀的算法。所以不要reinvent wheels. 把精力花在其他更高效的事情上,总是记住80/20原则。

Estimate the order of your algorithm and test it.
预估你算法的阶,并测试验证。

Be wary of premature optimization. It is always a good idea to make sure an algorithm really is  a bottleneck before investigating time trying to improving it.

总是警惕早期优化。 首先要确保你做了正确的事情,能够完成你的设计功能。才考虑优化。优化之前,找出花费时间最多的瓶颈,然后优化,这样才最经济。而不是把时间花在不是瓶颈的模块,效果可能不理想。

Wednesday, 19 October 2016

程序员修炼之道读书笔记 38




Document your assumptions always. 为你的假设建立文档(也可以在代码注释中说明你的编程假设)
So next time something seems to work, but you don't know why, make sure it isn't just a coincidence.
下一次当你碰到一些代码看起来工作但是你不知道为什么的时候,请务必确定那不是一个巧合。建议深挖出里面的逻辑,如果工作,弄清楚为什么工作,如果不工作,同样搞明白为什么工作。通常情况下,后者比较容易,前者比较难。 因为一般人会说,well, it works. I don’t have to know why. 事实上,那极有可能是个巧合,你所谓的work,只是基于简单的测试。因为我们不能做到完全覆盖测试,所以明明白白,清清楚楚的知道其中的来龙去脉,非常重要。切记!切记!(笔者曾经干过多次,代码看起来工作,然后就不去追根问题的事情,最终被人找,自己挖坑还得自己填。现在想想实在是不应该,那是在靠运气编程!)
POSIX strcpy isn't guaranteed to work for overlapping strings.
POSIX不能使用strcpy来互相拷贝内存有重合的字符串。

Tuesday, 18 October 2016

联想笔记本怎如何设置不按fn键,直接使用F1~F12功能键

(1)bios中config里面有keyboard,在其中把FN键更能键锁定取消。
开机时进入BIOS----CONFIG----Keyboard/Mouse----Change to "f1-f12 keys",
选项设置为Legacy 。完成后保存重启就可以了。
 (2)若bios里没有,试试FN+ESC,看看FN上面有没有指示灯,可以调整功能键。如果FN上没没有指示灯
,恢复一下bios设置。
 (3)如果还不行,按FN+ESC也没用的话,那么这款机器就无法更改了。
 
我本人的电脑 W540,采用方法3,瞬间解决!

原文链接:http://zhidao.baidu.com/search?lm=0&rn=10&pn=0&fr=search&ie=gbk&word=%C1%AA%CF%EBfn%BC%FC%C4%AC%C8%CF%BF%AA%C6%F4

Monday, 17 October 2016

The art of Doing twice the work in Half the time (5) && (6) && appendix



The art of Doing twice the work in Half the time (5)
Deliver happiness
Happy today and happy tomorrow.
It is the journey not the result.
Get better every day and keep it.
Change or die.

The art of Doing twice the work in Half the time (6)
Change for free.
Deliver fast, if fail, fail fast.
DOD: Definition of Done.
All man dream, but not dream equal. Dream of the day is dangerous.
Scrum can be applied in any endeavors.
Get rid of all management, give people freedom what they want to do.

Appendix:
The book talks about why.
Estimate by size not hours. Use Fibonacci number, 1,2,3,5,8,13,21…
Daily scrum meeting, what did you do yesterday, what are going to do today? What is getting in your way?
 Sprint retrospect.

Saturday, 15 October 2016

The art of Doing twice the work in Half the time (4)




What will bring the most value to the project or product? Organize / Prioritize by value.
Plan just enough to keep your team busy.
Planning Poker.
Business decide what should do while the team members decide how to do it.
Nothing is written in the stone, keep evolving.
Ask the oracle.
Happiness, scrum done in the right way, makes everyone happy.
Enjoy the process rather than just the result, you will be happier.
Happiness with rigor.
Happiness lead to success.
People not happy because they succeed, but people succeed because they are happy.
Feel excited for any small skills or knowledge you learned.
Ask you team member, what would make you happier?