天生我才必有用

TDD在嵌入式系统中运用的益处

Posted in 技术    作者:Ray    2011年九月2日
  1. Target hardware is not ready until late in the project, delaying software testing.
  2. Target hardware is expensive and scarce. This makes developers wait and build up mounds of unverified work.
  3. 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.
  4. Long target build times waste valuable time during the edit, compile,load, and test cycle.
  5. Long target upload times waste valuable time during the edit, compile,load, and test cycle.
  6. Long target upload times lead to batching numerous changes inone build, which means that more can go wrong, leading to more debugging.
  7. 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 编译选项

Posted in 技术    作者:Ray    2011年八月31日

1.编译时:

加入 -fprofile-arcs -ftest-coverage 选项

2.Link时:

加入 -fprofile-arcs

3.生成的文件:

gcda后缀名的文件 (GNU Compiler arc data)

gcno后缀名的文件。

Drupal 文件系统

Posted in PHP    作者:Ray    2011年八月25日

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

Posted in PHP    作者:Ray    2011年八月23日

最新的Drupal7提供了单元测试的功能,为你的代码健壮性提供了保证。

  1. 建立一个module.test的文件作为你模块的测试文件,module请替换成你的模块名称。
  2. 建立一个继承DrupalWebTestCase的类,并实现其中的getInfo的函数。
  3. 添加一个setUp的函数,这个函数类似所有单元测试中的setup函数,不过在这个函数中必须加入parent::setup(‘module’),其中module是你的模块名称。
  4. 在后台的激活testing模块。
  5. 在admin/config/development/testing/设定页面中,点击“Clean Environment”按钮,就可以在列表中看到你的测试模块了。
标签:

Linux环境下批量解压zip文件

Posted in Linux    作者:Ray    2011年四月15日

很多对于此问题的解答是编写一些批处理脚本来实现。其实最方便的方法就是使用unzip,在命令行输入unzip ‘*.zip’,由于在Linux环境下*具有特殊意义,所以记得必须在*.zip外添加引号。

获取所安装的Django版本?

Posted in 技术    作者:Ray    2011年三月25日
1
2
>>> import django
>>> django.VERSION
标签:

Andorid View对象常用方法

Posted in 技术    作者:Ray    2011年三月22日
  • 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下的子目录说明

Posted in 技术    作者:Ray    2011年三月15日
  • 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

Posted in 技术    作者:Ray    2011年三月15日

@[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
标签:

Android ADT 地址

Posted in 技术    作者:Ray    2011年三月13日

Eclipse 3.5 (Galileo) and 3.6 (Helios)

  1. Start Eclipse, then select Help > Install New Software….
  2. Click Add, in the top-right corner.
  3. In the Add Repository dialog that appears, enter “ADT Plugin” for the Name and the following URL for the Location:

    https://dl-ssl.google.com/android/eclipse/

    Note: If you have trouble acquiring the plugin, try using “http” in the Location URL, instead of “https” (https is preferred for security reasons).

    Click OK.

  4. In the Available Software dialog, select the checkbox next to Developer Tools and click Next.
  5. In the next window, you’ll see a list of the tools to be downloaded. Click Next.
  6. Read and accept the license agreements, then click Finish.
  7. When the installation completes, restart Eclipse.

Eclipse 3.4 (Ganymede)

  1. Start Eclipse, then select Help > Software Updates…. In the dialog that appears, click the Available Software tab.
  2. Click Add Site.
  3. In the Add Site dialog that appears, enter this URL in the “Location” field:

    https://dl-ssl.google.com/android/eclipse/

    Note: If you have trouble acquiring the plugin, you can try using “http” in the URL, instead of “https” (https is preferred for security reasons).

    Click OK.

  4. Back in the Available Software view, you should see the plugin listed by the URL, with “Developer Tools” nested within it. Select the checkbox next to Developer Tools, which will automatically select the nested tools. Then click Install
  5. On the subsequent Install window, all of the included tools should be checked. Click Next.
  6. Read and accept the license agreements, then click Finish.
  7. When the installation completes, restart Eclipse.
标签: