2008年03月 存档

不同的字符,一样的MD5

2008年03月24日,星期一
d131dd02c5e6eec4693d9a0698aff95c2fcab50712467eab4004583eb8fb7f8955ad340609f4b30283e4888325f1415a085125e8f7cdc99fd91dbd7280373c5bd8823e3156348f5bae6dacd436c919c6dd53e23487da03fd02396306d248cda0e99f33420f577ee8ce54b67080280d1ec69821bcb6a8839396f965ab6ff72a70

d131dd02c5e6eec4693d9a0698aff95c2fcab58712467eab4004583eb8fb7f8955ad340609f4b30283e488832571415a085125e8f7cdc99fd91dbdf280373c5bd8823e3156348f5bae6dacd436c919c6dd53e2b487da03fd02396306d248cda0e99f33420f577ee8ce54b67080a80d1ec69821bcb6a8839396f9652b6ff72a70

两个字符的MD5都是 edde4181249fea68547c2fd0edd2e22f

来源:http://www.mathstat.dal.ca/~selinger/md5collision/

[javascript]除了alert之外的对话框

2008年03月23日,星期日

一直很奇怪关闭一个Google Groups页面那个对话框是如何弹出来的,现在发现原来是onbeforeunload的返回值,我们不用alert也可以弹对话框啦

<script>
window.onbeforeunload = function(event){
        event = event || window.event;
        event.returnValue = 
"您的文章内容还没有进行保存!";
}
</script>
<body>
aaa
</body>

借用django.utils.autoreload实现python程序模块热插拔

2008年03月23日,星期日

现代Web服务器应用一个重要的指标是“Uptime”,也就是在线时间。例如一个大型论坛,升级一个功能,如果需要更新配置而重启Web服务器,可能服务就暂停几秒种,几秒种的损失对于Web来说是相当大的,所以我们需要实现模块热插拔。升级一个模块之后,系统自动把内存里的代码更新为最新文件系统上的版本。再举一个例子,假如一个关键业务是一个IM聊天机器人,那么升级一个机器人的功能就不可能让机器人下线再上线。软件系统模块“热插拔”就像硬件的plug 'n' play 一样,方便了开发流程,把文件上传到服务器FTP,网站就自动更新。

实现思路很简单,犯不着去调用文件系统的消息和事件,我们用最原始最简单的办法:用一个单独的线程,隔一段时间遍历当前目录下的 .py 和 .pyc 文件,搜集文件时间属性,如果文件时间属性变化了,则 reload(module)

其实django内置的开发服务器已经实现了这个功能,你保存一个工程的代码,服务器在不重启的情况下自动刷新,那么秉着“不要重复造轮子”的理念,我们直接用django现有的模块。网上了一下,发现是这个模块在起作用: django.utils.autoreload 。其实retoreload.py也是源自于CherryPy Project的一段代码。

调用就很简单了

#!/usr/bin/env python
#coding:utf-8

from django.utils import autoreload

def main():
    
print 1

#必须从命令行启动
if "__main__" == __name__:
    
import autoreload
    autoreload.main(main)

保存为 test.py ,命令行运行 python test.py ,显示 1,说明代码没有问题。好,打开 test.py 修改main()函数为 print 2,保存,发现命令行自动刷新了,显示2。

如果上面的代码在工程中应用,可以在main()里写不能down的监护进程,然后所有功能通过 from module import class 来实现,要更新一个功能,只需要更新 module 文件,整个服务在不中断的情况下就会自动升级,我们就成功实现了模块热插拔。

脚本语言的确更加适合Web,如果是C语言开发的系统,每更新一个功能模块都需要编译一次,开发效率真是底下(当然用 .so/ .dll / COM 等技术就比较高级一点了)

《这里不是斯巴达》囧图

2008年03月23日,星期日

Meet The Spartans这部片子非常的恶半夜凉初透搞了GTA:SA、youtube和American Idol

4.JPG3.JPG2.JPG1.JPG

太浮躁了,看一篇好文章静静~

2008年03月22日,星期六

有一篇很老的文章,讲:花10年的时间学会编程

Here's my recipe for programming success:

  • Get interested in programming, and do some because it is fun. Make sure
    that it keeps being enough fun so that you will be willing to put in ten
    years.
  • Talk to other programmers; read other programs. This is more important
    than any book or training course.
  • Program. The best kind of learning is

    learning by doing
    . To put it more technically, "the maximal level of
    performance for individuals in a given domain is not attained automatically
    as a function of extended experience, but the level of performance can be
    increased even by highly experienced individuals as a result of deliberate
    efforts to improve."
    (p. 366)
    and "the most effective learning requires a well-defined task with an
    appropriate difficulty level for the particular individual, informative
    feedback, and opportunities for repetition and corrections of errors." (p.
    20-21) The book
    Cognition in
    Practice: Mind, Mathematics, and Culture in Everyday Life
    is an
    interesting reference for this viewpoint.
  • If you want, put in four years at a college (or more at a graduate
    school). This will give you access to some jobs that require credentials,
    and it will give you a deeper understanding of the field, but if you don't
    enjoy school, you can (with some dedication) get similar experience on the
    job. In any case, book learning alone won't be enough. "Computer science
    education cannot make anybody an expert programmer any more than studying
    brushes and pigment can make somebody an expert painter" says Eric Raymond,
    author of The New Hacker's Dictionary. One of the best programmers I
    ever hired had only a High School degree; he's produced a lot of
    great
    software
    , has his own

    news group
    , and made enough in stock options to buy his own
    nightclub.
  • Work on projects with other programmers. Be the best programmer on some
    projects; be the worst on some others. When you're the best, you get to test
    your abilities to lead a project, and to inspire others with your vision.
    When you're the worst, you learn what the masters do, and you learn what
    they don't like to do (because they make you do it for them).
  • Work on projects after other programmers. Be involved in
    understanding a program written by someone else. See what it takes to
    understand and fix it when the original programmers are not around. Think
    about how to design your programs to make it easier for those who will
    maintain it after you.
  • Learn at least a half dozen programming languages. Include one language
    that supports class abstractions (like Java or C++), one that supports
    functional abstraction (like Lisp or ML), one that supports syntactic
    abstraction (like Lisp), one that supports declarative specifications (like
    Prolog or C++ templates), one that supports coroutines (like Icon or
    Scheme), and one that supports parallelism (like Sisal).
  • Remember that there is a "computer" in "computer science". Know how long
    it takes your computer to execute an instruction, fetch a word from memory
    (with and without a cache miss), read consecutive words from disk, and seek
    to a new location on disk. (Answers here.)
  • Get involved in a language standardization effort. It could be the ANSI
    C++ committee, or it could be deciding if your local coding style will have
    2 or 4 space indentation levels. Either way, you learn about what other
    people like in a language, how deeply they feel so, and perhaps even a
    little about why they feel so.
  • Have the good sense to get off the language standardization effort as
    quickly as possible.

大师级人物讲话就是不一样~~咳咳~~~

Debian下建立PPTP VPN

2008年03月21日,星期五

PPTP VPN和OpenVPN的不同之处在于PPTP VPN支持Windows自带的VPN拨号器连接。

apt-get install pptpd
vim /etc/pptpd.conf
修改
localip 10.5.1.3
remoteip 10.5.1.241-246
其中localip要保证和ifconfig里的结果一样
remoteip是一个网段,要保证被2整除。

vim /etc/ppp/options
添加两个DNS
ms-dns 202.112.14.151
ms-dns 202.112.14.161

vim /etc/ppp/chap-secrets
添加几个VPN帐户,例如这里的alice和bob
alice pptpd a-strong-password *
bob pptpd another-strong-password *

允许forward VPN连接
vim /etc/sysctrl.conf
删除 #net.ipv4.conf.default.forwarding=1 这一行前面的 #
再 vim /etc/init.d/pptpd
在start后面加上
echo 1 > /proc/sys/net/ipv4/ip_forward 
也就是:
case "$1" in
  start)
    echo -n "Starting PPTP Daemon: "
    echo 1 > /proc/sys/net/ipv4/ip_forward
    start-stop-daemon --start --quiet --pidfile $PIDFILE --exec $DAEMON \
        -- < /dev/null > /dev/null
    echo "pptpd."
    ;;

最后 /etc/init.d/pptpd restart 好了,赶快试试你的VPN是否正常工作

来源:http://pigtail.net/nicholas/pptp/

命令行实现Skype Portable绿色免安装便携2008.3.22TW海峡纪念钻石会员版

2008年03月21日,星期五

网上无意中发现了skype.exe的命令行参数,所以可以轻易实现skype免安装便携版

This is a list of the command line parameters for Skype that I know of:

/nosplash Starts Skype without the splash screen.
/minimized Starts Skype minimized to the system tray.
/datapath:"path" Use alternate path for saving settings etc.
/removable (Use with /datapath) Don't persist specified path since it may not be available next time.
/callto:Skype name or phone no. Calls the specified user or phone number.
/shutdown Shuts down Skype.

Note that parameters can be combined, e.g.: Skype.exe /minimized /nosplash

All of the parameters above have been tested with Skype Version 2.5.0.151.

Do you have anything to add to this list? Please let me know by e-mail: supermagle@ter.dk

D:\Chat\Skype\Skype.exe /datapath:".\" /minimized

把配置文件保存到当前目录~~~跟无聊的NSIS脚本说bye-bye吧~~

Update: 看到hung也是这么做的

[XMPP]Openfire不能和Google Talk互通故障解决

2008年03月21日,星期五

今年2月份的时候,地球上很多XMPP服务器不能和Google Talk互通了,原因是Google App加入了即时聊天功能。我就碰到这个情况了,今天到处求助,后来Jabber.org的一位成员指点了一下,找到了Google的官方解释

例如,dormforce.net申请了Google Apps,邮件托管在Google Apps Standard,自动开启了 即时聊天 功能,Google这一举动实际上破坏了XMPP Federation。我们自己架设了Openfire作为XMPP服务器,Google总是优先连接自家的XMPP服务器,所以 @dormforce.net 就不能和 @gmail.com 的用户互通,和其他XMPP域(例如 @jabber.org 等)则正常

现在把Google Apps的 即时通讯 disable了,过一会儿再看看是否正常。如果还不正常可以向Google发邮件

为你的Openfire服务器申请SSL证书CA授权

2008年03月21日,星期五

https://xmpp.net 按照步骤一步一步做就行了,唯一需要非常注意的是:填写为哪一个域申请证书的时候,sub-domain最好填写 *,表示所有二级域名都支持!

我当时就犯傻了,忘记填了,结果只给 dormforce.net 主域名申请到了证书,汗!

ASCII Demo Scene

2008年03月20日,星期四

突然对ASCII Demo Scene感兴趣了。网上疯狂的搜集资料。似乎最著名的是来源就是Text Mode Demo Competition。但是似乎现在更加流行的是Javascript Demo Scene。最直接的scene可能要算这个redbug了,很让人过瘾。元老级网站pouet有Javascript专栏,其中佼佼者是tAAt的DentaalispiranttiSpaceless SpotFartart,h还有Swansontec - Antimatter

p01网站搜集了很多令人惊讶的256字节js动画,甚至有个专门的256 byte dHTML编程大赛

每次看scene总是给人一种非常吃惊的感觉,你会想“OMG, 这么短的代码产生了这么酷的特效!”