Archive for the ‘中文文章’ Category.

禁用Visual Studio的Addins

某些VS的Addins会导致程序异常缓慢或出错,一个小技巧是在启动VS的时候提前按住左边的shift键,即可禁止加载所有插件。

Display dihedral angle in PyMOL

An alternative and better ways is to use the ‘distance’, ‘angle’ and ‘dihedral’ commands of ‘cmd’ object. Note not using ‘get_distance’, ‘get_angle’ and ‘get_dihedral’, they are for different purpose. The syntax is e.g. ‘dihedral dih_obj_name, id 1, id 2, id 3, id4’, i.e. giving an object name and four atom selections. (In this example, we use atom IDs for atom selections. Other syntax for atom selection should work too.) Using this method, the measurement will be automatically updated while playing the movie

Python模块的反安装

Python的distutils可以很方便地制作模块安装程序,但是没有提供反安装/卸载功能。

可以通过一个trick来实现反安装:

首先,安装模块时使用“–record” 参数把所安装文件记录到一个文件中
python setup.py install –record files.txt

然后通过这个“反安装文件”来卸载:
cat files.txt | xargs rm -rf

Continue reading ‘Python模块的反安装’ »

PiCloud 基于Python的云计算平台

Handy ‘which’ command on Windows

VERY handy!

1
2
3
4
5
6
7
8
9
10
 @echo off
rem --------------------------------------------------------
rem File: which.cmd
rem Description: Windows equivalent of Unix which command
rem Author: Pankaj Kumar
rem Copyright 2004 Pankaj Kumar. All Rights Reserved.
rem License: This software is available under GPL (http://www.gnu.org/licenses/gpl.html)
rem ---------------------------------------------------------
setlocal
if "%1" == "" goto noArg

set fullpath=%~$PATH:1
if “%fullpath%” == “” goto notFound
echo Found in PATH: %fullpath%
goto end

Continue reading ‘Handy ‘which’ command on Windows’ »

Firefox和ThunderBird自动优化内存使用

下面的方法对Firefox和ThunderBird都有效:

在Firefox地址栏输入about:config或ThunderBird的工具-》高级-》配置编辑器中, 增加布尔变量config.trim_on_minimize为true。

重启软件后,每当程序被最小化时都会自动释放内存,很有效。

注意一点是,如果装有minimize to tray (最小化至托盘)之类的插件,该功能将无效!如果认为释放内存更重要的话,可以暂时disable那些插件。

Print directory tree on Windows and Linux using tree, sed, awk or Python

Windows: there is ‘tree.com‘ command showing the directory structure.
http://chxkyy.javaeye.com/blog/213864

Linux: there is a ‘tree‘ program for Linux and also available on some Linux distributions, such as Debian. (apt-get install tree)
http://www.debian-administration.org/article/Commands_you_might_have_missed_tree

Continue reading ‘Print directory tree on Windows and Linux using tree, sed, awk or Python’ »

Formlayout – an user-friendly way to interact

The online document is very simple but maybe too simple. It shows how to create a basic dialog WITHOUT tab, but formlayout in fact can do more, like building a tabbed dialog shown in the picture.

Continue reading ‘Formlayout – an user-friendly way to interact’ »

Bash: exit codes for background jobs

Useful commands:

  • wait <pid>: wait the background job with specified pid to be finished and return the exit code ( hint: stored in $? )
  • jobs -p: list the pids of all the background jobs (hint: use for statement of bash to loop over each process)
  • ( sleep 30s; /bin/false ) & : generate a background testing job with a error exit code

First, submit all the background jobs, no matter you use loop or line by line in a script.
Next, get the PIDs of the background jobs. After submitting EACH job, the PID of that job is in $!, which can be store to any user defined variable for later use.
Last, check the exit codes. You can either check the exit code of each job one by one or calculate the accumulative exit code. To check them one by one, just call wait command for each PID stored in previous step and check the value of $?; to check them cumulatively, see this post. (the trick is the sum of exit codes for all jobs should be zero if all jobs are finished successfully, or the sum must be non-zero)

umount: device is busy

Sometimes after mounting some nfs devices, you cannot easily un-mount them. You get some error: “device is busy”. I often get this error when I want to un-mount some shared folders like ‘/home’ and ‘/usr’.The reason is simple: the devices you are un-mouting are busy;) That’s to say some files on the mouted devices are being used by some process.

On internet you can find a lot of posts talking this problem. The essential thing is to figure out what processes are using the device and kill them. You can try ‘fuser’, ‘lsof’, ‘ps|grep’ . But in my cases, those commands don’t always work. Then I suggest you try ‘umount -l the_device’. This command solved my problem and most probably it should work for you too.

Continue reading ‘umount: device is busy’ »