富兰克林的13条修养美德
- 节制:食不过饱,饮酒不醉。
- 沉默:说话必须对别人或你自己有益;避免闲聊。
- 秩序:物归其所,事定期限。
- 决心:做应该做的事情;决心要做的事应坚持不懈。
- 俭朴:花钱必须于人于己有益;换言之,切忌浪费。
- 勤勉:不浪费时间,只做那些有用的事情,戒掉一切不必要的活动。
- 诚恳:不欺骗人;思想纯洁公正;说话也要如此。
- 公正:不做害人的事情,不用忘记履行对人有益二期又是你应尽的义务。
- 适度:避免极端;要容忍别人对你应得的处罚。
- 清洁:身体、衣服和住所力求清洁。
- 镇静:不要因为小事或普通的、不可避免的事故来扰乱自己。
- 贞洁:除非为了保持健康、延续子嗣,否则都应该注意节欲,不要因为纵欲导致精神不振、身体虚弱,伤害到自己或者别人的安宁及名声。
- 谦虚:学习耶稣和苏格拉底。
TDD在嵌入式系统中运用的益处
- Target hardware is not ready until late in the project, delaying software testing.
- Target hardware is expensive and scarce. This makes developers wait and build up mounds of unverified work.
- When target hardware is finally available, it may have bugs of itsown. The mound of untested software has bugs too. Putting themtogether makes for difficult debugging, long days, and plenty offinger pointing.
- Long target build times waste valuable time during the edit, compile,load, and test cycle.
- Long target upload times waste valuable time during the edit, compile,load, and test cycle.
- Long target upload times lead to batching numerous changes inone build, which means that more can go wrong, leading to more debugging.
- Compilers for the target hardware are typically considerably more expensive than native compilers. The development team may havea limited number of licenses available, adding expense and possibledelays.
GCC的code coverage 编译选项
1.编译时:
加入 -fprofile-arcs -ftest-coverage 选项
2.Link时:
加入 -fprofile-arcs
3.生成的文件:
gcda后缀名的文件 (GNU Compiler arc data)
gcno后缀名的文件。
Drupal 文件系统
Drupal7 的文件系统使用了3种自定义的URI,操作起来和访问http、ftp协议类似,比较直观。
- public://
- private://
- temp://
用户还可以自己定义stream wrapper,来实现自己的URI。具体内容参见:DrupalStreamWrapperInterface。
当调用file_save_data时,有三种模式可以选择:
- FILE_EXISTS_REPLACE:覆盖原有的文件
- FILE_EXISTS_RENAME:对文件名从新命名,自动添加_1,_2等后缀。
- FILE_EXISTS_ERROR:什么事情都不做,直接返回错误。
默认为FILE_EXISTS_RENAME模式。
如果保存成功则返回drupal的file对象。
Drupal Test Part 1
最新的Drupal7提供了单元测试的功能,为你的代码健壮性提供了保证。
- 建立一个module.test的文件作为你模块的测试文件,module请替换成你的模块名称。
- 建立一个继承DrupalWebTestCase的类,并实现其中的getInfo的函数。
- 添加一个setUp的函数,这个函数类似所有单元测试中的setup函数,不过在这个函数中必须加入parent::setup(‘module’),其中module是你的模块名称。
- 在后台的激活testing模块。
- 在admin/config/development/testing/设定页面中,点击“Clean Environment”按钮,就可以在列表中看到你的测试模块了。
Linux环境下批量解压zip文件
很多对于此问题的解答是编写一些批处理脚本来实现。其实最方便的方法就是使用unzip,在命令行输入unzip ‘*.zip’,由于在Linux环境下*具有特殊意义,所以记得必须在*.zip外添加引号。
获取所安装的Django版本?
1 2 | >>> import django >>> django.VERSION |
Andorid View对象常用方法
- getParent(): Finds the parent widget or container.
- findViewById(): Finds a child widget with a certain ID.
- getRootView(): Gets the root of the tree (e.g., what you provided to the activity via setContentView()).
/res下的子目录说明
- anim: Compiled animation files
- drawable: Bitmaps
- layout: UI/view definitions
- values: Arrays, colors, dimensions, strings, and styles
- xml: Compiled arbitrary XML files, Android-supplied XML readers to read
- raw: Noncompiled raw files (Audio & Video), stream-based APIs to read
Android Resource-Reference Syntax
@[package:]type/name
The type corresponds to one of the resource-type namespaces available in R.java, some of which are:
- R.drawable
- R.id
- R.layout
- R.string
- R.attr
The corresponding types in XML resource-reference syntax are as follows:
- drawable
- id
- layout
- string
- attr