Saturday, May 24, 2008

Sandip :: Weblog :: IP range to CIDR conversion

Sandip :: Weblog :: IP range to CIDR conversion: "#!/usr/bin/perl -w
# range2cidr.pl

use Net::CIDR;
use Net::CIDR ':all';

if (@ARGV == 0) {
die 'Usage Example: $0 192.168.0.0-192.168.255.255 n';
}

print join('n', Net::CIDR::range2cidr('$ARGV[0]')) . 'n';"

Friday, May 23, 2008

Wang Shi president of Wanke

《史记新篇》--王八二传(转载自天涯)
发信站: 北大未名站 (2008年05月20日20:42:28 星期 二) , 站内信件

时有王石者,其父从王震征新疆,有功,震爱其父,以之为柳州铁路局长,及石长,时广
东省督以女妻之,石倚父翁之名望,行商贾之事,无不应手而解,后以房产为业,竟积身
家亿万。石好登山,每出,必耗资巨万;其行小善一事,必刻石以记,好自作传记,开博
客,延枪手,其所售房产多巨幅书其事,图其影,以为宣传,其好名如此。
          
           洪朝五十九年四月初八,川中汶川大震,祸及数百里,灾民不绝
于道,号呼动于天地,举国哀悼。庙堂之上者,引车卖浆之下者,富商巨贾,黎民百姓,
无不慷慨解囊,热血相助,中华竟因此隐隐而有复兴之象焉。
          
           石放言曰,灾为常态,所属仆从人捐十文可也,多捐则为负担矣
。言一出,闻者无不大哗,继而责之以义。石于其博客舌辩之,不逞,遂闭其言路,不纳
众人。四月十二日,御驾亲赴川中救灾,忽有闻,石已通工部侍郎及川道相关员,言谈间
已定灾后商计矣。
          
           商贾之道,固有无利不起,亦有道义存焉。时富豪如和黄李氏,
台塑王氏,江苏陈氏者,无不倾资以救国难,贩夫走卒、乞儿戏子,踊跃救难者,一一难
书。国难当头,石前发冷言于公众,后谋私利于暗室,不亦鄙乎?时有人讽石曰:公可跨
世界高山,可跨汶川一坟乎?道义不存而富,是为为富不仁也

Tzu Chi Foundation

慈濟基金會Tzu Chi Foundation),全稱為「財團法人台灣佛教慈濟慈善事業基金會」,是台灣重要的佛教團體之一。1966年農曆3月24日,證嚴法師創立「佛教克難慈濟功德會」於台灣花蓮1967年則逕稱為「慈濟功德會」。1980年1月16日台灣省政府核准「財團法人佛教慈濟慈善事業基金會」立案,「慈濟功德會」改稱為「慈濟基金會」。1991年,慈濟救助孟加拉颶風災民,從此加開海外救援工作。1994年中華民國內政部核准「財團法人中華民國佛教慈濟慈善事業基金會」立案,慈濟基金會成為一個全國性的財團法人。2008年2月27日中国国台办正式批准在大陆成立慈济慈善事业基金会,并成为首个由非大陆人担任法定代表人的民间基金会[1]。四十年來,慈濟在台灣及國際間致力於社會服務、醫療建設、教育建設、社會文化等志業。慈濟的慈善腳步踏遍全球,並獲得台灣社會相當的信任,被譽為「台灣的良心」,不過另一方面,台灣內部亦有不少對慈濟基金會的批評,惟這些批評常常無法訴諸於主流媒體。

the last words to her only baby

妈妈给宝贝的短信遗言 每个看到的人都落泪了zz

发信人: zqmzq (太阳黑子|bless汶川,祈祷), 信区: Quake512
标 题: 妈妈给宝贝的短信遗言 每个看到的人都落泪了
发信站: 北大未名站 (2008年05月17日19:41:12 星期六), 转信

抢救人员发现她的时候,她已经死了,是被垮塌下来的房子压死的,透过那一堆废墟
的间隙可以看到她死亡的姿势,双膝跪着,整个上身向前匍匐着,双手扶着地支撑着
身体,有些像古人行跪拜礼,只是身体被压的变形了,看上去有些诡异。救援人员从
废墟的空隙伸手进去确认了她已经死亡,又在冲着废墟喊了几声,用撬棍在砖头上敲
了几下,里面没有任何回应。

  当人群走到下一个建筑物的时候,救援队长忽然往回跑,边跑边喊"快过来"。他
又来到她的尸体前,费力的把手伸进女人的身子底下摸索,他摸了几下高声地喊"有
人,有个孩子,还活着"。经过一番努力,人们小心地把挡着她的废墟清理开,在她
的身体下面躺着她的孩子,包在一个红色带黄花的小被子里,大概有3、4个月大,因
为母亲身体庇护着,他毫发未伤,抱出来的时候,他还安静地睡着,他熟睡的脸让所
有在场的人感到很温暖。

  随行的医生过来解开被子准备做些检查,发现有一部手机塞在被子里,医生下意
识地看了下手机屏幕,发现屏幕上是一条已经写好的短信"亲爱的宝贝,如果你能活
着,一定要记住我爱你",看惯了生离死别的医生却在这一刻落泪了,手机传递着,
每个看到短信的人都落泪了。

Wednesday, May 21, 2008

halt while booting: recovering vi editor sessions /kv

halt while booting: recovering vi editor sessions /kv

the solution is:
root@bsd:~$ rm /var/tmp/vi.recover/*


Kai Vermehr <k at eboy.com> writes:

> While booting I get the message "recovering vi editor sessions" and
> the booting process is halted for a couple of minutes. I'm new to
> FreeBSD so I don't know where to look. Booting is resumed and some
> time later I get a message that sendmail is starting -- again taking a
> long time ...
>
> Any ideas how to fix this?

The saved sessions are (by default) in "/var/tmp/vi.recover".
If you don't need to recover the sessions, clean the directory out.

Tuesday, May 20, 2008

快速评教

请复制(Ctrl+Ins)下面的代码,然后进入评教页面,把代码粘贴(Shift+Ins)进地址栏,敲回车(Enter)。就可以完成快速评教。



javascript:s=document.forms["Form1"].elements;for (i=4;i<s.length;i++) s[i].selectedIndex=1;s[4].selectedIndex=2;alert("OK");s[17].click();

Sunday, May 18, 2008

freebsd7 ntfs-3g Unable to mount

when using ntfs-3g in fstab

/dev/ntfs/MUSIC /media/music ntfs-3g locale=en_US.UTF-8 0 0

get the err message:

Inappropriate file type or format

when using mount -t ntfs-3g

[root@bsd ~]# mount -t ntfs-3g -o locale=en_US.UTF-8 /dev/ntfs/MUSIC /media/music/

mount: /dev/ntfs/MUSIC : Operation not supported by device

it only works like this: ntfs-3g -o locale=en_US.UTF-8 /dev/ntfs/MUSIC /media/music/


the solution is found in the freebsd's list

Unable to mount partition with ntfs-3g
>>
>> # mv /sbin/mount_ntfs /sbin/mount_ntfs.bak
>> # ln -s /usr/sbin/mount_ntfs-3g /sbin/mount_ntfs
>>
>> This is one of my /etc/fstab entries
>> /dev/ntfs/2vault /mnt/vault ntfs rw,late,gid=5,umask=113,dmask=002 0 0
>>

Saturday, May 17, 2008

PHP5 mail() header patch

PHP mail() header patch: "PHP mail() header patch
Motivation

If you have a PHP script that sends mail, the recipient of the mail message will only see which server it was sent from. There will normally be no record of who originated the message, or which script on the server actually caused it to be sent. This can make it difficult to trace misuse, even if you have comprehensive mail and webserver logs."

The Solution

This patch attempts to address this weakness by inserting an informational header to messages sent from PHP via the mail() function. The header identifies both the script and the apparent IP address that called it.

The header added has the form:

X-PHP-Script: for

PostgreSQL vs MySQL: Which is better?

PostgreSQL vs MySQL: Which is better?:

an interesting passage about the choice between PostgreSQL and MySQL.
MySQL is quicker and smaller while PostgreSQL is with more futures.
and, the final answer is BOTH!
haha~ Let's have a try!

speed up making the world

Rebuilding world

  • Run in single user mode.

  • Put the /usr/src and /usr/obj directories on separate file systems held on separate disks. If possible, put these disks on separate disk controllers.

  • Better still, put these file systems across multiple disks using the ccd(4) (concatenated disk driver) device.

  • Turn off profiling (set “NO_PROFILE=true” in /etc/make.conf). You almost certainly do not need it.

  • Also in /etc/make.conf, set CFLAGS to something like -O -pipe. The optimization -O2 is much slower, and the optimization difference between -O and -O2 is normally negligible. -pipe lets the compiler use pipes rather than temporary files for communication, which saves disk access (at the expense of memory).

  • Pass the -jn option to make(1) to run multiple processes in parallel. This usually helps regardless of whether you have a single or a multi processor machine.

  • The file system holding /usr/src can be mounted (or remounted) with the noatime option. This prevents the file system from recording the file access time. You probably do not need this information anyway.

    # mount -u -o noatime /usr/src

    Warning: The example assumes /usr/src is on its own file system. If it is not (if it is a part of /usr for example) then you will need to use that file system mount point, and not /usr/src.

  • The file system holding /usr/obj can be mounted (or remounted) with the async option. This causes disk writes to happen asynchronously. In other words, the write completes immediately, and the data is written to the disk a few seconds later. This allows writes to be clustered together, and can be a dramatic performance boost.

    Warning: Keep in mind that this option makes your file system more fragile. With this option there is an increased chance that, should power fail, the file system will be in an unrecoverable state when the machine restarts.

    If /usr/obj is the only thing on this file system then it is not a problem. If you have other, valuable data on the same file system then ensure your backups are fresh before you enable this option.

    # mount -u -o async /usr/obj

    Warning: As above, if /usr/obj is not on its own file system, replace it in the example with the name of the appropriate mount point.

Friday, May 16, 2008

in_proto.o(.data+0xa8): undefined reference to `sctp_input'

disable INET6 cause a *** Error code 1 while building freebsd kernel.

in_proto.o(.data+0xa8): undefined reference to `sctp_input'

the solution is to disable SCTP as well.

#options SCTP # Stream Control Transmission Protocol

From: William Grzybowski

Date: 2007-08-28 23:25:59


On 8/28/07, Yuri Pankov  wrote:
>
> On Tue, Aug 28, 2007 at 05:15:56PM -0300, William Grzybowski wrote:
> > Hi,
> >
> > I am getting some errors about sctp while i build kernel from today...
> > Could it be happening because i created a src.conf file disablind bind,
> > ipv6, ipfilter, kerberos and sendmail ? (i dont think so, but it was the
> > only thing which i modified...)
> >
> > uipc_syscalls.o(.text+0x341): In function `sctp_generic_recvmsg':
> > /usr/src/sys/kern/uipc_syscalls.c:2600: undefined reference to
> > `sctp_sorecvmsg'
> > uipc_syscalls.o(.text+0x86c): In function `sctp_peeloff':
> > /usr/src/sys/kern/uipc_syscalls.c:2238: undefined reference to
> > `sctp_can_peel_of
> > f'
> > uipc_syscalls.o(.text+0xa7a):/usr/src/sys/kern/uipc_syscalls.c:2279:
> > undefined r
> > eference to `sctp_do_peeloff'
> > uipc_syscalls.o(.text+0xdf0): In function `sctp_generic_sendmsg_iov':
> > /usr/src/sys/kern/uipc_syscalls.c:2478: undefined reference to
> > `sctp_lower_sosen
> > d'
> > uipc_syscalls.o(.text+0x109a): In function `sctp_generic_sendmsg':
> > /usr/src/sys/kern/uipc_syscalls.c:2371: undefined reference to
> > `sctp_lower_sosen
> > d'
> > rtsock.o(.text+0x123b): In function `rt_newaddrmsg':
> > /usr/src/sys/net/rtsock.c:896: undefined reference to `sctp_addr_change'
> > in_proto.o(.data+0xa8): undefined reference to `sctp_input'
> > in_proto.o(.data+0xb0): undefined reference to `sctp_ctlinput'
> > in_proto.o(.data+0xb4): undefined reference to `sctp_ctloutput'
> > in_proto.o(.data+0xbc): undefined reference to `sctp_init'
> > in_proto.o(.data+0xc8): undefined reference to `sctp_drain'
> > in_proto.o(.data+0xcc): undefined reference to `sctp_usrreqs'
> > in_proto.o(.data+0xdc): undefined reference to `sctp_input'
> > in_proto.o(.data+0xe4): undefined reference to `sctp_ctlinput'
> > in_proto.o(.data+0xe8): undefined reference to `sctp_ctloutput'
> > in_proto.o(.data+0xfc): undefined reference to `sctp_drain'
> > in_proto.o(.data+0x100): undefined reference to `sctp_usrreqs'
> > in_proto.o(.data+0x110): undefined reference to `sctp_input'
> > in_proto.o(.data+0x118): undefined reference to `sctp_ctlinput'
> > in_proto.o(.data+0x11c): undefined reference to `sctp_ctloutput'
> > in_proto.o(.data+0x130): undefined reference to `sctp_drain'
> > in_proto.o(.data+0x134): undefined reference to `sctp_usrreqs'
> > *** Error code 1
> >
> >
> > Bye.
> >
> >
> > --
> > William Grzybowski
> > ------------------------------------------
> > Jabber: william88 at gmail dot com
> > Msn: william.grz at hotmail dot com
> > Curitiba/PR - Brazil
>
> As you haven't provided your kernel config, please check if this thread
> looks
> related:
> http://lists.freebsd.org/pipermail/free … 14515.html


Sorry, i forgot to send my conf...
The build error was my mistake, i forgot that sctp needs INET6, even if you
dont will use V6...

My apologize :)

Thanks.

--
William Grzybowski
------------------------------------------
Jabber: william88 at gmail dot com
Curitiba/PR - Brazil
_______________________________________________
freebsd- mailing list
http://lists.freebsd.org/mailman/listin … sd-current
To unsubscribe, send any mail to "freebsd-current-"

谈生命


也许有一天,他再从海上蓬蓬的雨点中升起,
飞向西来,再形成一道江流,再冲倒两旁的石壁,
再来寻夹岸的桃花。然而,我不敢说来生,也不敢信来生......


---------------------
我不敢说生命是什么,我只能说生命像什么。

生命像向东流的一江春水,他从最高处了源,冰雪是他的前身。他聚集起许多细流,合成一股有力的洪涛,向下奔注,他曲折的穿过了悬崖峭壁,冲倒了层沙积土,挟卷着滚滚的沙石,快乐勇敢的流走,一路上他享受着他所曹遇的一切;有时候他遇到巉岩前阻,他愤激的奔腾了起来,怒吼着,回旋着,前波后浪的起伏催逼,直到他过了,冲倒了这危崖他才心平气和的一泻千里。的时候他经过了细细的平沙,斜阳芳草里,看见了夹岸红艳的桃花,他快乐而又羞怯,静静的流着,低低的吟唱着,轻轻的度过这一段浪漫的行和程。有时候他遇到暴风雨,这激电,这迅雷,使他心魂惊骇,疾风吹卷起他,大雨击打着他,他暂时浑浊了,扰乱了,而雨过天睛,只加给他许多新生的力量。有时候他遇到了晚霞和新月,向他照耀,向他投影,清冷中带些幽幽的温暖:这时他只想憩息,只想睡眠,而那股前进的力量,仍催逼着他向前走……终于有一天,他远远的望见了大海,呵!他已到了行程的终结,这大海,使他屏息,使他低头,她多么辽阔,多么伟大!多么光明,又多么黑暗!大海庄严的伸出臂儿来接引他,他一直不响的流入她的怀里。他消融了,归化了,说不上快乐,也没有悲哀!也许有一天,他再从海上蓬蓬的雨点中升起,飞向西来,再形成一道波斯湾,再冲倒两旁的石壁,再来寻夹岸的桃花。然而我不敢说来生,也不敢信来生!

生命又像一棵小树,他从地底聚集起许多策略,在冰雪下欠伸,在早春润湿的泥土中,勇敢快乐的破壳出来。他也许长在平原上,岩石上,城墙上,只要他抬头看见了天,呵!看见了天!他便伸出嫩叶来吸收空气,承受日光,在雨中吟唱,在风中跳舞,他也许受着大树的荫遮,也许受着大树的覆压,而他青春生长的力量,终使他穿枝拂叶的挣脱了出来,在烈日下挺立抬头!他遇着骄奢的春天,他也许开出满树的繁花,蜂蝶围绕着他飘翔喧闹,小鸟在他枝头欣赏唱歌,他会听黄莺清吟,杜鹃啼血,也许还听见枭鸟的怪鸣。他长到最茂盛的中年,他伸展出他如盖的浓荫,来荫庇树下的幽花芳草,他结出累累的果实,来呈现大地无尽的甜美与芳馨。秋风起了,将他叶子,由浓绿吹到绯红,秋阳下他再有一番的庄严灿烂,不是开花的的骄傲,也不是结果的快乐,而是成功后的宁静和怡悦!终于有一天,冬天的朔风,把他的黄叶干枝,卷落吹抖,他无力的在空中旋舞,在要下呻吟,大地庄严的伸出臂儿来接引他,他一声不响的落在她的怀里。他消融了,归化了,他说不上快乐,也没有悲哀!也许有一天,他再从地下的果仁中,破裂了出来。又长成一棵小树,再穿过丛莽的严遮,再来听黄莺的歌唱,然我不敢说来生,也不敢信来生。

宇宙的大生命中,我们是多么卑微,多么渺小,而一滴一叶的活动生长合成了整个宇宙的进化运行。要记住:不是每一道江流都能入海,不流动的便成了死湖;不是每一料种子都能成树,不生长的便成了空壳!生命中不是永远快乐,也不是永远痛苦,快乐和痛苦是相生相成的。等于水道要经过不同的两岸,树木要经过常变的四时。在快乐中我们要感谢生命,在痛苦中我们也要感谢生命。快乐固然兴奋,苦痛又何尝不美丽?我曾读到一个警句,是“愿你生命中有够多的云翳,来造成一个美丽的黄昏”。世界、国家和个人的生命中的云翳没有比今天再多的了。

作者:冰心

i love you but i dare not to say

我爱你/可是我不敢说/我怕说了/我马上就会死去/
我不怕死/我怕我死了/再没有人像我一样爱你

-------

我爱你!可是我不敢说

  我爱你,可是我不敢说出口



  因为你在我心里是那样的纯洁而完美



  我爱你,可是我不敢说出口



  我怕说了,



  你会马上在我的世界里消失



  因为你我相距千里



  我没有握住你双手的机会



  我爱你,可是我不敢说出口



  因为我除了真心的爱和我的全部幸福给你



  我,什么也不能保证



  我爱你,可是我不敢说出口



  我怕说了,



  我会死去



  死



  我并不害怕



  但



  我怕我死了



  在这个世界上再也没有人像我一样爱你



  也许我就该这样静静的等待



  等待一个奇迹的出现



  等待死神的来临



  但



  我不敢这样的等待



  我怕在等待的分分秒秒中你正受着煎熬



  正在煎熬着人世间的冷暖、忧愁



  我爱你,可是我不敢说出口



  我只能这样静静的想你,



  默默的爱着……

Linux tip: Bash test and comparison functions

test and [

The test builtin command returns 0 (True) or 1 (False), depending on the evaluation of an expression, expr. You can also use square brackets: test expr and [ expr ] are equivalent. You can examine the return value by displaying $?; you can use the return value with && and ||; or you can test it using the various conditional constructs that are covered later in this tip.


Listing 1. Some simple tests
              
[ian@pinguino ~]$ test 3 -gt 4 && echo True || echo false
false
[ian@pinguino ~]$ [ "abc" != "def" ];echo $?
0
[ian@pinguino ~]$ test -d "$HOME" ;echo $?
0

In the first example in Listing 1, the -gt operator performs an arithmetic comparison between two literal values. In the second example, the alternate [ ] form compares two strings for inequality. In the final example, the value of the HOME variable is tested to see if it is a directory using the -d unary operator.

You can compare arithmetic values using one of -eq, -ne, -lt, -le, -gt, or -ge, meaning equal, not equal, less than, less than or equal, greater than, and greater than or equal, respectively.

You can compare strings for equality, inequality, or whether the first string sorts before or after the second one using the operators =, !=, <, and >, respectively. The unary operator -z tests for a null string, while -n or no operator at all returns True if a string is not empty.

Note: the < and > operators are also used by the shell for redirection, so you must escape them using \< or \>. Listing 2 shows more examples of string tests. Check that they are as you expect.


Listing 2. Some string tests
              
[ian@pinguino ~]$ test "abc" = "def" ;echo $?
1
[ian@pinguino ~]$ [ "abc" != "def" ];echo $?
0
[ian@pinguino ~]$ [ "abc" \< "def" ];echo $? 0 [ian@pinguino ~]$ [ "abc" \> "def" ];echo $?
1
[ian@pinguino ~]$ [ "abc" \<"abc" ];echo $? 1 [ian@pinguino ~]$ [ "abc" \> "abc" ];echo $?
1

Some of the more common file tests are shown in Table 1. The result is True if the file tested is a file that exists and that has the specified characteristic.

Table 1. Some common file tests
OperatorCharacteristic
-dDirectory
-eExists (also -a)
-fRegular file
-hSymbolic link (also -L)
-pNamed pipe
-rReadable by you
-sNot empty
-SSocket
-wWritable by you
-NHas been modified since last being read

In addition to the unary tests above, you can compare two files with the binary operators shown in Table 2.

Table 2. Testing pairs of files
OperatorTrue if
-ntTest if file1 is newer than file 2. The modification date is used for this and the next comparison.
-otTest if file1 is older than file 2.
-efTest if file1 is a hard link to file2.

rc.conf config more than one IP address on one interface

the best way to configure more than one IP to one interface in freebsd is to edit /etc/rc.conf


ipv4_addrs_vr0="192.168.0.1/24 192.168.1.1-5/28" #I prefer this way


It is also possible to add IP alias entries using ifconfig(8) syntax. Assuming that the interface in question was ed0, it might look something like this:

ifconfig_ed0_alias0="inet 127.0.0.253 netmask 0xffffffff"
ifconfig_ed0_alias1="inet 127.0.0.254 netmask 0xffffffff"

sendmail caused freebsd hang at boot time

fressbsd hang at the boot time when it came to the sendmail period.

the solution is to add one line into /etc/hosts like this:

192.168.28.26 bsd.local bsd


My unqualified host name (localhost) unknown; sleeping for retry


Make sure the host's names (including localhost) are defined in
/etc/hosts, and that /etc/hosts is being used in name resolution
(on 5.3 that would be configuration via nsswitch.conf(5)).



1996: SUMMARY: gethostbyaddr() failed

I solved the problem by adding back my ppp ip address into my hosts file.

There is no lookup for your IP address into a hostname. If you have
multiple interfaces or multiple addresses on one interface then you
must have a lookup for all the IP addresses.

The message there isn't an error - it's a warning. Just an annoying one :-)

rgds
Stephen

>From casper@holland.Sun.COM Fri Apr 5 04:53 EST 1996
To: ying@share.sph.jhu.edu (ying He )
Content-Type: text
Content-Length: 543

>Dear Sun managers;
>My system keep getting following messages in file /var/adm/messages
>when sendmail, what caused these and Any way I can stop these?
>(alive is our hostname)
>--------------------------------------------------------------
>Apr 4 17:55:15 alive sendmail[28489]: gethostbyaddr() failed
>Apr 4 23:42:26 alive sendmail[28869]: gethostbyaddr() failed
>Apr 4 23:42:55 alive sendmail[28880]: gethostbyaddr() failed

Your system can't find all names for all interfaces.

Check for funny addresses with "ifconfig -a"

Casper

Ying

Wednesday, May 14, 2008

use tail to watch a log dynamically

Want to know how to watch a log file? still using cat,more, vi, or even worth, gedit to watch a log file? then this is the right one for you! tail

use -n to designate lines of log you want to see.

tail -F -n 5 /var/log/daemon.log


more details see man tail

Tuesday, May 13, 2008

黑暗的灵魂 签名档

一个人有著邪恶冷酷的心,却又能真正地爱著某些事物,是有可能的,而且这才叫黑暗
的灵魂,那种只会作恶的,不过是蒙昧的灵魂;那些不敢承认的,只叫做怯懦的灵魂;
真正散发著黑暗的甜美芳香的灵魂,是深深知道何谓善,何谓恶,而后坚定不悔地选择
恶的那些人,他们知道自己在做什么,对前途有著坚定的决心。