Archive for the ‘Notes’ Category.
Internal overflow compressing coordinates
I occasionally got this error while running some mpi programs. I could not find the exact reason. Even when I google it, it seems no relevant explanation of it. By investigating the codes with debugger, I notices some data in the memory are huge, when I correct them, the error information was gone too. Therefore I guess this error is related to the expression of illegal numbers. However, I would like to know more about it if someone can point out the exact reason.
Mount Windows shared folders automatically with fstab
According to the article “Mounting smbfs Shares Permanently Help File” published on JustLinux by Ray Cowan, we could mount a Windows shared folder automatically using /etc/fstab. There are many discussions about how to do this on the internet. E.g. some people suggest using ~/.bashrc or ~/.bash_profile to fulfill this. But there are not the right solution. Because the mounting should only be done once not more. The essential thing in Ray’s article is one can use options of smbmount command in fstab. The working format looks like
//servername/sharename /mountdirectory smbfs credentials=/home/myhomedirectory/.smbpasswd,uid=myusername,gid=mygroupname 0 0
Continue reading ‘Mount Windows shared folders automatically with fstab’ »
Add menu item to Mantis
Modify config_inc.php and add
1 2 3 4 5 6 7 8 | $g_enable_project_documentation = ON; $g_smtp_host = 'localhost'; $g_window_title = 'SimuWorld Bugtracker'; $g_logo_image = 'images/mantis_logo.gif'; $g_favicon_image = 'images/favicon.ico'; //The following line add two custom menu items with different access level controls //The contants used here can be found in ./core/constant_inc.php, e.g. DEVELOPER, ANYBODY etc. $g_main_menu_custom_options = array( array( "WebSVN",DEVELOPER,'url_to_websvn' ),array( "test", ADMINISTRATOR,'' ) ); |
The recognized user roles can be found in ./core/constant_inc.php
Subversion+websvn on Debian
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.)
通过Samba在VirtualBox的guest和host间共享目录
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 来映射磁盘目录。
Copy/paste in gnome-terminal
1. Change the default keyboard shortcuts to ctrl+c and ctrl+v. They are more common shortcuts on most OS.
2. Highlighting texts and Middle mouse button clicking will do copy/paste. These are similar to the operation in PuTTY where right mouse button click is used.
Sound for non-root users on Debian
After a fresh installation everything seems work fine on my Debian. But for a non-root user, the volume control widget on the gnome desktop shows a little red cross, and there is no sound. It’s good if you hate playing music while you are working. However, in case you want it, there is a simple way. By default there is a group named ‘audio’ on Debian, the users in this group automatically get sound:) Root is of course one of them. If you also want sound, add yourself to that group by ‘adduser yourname audio’ then restart.
Control file extensions of Notepad2
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.
禁用Visual Studio的Addins
某些VS的Addins会导致程序异常缓慢或出错,一个小技巧是在启动VS的时候提前按住左边的shift键,即可禁止加载所有插件。
