PyWordpress系统更新2008-12-25 23:35:21comments ( 4 )
系统做了些修改,去掉了Evoque模板系统,使用了自己弄得更简单的系统,使用了cache,写了插件功能,密码使用了和WordPress同样的phpass加密啊方法,还有更多不再列出。
关于hook函数,基本如下。
#! /usr/bin/python
# -*- coding: utf-8 -*-
import types
hooks = {}
def call(hook,*args):
if hooks.has_key(hook):
if len(hooks[hook]) > 0:
for fn in hooks[hook]:
fn(*args)
def register(hook,fn):
if not isinstance(fn,types.FunctionType):
return
if hooks.has_key(hook):
hooks[hook].append(fn)
else:
hooks[hook] = [fn]
Silverlight属性windowless在Opera下的bug2008-12-12 16:13:31comments ( 6 )
关于silverlight的windowless(无窗口模式)该值确定 Silverlight 插件是否显示为无窗口,在该模式下别的html元素可以覆盖带该silverlight插件上,当然有事确实需要这么多,经测试在Opera浏览器下设置windowless为true时,发现插件出现异常,xaml内容显示不出来,其它浏览器都能正常显示。
关于windowless,官方说:只有在必要时,才将 Windowless 属性设置为 true。在无窗口模式下,性能会受到严重影响(例如动画中的撕裂)。由于这个原因,不建议在无窗口模式下进行任何媒体播放。
初雪2008-12-10 23:45:45comments ( 10 )
早上醒来发现外面在下雪,今年的第一场雪,絮絮的下着,有点兴奋,在手机里写了几个字:这里下雪了。然后又删除了,应该没有人会期待我的短信息!洗漱后,出门去上班,下地铁的时候,发现雪已经停了,应该是场过路雪吧。

红布绿花朵,一缕清音2008-12-10 15:46:39comments ( 0 )

更新:
Moonlight 1.0 Beta 1一个关于MediaElement的Bug2008-12-10 13:34:39comments ( 0 )
Moonlight 是微软的Silverlight在Unix系统上的实现,而且是开源的.如见发布了1.0 beta 1版本。昨天在ubuntu上安装了下,惊喜的发现一听的在线播放器可以正常的加载silverlight/moonlight控件了。在使用中老王发现一个bug,就是MediaElement在暂停(pause)之后,播放中的MediaElement.position.seconds将会变为0,播放(Play)之后回到原来的播放处.这就需要在执行暂停操作之前,先把MediaElement.position.seconds放到一个临时变量里,暂时想到这个解决方法。
放一张截图,点击可看到大图:
IE7下flash报__flash__removeCallback的js错误2008-12-10 09:57:02comments ( 0 )
如果页面里使用了flash,并且flash里使用了flash.external.ExternalInterface.addCallback方法,刷新网页的使用会报__flash__removeCallback的js错误:缺少对象(Line 53),(Jscript-scriptblock).
函数错误为:
function __flash__removeCallback(instance, name) {
instance[name] = null;
}
调用处为:
__flash__removeCallback(document.getElementById(""), "dewprev");
可以发现这里的document.getElementById("")返回的实例是null,也就难怪__flash__removeCallback会报错了,估计这个flash内置的方法应该做些判断,或许应该写为:
function __flash__removeCallback(instance, name) {
if (instance != null) { instance[name] = null; }
}
反过来想这里的document.getElementById("")到底是要获取哪个对象,经过测试发现,应该是获取flash控件Object对象的id/name属性的,之所以出现这个错误,是因为未给Object设置id/name属性,设置后就不会出错了。
另外推荐下我下IE下使用的js调试工具:CompanionJS 。
利用python解析ini文件2008-12-09 15:36:17comments ( 0 )
关于ini文件的说明请看这里,自己利用python写了个简单的函数把相关属性解析为字典(dict)。
def parse_ini(ini_file):
import re,os.path
cf = {}
sel = None
if not os.path.isfile(ini_file):
return cf
fp = open(ini_file,'r')
for line in fp.readlines():
line = line.replace('\n','').strip()
if not line.startswith('#') and not line.startswith(';'):
sels = re.match(r'^\[(.+?)\]',line)
if sels:
sel = sels.groups()[0]
cf[sel] = {}
elif line.find('=') > 0:
vs = line.find('=')
ds = line.find(';')
val = line[(vs+1):].strip()
mtd = re.match(r'^"(.+?)"',val)
mts = re.match(r"^'(.+?)'",val)
if mtd:
val = mtd.groups()[0]
elif mts:
val = mts.groups()[0]
elif ds >0:
val = line[(vs+1):ds].strip()
else:
val = line[(vs+1):].strip()
if sel:
cf[sel][line[:vs].rstrip()] = val
else:
cf[line[:vs].rstrip()] = val
fp.close()
return cf
ini文件如下:
; last modified 1 April 2001 by John Doe
[owner]
name=John Doe
organization=Acme Products
[database]
server=192.0.2.42 ; use IP address in case network name resolution is not working
port=143
file = "acme payroll.dat"
将解析为:
{'owner': {'organization': 'Acme Products', 'name': 'John Doe'}, 'database': {'port': '143', 'file': 'acme payroll.dat', 'server': '192.0.2.42'}}
javascript魔术方法2008-12-07 22:58:08comments ( 0 )
var User=function(){
this.actions= {
stat:function(){
return false;
},
login:function(){
alert(this.stat());
}
};
this.forward = function(method) {
var argArray = [].slice.call(arguments,1);
return this.actions[method].apply(this.actions, argArray);
};
};
var user = new User();
user.forward('login','Hello World!');
WordPress插件post-to-qzone-v0.2.12008-11-23 15:14:09comments ( 4 )
增加发布时的格式配置,修改原来版本中在编辑文章时默认是发布到qzone的bug。

在线音乐播放器功能之添加到列表2008-11-22 04:16:24comments ( 1 )
在不少在线音乐网站里都有添加到播放列表的功能,这个功能比较实用的,因为用户无需再打开多余的浏览器窗口,直接将要播放的歌曲追加到已经打开的播放页面里,我在过去曾经使用window.opener记录窗口,但是效果很不好。偶尔发现actionscript有个叫LocalConnection的类,可以实现客户端多个flash的数据通信,而且flash可以通过flash.external.ExternalInterface的call和addCallback方法和浏览器的javascript交互。思路大概是这样的,用户通过鼠标点击的js事件将数据发送到当前页面的发送方flash里,然后再通过已经打开的浏览器窗口里的接收方flash调用设置好的javascript函数,把数据渲染到该页面。呵呵,表达能力有限,见谅!测试发现,可以跨浏览器通信,就是说你在firefox里打开接收端的fash,你在IE里打开发送端依然可以将信息发送到firefox里。
我写了如下代码:
// Code in the receiving SWF file
var receiving_lc:LocalConnection = new LocalConnection();
receiving_lc.allowDomain = function(sendingDomain):Boolean{
return (sendingDomain==this.domain()
|| sendingDomain=="www.1ting.com"
|| sendingDomain=="play.1ting.com");
}receiving_lc.methodToExecute = function(song_ids:Array) {
flash.external.ExternalInterface.call("add_to_play_list",song_ids);
};receiving_lc.connect("_lc_play_list");
//Code in the sending SWF file
var sending_lc:LocalConnection = new LocalConnection();
var song_ids:Array;
sending_lc.onStatus = function(infoObject:Object) {
switch (infoObject.level) {
case "status" :
break;
case "error" :
getURL("http://play.1ting.com/p_"+song_ids.join("_")+".html", "_1ting");
break;
}
};var add_to_play_list:Function = function(sids:Array):Void{
sending_lc.send("_lc_play_list", "methodToExecute", song_ids = sids);
}flash.external.ExternalInterface.addCallback("add_to_play_list",null,add_to_play_list);
