Archive for the ‘Cherub in Work’ Category

Key words include: Windows 7 64bit, MinGW, Sublime Text 2 and CMake. github has this sublime text 2 c++ project boilerplate, which includes a CMakeLists.txt demonstrating linking to the Boost regex library.

Install MinGW

Download from MinGW Distro. This distribution includes up-to-date MinGW, as well as several often used libraries, e.g. Boost. Installation is as easy as extracting. Note that, GCC’s mode is C++11 by default since v11.2.

After extracting to C:\, add the following paths to the system environment variable PATH: (If not installed to C:\MinGW, we need further update cmake commond’s CMAKE_MAKE_PROGRAM in the project boilerplate.)

  • C:\MinGW\bin
  • C:\MinGW\lib
  • C:\MinGW\include

Install CMake

Download the Windows installer (only 32bit) from the official site.

After installed to the default path, add C:\Program Files (x86)\CMake 2.8\bin to PATH.

Set up Sublime Text 2

Assume Sublime Text 2 and Package Manager installed.

Use Package Manager to install CMake Syntax.

Download the project boilerplate.

Use the project boilerplate

Set the default Build System as make (Tools -> Build System –> make).

Ctrl+Shift+P –> cmake to run cmake

Ctrl+B to make


Will add “run” and “debug” two commands. And perhaps add auto complete suggestions supports for Sublime Text 2.

Reference Sites

Read Full Post »

I was surprised there is no straight setting to automate unit tests after build for Visual C# projects. (Visual Studio 2010 Professional)

Quick answer: Set the Post-build event command line of the Test Project’s Build Events to the following script:

"$(DevEnvDir)mstest.exe" /runconfig:"$(SolutionDir)\Local.testsetting"s /testcontainer:"$(TargetPath)"

The idea is to use mstest.exe to run the Test Project automatically after build. If any of the unit tests fails, the build fails.


Long answer:

Say we have a simple Visual C# Console Application. The template generates a Program class. We add a member function int Program::Foo(int i), as the following:

public int Foo(int i)
    return i * 2;

We then add unit test(s) for this method, by right clicking on the Foo method, and selecting Create Unit Tests. Accept to create a new Visual C# Test Project.



Edit the unit test as needed.

Edit the Test Project’s Post-build event property: Project-> TestProject1 Properties … –> Build Events, and add the mstest.ext script from the top of this article.

Now press F7 to build the solution. You may find the following output of executing the unit tests.

Starting execution…
  Results               Top Level Tests
  ——-               —————
  Passed                TestProject1.ProgramTest.FooTest
  1/1 test(s) Passed
  Test Run Completed.
    Passed  1
    Total   1
  Results file:  … 

Test Settings: Local

Build succeeded.


Note that, if any of the unit tests fails, the build fails.

Read Full Post »

Nagios troubleshooting

1. 确认各个plugin单独能执行,往往是因为某些环境相关的设置(例如路径、例如权限)导致脚本本身不能执行。

2. 以非dameon的方式运行nagios,nagios.log的信息就显示在console上了。

bin/nagios etc/nagios.cfg

3. 检查nagios.log,nagios.cfg的log_file配置指定了nagios.log的位置。如果nagios.log并没有出现,可能是运行nagios的用户(在安装nagios时指定)没有对nagios.log所指定的目录的写权限。

4. 加速nagios启动后的查询的执行,在nagios.cfg中有如下配置影响nagios启动后的查询执行。





5. 设置nagios.cfg的debug_level配置,输出debug信息。debug信息输出到nagios.debug,其配置见debug_file。比较有用的是Macros,可以nagios处理Macros的结果,用于验证命令是否正确执行。

6. 自定义的plugin做好log输出,便于检查是否执行以及是否正确执行。

Read Full Post »

JavaScript and ActionScript can talk to each other via ExternalInterface API. It would be convenient to make this channel ready in the html-template of Flash Builder.

html-template can be found at {Flash Builder installation root path}/sdks/{Application’s default SDK}/templates/swfobject/index.template.html.

Add the following codes to after <body> tag

   <script type="text/javascript">
        function getSWF()
            if (navigator.appName.indexOf("Microsoft") != -1)
                return window["${application}"];
                return document["${application}"];
        function jsLog(param)

getSWF method returns the loaded SWF object. jsLog method is a default JavaScript method for ActionScript to call.

For example, say we implement a method called asLog in ActionScript, which is registered to ExternalInterface as:

ExternalInterface.addCallback("asLog", asLog); 

So, once the application is fired (we set Firefox as the default browser for Flash Builder), we can type the following code in Firefox Firebug console to call SWF’s asLog method:

swfObj = getSWF();

It’s handy to make this little change to Flash Builder’s default html-template.

Read Full Post »

本教程中,我们将使用ActionScript 2.0开发应用AISpeech API的汉语口语评测应用。


向AI Speech Ltd 索取开发者应用ID(application ID) 和密钥 ( secret key) ,以及AISpeech API AS2.0 SDK。本教程描述如何使用ActionScript 2.0来创建应用AISpeech API的应用,如果您需要了解如何使用ActionScript 3.0来创建应用AISpeech API的应用,请参考这篇快速教程

我们假设读者掌握ActionScript 2.0语法,拥有Flash IDE(本教程使用Flash Professional CS5.5),并且准备好了耳机和麦克风设备。应用发布和SDK的使用需要通过Web服务器发布以展示使用效果。



我们将构建一个汉语口语评测应用, 这是一个用于浏览器的Flash应用。这个应用可以让用户阅读一个汉语句子,然后录制用户的语音,并且调用AISpeech API对用户录音进行评分。该应用显示每个字的得分和声调得分。发音更标准的用户将获得较好的分数。


Read Full Post »

AISpeech API online document well defines the core response data structure, however in Chinese. As requested by several Not-Chinese clients and developers, here I translate some parts of the document. I hope AI Speech Ltd can soon update its documents for an English version.

This article covers the AISpeech API’s English sentence pronunciation evaluation core’s responses.


Read Full Post »

In the previous post, we have quickly went though the process of building an spoken English assessment application using AISpeech API clouding service, in additon to their ASSDK (ActionScript 3.0).

In this article, we are going to build up a more completed version. We will explore almost every main methods ASSDK has provided, in addition to looking at those ASSDK returns and responses.


Read Full Post »

Older Posts »