Posted on

Adding user defined dictionary to Eclipse to add new words to spelling check

After installation of Eclipse, Eclipse automatically starts to check spellings for you. It uses its default dictionary file and you may find many words that you use on your daily basis do not exist (yet) in the default dictionary. How to add them?

Unless you provide a user-defined dictionary for Eclipse, no new words can be added. In order to do this, you may first download a standard US-English dictionary from:

Unzip the package after downloading. Copy the “en_US.dic” file to some folder (one that you keep Eclipse library files, for example. One that you don’t delete easily).

Open Eclipse-Preferences-General-Editors-Text Editors-Spelling, Make sure that the “Enable spell checking” is checked. In the “dictionary-User defined dictionary” section, copy the full path of the above pasted dictionary file. For me, it is


Thus the page will look like this

Click Apply or OK. Now you will be able to add new words to the dictionary.  For example:


Posted on

Start scientific computing on a new OS X

You got your new (expensive) Mac computer. Exciting! The next step, you want to use it for scientific computing/data analysis, e.g. deep learning, algorithm developments, machine learning, etc., let me help you get started.


First of all, the programming environment on an OS X system is based on a software that is found in the Apple App Store. You need to download the newest version to enable the newest features. Its name is XCode. You’ll need to sign in with your Apple ID. It’s free to create a new one.

首先,OS X系统上的编程环境依赖于一个要在Apple App Store里下载的软件,没错,这个软件你必须在App Store下载。第一步就是到App商店下载最新版的这个软件,它的名字叫:XCode. 想开始下载你需要先用Apple ID登录。如果你还没有账户可以建立一个,免费。

Now you are ready to install the next important tool called macports. Macports integrated almost all useful packages for you to do programming. Here is its official website. Download it and install. Refer to the installation guide on the website for instructions.

接下来需要装一个非常重要的Mac上常见的软件。这个软件叫macports. Macports是一个安装包管理软件,它整合了基本上所有的常用编程工具和库。到下面的官方网站去下载并安装macports. 参见官网给的安装说明完成安装。

After it’s installed, open a Terminal window (which is found in Launchpad-Other), type the following command


xcode-select --install

This installs all the command line tools macports needs. Then, accept the XCode license by


xcodebuild -license

Now you are ready to install ports from macports. The following website of macports listed some useful commands to operate with port.


To install a port package, you need the sudo privilege. If you do not, ask the admin of the computer to install or create one for you. The command to install package named packagename is


sudo port install packagename

You may go through the available list for all the ports you can install. From my own perspective, I found the following ones particularly useful. Notice that I specified python 3.7 rather than python 2 for the Python packages. This change was made recently (Aug 2018) because the Numpy community is dropping the support for Python 2, and most other communities are doing the same. I believe it is time to switch:

在官网的”Available ports”栏里,你可以搜索或者列出所有可用的ports。输入关键词即可搜索。个人认为以下的ports在使用时非常有用。有一点要注意的是,我使用了Python 3.7作为默认Python版本,而不是Python 2。这主要是因为Numpy社区准备取消对Python 2的支持,而其他的社区也在做类似的决定。我个人觉得,是时候放弃Python 2转成3 了。:

  • python37, py37-numpy, py37-matplotlib, py37-ipython, py37-notebook
  • inkscape
  • cmake
  • openmpi

macports manages the dependencies for each package automatically, so that if you install one, all the dependencies will be installed with them. So in the end you don’t have to specify all the packages manually because most of them will be installed with others. For example, to check the dependencies of py37-notebook, you can do

macports 为每一个安装包自动管理相应的需求包。当你安装一个包时,所需要的其他包也会一起安装。所以说,最后你并不需要手动输入所有需要的包,因为多数都会跟着别的包一起安装。比如,要获取py37-notebook的需求包,你可以用一下命令:

$ port echo depends:py37-notebook

Running other commands in Terminal requires you to have known basics about SHELL scripting already. You may now install many IDEs to start writing codes in languages you like. If you would like to know where the compiler/interpreter is, you may try the which command. e.g.


$ which cmake

The command returned with the path to cmake on your Mac. Usually macports installs its binaries to the /opt/local/bin/ directory. Your Python 3 is very likely to be there too: /opt/local/bin/python. If it doesn’t return anything, then this executable is not available yet. For more details, see some introductory docs about $PATH variable in SHELL.

这个命令返回了你的Mac上cmake的路径。一般来说,macports会把可执行文件安装在/opt/local/bin/路径,所以你的Python 3也很可能在那里: /opt/local/bin/python. 如果命令没有返回任何结果,那说明你找的可执行文件还不存在。关于这个命令的详情,可以参见在SHELL环境里设置$PATH变量的介绍文档。

Another very useful command for port is to search for an available package with a keyword. Do:


port search [--name] [--regex] '<searchtext>'

[--name] and [--regex] are both optional. e.g. if I search for a very useful program for vector diagram drawings, called inkscape, the return will be like shown in the following figure.

[--name] and [--regex] 都是可有可无的。比如,如果我想找一个叫inkscape的可以画矢量图的好用软件,命令返回结果如下图。

As for the common IDEs to use on a Mac, I recommend:


  • For C++/C or Fortran programming: Netbeans (Download online)
  • For Python programming: PyCharm (Download online)
  • For general programming: MacVim (Available as a macports port)
  • For HTML, CSS, JavaScript, etc. (website design): Coda (Download online)

One next important question is, since ports often depend on others, for example, py37-notebook depends on py37-jupyter_core, but each port maintains its own version, how would one make sure each port is up-to-date, or at least should work flawlessly with each other? How would you make sure the Python package you are developing can be readily adopted by others and they have the required version of Python modules (e.g. if you developed your codes with Numpy-1.15.4, but your user installed 1.14?). There is an optional software you can use to solve this headache, which I will explain in another post:

还有个重要的问题就是,由于这些ports依赖其他的ports来工作,比如py37-notebook依赖于py37-jupyter_core,但每个port都维护着自己的版本,你怎么才能确保所有的port都是最新的,或者至少是互相不起冲突呢?你又怎么去确定你开发的Python程序可以被用户直接使用,前提是这个用户已经有了你需要的module版本呢?(例如你需要numpy 1.15.4 版本,而用户安装的是1.14?)有一个软件可以解决这个问题,我将在另外的帖子里介绍这个问题:

Anaconda, should I bother?

Posted on

How to work with CMake and Netbeans (8.2 or newer) on OS X

After an exhausting search for a good IDE for C++, I finally stopped at Netbeans. I appreciate its convenient zoom-in/out feature, auto-completion, user-friendly interface, etc.

The first challenge I met was to set up the project to work with CMake, as I decided to think beyond the GNU make. I use a MacBook, therefore many programmer tools have to be “manually” installed, including CMake. In this journal, I’ll demonstrate how to set up a project in Netbeans to work with CMake on Mac OS X.


You need the following softwares to work with:

  • macports (Follow the website instructions to install)
  • Netbeans (Download “All”)


After macports is installed, install CMake and tree on the command line in a Terminal:

sudo port install cmake tree

macports will find the pre-requisites for cmake and complete the installation. You can now test CMake by:

cmake -version

This will give you the version number of your CMake. Test tree program by just typing tree in the prompt and it will give you a hierarchy of the current folder. Now you are ready to go.

Working with a small C++ project

Here we use a simple example of a C++ program that uses its own header for complex numbers (not even close to complete but enough for demonstration), called HelloComplex

Supposedly you have written the header and source files and want to start a Netbeans project. The file hierarchy starts with the following:

The contents of each file shouldn’t be of great importance. However, the bash  file in this example is greatly useful for setting up Netbeans and also for even just CMake:

(P.S. you probably want to add execution permission to the bash file first, by

chmod +x ./

What it does is to limit the build from CMake in one directory in ./build/, so the Makefile and other CMake “junk files” will stay in ./build/ . When one wants to clean the build, just do

./ clean

The shell script will first look for an existing ./build/Makefile and do the designated make clean process.  Thereafter, the ./build/ directory is completely removed, and an empty ./build/ is created for the new build.

Letting NetBeans know where to find cmake

Before the project is created, go to NetBeans->Preferences->C/C++->Build Tools. You should be able to see GNU there, like the following window:

Click on $PATH, which tells NetBeans where to look for binaries. Note that this $PATH is not necessarily the same as that as a system environment variable. Add the directory that contains the cmake command. As an example, on my computer cmake is in  /opt/local/bin/, so I added it:


Start a NetBeans project with the above file hierarchy

So, NetBeans can find cmake from your system, so the can be executed.  Now go to File->New Project… The window below will pop out,

Click on Next, then  choose the root folder, such as below. Choose the modified GNU Mac. Choose Custom Configuration mode.

Check the box on Pre-build step is required, and choose the root folder to run in. Use the custom command in shell to do the build. In our case, it’s just ./  Be sure to change the accessibility to make it executable.

Hit Next, and then use the root directory as the working directory. Change the Clean Command and Build Command to ./ clean and ./ . Check the box for clean and build after finish.

Click on Next again, choose the source file location, which is the root directory in our case.

Click on Next, and choose Automatic Configuration (No figure for this step). The final step will be automatically completed by the software. Click on Finish, then the shell script will be executed automatically, as it was specified as the command to build the program. The following workstation should now be available, and the first pre-build should be done also.

You may run the executable in the ./bin/ directory in NetBeans, the output will be shown in the window.

Summary and reminders

This blog only describes how to start the NetBeans project from existing files, but does not include the details of CMake and C++ codes being used. If you are interested, please read my other blog on CMake. You should be able to click on Run from now on. Work on the source files including headers, re-build, and run!

Comments or questions, if any

Please leave them in the comments below. I’ll try to improve my blogs. Thanks!

Posted on 2 Comments

美高校毕业生申请OPT攻略 – 言简意赅无废话!


Optional Practical Training (OPT), 就是让学生毕业后能留美工作的手续


本文主讲毕业生办OPT的流程。但在读F-1学生也可以申请pre-completion OPT,只需要在学校呆满1年即可。毕业生办post-completion OPT.


  1. 大概毕业前3,4个月的时候,跟老板确定大概哪个月份毕业。假设定5月1。注意是毕业时间不是答辩时间!答辩在毕业前,之后要交论文稿件预留时间;

  2. 跟学校international office说一下,要求开始出具OPT的证明。IO会咨询老板意见,老板confirm。IO给你一个新的I20,上面指明是给OPT申请用的。会有一个targeted graduation date;

  3. 毕业前3个月的时候(最早90天前交材料),把材料寄出:需要的材料quote如下: 

    To complete your OPT application, please do the following:

    • Print your name, sign, and date the I-20 where indicated.
    • Make a copy of the I-20 once you’ve signed it. You will keep the original and the copy will go in your application packet.
    • Assemble the OPT packet in the following order: o   I-765 (top page) o   Page three of I-20 copy o   Page one of the I-20 copy o   Copy of your passport identity page o   Copy of your paper I-94 card, front and back OR print out of your electronic I-94 record
    • Staple your bagged passport photos to the upper right corner of the I-765 only.
    • Staple your check/money order to the top center of your I-765 only.
    • Staple the entire packet together in the upper left corner.
  4. 寄出材料。与此同时,准备答辩材料,开始找工作,跟公司说明5月2号之后可以工作。公司HR会明白,发offer的时候上面start date会写5月2号或者之后,但最好不要太晚,因为OPT期间失业天数有限。如果start date是5月11号,但5月1号拿到了EAD卡,这10天就是unemployed status。

  5. (难点): 假如file太晚,毕业之后还没拿到EAD卡,这段时间都算失业期,即使批准了还没到手也算;file也不能太早,90天限制。

  6. 4月某天答辩,催一催USCIS,大概5月1号或者之后拿到OPT EAD card,去公司报道。

注意 先跟老板沟通好毕业时间。毕业时间决定了答辩时间和申请OPT的时间。OPT批准时间多则2,3个月,邮寄等等都需要count在内,不可轻视。宁可早点拿到不要晚。OPT加急非常麻烦,一定要早点行动。