Using Eclipse as Node Applications Debugger
https://github.com/joyent/node/wiki/Using-Eclipse-as-Node-Applications-Debugger
Eclipse debugger plugin for V8 can be easily used to debug node scripts. (On OSX 10.5 the plugin requires an Eclipse 64 bit Version, started with Java SE 6). The V8 engine provides debugging support by enabling attachment of the remote debugger on a TCP port (5858 is node’s default). There are 2 debug related node options:
node –debug[=port] NodeApp.js
or
node –debug-brk[=port] NodeApp.js
The –debug option will just enable remote debugger connection on given port and then start the application normally. Even when debugger is connected to the running node instance later on, the script execution will not be stopped until “Suspend” command is issued by Eclipse debugger. Another way to stop the execution is to browse the source code of the JavaScript modules comprising the application and double click on the line number at the desired position in script to break at (most likely a callback). Once execution stops you can set/clear more breakpoints, but also inspect call stack and view content of all program variables.
The –debug-brk option is needed when your script is short lived (no time to attach debugger) and/or you want to observe the NodeApp.js execution from the very start. This option will force execution to break at the first line of the main script and wait for debugger to connect. The behavior upon connection is now different – the script is suspended and no breakpoints are set. Note that V8 engine debugger is not behaving very good when it steps over or steps into require() method (it will crash), so try to set up first breakpoint past the initial module loading. This will also enable you to set breakpoints in any of those modules as well.
Installation
Rather than installing the V8 Eclipse Debugging Plugin on an existing Eclipse Java or Eclipse C++ installation, you might want to install the plugin into its own Eclipse Platform. This prevents an instability of the plugin, Node.js or V8 from disrupting your Java or C++ projects. You can download a clean slate Eclipse Platform, then use the plugin update utility to install V8 Eclipse Debugging Plugin.
- Download a clean slate Eclipse Platform for your operating system.
- Unzip the Eclipse Platform to a directory on your hard drive.
- Run the Eclipse Platform. You will be asked to create a workspace. Create a workspace separate from any Java or C++ workspaces you may already have created. If this is your first time using Eclipse, the default is fine.
- Proceed to the workbench by clicking the icon with the arrow titled Workbench in the top right corner of the Eclipse window.
- Select the menu item Help > Install New Software…. A dialog box titled Install will appear. This contains a plugin installation wizard. The first step of the wizard is titled Available Software.
- At the top of the dialog you will see a combo box labeled Work with:. Click the button to the right of the combo box labeled Add. A dialog box titled Add Repository will appear.
- In the textbox labeled Name: enter Google Chrome Developer Tools. In the textbox labeled Location: enter http://chromedevtools.googlecode.com/svn/update/dev/. Click OK.
- Now select Google Chrome Developer Tools – http://chromedevtools.googlecode.com/svn/update/dev/ from the Work with: combo box. Google Chrome Developer Tools will appear in the table below. Click the checkbox next to Google Chrome Developer Tools in the table. Click the button labeled Next > at the bottom of the dialog box. The next wizard step titled Install Details is displayed.
- Click the button labeled Next >. The next wizard step titled Review Licenses is displayed.
- Once you are satisfied with the licenses, you can select the I accept the terms of the license agreement radio button and click the button labeled Finish. A progress dialog box titled Installing Software will be displayed. After installation is complete click the Restart Now button.
- Eclipse will restart with the V8 Eclipse Debugging Plugin installed.
Sample Debugging Session
Here is a simple script that will be used to demonstrate debugging procedure:
// dbgtest.js
var sys=require(‘sys’);
var count = 0;
sys.debug(“Starting …”);
function timer_tick() {
count = count+1;
sys.debug("Tick count: " + count);
if (count === 10) {
count += 1000;
sys.debug("Set break here");
}
setTimeout(timer_tick, 1000);
}
timer_tick();
Start the above script:
$ node –debug dbgtest.js
debugger listening on port 5858
DEBUG: Starting ...
DEBUG: Tick count: 1
DEBUG: Tick count: 2
DEBUG: Tick count: 3
// and so on
Assuming that you have already installed Eclipse, together with the plugin mentioned above, now you need to make initial debug profile.
In the Menu, choose Window → Open Perspective → Other, then select Debug from the list and click OK, to ensure you are viewing the debug perspective.

Posted in technology.
– March 30, 2012
反面意见和中国文化
从古至今,中国人似乎都不喜欢反面意见,从历朝历代的官员到某个部门的领导,反面意见代表着一种不和谐,反面意见让领导者没有面子。中国人对于提反面意见早有独特的见解,忠臣进谏便是史书和戏剧经常上演的故事,魏征和海瑞是提反面意见的杰出代表。
“以铜为镜可以正衣冠,以人为镜可以明得失,以古为镜可以知兴替”唐太宗对于魏征的评价说明了帝王将相对于反面意见的高度重视。一国之君在治理国家的时候,如果各个官员都是阿谀奉承,众口一词,时间久了,恐怕这个王朝就不长久了。可是中国历来对反对意见的认识不太清楚,认为反对意见就是对领导者进行劝告建议,抵制领导者的决策,一旦出现这样的反对声音,就会出现巨大的矛盾。如果从西方管理学的角度来考量这个问题,我们能够找到不同的解释。彼得·德鲁克认为反对意见的存在有如下的三个理由:第一,唯有反对意见,才能让领导者不至于成为组织的俘虏。在一个组织中,每一个人对领导者都有所求,希望主管的决策对自己有利。突破这一陷阱,能使领导者不至成为某方面的俘虏的办法,就在于引起争辩,掌握实据和经过深思熟虑的反面意见。第二,反面意见本身,是决策所需的另一方案,当领导者执行自己的计划时,反面意见可以作为备用方案,当相关的外界环境发生变化时,反面意见所提供的备用方案就能为领导者提供更多的选择。第三,反面意见可以激发想象力,有时最好的方案常常是还没有想到的那一个,只有反面意见才能让领导者找到正真最合适的那个方案。这也是安德鲁·卡内基善用比自己能力强的人的秘密。
在现实生活中,提出和聆听反面意见,都不是一件容易的事情,甚至可以说这是每个人都值得学习的一门艺术。上司在很多时候之所以为上司是因为他/她拥有更多的信息,下属在提反面意见的时候要懂得分寸和火候,提供上司所不了解的信息作为必要补充,适当的表达自己的见解和观点。下属的职责在于汇报和请示,不需要替上司做决策,真正的决策权应该掌握在信息更多的一方。
Posted in 光影生活.
– March 19, 2012
上海市集中空调通风系统卫生管理办法
http://wenku.baidu.com/view/9f548d4d767f5acfa1c7cd43.html
http://www.bravobtt.com/?p=2&a=view&r=64
http://www.hs.sh.cn/wjs/b/87387.shtml
– January 31, 2012
狗狗不能吃的东西列表(转载)
含酒精的饮料:会导致醉酒中毒、昏迷甚至死亡。
婴儿食品:有可能含有洋葱粉,会使狗狗中毒(见下面洋葱一栏)。如果大量喂食,可导致营养不足。
鱼骨、家禽骨以及其他肉食的骨头:可导致消化系统阻塞或划伤。
猫食:通常含有过高的蛋白质和脂肪。
巧克力、咖啡、茶以及其他含有咖啡因的食品:含有咖啡因、可可碱或茶碱,有可能引起狗狗中毒,并影响心脏及神经系统。
柑橘(柠檬)油提取物:可能导致呕吐。
剔下来的肥肉:可导致胰腺炎。
葡萄和葡萄干:含有一种未知的毒素,可破坏肾脏。但葡萄籽提取物不存在此问题。
蛇麻草:含有未知的化合物,可导致气喘、心跳加快、体温升高、心脏病突发甚至死亡。
含铁的人用维生素补充品:可破坏消化系统内壁,对肝脏和肾脏等器官有毒性。
大量的肝脏食品:可导致维生素A中毒,影响到肌肉和骨骼。
澳洲坚果:含有不明毒素,可影响消化系统、神经系统和肌肉。
大麻:可抑制神经系统、引起呕吐或改变正常的心律。
牛奶以及其他乳制品:有些成犬和猫体内缺乏足够的分解乳糖的酵素(乳糖酶)。因此会导致腹泻。不含乳糖的乳制品比较适合宠物食用。
发霉腐败的食品、垃圾:含有多种毒素,可导致呕吐、腹泻并且可能影响到其他组织。
蘑菇:含有毒素,可影响体内多种系统,引起休克甚至死亡。
洋葱及大蒜(生的、熟的或制成粉末的):含有二甲亚砜,可破坏血红细胞,导致贫血。猫比狗更容易受到影响。大蒜比洋葱的毒性小些。
柿子:柿子籽可导致肠道阻塞和肠胃炎。
桃和李子的果核:可导致消化道阻塞。
土豆、大黄和西红柿的叶(芽);土豆和西红柿的茎:含有草酸盐,可影响消化系统、神经系统和泌尿系统。对家畜的影响更大。
生鸡蛋:含有一种酵素——抗生物素蛋白,会影响维生素H(一种B族维生素)的吸收。可导致皮肤病及背毛问题。生鸡蛋也可能含有沙门氏菌。
生鱼:可导致维他命B1不足,引起食欲减退、心脏病(或其他疾病)突发,严重的可导致死亡。如果经常喂食生鱼的话,引起这些的可能性更大。
盐:如果食用大量的盐,可导致电解质不平衡。
线:可在消化系统内缠绕,称为“线异物”。
Posted in 健康生活.
– September 15, 2011
Buddha’s Brain: The Practical Neuroscience of Happiness, Love, and Wisdom
Posted in 点滴体会.
– September 14, 2011
![IMG_0228[1]](http://www.bigtaro.com/wp-content/uploads/2011/09/IMG_02281-e1316786026940-225x300.jpg)
![IMG_0229[1]](http://www.bigtaro.com/wp-content/uploads/2011/09/IMG_02291-e1316786093451-225x300.jpg)
![IMG_0231[1]](http://www.bigtaro.com/wp-content/uploads/2011/09/IMG_02311-e1316786173785-225x300.jpg)

