Le's profileSomething like a home pa...PhotosBlogListsMore Tools Help

Blog


    March 30

    mysql auto_increment计数器设定

    如果一个表的id列使用了mysql的auto_increment功能,假如你添加了2条记录,删了第二条,再加入第三条,id 2不会被复用。
    也就是说第三条的id是3,而不是2。你的表里面就永远缺少了id为2的记录。
    假如你不希望2被空置,你可以把某个现有记录的id改成2,同时修改该记录里所有id相关的值,比如mediawiki的user表里的密码。
    然后用这个命令来设置下一条记录你希望赋予的id
    ALTER TABLE user AUTO_INCREMENT = 10;

    mediawiki手工添加用户/重设密码

    主要只在一点,那就是密码如何得来
    在默认情况下,也就是没有salt的情况下,密码是两次md5 hash的结果
    首先取密码的md5值,然后前面冠以用户id和一个hyphen,再取一次md5值
    比如要添加一个用户名叫foobar,密码为passwd
    先select max(user_id) from user;
    假设得到最大值为10,那么下一个用户id就是11,所以执行:
    insert into user(user_name, user_password) values ('foobar',md5(CONCAT('11-',md5('passwd'))));

    March 27

    WTF....

    I ran this yesterday(and I forgot to check the result, till today... wtf...):
    zhangle@wheatbuild-lx ~/home $ whois gentoo.cn
    Domain Name: gentoo.cn
    ROID: 20070204s10001s16465200-cn
    Domain Status: pendingDelete
    Domain Status: inactive
    Registrant Organization: 南京一招信息科技有限公司
    Registrant Name: 要得商务网保护注册
    Administrative Email: yizhao_cq@163.com
    Sponsoring Registrar: 北京新网互联科技有限公司
    Registration Date: 2007-02-04 01:21
    Expiration Date: 2008-02-04 01:21

    I ran this today
    zhangle@wheatbuild-lx ~/home $ whois gentoo.cn
    Domain Name: gentoo.cn
    ROID: 20080327s10001s82852638-cn
    Domain Status: ok
    Registrant Organization: 海南得一网络科技开发有限公司
    Registrant Name: 海南得一网络科技开发有限公司
    Administrative Email: qinger1314@263.net
    Sponsoring Registrar: 厦门市中资源网络服务有限公司
    Name Server:ns1.cnolnic.net
    Name Server:ns2.cnolnic.net
    Registration Date: 2008-03-27 04:07
    Expiration Date: 2009-03-27 04:07

    wiki.gentoo-cn.org

    http://wiki.gentoo-cn.org/
    刚刚弄好的,基本什么都没有
    还没有开放注册
    以后准备拿这个做gentoo-cn的首页,而不仅仅是wiki而已
    wiki还放在zh.gentoo-wiki.org
    这个首页就当作个portal站点,发布点新闻了啥的

    How to ssh-add in cron job

    ssh-add can let your ssh-agent remember the passphrase of your ssh
    secret key, so that you don't need to type any password when loging
    into a remote machine.
    However, it is an interactive program, you can't call it in a cron
    job. Even if you can, you will expose your passphrase in a file, which
    is not safe.

    The solution is actually very easy. You don't really need to ssh-add.
    All you need to do is letting ssh know some environment variable.

    First of all, I recommend you set up ssh-agent forwarding with GNU
    screen following instruction here:
    http://www.deadman.org/sshscreen.html
    Then in your cron job script, source ${HOME}/bin/fixssh first.
    Done!

    Enjoy ;)
    March 23

    2008.0 Simplified Chinese handbook all finished

    http://www.gentoo-cn.org/trads/
    http://www.gentoo-cn.org/doc/zh_cn/handbook/draft/
    http://www.gentoo-cn.org/doc/zh_cn/handbook/2008.0/
    http://www.gentoo-cn.org/gitweb/?p=gentoo-cn;a=shortlog

    Not too much work to do actually.
    First I copied current handbook and 2007.0 networkless handbook.
    Then wrote a little script to update version number and date and
    change all occurrences of 2007.0 to 2008.0 automatically.
    Then made a diff between old and new English handbook.
    Then modify old handbook according to the diff of English version.
    Done ;)
    March 19

    mips prelink

    看到有人在linux-mips上问mips的prelink问题
    有人给了一个邮件的连接
    http://sourceware.org/ml/prelink/2007-q4/msg00001.html
    那个提问者试验之后发觉管用
    先记下来,以后有时间再看

    Gentoo Prefix

    although this is from gentoo-core, but i think its publicity could be justified.

    In short, Gentoo Prefix is Gentoo Everywhere!
    http://www.gentoo.org/proj/en/gentoo-alt/prefix/index.xml

    From Fabian Groffen:
    Just for those who don't know, or haven't realised, Gentoo for Mac OS X
    (use another term like above and you get letters from Apple's lawyers)
    is for more than 2 years dead, and just only recently completely
    burried.  This is not really a "loss", on the contrary, it's a big win,
    since there is something new under the horizon (for about 2 years as
    well), called "Prefix".
                                                                                                                                  
    While OS X was the first platform on which "Prefix" was deployed,
    "Prefix" is all but tied to OS X.  In short, "Prefix" is just a way to
    get a "Gentoo installation", without kernel and libc, to run in
    userspace on another OS.  This in general includes the toolchain and all
    the utilities (such as GNU sed) in exactly the same way as Gentoo Linux
    has them, where possible.
                                                                                                                                  
    Currently, "Prefix" runs on AIX (haubi gave a talk about problems
    specific to that platform at Chemnitzer LinuxTage), Solaris, Fedora
    Linux, Debian Linux, (Vanilla) FreeBSD and of course Mac OS X (Darwin).
    Other platforms such as Interix, HPUX, True64, OpenBSD and NetBSD are in
    the works.


    Conclusion, "Prefix" is all but Mac OS X, and a "product" in itself!


    March 18

    up_trads_xml.pl的改动

    3月12日的TODO list里第一条完成
    1. 根据git log的输出,自动更新文档的最后更新者姓名

    另外我更新了handbook里剩下的还未更新的所有文档

    --
    Zhang Le, Robert
    http://r0bertz.blogspot.com
    http://zh.gentoo-wiki.com
    http://savannah.nongnu.org/projects/pgubook
    http://groups.google.com/group/gentoo-china
    http://groups.google.com/group/szlug

    香港是一个什么样的社会

    香港是一个有钱人的社会
    穷人几条人命不如富人几张照片

    March 17

    加了一条iptables规则

    iptables -t nat -I PREROUTING -p tcp -s ! 192.168.1.0/24 --dport 22 -j DNAT --to-destination 192.168.1.106
    现在如果从外面ssh进来,就会登录这台新机器
    如果从内网登录,还是会登录到盒子里
    DMZ仍然是设成盒子的,:)
    March 16

    终于把最近买的这台机器启动起来了

    昨天搞了一天
    原因是BIOS int 13h中断的某些请求在adaptec 29160 scsi卡解释int 13h中断的时候不能返回正确结果。
    (注:scsi硬盘不能相应int 13h中断,scsi卡要把中断请求解释成scsi命令才可以)
    这是唯一可以肯定的。grub发出中断,得不到正确结果。这是可以确认的事实。
    具体是主板的问题还是scsi卡的问题就不知道了。

    一开始,想直接从scsi硬盘启动,结果grub显示Grub Hard Disk Error。
    查文档的解释,几乎没有什么用处。
    看grub源代码,汇编,stage1.S,发现和13h中断有关。
    于是想,既然scsi直接启动不行,那就把grub装在sata硬盘上。

    于是4个sata各分出10M,做了个raid1,把boot放在上面
    结果,可以加载grub stage1_5了
    不过,只得到一个grub minimal shell,没有显示菜单
    cat (补齐,只有一个(fd0),打上(hd0,再补齐就说Selected disk not exist
    接着看源代码,发现stage1_5获得控制权后一开始就会尝试打开grub.conf,这时候还会发出13h中断以获得grub.conf所在硬盘的geometry。
    而这个时候如果scsi卡解释int 13h中断的话,这个请求还会失败。失败后,就会得到一个minimal shell

    我把scsi卡和网卡拔了插,插了拔,主板里相关设定反复设定,还升级了主板BIOS。因为我怀疑是不是我设置(软件/硬件)不当导致的。
    最后想到一点:既然int 13h对scsi硬盘不行的话,那干脆就在scsi卡里关掉对13h的解释。反正现在不从scsi硬盘启动。
    Linux启动后就不再靠bios中断访问scsi硬盘,:)

    于是问题终于解决了
    方法包括2点:
    1. boot分区不放在scsi硬盘上
    2. 禁用scsi卡对int 13h的解释

    --
    Zhang Le, Robert
    http://r0bertz.blogspot.com
    http://zh.gentoo-wiki.com
    http://savannah.nongnu.org/projects/pgubook
    http://groups.google.com/group/gentoo-china
    http://groups.google.com/group/szlug
    March 14

    最近在看What every programmer should know about memory

    前段时间刚看完How to write shared libraries.
    最近开始看这个

    刚看到一个对于多核cpu的测试
    大概意思说的是,一个4核cpu,在上面运行一个4个线程的程序,四个线程访问同一块数据(称为working
    set),如果这个cpu只有一个内存控制器,这个内存控制器只有一个总线和内存相连接,当working set
    size达到2的20几次方,接近30次方个字节的时候,4个核4个线程的效果只与2核2线程相当,并且低于1核1线程的2倍。

    所以drepper说,现实中很难找到只有一个内存控制器的四核cpu。

    --
    Zhang Le, Robert
    http://r0bertz.blogspot.com
    http://zh.gentoo-wiki.com
    http://savannah.nongnu.org/projects/pgubook
    http://groups.google.com/group/gentoo-china
    http://groups.google.com/group/szlug

    搞到一个SCSI硬盘

    还有一个Adaptec SCSI卡,买了一个Internal 68pin SCSI cable
    第一次玩
    使用上没有感觉到什么大的不同
    这里有一些速度的比较
    http://en.wikipedia.org/wiki/List_of_device_bandwidths
    http://en.wikipedia.org/wiki/Serial_ATA
    不过至少对我来说什么速度稳定性都是次要的
    最主要的是有个硬盘可以用
    再一个是可以顺便玩玩新东西
    March 13

    纯汉语拼音组成的诗

    啊我饿,咦无鱼,哎诶胃.熬藕莜,液约饵,按恩饮.问匀昂?哼应嗡.
    这首还行
    播泼没佛, 得忑呢了; 割颗何急? 期系织吃. 时日自此, 思衣物?
    这首有点牵强

    另外今天下午我自己独立想出了第一首的前6个
    其他的是从这里看到的
    http://www.9ye.com/info.php?modules=info_show&i_id=c9e4174a5c88f5f864da8223a0172219

    我搜索了一下,只搜到几个结果
    应该可以说明我的“啊我饿,咦无鱼”的originality
    就像牛顿和莱布尼兹各自独立创立了微积分
    英雄所见略同

    PS:最近在教人学普通话

    位卑未敢忘忧国

    (02:41:17 PM) !Robert![ 啊! ]: http://www.lemote.com/bbs/viewthread.php?tid=13144&extra=page%3D1
    (02:41:25 PM) !Robert![ 啊! ]: 看3楼和17楼
    (02:41:31 PM) !Robert![ 啊! ]: 看的我热泪盈眶
    (02:44:38 PM) !Robert![ 啊! ]: 哎,感慨万千

    随手记一下,省得忘了


    PS:
    其实中国现在的很多问题,追到底,就会追到体制上
    很多人都知道
    可是没办法