Sunday, February 7, 2010

这两天遇到的某些国内discuz论坛输出的RSS问题解决。

主要遇到了两个问题。
1.GBK编码问题
如果RSS输出是gbk编码,Zend_Feed可以处理(不过会有些警告)。而Simplepie则全部处理成乱码了。
解决这个问题只能是把gbk当成gb2312来处理。
$content = str_replace('encoding="gbk"', 'encoding="gb2312"', $content);


2.半个汉字,或非gb2312内的字符在第一或最后一个的时候,CDATA标签无法识别(Zend_Feed和SimplePie都不行)。
解决办法就是在CDATA与字符之间加一个空格。
$content = preg_replace('/\]\]\>/', ' ]]>', $content);
$content = preg_replace('/\<\!\[CDATA\[/', '<![CDATA[ ', $content);

Saturday, February 6, 2010

Version Control with Git 学习笔记(更新中)

1.当git checkout的时候,如果有一个文件名和一个tag重名,可以用两个中线来指定文件名,比如:
$git checkout main.c  //checkout tag name
$git checkout -- main.c //checkout file name


2.指定log编辑器
setenv GIT_EDITOR vim  //tch
export GIT_EDITOR=vim //bash


3.--author when met some wired message :P

4.比较两个版本
git log
git diff 0f793b8262cbd843e8ad7c75430aab7bebc6522d^1..HEAD wp-content/themes/bugbam/header.php

5.diff stat
git diff master~5 master

Tuesday, February 2, 2010

dante server INSTALL note

1. install dante server

sudo apt-get install dante-server


skip the error message from the output of configure dante-server once installed. that's cause dante configuration was not complete.

2. start editing the config file

vi /etc/danted.conf

--
# log to what file
logoutput: stderr /var/log/danted.log

# listening interface and port
internal: ppp0 port = 80

# outgoing interface
external: ppp0

# method: username requires the client to provide a username and password which match the system password file.

# method: none requires no form of authentication.
method: username

# privileged ports like 80 and 443 must use root permission.
user.privileged: root

# the package seems not complied with libwrap support.
#user.libwrap: nobody

# allowed IPs
client pass {
from: 0.0.0.0/0 to: 0.0.0.0/0
}

# allowed protocols with these source IPs
pass {
from: 0.0.0.0/0 to: 0.0.0.0/0
protocol: tcp udp
}


3. run dante-server

sudo /etc/init.d/danted start

Monday, January 25, 2010

Change Joomla default meta info in a Component

In the templates of Component, in view.html.php before display() be called. add following line:


$document =& JFactory::getDocument();
$document->setDescription('you description');
$document->setMetaData('keywords', 'you keywords');

关于对DOM Level 1和2的理解。

参考:
https://developer.mozilla.org/En/DOM_Levels

根据自己的理解总结一下DOM Levels的实现。

DOM Level 1:
实现了文档结构化,就是《a href="xx" target=""》这样的tag以及attribute的定义。
http://www.w3.org/TR/DOM-Level-1/

DOM Level 2:
1.实现了命名空间。
2.实现动态更新以及访问(动态更新后可以看到更新结果)。addChild, removeChild
3.事件,比如addEventListener,来实现响应各种事件,比如EventTarget, MouseEvent(但不包括键盘事件,奇怪,文档上是这么说的)
4.支持CSS的访问了。 比如div.style.display='none';还有一些CSS相关的方法。
5.实现Traversal,比如NodeIterator(我是没用过)。还有Range,这个在online editor里常见,就是TextRange之类的实现。这块不熟,还是看要w3c的详细文档吧:http://www.w3.org/TR/DOM-Level-2-Traversal-Range/

总之现在主流的浏览器基本实现了Level2 小量实现了Level3。

Friday, January 22, 2010

A little example to figure out Javascript scope

function f1() { var a=1; f2(); }
function f2() { alert(a); }
f1();


function f1() { 
var a=2;
function f2() {
alert(a);
}
f2();
}
f1();


Try it.

Wednesday, December 30, 2009

install a git server on ubuntu

install software
sudo apt-get install git-core gitweb


edit config with apache
sudo vim /etc/apache2/conf.d/git

<Directory /var/www/git>
Allow from all
AllowOverride all
Order allow,deny
Options ExecCGI
<Files gitweb.cgi>
SetHandler cgi-script
</Files>
</Directory>
DirectoryIndex gitweb.cgi
SetEnv GITWEB_CONFIG /etc/gitweb.conf

copy file
sudo mv /usr/share/gitweb/* /var/www/git
cp /usr/lib/cgi-bin/gitweb.cgi /var/www/git/


restart apache
sudo /etc/init.d/apache2 reload

//Then you can visit you git website.
http://localhost/git


=========================

create a new project rep
cd /var/cache/git/
sudo mkdir project.git
cd project.git
sudo git init
sudo vim .git/description
git config --global user.name "Your Name"
git config --global user.email "you@example.com"
git commit -a


git daemon start command
touch .git/git-daemon-export-ok
sudo git daemon --base-path=/var/cache/git --detach --syslog --export-all --verbose --enable=receive-pack


=====================
checkout code
cd ~
git clone git://server/project.git project