yichao firstname, zeaster nickname, zhang lastname

A tool that import all posts from wordpress to blogger in python

the tool can be downloaded from
http://yichao.zhang.googlepages.com/wordpress2blogger.py

Readme:

1 set the following parameters in the wordpress2blogger.py file
# set your wordpress username, password, xmlrpc url    
wp_username = 'admin'  
wp_passwd = 'mypwd'
wp_url = 'http://localhost/wordpress/xmlrpc.php'
                       
# set your blogger email, password, blogid
# blogid is in your blogspot Dashboard url, for example:
# http://www2.blogger.com/posts.g?blogID=18083698, "18083698" is your blogid.
blogger_email = 'yichao.zhang@gmail.com'
blogger_passwd = 'mypwd'
blogger_blogid = '18083698'

# set how many recent posts do you want to import from wordpress to blogger
wp_recent_posts_num = 5 

# set debug mode = True if you want to get debug info
DEBUG = True

3 make sure python in your path

4 in terminal, type the following command
   "python wordpress2blogger.py"

js feature by jQuery copied from codeplayer

Now, after loading this page, all titles of the posts are folded and click "+" to unfold, click title to dig into the single post page.
The feature above is implemented by the following code copied from codeplayer.
css part:
.mytoggle{
  cursor:pointer;
  font-size:22px;
  color:green;
}

script part:
<script src='http://www.douban.com/js/jquery.js' type='text/javascript'></script>
<script language='javascript'>
$(function(){
  $(".post-title").prepend("<span class='mytoggle'>-</span>");
  $(".mytoggle").click(
    function(e){
      var content = $(this).parent().next().next();
      content.toggle();
      if(content.css("display")=="none")
        $(this).html("+");
      else
        $(this).html("-");
    }
  ).click();
})
</script>

Translate ipmsg into GBK on Mac OS X

在公司使用ipmsg作为即时通讯工具,不过那是windows版的,用了Mac后自然无法使用了。
最近发现不用ipmsg,好多公司的通知都收不到了,虽然偶现在实习写论文,也没什么大事儿,但还是有点不方便。
于是google之:
惊喜!ipmsg竟然有unix,Mac OS X,java等诸多版本。
立马下了个Mac的版本,装上一看,都是日文!原来ipmsg是日本人开发的,除了windows版有国人azhi做了汉化,并改名为飞鸽传书,其他版本均不支持中文。

无奈!只好试试java版的了,发现使用swt写的,于是自己汉化之。
汉化还是比较容易的,有源代码,这点上还是要赞一下那位日本作者!
主要改了3个地方,
一是把界面显示的文字汉化
二是把消息传递时的字符编码改为GBK,本想改为UTF-8的,但这样和windows版的又不兼容了,所以只好改为GBK。
三是把保存日志时的字符编码改为GBK。

另外,java版的ipmsg每次都会弹出个login的对话框,需要点一下才可以登陆,麻烦!于是改代码,把这个对话框去掉了,每次都只从ipmsg.properties文件中读取用户以及分组信息。

接下来要赞一下eclipse!
这个swt工程可以直接export成苹果的应用程序,app格式,帅呆了!
另外,程序中使用了当前目录下的文件,如icon.gif或ipmsg.properties等。通过自己建了个"./testfile.txt"的文件后,知道原来打包成.app后的当前目录就是.app所在的目录。于是把icon文件夹以及ipmsg.properties放到和ipmsg.app平级的位置就可以了!

哈哈,这下在Mac OS X下也可以使用ipmsg了,虽然java版的不支持文件传输,但以后接收公司通知是没问题了。
文件传输的问题也可以通过苹果自带的ftp服务器方便的解决。哈哈

PS - 2009-02-16:
应网友的请求, 把原来打好包的ipmsg放到了这里, 方便有需要的朋友下载
http://blogsync-java.googlecode.com/files/ipmsg-macosx.zip

另外, 如果有朋友想继续完善ipmsg for Mac OS X 的功能, 可以下载这个eclipse项目.
http://blogsync-java.googlecode.com/files/ipmsg_eclipse_project.zip

active mode OR passive mode on FTP

自从给小黑装上了Mac OS X就再也不想用windows了,不管是xp还是vista,都太蹩脚了
在公司和同事传文件时,苹果自带的ftp服务器就派上了用途。
苹果自带的这个ftp服务器还是很好用的,不需要配置,只需要在sharing中启动ftp服务,打开防火墙就OK了。
但接下来也遇到了一点点麻烦:
同事使用windows自带的ftp命令行工具则可以访问我的ftp服务器,使用flashFXP则无法访问。
后来证实是因为ftp命令行使用active mode(主动模式)所以可以访问,而flashFXP选用passive mode(被动模式)无法访问,不选用被动模式则可以正常访问。

于是google之:
看到这篇文章,疑惑顿释。
主动模式和被动模式是相对于ftp服务器来说的,即是ftp服务器主动同客户端建立通讯socket或ftp服务器被动接受客户端发来的建立通讯socket请求。
ftp以及telnet等老式的通信协议使用了2种端口,一个是命令端口(Command Port),另一个是数据端口(Data Port)
ftp的命令端口是21,这个端口在苹果防火墙设置中被开放。但另一个数据端口是在通信时由客户端随机指定的,如果使用被动模式,客户端使用数据端口进行通信时就会被Mac的防火墙拦住。而使用主动模式时,是ftp服务器使用数据端口和同事的机器建立socket,而同事机器上没有防火墙,因此可以正常访问。

后来,在同事机器上装了天网防火墙,建立了若干规则,很容易就验证了上述想法。

xmlrpc for python

使用python处理xmlrpc太简单了,又一次感受到了python的力量!
下面以使用python调用wordpress提供的xmlrpc方法为例简单介绍一下:

1) how to call xmlrpc method in python
>>> import xmlrpclib
>>> from pprint import pprint
>>> server = xmlrpclib.ServerProxy("http://localhost/wordpress/xmlrpc.php")
>>> pprint(server.system.listMethods() )

['system.multicall',
 'system.listMethods',
 'system.getCapabilities',
 'demo.addTwoNumbers',
 'demo.sayHello',
 'pingback.extensions.getPingbacks',
 'pingback.ping',
 'mt.publishPost'......]

>>> blogs = server.metaWeblog.getRecentPosts('','admin','passwd',5)
>>> pprint(blogs)
>>> print(blogs[2]['permaLink'])

http://localhost/wordpress/?p=135

2)how to setup a xmlrpc server in python

import calendar, SimpleXMLRPCServer
#The server object
class Calendar:
    def getMonth(self, year, month):
        return calendar.month(year, month)

    def getYear(self, year):
        return calendar.calendar(year)
calendar_object = Calendar()
server = SimpleXMLRPCServer.SimpleXMLRPCServer(("localhost", 8888))
server.register_instance(calendar_object)
#Go into the main listener loop
print "Listening on port 8888"
server.serve_forever()

3)write a client to test server above
import xmlrpclib
server = xmlrpclib.ServerProxy("http://localhost:8888")
month = server.getMonth( 2002, 8 )
print month

     August 2002
Mo Tu We Th Fr Sa Su
                 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

PS:
pprint means pretty print. A cool tool too.

Reference:
1 http://docs.python.org/lib/module-xmlrpclib.html
2 http://www-128.ibm.com/developerworks/library/ws-pyth10.html
3 http://groovy.codehaus.org/XMLRPC

A simpler tool that imports all posts from wordpress to blogger/blogspot

jigar told me that the tool I post yesterday is too technical in Groups Google.
see
"""
can you make it simpler by making a standalone application. (I m trying
with that.)
This is too technical.
 If successful definitely it will be most useful thing around for
blogger.
"""
so I made it simpler by building a standalone. and
The simpler tool can be downloaded from this link.

After that, I found python is more suitable to do this staff and I'll try to make a more simpler tool written in python later.

Readme.txt
0. What is it used for?
This is a simple tool to import all posts from wordpress to blogger/blogspot.

1. How to use it?
1.1 as standalone app
for windwows user
1) set java in your path
2) set some parameters in run.bat, see details in run.bat
3) run run.bat now.

for linux/Mac OS X user
1) set java in your path
2) some parameters in run.sh, see details in run.sh
3) run run.sh now.

1.2 you can compile it and run it of course!
This tool depends on (a) Google Data APIs java client library and (b) apache xml-rpc library.
You can find them on
(a) http://code.google.com/apis/gdata/download/gdata.java.zip
(b) http://ws.apache.org/xmlrpc/download.html

download and put the above two libraries in your classpath
now configure some parameters in src/org/easter/blogsync/SyncWorker.java
1) set your wordpress blog url
2) set your wordpress blog username and password
3) set your blogger username and password
4) set your blogger blogid. Don't know what's your blogger's blogid? go to step 2.
5) set how many recent posts do you want to import from wordpress.

ok, let's run SyncWorker.java, and done.

2. what is my blogger blogid?
It's in your blogspot Dashboard url, for example: http://www2.blogger.com/posts.g?blogID=18083698
"18083698" is your blogid.


install subversion on Mac OS X

DO NOT use *.zip file, that's for windows!
decompress *.tar.gz and *-deps.tar.gz and just run:
./configure --with-apxs=/usr/local/apache2/bin/apxs --prefix=/usr/local/subversion --with-ssl --without-berkeley-db

simple shell to compress and decompress .tar.gz on Mac OS X

compress:
tar -czf dirname.tar.gz dirname

decompress:
tar -xzf dirname.tar.gz

parameter -z means .gz

A tool that imports all posts from wordpress to blogger/blogspot

The tool can be download from this link

Readme.txt:

0. What is it used for?
This is a simple tool to import all posts from wordpress to blogger/blogspot.

1. How to use it?
This tool depends on (a) Google Data APIs java client library and (b) apache xml-rpc library.
You can find them on
(a) http://code.google.com/apis/gdata/download/gdata.java.zip
(b) http://ws.apache.org/xmlrpc/download.html

download and put the above two libraries in your classpath
now configure some parameters in src/org/easter/blogsync/SyncWorker.java
1) set your wordpress blog url
2) set your wordpress blog username and password
3) set your blogger username and password
4) set your blogger blogid. Don't know what's your blogger's blogid? go to step 2.
5) set how many recent posts do you want to import from wordpress.

ok, let's run SyncWorker.java, and done.

2. what is my blogger blogid?
It's in your blogspot Dashboard url, for example: http://www2.blogger.com/posts.g?blogID=18083698

"18083698" is your blogid.

The tool can be download from this link

technorati tags:, ,

blogger/blogspot is running on tomcat 4.1.24 ?!

log in http://www.blogger.com/feeds/default/blogs

input invalid authentication info, it shows up:

BTW: Google do not have a custom error page ?!

see this image:

technorati tags:,

python.cn上的几个大牛

limodou 人称李木头,此人技术深厚,擅长写作技术blog,信仰“自己的才是大家的”!

Zoom. Quiet 人称woodpecker社区大妈,虽称大妈,不过看上去像是位艺术家,发型极具特色
http://blog.zoomquiet.org/pyblosxom/
http://www.douban.com/people/zoomq/

刘鑫 March.Liu
http://blog.csdn.net/ccat

宁柯
beyking@gmail.com
www.china-django.com

zsp(张沈鹏)

Install apache 2.0.x, mysql 5.0.*, php 5.2.0 on Mac OS X

1 install apache
./configure
make
sudo make install


apache installed on /usr/local/apache2

2 install mysql
cp -Rf mysql-5.0.* /System/Library/Frameworks/Mysql.framework/
ln -s /System/Library/Frameworks/Mysql.framework/mysql-5.0.* /usr/local/mysql
ln -s /usr/local/mysql/data /Volumes/WRK/mysql-4.1.22/data


start mysql (do NOT start as root):
/usr/local/mysql/bin/mysqld
stop mysql
/usr/local/mysql/bin/mysqladmin shutdown

3 install php
./configure --with-apxs2=/usr/local/apache2/bin/apxs --with-mysql=/usr/local/mysql --prefix=/usr/local/php
make
sudo make install
cp src/php-5.2.0/php.ini-dist /usr/local/php/php.ini

4 config apache
vi /usr/local/apache2/conf/httpd.conf

LoadModule php5_module        modules/libphp5.so
AddType application/x-httpd-php .php .phtml
AddType application/x-httpd-php-source .phps
PHPIniDir "/usr/local/php"

DirectoryIndex index.html index.html.var index.php

ln -s /usr/local/apache2/htdocs /Volumes/WRK/Apache2/htdocs

that's all.

cnn news on 01.09

And thanks for staying with us. Here I'm Rechard Lui at the CNN center in Atlanta with your news update this hour.

A massive plan to security Baghdad said to be at the center of President Bush's new Iraq strategy. CNN has learned under this plan the capital and its neighbourhoods will be cordoned off and more US Iraqi troops will be moved in. President is expected to tell us more during the speech which is expected to happen on Wednsday at 9:00pm Eastern.

Scientists may have alternatives to a controversial embryonic stem cells. Researchers at Wake Forest and Harvard say they found stem cells in amniotic fluid donated by pregnant women. They say they've extracted them without harming the mother or the fetus. And the cells hold the same possibilities as the embryonic stem cells.

Colorado's latest snow storm is hurting rescurers' efforts to save thousands of cows stranded in the snow. Helicopters are dropping bales of hay to feed hungry cattle and an agricultural official says that about thirty five hundred cattle may have died in the state so far. He adds there that surviving cattle face the threat of lung infections from stress and dehydration.

Home Security at the port of Mami reporting all secure today. The cargo area was shut and three men were detained yesterday. The driver raised suspicions at a security gate. He did not have the right ID and he indicated he was alone and there were really three men in the truck in total. The two iraqis and a Lebanese national are in local police custody.

Today is the fifth anniversay of the "No Child Left Behind" act. Education Secretary Margaret Spellings commemorated the anniversary with the speech to education leaders this morning. The law aims to ensure that all children can do reading and math skills at grade level by 2014.

And while the college football season is ending, the NFL postseason is still going. We are down to the final 18, in the case you've been counting. It is the Eagles and the Saints on saturday night. The Bears and Seahawks will be swore to square off there on Sunday afternoon. Ah, the coaches, they will be in the place they used to call home Baltimore on Saturday afternoon. And the Patriots meet the Chargers in Santiago on Sunday. Some good matches up there.

And that's the news this hour. Remember whether you are on line or watching TV, we're your source CNN for up-to-minute headlines anytime day and night. Have a great one!