Make javascript node.tmbundle works with TextMate under node.js 0.6.5

I downloaded the TextMate bundle for node.js.
But this bundle doesn’t work properly.
When i clicked cmd+R to run javascript, it reports that it cannot get variable “TM_FILE” from undefined.
And the console output contains a warning that module “sys” is renamed as “util”.

To fix this two issues:
Some fix these 2 issues, some modification to command script is needed:

  1. Open Command Editor in TextMate, and edit the command script of “Run File or Spec” under “JavaScript Node” category:
  2. Change var sys = require("sys"); to var sys = require("util"); to fix the warning.
  3. Replace all instances of process.ENV. with process.env.

After modification, close the Bundle Editor. Then ask TextMate to reload all the bundles.
Then the command will work perfectly now.

There is another Trick, since there had been a bundle called javascript in TextMate. So this node js bundle doesn’t activated when you editing .js file.
You need to press ctrl + alt + n to activate the bundle manually.

This problem can be fixed by changing scope selector of all the snippets and commands. You can change it from “source.js.node” to “source.js”

Windows 7 下脚本启用或者关闭网卡的方法

方法一:NetSH 大法~
采用下列 Netsh 脚本

Netshell Script
set interface name="Local Area Connection" admin=ENABLED/DISABLED

方法二:Powershell+WMI 大法

$adapter = get-wmiobject Win32_NetworkAdapter -filter "NetConnectionID='Local Area Connection'"

同理可以 VBS+WMI 大法~

Windows 7 的 UAC 很严格,不能像 WinXP 里那样随意修改系统设置而不通知用户。
如果不赋予脚本执行环境以 Administrative 权限的话,脚本会执行失败,WMI 返回码为 05,Netsh 报错:“An interface with this name is not registered with the router.”
因此在启动 Netsh 或者 Powershell 时需要指定 Administrative 权限,可通过右键菜单 Run as Administrator 实现。
然后会出现 UAC,Allow 即可~
由于 UAC 权限具有继承性,即一个具有 Administrative 权限的 Process 启动的 Process 默认是具有 Administrative 权限的(除非显式的禁止继承)~
因此可以通过启动一个有 Administrative 的 Cmd 或者 Powershell 的 Shell 来让脚本具有 Administrative 权限~

该方法仅在 Win7 下测试通过~WinXP 下不通过~
似乎原因是由于 WinXP 的 WMI Class 不支持 Enable 和 Disable 方法造成的~具体解决方案未知。