Archive for the ‘计算机和互联网’ Category.
April 8, 2010, 12:54 am
To get subversion+apache2 work on Debian is not very difficult. Basically including the following steps (ref: this post):
- sudo apt-get install apache2 subversion libapache2-svn
- sudo a2enmod dav_svn (load the svn module)
- sudo nano /etc/apache2/mods-enabled/dav_svn.conf (edit this file to specify the actual svn repositories path and setup basic user authentication)
- sudo mkdir /var/svn-repos ;sudo svnadmin create /var/svn-repos (create svn repository)
- sudo chown -R www-data:www-data /var/svn-repos; sudo chmod -R 770 /var/svn-repos (give right permission to apache server. This is crucial for browsing the svn repos via web browser. Some articles suggest creating a new group ‘subversion’ and add all svn user to that group, but I found that’s not the best solution to use svn+ssh protocol and websvn together. Then we can use ‘adduser’ command to create new users, and add them to the group ‘www-data‘ using ‘usermod -G www-data user_name’ command. Without this step, the users cannot update or commit via http or svn+ssh because only the users in www-data group can access the repos with permission 770 set above. I also found this is a workaround for the SSH permission problem due to the owner change when codes are committed by specific users, because all the svn users are now the members of www-data group and they all have access to the repos due to group policy, although the ownership can change to the user who commits codes if svn+ssh protocol is used. If users commit codes via http, the ownership of the repo folders will not change and always belongs to the ‘www-data’ user. )
- sudo htpasswd2 -cm /etc/apache2/dav_svn.passwd bob (Add a user ‘bob’ to allow browsing the svn repo. Bob should be in the subversion group. This command will ask to input user password.Note:remember the path of this file, we will use it again when we set up websvn.)
- sudo /etc/init.d/apache2 restart (restart apache to enable the new settings.)
- Now we should be able to access the svn repo via http://hostname/svn/repo_name (the path depends the settings in /etc/apache2/mod-available/dav_svn.conf. Note the ‘SVNParentPath’ setting.)
Continue reading ‘Subversion+websvn on Debian’ »
April 7, 2010, 2:08 am
Virtualbox支持客户机和宿主机之间共享目录,但是根据版本不同,会有些问题。例如对于3.1.x版本,windows XP host和Debian guest组合下,VBox自己的共享目录(写入)性能极差甚至报错(本人遇到)。其实,在客户机和宿主机之间共享文件的还有一些其他方式,例如可以通过ftp或samba,二者都支持所有操作系统下的共享,但是相比之下samba更具优点,因为在Windows和Linux下都可以把Samba共享目录映射为本地磁盘目录。
先来看Linux访问Windows共享目录的情况。这比较容易,因为Windows上共享文件十分方便,可以通过点击右键实现文件夹共享。在Linux客户端,只要使用smbclient或者smbmount命令即可以实现远程共享目录的访问和映射。具体步骤包括:
1. 在Windows机器上选择文件夹,点击属性-》共享,指定共享名称和权限(是否可写)
2. 在Linux客户机上安装smbclient,然后执行smbclient -L ip_of_win_server来查看服务器所有共享资源。
3. 链接到共享文件夹,smbclient //ip_of_win_server/sharename -U username来连接,如果成功则会出现smb提示符可以使用samba client的命令操作远程目录。(默认需要Windows用户密码)或者使用sudo smbmount //ip_of_win_server/sharename local_path -o uid=your_user_name gid=your_group_name 来映射磁盘目录。
Continue reading ‘通过Samba在VirtualBox的guest和host间共享目录’ »
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模块的反安装’ »