Posted in C++, 学习, 生活 on October 11th, 2008 No Comments »
小学就知道,数学定理中规定了余数永远非负,但是在计算机中的模运算不是这样,因此,不能把计算机程序设计中的模运算等同于数学概念中的取余数。
计算机取模运算的结果符号与被除数一致,也就是说取模运算的结果有可能为负数。
对于正数,二者计算出的结果是相等的,但是负数就不相等了。这就意味着,如果以后在使用数学中余数相关定理的时候,要注意计算机中余数的计算和数学定义不是完全一致的, 所以在计算机上,对于负数,数学定理并不完全适用。当然,对于正数,二者是没有区别的。至于为什么计算机上要这么实现,我想恐怕还是历史原因,最早的计算 机如果这样计算除法(取余是靠除法来完成的),那么就涉及到浮点数的计算以及取下界,这样,将比较大的降低效率,所以实现成了这样的方式,一直沿用至今。
Posted in NetBSD, Unix,Linux,BSD, 生活 on August 19th, 2008 No Comments »
最近整理了一下在NetBSD下建立Raid1的过程,当时建立bsdchina.org服务器的时候由于时间仓促没有将整个的制作过程记录下来,前两天抽时间在虚机中重新做了这个过程,跟大家分享。
起因:现在一些SATA的主板上自带的Raid控制器并不能被NetBSD识别,因此如何将双硬盘制作为Raid1从而提高数据安全性成为一个比较头疼的问题,最终在bsdchina.org服务器上,采用了软件模拟Raid控制器的方式来实现Raid1。使用的软件是NetBSD标准安装中自带的RaidFrame软件。
过程:
1 在VMware中建立虚拟机,两块硬盘大小10G。
2 安装NetBSD4.0系统至disk0。
3 启动系统后,dmesg|grep -i raid 检查内核是否支持RaidFrame,如果输出类似下面的格式则表示内核有RaidFrame支持。
# dmesg|grep -i raid
Kernelized RAIDframe activated
4 如果没有RaidFrame支持,请先编译内核使其支持RaidFrame。
5 执行df,查看硬盘使用情况。
disklabel -r wd0
# fdisk /dev/rwd0d
通过上面的一些命令,可以帮助我了解目前虚机中第一块硬盘的情况,接下来要在第二块硬盘上做一些准备工作,核心的操作就是将第二块硬盘wd1中的全部扇区用0填充,命令如下:
# dd if=/dev/zero of=/dev/rwd1d bs=8k count=1
执行完毕后,通过如下的命令来确认第二块硬盘上的mbr和全部的数据已经被清空。
# disklabel -r wd1
观察上面的信息,offset都为0证明全部分区没有数据占用。由此可以确定硬盘上既没有数据也没有mbr引导记录。
接下来,我将第一块硬盘上的mbr中的引导记录传送至第二块硬盘。在此之前,先将第二块硬盘wd1设置为可启动。
# fdisk -0ua /dev/rwd1d
按照如下的内容进行回答。
fdisk: primary partition table invalid, no magic in sector 0
Disk: /dev/rwd1d
NetBSD disklabel disk geometry:
cylinders: 19386, heads: 16, sectors/track: 63 (1008 sectors/cylinder)
total sectors: 19541088BIOS disk geometry:
cylinders: 1023, heads: [...]
Posted in Linux学习笔记, 生活 on August 11th, 2008 No Comments »
vino的密碼是放在gconf xml裡面, 而且是用base64編碼方式存放
所以我的作法是…先到online的Base64 Encoder and Decoder將自己的密碼encode後,
然後再下
gconftool-2 -s -t string /desktop/gnome/remote_access/vnc_password 編碼後的密碼
這樣一來就可以再次用vnc連上遠端電腦了
以密碼”test”為例 , 經過base64編碼得到”dGVzdA==”
gconftool-2 -s -t string /desktop/gnome/remote_access/vnc_password dGVzdA==
Posted in 生活 on May 19th, 2008 No Comments »
出处:http://axp1.csie.ncu.edu.tw/~rick/blog/?p=162
ubuntu 7.10 下使用 VirtualBox 時,欲設定 USB 裝置時,會跳出 “Could not load the Host USB Proxy Service (VERR_FILE_NOT_FOUND). The service might be not installed on the host computer.” 訊息,表示沒有權限。這個問題其實是因為 ubuntu 7.10 預設把使用 USB 的權限關了。解決方法如下:
1. 開啟 /etc/init.d/mountdevsubfs.sh
$sudo vim /etc/init.d/mountdevsubfs.sh
2. 找到這段文字:
#
# Magic to make /proc/bus/usb work
#
#mkdir -p /dev/bus/usb/.usbfs
#domount usbfs “” /dev/bus/usb/.usbfs -obusmode=0700,devmode=0600,listmode=0644
#ln -s .usbfs/devices /dev/bus/usb/devices
#mount –rbind /dev/bus/usb /proc/bus/usb
將 comment [...]
Posted in 生活 on May 19th, 2008 No Comments »
安装过程中会提示编译vboxdrv的kernel-module 。需要准备以下软件包
apt-get install build-essentials
apt-get install linux-headers-`uname -r`
并且执行sudo m-a prepare,这句话必须执行
Posted in 生活 on April 16th, 2008 No Comments »
http://www.allwiki.com/wiki/Mediawiki%E7%AE%80%E6%98%8E%E7%BC%96%E8%BE%91%E6%95%99%E7%A8%8B#.E7.BC.96.E8.BE.91.E4.B8.8A.E6.89.8B
Posted in 生活 on March 31st, 2008 No Comments »
After asking around in the SharePoint Community and finally asking Microsoft Support (who turned out to be very helpful – many thanks!), we found the following solution on how to display the datasheet view:
1. Close Internet Explorer
2. Start -> Run… -> “regedit” (without quotation marks)
3. In the Registry Editor, delete the following Folder (sub-key)…
Path: HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Internet [...]
Posted in bsdchina.org服务器维护, 生活 on February 24th, 2008 No Comments »
make -f Makefile.init makefiles ‘CCARGS=-DUSE_CYRUS_SASL -DUSE_SASL_AUTH -DHAS_MYSQL -I/usr/pkg/include/mysql -I/usr/pkg/include’ ‘AUXLIBS=-L/usr/pkg/lib/mysql -L/usr/pkg/lib -lmysqlclient -lsasl2 -lz -lm’
The Bold Font is necessery. The first is tell the complier we use cyrus to do the authentication. and the second one is also import that although the sasl2 lib is in /usr/pkg/lib/sasl2 but we must use /usr/pkg/lib instead of using [...]
Posted in 生活 on February 23rd, 2008 No Comments »
Yes, As you have seen, our sever come back to work now. It’s running at the new kernel NetBSD 4.0 Enviroment now. I confirm that the upgrade process is very unsuccessful. And I’m not sure the server will be ok after a period of time. It may be crush suddenly. I think the next time [...]
Posted in MOSS, 生活 on December 9th, 2007 No Comments »
3/29/2007
SharePoint workflows - InfoPath 2007 form ‘code-behinds’
After taking a bit of a break from workflows to attend to other aspects of MOSS customization, I’m preparing to get back into it. In digging thru some old files
After taking a bit of a break from workflows to attend to other aspects of MOSS customization, I’m preparing to [...]