2008年02月 存档

[IE]去掉“此页包含安全和非安全项目”提示

2008年02月29日,星期五

全民上网进入https时代,但是IE上网始终会出现

This page contains both secure and non-secure items. Do you want to download the non-secure items?

这个狗屁提示,很烦,于是想去掉。

IE选项里翻了半天,最后找到了:杂项 - 显示混合内容

或者偷偷懒的导入这个reg文件即可。

Windows Registry Editor Version 5.00

[HKEY_CURRENT_USER\Software\Microsoft\Windows\CurrentVersion\Internet Settings\Zones\3]
"1609"=dword:00000000

顺便发现微软一个很搞笑的KB184960,它说这个提示是:
This behavior is by design. You cannot disable this error message.

最后吼一句:有没有谁知道一种系统tweak软件,能够根据调节的动作自动生成reg/bat/vbs/inf文件?并且支持通过WMI和远程注册表来调节?

【有图有真莫道不消魂相】《The Bourne Identity 谍影重重》 里的人民币

2008年02月29日,星期五

13.JPG

2.JPG

由于遭受未知来源的ARP攻击全校断网了几个小时,于是看电影打发时间。结果很火星的在《谍影重重》发现了人民币,看来外国特务潜入我国比较频繁啊。大概在主角Bourne进银行拿到了自己的箱子,打开一堆钞票的时候,哇~~~

告别portable外挂程序:用命令行实现Portable Firefox/Thunderbird

2008年02月27日,星期三

以前只知道 Mozilla 的东西 -p 可以选择非C:盘的配置文件,现在发现一个更加强大的未公开命令行参数: -profile "path" 可以直接以路径 path 下的配置文件启动Firefox和Thunderbird。

那么可以告别NSIS写的Portable版本了!直接新建两个个快捷方式,通过相对路径,工作环境可以随便转移了!

D:\浏览器及工具\Firefox\firefox.exe -Prefetch:1 -turbo -profile ".\est_profile"
D:\NetWorks\ThunderbirdPortable\App\thunderbird\thunderbird.exe -profile "..\..\Data\profile"

Linux下同理,把路径写成Unix风格的 ../../my_profile 就行了

Product key error

2008年02月26日,星期二

安装Windows Server 2008,本来想用OEM的方法激活,但是可耻的失败了。

---------------------------
Product key error
---------------------------
The product key you have entered will not work with this edition of Windows Server®.

You must either run Windows Server® Setup or enter a Windows Server® Standard product key.
---------------------------
OK
---------------------------

网上有OEM激活的教程:由于Windows Server 2008和 Windows Vista SP1用的是同一个内核,所以可以先安装一个HP OEM Vista,然后把这两个文件替换Server 2008的同名文件
%WinDir%\System32\Licensing\pkeyconfig\pkeyconfig.xrm-ms
%WinDir%\ServiceProfiles\NetworkService\AppData\Roaming\Microsoft\SoftwareLicensing\tokens.dat
再用OEM激活,据说有人成功过。但是缺点是:Server 2008变成了workstation版本,例如 我的电脑 - 服务器管理 变成了计算机管理,IIS和AD也不是服务器版本的

那么,我还需要再装一次Vista么,囧

数羊也可以这样数

2008年02月26日,星期二

2008-2-26 13:37:35 大师兄(H) [Emoticon] 数绵羊 1只羊 2只羊 3只羊 4只羊 5只羊 6只羊 7只羊 8只羊 9只羊 10只羊 11只羊 12只羊 13只羊 14只羊 15只羊 16只羊 17只羊 18只羊 19只羊 20只羊 21只羊 22只羊 23只羊 24只羊 25只羊 26只羊 27只羊 28只羊 29只羊 30只羊 31只羊 32只羊 33只羊 34只羊 35只羊 36只羊 37只羊 38只羊 39只羊 40只羊 41只羊 42只羊 43只羊 44只羊 45只羊 46只羊 47只羊 48只羊 49只羊 50只羊 51只羊 52只羊 53只羊 54只羊 55只羊 56只羊 57只羊 58只羊 59只羊 60只羊 61只羊 62只羊 63只羊 64只羊 65只羊 66只羊 67只羊 68只羊 69只羊 70只羊 71只羊 72只羊 73只羊 74只羊 75只羊 76只羊 77只羊 78只羊 79只羊 80只羊 81只羊 82只羊 83只羊 84只羊 85只羊 86只羊 87只羊 88只羊 89只羊 90只羊 91只羊 92只羊 93只羊 94只羊 95只羊 96只羊 97只羊 98只羊 99只羊 100只羊 101只羊 102只羊 103只羊 104只羊 105只羊 106只羊 107只羊 108只羊 109只羊 110只羊
2008-2-26 13:38:04 lee 如果是程序数的就没意义了。
2008-2-26 13:38:16 lee 作为一个正常的变半夜凉初透态,应该手写。
2008-2-26 13:38:37 大师兄(H) [Emoticon]
2008-2-26 13:38:39 什么(和谐中) [Emoticon]
2008-2-26 13:39:31 sys@pyth [Emoticon]
2008-2-26 13:40:15 萧萧 把数羊的程序发上来看看
2008-2-26 13:40:37 sys@pyth 为什么会这样呢? 有如此变半夜凉初透态的吗? 可以用 string.split('只羊')
2008-2-26 13:40:45 Zero Cool [Emoticon]
2008-2-26 13:40:58 Zero Cool for
2008-2-26 13:41:15 琳琳的小狗 汗,这种也写程序?
2008-2-26 13:41:31 琳琳的小狗 估计你想睡觉的时候,越写越精神
2008-2-26 13:41:41 萧萧 对我这样的菜鸟来说也是难题
2008-2-26 13:41:41 lee 有多少种写法呢?
2008-2-26 13:42:11 琳琳的小狗 汗
2008-2-26 13:42:25 大师兄(H) [Emoticon]
2008-2-26 13:42:39 萧萧 至少要找到这个窗口
2008-2-26 13:43:17 lee >>> ' '.join(map(lambda x:'%d sheep'%x, range(1, 10))) '1 sheep 2 sheep 3 sheep 4 sheep 5 sheep 6 sheep 7 sheep 8 sheep 9 sheep' >>>
2008-2-26 13:43:22 Zero Cool while 。。。。。
2008-2-26 13:44:07 琳琳的小狗 def sheep(): i = 1 while(true): yield i+"只羊"
2008-2-26 13:44:24 琳琳的小狗 s = sheep()
2008-2-26 13:44:28 琳琳的小狗 s.next()
2008-2-26 13:44:42 est(252889189) 汗啊,水区谈技术,技术区灌水啊,传统啊
2008-2-26 13:44:44 琳琳的小狗 忘记i+1鸟
2008-2-26 13:45:14 琳琳的小狗 这样写应该是比较节约内存的鸟
2008-2-26 13:45:15 头太晕-要和谐 def sheep(n): for i in range(1,n+1): print ' %i只羊' % (i,),
2008-2-26 13:45:47 lee 写一个java风格的
2008-2-26 13:45:46 琳琳的小狗 [Picture]
2008-2-26 13:45:56 lee 先要继承一个基类
2008-2-26 13:46:15 Zero Cool 这羊3条腿?
2008-2-26 13:46:30 琳琳的小狗 对啊,因为有不同长相的样,所以为了做到灵活性
2008-2-26 13:46:31 sys@pyth s=[str(i)+'只羊' for i in range(101)]
2008-2-26 13:46:35 琳琳的小狗 你还得来个策略模式
2008-2-26 13:46:41 琳琳的小狗 搞个interface……
2008-2-26 13:46:49 jerk 作为一个正常的变半夜凉初透态,应该手写
2008-2-26 13:47:01 琳琳的小狗 不正常的变半夜凉初透态就写code?
2008-2-26 13:47:04 jerk lee 有广告天赋
2008-2-26 13:47:08 代码人生 用工厂方法
2008-2-26 13:47:45 头太晕-要和谐 做一个网页,每次访问的时候,告诉你,你是第几只访问本页面的羊
2008-2-26 13:47:51 萧萧 继续需求 只在庙里数羊
2008-2-26 13:48:15 大师兄(H) [Emoticon] 一只羊 二只羊 三只羊 四只羊 五只羊 六只羊 七只羊 八只羊 九只羊 十只羊 十一只羊 十二只羊 十三只羊 十四只羊 十五只羊 十六只羊 十七只羊 十八只羊 十九只羊 二十只羊 二十一只羊 二十二只羊 二十三只羊 二十四只羊 二十五只羊 二十六只羊 二十七只羊 二十八只羊 二十九只羊 三十只羊 三十一只羊 三十二只羊 三十三只羊 三十四只羊 三十五只羊 三十六只羊 三十七只羊 三十八只羊 三十九只羊 四十只羊 四十一只羊 四十二只羊 四十三只羊 四十四只羊 四十五只羊 四十六只羊 四十七只羊 四十八只羊 四十九只羊 五十只羊 五十一只羊 五十二只羊 五十三只羊 五十四只羊 五十五只羊 五十六只羊 五十七只羊 五十八只羊 五十九只羊 六十只羊 六十一只羊 六十二只羊 六十三只羊 六十四只羊 六十五只羊 六十六只羊 六十七只羊 六十八只羊 六十九只羊 七十只羊 七十一只羊 七十二只羊 七十三只羊 七十四只羊 七十五只羊 七十六只羊 七十七只羊 七十八只羊 七十九只羊 八十只羊 八十一只羊 八十二只羊 八十三只羊 八十四只羊 八十五只羊 八十六只羊 八十七只羊 八十八只羊 八十九只羊 九十只羊 九十一只羊 九十二只羊 九十三只羊 九十四只羊 九十五只羊 九十六只羊 九十七只羊 九十八只羊 九十九只羊
2008-2-26 13:48:35 代码人生 如果还要在尼姑庵里数猪,就要用桥接模式了
2008-2-26 13:48:47 jerk 设计模式
2008-2-26 13:48:55 jerk 点也不懂
2008-2-26 13:48:58 萧萧 有人在庙里灌水就数羊,自动的
2008-2-26 13:49:07 头太晕-要和谐 如果在白云观里数驴呢?
2008-2-26 13:49:23 大师兄(H) 弄杯咖啡 再数就真睡了....
2008-2-26 13:49:29 lee >>> eval('"' + '%d sheep ' * 10 + '"%' + str(tuple(range(10)))) '0 sheep 1 sheep 2 sheep 3 sheep 4 sheep 5 sheep 6 sheep 7 sheep 8 sheep 9 sheep ' >>>
2008-2-26 13:49:41 琳琳的小狗 邪有暗香盈袖恶的eval……
2008-2-26 13:49:42 代码人生 太不标准了,用接口模式吧随便数啥
2008-2-26 13:49:50 sys@pyth >>> s=''.join([str(i)+'只羊 ' for i in range(101)]) >>> print s 0只羊 1只羊 2只羊 3只羊 4只羊 5只羊 6只羊 7只羊 8只羊 9只羊 10只羊 11只羊 12只羊 13只羊 14只羊 15只羊 16只羊 17只羊 18只羊 19只羊 20只羊 21只羊 22只羊 23只羊 24只羊 25只羊 26只羊 27只羊 28只羊 29只羊 30只羊 31只羊 32只羊 33只羊 34只羊 35只羊 36只羊 37只羊 38只羊 39只羊 40只羊 41只羊 42只羊 43只羊 44只羊 45只羊 46只羊 47只羊 48只羊 49只羊 50只羊 51只羊 52只羊 53只羊 54只羊 55只羊 56只羊 57只羊 58只羊 59只羊 60只羊 61只羊 62只羊 63只羊 64只羊 65只羊 66只羊 67只羊 68只羊 69只羊 70只羊 71只羊 72只羊 73只羊 74只羊 75只羊 76只羊 77只羊 78只羊 79只羊 80只羊 81只羊 82只羊 83只羊 84只羊 85只羊 86只羊 87只羊 88只羊 89只羊 90只羊 91只羊 92只羊 93只羊 94只羊 95只羊 96只羊 97只羊 98只羊 99只羊 100只羊 >>>
2008-2-26 13:50:20 萧萧 贴上来的不行
2008-2-26 13:50:36 大师兄(H) <script language="JavaScript"> <!-- var str='|一|二|三|四|五|六|七|八|九|十'.split('|'); for (i=1;i<100;i++ ) { if(i<=10) document.write(str[i]+'只羊 '); else if(i<20) document.write('十'+str[i%10]+'只羊 '); else document.write(str[parseInt(i/10)]+'十'+str[i%10]+'只羊 '); } //--> </script>[Emoticon]
2008-2-26 13:50:38 sys@pyth [Picture]
2008-2-26 13:50:41 lee >>> eval('"' + '%d sheep ' * 10 + '"%' + str(tuple(range(10)))) '0 sheep 1 sheep 2 sheep 3 sheep 4 sheep 5 sheep 6 sheep 7 sheep 8 sheep 9 sheep ' >>>
2008-2-26 13:50:47 萧萧 要求无鼠标响应
2008-2-26 13:50:48 sys@pyth 那怎么办,手写?
2008-2-26 13:51:06 萧萧 事件
2008-2-26 13:51:55 sys@pyth 有什么具体要求啊? 设计模式要用上?
2008-2-26 13:52:02 sys@pyth 用事件激发的?
2008-2-26 13:52:36 琳琳的小狗 事件驱动,设计模式……汗
2008-2-26 13:52:55 sys@pyth 我没有看到你们数羊题目的设计要求
2008-2-26 13:53:05 头太晕-要和谐 >>> def sheep(): i = 1 while(True): yield ' %i只羊' % (i,) i += 1
>>> >>> for s in sheep(): print s 看谁数的多.我差点儿死机...
2008-2-26 13:53:08 est 求白云观群号
2008-2-26 13:53:09 琳琳的小狗 要概要设计还是详细设计
2008-2-26 13:53:16 Zero Cool 建议用鼠标画来的更有艺术
2008-2-26 13:53:17 萧萧 就是写一个机器人数羊
2008-2-26 13:53:28 琳琳的小狗 那是,我说了yield最节约内存
2008-2-26 13:53:41 sys@pyth >>> print ''.join([str(i)+'只羊 ' for i in range(101)])
2008-2-26 13:53:48 sys@pyth 这个不可以吗?
2008-2-26 13:54:01 头太晕-要和谐 sys数到100睡不着怎么办?
2008-2-26 13:54:03 sys@pyth 写个机器人数羊
2008-2-26 13:54:26 sys@pyth 我再重新写
2008-2-26 13:54:29 琳琳的小狗 哈哈哈哈
2008-2-26 13:54:32 头太晕-要和谐 一定要是死循环,必须数到睡着为止.
2008-2-26 13:54:49 琳琳的小狗 那你脑子死机了……
2008-2-26 13:55:07 大师兄(H) 应该是 按一下 数一下 睡着了 就停了
2008-2-26 13:55:08 头太晕-要和谐 i = 1 while(True): print ' %i只羊' % (i,), i += 1
2008-2-26 13:55:21 sys@pyth while 的效率最低
2008-2-26 13:55:39 琳琳的小狗 你用生成器呀
2008-2-26 13:55:56 sys@pyth 生成器,能讲讲不? 有啥用啊?
2008-2-26 13:56:12 琳琳的小狗 yield
2008-2-26 13:56:20 琳琳的小狗 python in a nutshell 2e
2008-2-26 13:56:22 sys@pyth yield 我没有看懂
2008-2-26 13:56:43 琳琳的小狗 就象一个暂停按钮
2008-2-26 13:56:45 sys@pyth 好像是封装了一个累加器函数似的,还可以访问
2008-2-26 13:57:09 sys@pyth 这个累加器里面还隐藏了一个暂停按钮
2008-2-26 13:57:16 头太晕-要和谐 我已经困了.
2008-2-26 13:57:18 头太晕-要和谐 我要睡觉了.
2008-2-26 13:57:19 sys@pyth 是不是这个意思?
2008-2-26 13:57:22 代码人生 生成器模式?
2008-2-26 13:57:34 琳琳的小狗 你yield x的话
2008-2-26 13:57:49 琳琳的小狗 到了这句,他暂停你的方法
2008-2-26 13:58:04 琳琳的小狗 然后返回一个特殊的对象
2008-2-26 13:58:18 琳琳的小狗 这个对象有个next()方法
2008-2-26 13:58:29 琳琳的小狗 每次调用,都先返回当前的x
2008-2-26 13:58:38 sys@pyth 也就是一个特殊的方法,
2008-2-26 13:58:40 琳琳的小狗 然后继续执行方法剩下的代码
2008-2-26 13:58:57 sys@pyth 内含暂停按钮的,可以累加的东东
2008-2-26 13:59:04 琳琳的小狗 如果再次到达这句,那重复做,over
2008-2-26 13:59:20 sys@pyth 早这么解释,我早就听懂了
2008-2-26 13:59:37 琳琳的小狗 到最后执行到方法完毕,如果你再调用next,会产生一个异常
2008-2-26 13:59:43 sys@pyth 还用灰衣人那么长篇大论吗
2008-2-26 13:59:56 琳琳的小狗 说实话,我之前也没看懂他老人家写的那个
2008-2-26 13:59:59 sys@pyth 异常就 返回一个-1
2008-2-26 14:00:07 琳琳的小狗 我是看python in a nutshell
2008-2-26 14:00:15 sys@pyth 你这么解释我 我看懂了
2008-2-26 14:00:26 琳琳的小狗 不是返回-1,直接抛异常了
2008-2-26 14:00:50 琳琳的小狗 shhgs在国外呆久了,解释中文都太深
2008-2-26 14:01:56 sys@pyth 抛异常也可以的
2008-2-26 14:02:25 琳琳的小狗 那你不能说返回-1赛,我们pythoner要严谨[Picture]
2008-2-26 14:02:44 sys@pyth 汗、、、、、,习惯了

真服了这帮写python的了

stackless, threads, stack, whatever

2008年02月26日,星期二

再写一个comet-like Web app的时候,无意中翻到了上古神器Eurasia3,也翻到了stackless,每次碰到stackless就小小的震撼一下,就像阳光照不到的阴暗角落,不知道哪里有什么样稀奇古怪的东西。还是在IBM developerWorks上翻到了一点支离破碎的东西(中文 | 英文):

Mertz:Stackless Python 确切来说是什么?有什么初学者可以理解的概念能够解释有关 Stackless 的不同之处?

Tismer:Stackless Python 是一种不在 C 堆栈上保存状态的 Python 实现。它的确有堆栈 -- 要多少有多少 -- 但这些是 Python 堆栈。

C 堆栈不能从例如 C 这样的语言以干净的方式进行修改,除非以预期的顺序进行。它对您施加了很大限制:您必须回到这里,与您离开的方向正好相反。

“普通的”程序员一开始不会认为这是个限制。他们必须从开始就要学会将想法转向堆栈。堆栈没有什么坏处,并且通常它们施加的执行顺序就是实际上的顺序,但这并不意味着我们必须等待一个这样的堆栈序列完成才能运行另一序列。

程序员在必须执行非阻塞调用和回调时意识到这一点。堆栈突然挡住去路,我们必须使用线程,或将状态明确存储在对象中,或者构建显式的可切换堆栈等等。Stackless 的目的是帮助程序员避免这些问题。

Mertz: Exactly what is Stackless Python? Is there something a beginner can get his or her mind around that explains what is different about Stackless?

Tismer: Stackless Python is a Python implementation that does not save state on the C stack. It does have stacks -- as many as you want -- but these are Python stacks.

The C stack cannot be modified in a clean way from a language like C, unless you do it in the expected order. It imposes a big obligation on you: You will come back, exactly here, exactly in the reverse way as you went off.

"Normal" programmers do not see this as a restriction in the first place. They have to learn to push their minds onto stacks from the outset. There is nothing bad about stacks, and usually their imposed execution order is the way to go, but that does not mean that we have to wait for one such stack sequence to complete before we can run a different one.

Programmers realize this when they have to do non-blocking calls and callbacks. Suddenly the stack is in the way, we must use threads, or explicitly store state in objects, or build explicit, switchable stacks, and so on. The aim of Stackless is to deliver the programmer from these problems.

还是一片空白啊。但是感觉HTML - CGI - AJAX这一些东西一路过来,可能对并发编程有相当大的促进吧?加上现在的comet,简直是 ** 性的东西。

顺便看了一下文章发表的时间:
David Mertz (mertz@gnosis.cx), President, Gnosis Software, Inc.

01 Oct 2000

瞬间觉得自己超级渺小。8年前我在做什么?跟老师在昏暗沉闷的微机室学习DOS, WPS……Guido在1989圣诞节无聊写了个python出来。Tismer在1999无聊写了个stackless

史上最强Ctrl+C, Ctrl+V!!!

2008年02月26日,星期二

http://202.202.128.32/outside/organization/service/metc/cnw7.html

大家看了有啥感觉啊?

[python]基于htmllib.HTMLParser的html2text

2008年02月24日,星期日

def html2text(strHtml):
    """处理html 4.01和部分xhtml 1.0转义字符"""
    class SimpleParser(htmllib.HTMLParser):
        def anchor_end(self):
            if self.anchor:
                self.anchor = None
        def handle_image(self, src, alt, *args):
            #self.handle_data(alt)  #可以重写为alt属性
            pass                    #图片替换成空
        def convert_entityref(self, name):
            name2codepoint["nbsp"]  = 0x0020
            name2codepoint["apos"]  = 0x0027
            if name in name2codepoint and name<256:
                return chr(name2codepoint[name])
            else:
                return
        def convert_charref(self, name):
            return unichr(int(name)).encode("gb18030")


file = StringIO.StringIO() p = SimpleParser(formatter.AbstractFormatter(formatter.DumbWriter(file))) p.feed(strHtml) p.close() return file.getvalue()

贴在这里备用。相当与js DOM编程里的 innerText 功能。该死的BeautifulSoup为啥不集成这个功能啊?

[Python]给urllib2添加自动Referer, Cookie处理功能

2008年02月24日,星期日

urllib2是个非常好用的http客户端库,但是用来写爬虫可能会遇到一些问题,一是连续请求某一网站的时候,cookie需要手动添加到HTTP请求头里,二是手动处理Referer页。这里贴一段代码,可以自动处理Cookie和Referer问题。每一个请求会自动添加上一次的cookie和referer。

以后做爬虫,如果规模较大,性能要求较高,还是用pycURL这个库吧,C写的。一般的小规模应用,要方便的跨Linux/Windows平台还是用下面的代码比较灵活方便。


class HTTPRefererProcessor(urllib2.BaseHandler):
    def __init__(self):
        self.referer = None 


def http_request(self, request): if ((self.referer is not None) and not request.has_header("Referer")): request.add_unredirected_header("Referer", self.referer) return request


def http_response(self, request, response): self.referer = response.geturl() return response


https_request = http_request https_response = http_response


def main(): cj = CookieJar() opener = urllib2.build_opener( urllib2.HTTPCookieProcessor(cj), HTTPRefererProcessor(), ) urllib2.install_opener(opener)


urllib2.urlopen(url1) #打开第一个网址 urllib2.urlopen(url2) #打开第二个网址


if "__main__" == __name__: main()

参考了部分ClientCookie库的代码。

终于明白cp936是什么意思了

2008年02月22日,星期五

一直为GB2312,GBK,GB18030和CP936之间的关系头痛,今天得到Python群里一位高人指点,明白了cp936就是指系统里第936号编码格式,也就是GB2312。

可以看这个表:

936 gb2312 简体中文(GB2312)

至于Unicode, UCS2, UTF-8之间的种种关系还是比较困惑。特别是Unicode和Unicode对象、UTF-8编码的Unicode对象……非常郁闷