Symbol Navigation in Atom Editor

There is a “Go to Declaration” in context menu of Atom Editor, but it doesn’t work by default. It is because Atom doesn’t scan the project to generate symbols, it depends on tags, tags can be generated by run command “ctags -R in project root”.

cmd-r can lookup symbols in current buffer (file), it doesn’t requires tags pre-generated.

cmd-shift-r can search the symbol over the whole project, it requires tags.

Go to Declaration shortcut menu is same as cmd-shift-r and typing the symbol under the cursor. It is a frequent operation, thus the hot key cmd-alt-down is assigned 。

Atom doesn’t provide the function to find all the reference to a specific symbol, yet.

在 Mac OS X 系统里使用 Docker

目前的 Docker 实现是建立在 Linux CGroup 等技术之上,因此无法在 MacOS X 上原生使用(不过都折腾libcontainer了,不久应该会很快会有原生版本了吧)。需要建立一个 Linux 虚拟机,然后在虚拟机内的 Linux 上安装使用。为了简化整个安装使用, 提供了一个完全自包含的安装包,它会:

  1. 检测 Virtual Box 虚拟机软件,如果没有则安装之,有则启动运行之。
  2. 创建名为  boot2dock-vm  headless vm,这个 vm 非常精简,只提供了运行 docker 所需要的基本环境,比自己从头安装一个 Linux 省很多。
  3.  Mac OS X Host 上安装 boot2docker   docker 命令。
  4.  Mac OS X Host 上安装 boot2docker app。这个 app 其实就打包了一个 Apple Script 脚本,
  5. 它会打开一个系统 Terminal 并启动虚拟机并做一些环境设置。在初次运行时会把 /usr/local/share/boot2docker/boot2docker.iso  复制到 ~/.boot2docker/ 里,然后调用boot2docker init完成初始化。

因此,在习惯使用的Terminal 软件如 iTerm2 里,自己调用boot2docker up 也是一样的。boot2docker 启动之后,就可以在 Mac OS X 的环境里使用 docker 命令工作了,用法跟标准的lxc-docker 一样,它知道通过ssh将工作转发给虚拟机里的 docker 实现。如果想要直接在虚拟机内工作,用 boot2docker ssh 就要以获得一个运行在虚拟机内的shell了。

 Mac OS X 下,除了 外,还有一个 skitematic  也可以提供 docker 环境。Skitematic 实际上是在 boot2docker 的基础上又做了一层包装并提供 GUI 方式管理docker 以及访问 docker hub Skitematic 挺好用的,但是它其实是个web app,并且内部依赖,所以第一次使用需要翻墙否则界面不正常。更重要的时,它带的 boot2docker 注意了会用 dev 做为 Virtual Box 虚拟机的名称,但是放在 Mac OS X 里的其它文件跟 独立安装的 boot2docker 是有冲突的。

在配置好 boot2docker之后又使用Skitematic 的结果是先后出现了以下2个问题:

  1. docker 命令版本(1.1.8)变得比独立安装的 boot2docker-vm 里的(1.17)要高,访问boot2docker-vm会报以下错误:
    1. FATA[0000] Error response from daemon: client and server don’t have same version (client : 1.18, server: 1.17)
    1. 由于 Skitematic GUI没有关闭VM的界面,需要File | Open Docker Command Line Console 然后 boot2docker down 或得用 VirtualBox app  VM 管理功能关闭之,然后用 的安装包安装取得老的 docker 命令。
    2. 如果需要让两者都能用,可以把 1.17 版本的 /usr/local/bin/docker 备分到 /usr/local/bin/docker117,以后记得有 docker117 为访问 boot2dcker-vm。或者只用boot2docker ssh 取得虚拟机上的 shell 工作。
  1. 来回折腾之后,boot2docker console  会错误的尝试用 domain socket 而不是 ssh 连接 boot2dock-vm,从而报下面的错误:
    1. FATA[0000] Get http:///var/run/docker.sock/v1.17/images/json: dial unix /var/run/docker.sock: no such file or directory. Are you trying to connect to a TLS-enabled daemon without TLS?
    2. 如果用 boot2docker app 打开 console 的话,会看到:

bash-3.2$/usr/local/bin/boot2docker up

Waitingfor VM and Docker daemon to start…







Toconnect the Docker client to the Docker daemon, please set:


export DOCKER_HOST=tcp://

export DOCKER_CERT_PATH=/Users/pinxue/.boot2docker/certs/boot2docker-vm


bash-3.2$$(/usr/local/bin/boot2docker shellinit)




bash-3.2$docker version

Clientversion: 1.5.0

ClientAPI version: 1.17

Goversion (client): go1.4.1

Gitcommit (client): a8a31ef

OS/Arch(client): darwin/amd64

Serverversion: 1.5.0

ServerAPI version: 1.17

Goversion (server): go1.4.1

Gitcommit (server): a8a31ef


  1. 把提示的三个 DOCKER_ 环境变量设置一下就好了。

使用 boot2docker 时,所有的 container 都在boot2docker up命令启动的 Virtual Box VM 里,container 使用的端口通过 docker -P 或者 –p 映射到了 VM 里的 LinuxHost 上,但是在 Mac OS X 里是没有的。从本机倒是可能用VMip访问到 container,从移动设备或其它机器上需要访问 container 时,就需要在 Mac OS X 上再做一次端口映射(portmapping)。有两个方法,在 里有介绍:

  1.  Mac OS X  VM Linux 之间临时建立 ssh tunnel
    1. boot2docker ssh -vnNTL 8000:localhost:8000
  2.  Virtual Box  NAT 端口映射能力建立永久性的映射
    1. 虚拟机已关闭时:VBoxManage modifyvm “boot2docker-vm” –natpf1 “tcp-port8000,tcp,,8000,,8000”;
    2. 虚拟机在运行时:VBoxManage controlvm “boot2docker-vm” natpf1 “tcp-port8000,tcp,,8000,,8000”;


** 练练手还是不错的,不过真的挺容易把自己绕晕,开个海外的便宜 VPS 操练会更好,pull 时速度也会好很多。

!! 太多字了,翻译成英文太费时间,先欠着…

Iron-Router auto routing by name conversion

Once got the idea of Iron Route routing method, Conversion over Configuration popped up in my mind immediately. I have named the templates same as their path, it is boring to type it again in JavaScript code.

Iron Router’s document mentions catchall route with path-regex syntax, but thing can be way far simpler:

Route.route(‘/:path’, function () { this.render(this.params.path); }

Meteor’s Android Support

Meteor’s Android Support

To run ‘meteor add-platform android’ in the project direcotry will add android support to the project. It requires to install android support of meteor at the first time of use. The field will be installed into ~/.meteor/android-bundle. Then we may use ‘meteor run android’ or ‘meteor run android-device’ to launch app in android emulator or device. If the server side is deployed to some server, append –mobile-server https://hostname:port to use it instead of running local server.


By default, meteor installs a copy of android sdks in ~/.meteor/android-bundle /android-sdk, it takes about 1.8GB disk. It is a good idea to have a self-contained clean environment. But if you have installed android sdks and are using a laptop with not-replacible SSD like me, USE_GLOBAL_ADK is the life saver. (Indeed there is a redundant copy of ant, too. But ant is small in size, I just let it go.)

I have met following issues:

meteor –verbose run android
Found undefined
need re-install the haxm in android-sdk extras.


meteor install-sdk
Valid ABIs: default/armeabi-v7a
Error: Invalid –abi x86 for the selected target.

meteor creates its ad with –target 1, 1 is target id, not api level. In the Android SDK installed by meteor, there is only one target with x86 image. But when setting USE_GLOBAL_ADK=t to reuse the system android sdks, most likely the first target doesn’t support x86. Then we have the problem.

It is easy to handle, let’s run:

android-sdk/tools/android list target

to find a target with x86 abi image. In my environment, target 25 is the answer. Then:

android-sdk/tools/android create avd –target 25 –name meteor –abi default/x86 –path /Users/pinxue/.android/avd/meteor.avd

Now, meteor install-sdk android will work.


meteor –verbose run android-device
run failed silently, –verbose shows:
ERROR: Failed to launch application on device: ERROR: Failed to install apk to device: pkg: /data/local/tmp/CordovaApp-debug.apk

It is because the device is running out of storage space, delete some file and run the command again.

iOS BLE application restore

According to Apple’s documentation, Bluetooth related app can assign a restore identifier to itself so that it can be re-launched by system when BLE events arrived and the app has been killed by System. I made a test on this and found some facts Apple didn’t describe it clearly.

  1. If the app got killed by system due to resource limitation, it exactly can be re-launched, as Apple’s Core Bluetooth Programming Guide described.
  2. If the app got killed by user sliding up the app card away, it won’t be relaunched
  3. If the app connected to a bluetooth peripheral, it looks like the system assigned it a high priority so it is unlikely to be a candidate when system needs killing something.
  4. After centralManager:willRestore: method, centralManager:didUpdateState: is always got called,  so let the latter handle both the cases of normal launching and re-launching by system is OK.

Therefore, there is still no safe way to handle BLE communications in background since user can always kill the app, and it is usual for us iPhone users.