Archive for the ‘软件应用’ Category.
April 1, 2010, 5:14 pm
Bash下可以使用”cd -”来实现在当前目录和上一次访问的路径间切换。 如果我们需要回退多级目录怎么实现呢?
Bash有两个内置命令pushd和popd,每次调用它们,系统会把当前目录压入目录栈中保存起来,或者从栈顶弹出一级目录并进入那个目录。利用这两个命令可以实现访问路径的存储与调用。为了使用方便可以在~/.bashrc中创建一个自己的命令,例如
1 2 3 4 5 6
| function cd {
if [ -n "$1" ]; then pushd $1 > /dev/null
else pushd $HOME > /dev/null
fi
}
alias pd='popd > /dev/null' |
这里创建的cd函数覆盖了built-in的cd命令,可以自动保存当前路径到栈中。而调用pd命令则可以返回上次访问的目录。
如果我们想恢复系统默认的cd命令怎么办呢?可以使用“unset -f cd”来取消自定义的cd函数。
Continue reading ‘Bash下的目录回退’ »
March 30, 2010, 11:23 pm
1. apt-get install mpich2 (remove other implementation to prevent trouble)
2. create .mpd.conf file under home dir ~/ , add a line “password=qwert” (replace qwert with any other texts)
3. create a hostfile or machine file (e.g. mpd.hosts) with node names listed one per line. (this file can be in any folder)
4. start mpd. There is a script shipped with mpich2 “mpdboot”. It accept some options. “mpdboot -f mpd.hosts -n #” with #<= number of nodes listed in mpd.hosts file. This command will start mpd on all the nodes if ssh or rsh is set correctly (without password).
5 use mpdtrace to verify the node names (nodes having been added to the mpd ring, ready to be used in the following mpirun calls).
6 mpirun -np N -host node1,node2 ./program (it’s not necessary to use all the nodes in the ring, but some of them is fine)
March 22, 2010, 7:54 pm
By default Notepad2 add a .txt extension to the file name when you save a newly created file. For files already having extensions, this will not be done. However, this is sometimes annoying if you often create files which do not use txt as extension although they are actually plain text files. I think this is almost a daily work for programmers. To cancel this feature, there are two ways. First, when you save the newly created file, simply add quote symbols around the file name like “new_file”, then the file will be save without an extension or with any extension you give. This trick also works for the Windows Notepad program. Another hack is to modify notepad2.ini, there you can create a new section (if it’s not there already) named “[settings2]“. The settings given in this section will override the default behavior. Then add an entry “DefaultExtension=”, yeah just leave nothing behind the equal sign, no suffix will be appended automatically then. There are more options for the customized section, see here.
No doubt, Notepad2 should be a must-have replacement on Windows.
March 15, 2010, 1:55 pm
VS中编译有时很费时间,如果有声音提示编译结果会比较方便,这样就不用总是查看输出窗口了。根据这篇文章,VS声音提示并不在VS软件设置中,而是在系统的“控制面板”中。打开“声音和音频设备”点击“声音”选项卡,在“程序事件”列表下找到“Microsoft Visual Studio”,就可以为编译成功、编译失败和取消编译等事件指定声音了。
我的设置是:
编译成功 — notify.wav
编译失败 — Windows XP Critical Stop.wav
到达断点 — Windows Navigation Start.wav
March 12, 2010, 3:55 pm
I’ve tried to download many freeware or trial versions in order to convert lots of html files downloaded from internet into some Ebook format, such as chm or pdf. Unfortunately and surprisingly none of them is satisfactory. Some cracked commercial software do exist, but I don’t like to be a victim of Trojan.
What a luck! I found this Chinese guy (strongerhorse, or old horse in Chinese) made many useful programs and releases them as freeware. Two of them are just for the task I mentioned in the beginning.
Continue reading ‘Killer apps to tidy up html files and make Ebook’ »
March 10, 2010, 7:07 pm
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
March 7, 2010, 11:23 pm
Python的distutils可以很方便地制作模块安装程序,但是没有提供反安装/卸载功能。
可以通过一个trick来实现反安装:
首先,安装模块时使用“–record” 参数把所安装文件记录到一个文件中
python setup.py install –record files.txt
然后通过这个“反安装文件”来卸载:
cat files.txt | xargs rm -rf
Continue reading ‘Python模块的反安装’ »
February 10, 2010, 4:36 pm
下面的方法对Firefox和ThunderBird都有效:
在Firefox地址栏输入about:config或ThunderBird的工具-》高级-》配置编辑器中, 增加布尔变量config.trim_on_minimize为true。
重启软件后,每当程序被最小化时都会自动释放内存,很有效。
注意一点是,如果装有minimize to tray (最小化至托盘)之类的插件,该功能将无效!如果认为释放内存更重要的话,可以暂时disable那些插件。
December 16, 2009, 7:10 pm
bash下time是一个很有用的命令,它可以为一段脚本或一个程序的执行计时,这通常在粗略比较程序执行效率的时候很方便。但是你会发现,time命令输出的时间文字不能被简单地重定向,例如重定向至一个文本文件,只能显示在屏幕上,这对于非交互计时很不方便。例如:
time command > file.txt
Continue reading ‘重定向 Bash “time” 命令的输出’ »