Home | Syndication | Delicious | Douban | Twitter

Playing with MLDonkey

May 24th, 2009

If you're a non-Windows user, Linux or Mac, whatever, and want a client to connect eDonkey network, probably you'll try aMule which is a clone of eMule. I'm not saying that aMule sucks, but… it's just not good enough. Actually we do have another choice, MLDonkey. Know what's coolest? MLDonkey is a multi-protocol P2P client. In addition to eDonkey, it also supports BitTorrent, HTTP, FTP, FastTrack, etc. Check out the full list.

Ubuntu repository has MLDonkey, but the version is a bit little old. If you don't mind, it's easy to get it installed through apt-get utility, of course. I'm going to compile MLDonkey from source code, because it's also easy to do the compilation.

Firstly install the prerequisites to make your enviroment ready for compiling:

$ sudo apt-get install ocaml libbz2-dev libgd2-xpm-dev libmagic-dev

Then get the source package and compile it:

$ tar jxvf mldonkey-3.0.0.tar.bz2
$ cd mldonkey-3.0.0
$ ./configure
$ make

No necessary to run any command like 'sudo make install' to finish the installation, because what we need is only one file. It's mlnet generated after compiling. Just copy it to any place you want, e.g., /usr/local/bin.

$ sudo cp mlnet /usr/local/bin

The installation is done!

Run mlnet to start MLDonkey:

$ mlnet &

A working folder, .mldonkey, is created in the current logged-in user's home directory during the first running.

Two official ways are provided to interact with MLDonkey:

  • CLI via telnet. Default port is 4000. Try telnet localhost 4000
  • web interface via browser. Default port is 4080. Try http://localhost:4080

If you dislike both and want a full-function GUI tool, you can try Sancho. CLI is my favorite. The following is a list of common-use commands.

> ?
short help

> ??
long help

> save
save options into the configuration files

> kill
shutdown MLDonkey

> q
exit the CLI admin console

> users
print all MLDonkey users

> whoami
print the current logged-in MLDonkey user

> passwd <thepwd>
change your password

> auth <username> <password>
authicate yourself before executing any directive

> networks
print the enabled networks currently

> disable <num>
disable the specified network

> set client_name <new-client-name>
set the client name

> set allowed_ips "ip1 ip2 ip3"
set which IPs have access to admin consoles.
For example,
> set allowed_ips "127.0.0.1 192.168.0.157"

> set max_hard_download_rate <digit>
set the maximal download rate. 0 means umlimited.
For example,
> set max_hard_download_rate 0

> servers <URL>
load servers from a file or a URL
For example,
> servers http://www.emule.org.cn/server.met

> n <server name or IP> [<port>]
add a new server manually
For example,
> n no1.eserver.emule.org.cn 8080
> n no2.eserver.emule.org.cn 8080

> vm
print the connected servers

> dllink <download-link>
add a download task

> vd
print the downloading tasks

> reshare
check shared files for removal

By default the downloaded files can be found in $HOME/.mldonkey/incoming/files or $HOME/.mldonkey/incoming/directories. Just move the downloaded files out, then run the above 'reshare' command.

BTW, I'm using Ubuntu Linux 9.04 when writing this post.

Say Goodbye to Partial Content in Google Reader

May 22nd, 2009

Hate those feeds not providing full content? Users of Firefox and Google Reader don't have to suffer more, like me. There are always sweet workarounds for us. Extensibility is the power.

First of all, install greasemonkey which allows using javascript to change web pages on-the-fly. It likes a kind of container for javascript in Firefox. Then go to userscripts.org, and install this script: google reader full feed changer.

According to your OS, you can find a .js file under the folder

  • Ubuntu Linux: $HOME/.mozilla/firefox/profile_id/gm_scripts/
  • Windows XP: %APPDATA%\Mozilla\Firefox\Profiles\profile_id\gm_scripts\

Use your favorite editor to open it, and add your definitions in SITE_INFO like the following code snippet:

{
    url: 'http://chinese.wsj.com',
    xpath: '//div[@id="A"]',
    charset: 'gb2312'
},
{
    url: 'http://cn.reuters.com/',
    xpath: '//div[@id="resizeableText"]'
},
{
    url: 'http://www.ftchinese.com/',
    xpath: '//div[@class="content"]'
},
{
    url: 'http://www.infzm.com',
    xpath: '//div[@id="content-context"]'
}

url: define the domain name(s). If the URLs of feed and detail page have different domains, you need to define them all, for example,
      url: 'http://(www|feed).openow.net'
      url: 'http://(huang.yunsong.net|feeds2.feedburner.com)'

xpath: define the HTML tag before the content. You can find the tag in the HTML source code of any detail page.

charset: define the character set of the detail page. It's an optional parameter.

OK. That's it!

Hmm… feeling… too much technical above. It might be a bit little boring and not easy to get started. Some of you doesn't like it. Right? OK, here comes an independent compiled Firefox add-on for making Google Reader better. Try it instead. Have fun!

NVIDIA Graphics Driver 180 Not Stable

April 25th, 2009

Everything was fine when my ThinkPad T61p worked with the version 177 or 173 of NVIDIA Graphics Driver. When I got a notification that there was a new version 180 available, I was happy to upgrade it at once. Then problems came… sometimes my laptop got sudden black-screen crash on both Ubuntu 8.10 and 9.04! Yes, it's black-screen, not Microsoft style blue-screen.

I found the following entries in /var/log/messages

Apr 25 12:35:56 hystp2 kernel: [ 5123.002987] Xorg[2927]: segfault at 5 ip b64df209 sp bfb99f60 error 4 in nvidia_drv.so[b6491000+3b4000]
Apr 25 12:35:56 hystp2 bonobo-activation-server (huangys-6077): could not associate with desktop session: Failed to connect to socket /tmp/dbus-n45hu1LoDE

Seems that keeping crash is caused by NVIDIA driver. I have to switch back to 173. Is there any better solution than back to an old version?

Years passed, lacking of hardware driver support is still a big problem for Linux promotion. Although NVIDIA driver has bugs, it supports Linux better than ATI. Speaking of ATI driver for Linux… it really sucks.

Hotmail Enables Free POP3 Access

March 25th, 2009

Guess it's an old news already. The Hotmail's POP3 access service, which was provided to Hotmail Plus subscribers only, is free now! Lots of people have switched or are switching to Gmail which provides many great features including free POP3 and IMAP access services, but it's still a good thing to see this happen to Hotmail, right?

POP3 server: pop3.live.com
port: 995
security: SSL
username: yours@hotmail.com (or any other domains supported by Microsoft, e.g., msn.com, live.com)

SMTP server: smtp.live.com
port: 587
security: TLS
authentication required: Yes. Use your POP username here.

Rocks! WordPress MU + HyperDB

March 22nd, 2009

Indeed it's very easy to get WPMU installed and up, but you'll find the number of tables in WPMU database increases every time a new blog is created. If you're providing public blogging service, the number of tables is going to 100, 1000, … very soon. Yes, WPMU is great, but the tables keep increasing, that may drive you mad. I was mad, at least.

In WPMU version 2.7, there are 9 global tables: blogs, blog_versions, registration_log, signups, site, sitecategories, sitemeta, usermeta, users. These 9 tables are fixed and serving for WPMU system globally. Every blog has its own 8 tables: comments, links, options, postmeta, posts, terms, term_relationships, term_taxonomy. These 8 tables are created over and over every new blog is created.

This designing is cool and useful from scalability view, especially for those big blogging service providers, wordpress.com is a good example. But WPMU uses only one database by default, it's hard to manage the excessive tables in one database, and the performance should also not be good. OK, here comes HyperDB, which can solve this problem. Actually HyperDB is derived from the code using by wordpress.com.

Before starting installing and configuring, we need to define a rule for databases. In this post, the rule is:

  • One database (wpmu_db0) for the global tables and the tables of first blog. It can be called global database.
  • Additional 3 databases (wpmu_db1, wpmu_db2, wpmu_db3) for the tables of other blogs, each database serves 2 blogs.

Of course, you can define your own rules based-on your needs. It's flexible.

We can start now. The first thing is to set up a standard WPMU using the global database in the installation wizard. After that, go to WordPress website and download HyperDB. The version I'm using is 2008-11-27. There are three files in HyperDB package:

  • db.php, which needs to be uploaded to wp-content directory
  • db-settings.php, which needs to be uploaded to the directory that holds wp-config.php
  • readme.txt, oh, you know what it means

Then add the following lines near the top of wp-config.php

define('WPMU', true);
require('db-settings.php');

Then add the blow code at the bottom of db-settings.php

// a handy function for mapping blog tables to dataset
function add_blog_tables($ds, $blog_id){
    add_db_table($ds, 'wp_' . $blog_id . '_comments');
    add_db_table($ds, 'wp_' . $blog_id . '_links');
    add_db_table($ds, 'wp_' . $blog_id . '_options');
    add_db_table($ds, 'wp_' . $blog_id . '_postmeta');
    add_db_table($ds, 'wp_' . $blog_id . '_posts');
    add_db_table($ds, 'wp_' . $blog_id . '_terms');
    add_db_table($ds, 'wp_' . $blog_id . '_term_relationships');
    add_db_table($ds, 'wp_' . $blog_id . '_term_taxonomy');
}

// add databases
add_db_server('global', 0, 'mysql3326_1', 1, 1, 'localhost:3326', '', 'wpmu_db0', 'wpuser', 'thepwd');
add_db_server('s1', 0, 'mysql3326_2', 1, 1, 'localhost:3326', '', 'wpmu_db1', 'wpuser', 'thepwd');
add_db_server('s2', 0, 'mysql3306_1', 1, 1, 'localhost:3306', '', 'wpmu_db2', 'wpuser', 'thepwd');
add_db_server('s3', 0, 'mysql3306_2', 1, 1, 'localhost:3306', '', 'wpmu_db3', 'wpuser', 'thepwd');

// add global tables which are in global database
add_db_table('global',  'wp_blogs');
add_db_table('global', 'wp_blog_versions');
add_db_table('global', 'wp_registration_log');
add_db_table('global', 'wp_signups');
add_db_table('global', 'wp_site');
add_db_table('global', 'wp_sitecategories');
add_db_table('global', 'wp_sitemeta');
add_db_table('global', 'wp_usermeta');

// add the tables for the first blog (created during wpmu installation)
// the first blog's tables are in global database
// of course, you can move it to any database you want
add_blog_tables('global', 1);

$dbsnum=3; // 3 additional databases
$blogs_per_db=2; // each database serves 2 blogs

for($db_id=1; $db_id<=$dbsnum; $db_id++){
    $dataset = 's' . $db_id;
    $max = $db_id * $blogs_per_db + 1; // include
    $min = $max - $blogs_per_db + 1; // include
    for($blog_id=$min; $blog_id<=$max; $blog_id++){
        add_blog_tables($dataset, $blog_id);
    }
}

That's it!

WordPress MU Local Installation

March 11th, 2009

Resovling Domain Names Locally

Wanna try WPMU on local machine? If you use localhost or 127.0.0.1 as the server address directly, you always get a message similar to the following:

Do not use an IP address (like 127.0.0.1) as your server address. Do not use a single word hostname like localhost.

That means a FQDN is needed, the good thing is that it's easy to resolve domain names virtually locally. Open the hosts file:

  • C:\WINDOWS\system32\drivers\etc\hosts (Windows)
  • /etc/hosts (Linux)

Add or modify something, and make sure there is a line like the following in the file:

127.0.0.1    localhost hys.lan bloga.hys.lan blogb.hys.lan blogc.hys.lan blogd.hys.lan

Here, hys.lan is used to install WPMU, blog(a-d).hys.lan are addresses for testing, I'll use these four to create weblogs.

Configuring Apache

Make sure two things:

  • Apache is listening on port 80, because WPMU doesn't support server address with port number.
  • mod_rewrite is enabled.

Then adds a virtual host section:

<VirtualHost *:80>
  DocumentRoot /opt/wordpress-mu
  ServerName hys.lan
  ServerAlias *.hys.lan
  <Directory "/opt/wordpress-mu">
    AllowOverride FileInfo
    Order allow,deny
    Allow from all
  </Directory>
</VirtualHost>

Preparing Database

Create an empty database, and grant permissions to a database user.

mysql> create database wpmu_db;
mysql> grant all privileges on wpmu_db.* to wpuser@'%' identified by 'thepwd';
mysql> flush privileges;

Installing WPMU

It's very easy to get WPMU up. Open your browser, and type the server address, in my case, it's http://hys.lan. Provide the required information, and press the "Submit" button to go. Waiting for a while, WPMU is installed and runs successfully.

Enable OpenSSL Support for PHP on Windows

March 11th, 2009

As a prerequisite, two libraries must be existing in your Windows system: libeay32.dll and ssleay32.dll. Two ways to achieve this:

  • Install OpenSSL for Windows
  • Or, copy these two files to C:\WINDOWS\system32 folder. They're shipped with PHP package, you can find them in PHP root folder.

OK, it's time to open php.ini by using any text editor, and remove the semicolon before the following line:

extension=php_openssl.dll

Done!

Dropbox

January 10th, 2009

Cloud Computing 越来越引人注目,成为时尚,storage 作为一个最现实的需求,有不少厂商涉足,比如 Amazon S3、box.net、Windows Live SkyDrive 等等,在这纷繁的服务之中,Dropbox 是很有理由引人注目的。

Dropbox 不仅仅是让用户将本地文件上传到其服务器,而且还很细致地保存了每一次文件更新时的修订(revision)。用过 CVS/SVN 等版本管理系统的人对此应该很熟悉。是否有必要保存所有文件的修订版,这是一个仁者见仁、智者见智的事情,也要视乎用户的具体需求。Dropbox 也可以考虑提供一些配置项,让进阶用户可以自行控制。

Dropbox 的客户端非常小巧,且支持 Windows, Mac, Linux 三大主流桌面操作系统,这样的做法很好地兼容了用户现有的习惯,这个小小的客户端将本地数据与远程数据进行同步,对用户来说,一切都是透明的。我最初接触 Dropbox 的客户端时就立刻想起了 TortoiseCVSTortoiseSVN 这两个很酷的 CVS/SVN 客户端。我猜 Dropbox 的开发团队的灵感应该多少来自于这两只“乌龟”。

在用户本地,Dropbox 指定一个本地目录作为其工作目录,这样就要求所有受管资源都位于此目录下,这自然是一种简单、易懂的方式,但其实可以做的更灵活一些,允许用户在本地文件系统中任意漫游指定需要加入到 Dropbox 管理矩阵中的资源。与此相关联的一个需求是,Dropbox 需要一个忽略机制,即,允许忽略受管父资源旗下的某些符合条件的子资源。

Dropbox 也为图片管理提供一种新思路,它最大限度地利用了现有的文件系统的资源组织模式,一个目录映射成一个相册。受到现有文件系统的局限,这种图片管理方式简则简矣,但缺少必要的进阶图片管理的手段。我觉得至少需要支持图片信息的编辑,比如 title、description、camera、geographic、tag 等,可以利用多种手段达到这一目的,包括图片元数据或者 Dropbox 提供额外的字段来支持。

进一步地,Dropbox 可以在公共知识资源的共享与共建、API 等方面做些改进。一个渐趋完美的 online/cloud storage 是很可期待的。

@ Beijing Capital Airport

[April 21st, 2009] 如果感觉 Dropbox 还不错,想注册的话,请用这个 referral 地址来注册吧 https://www.getdropbox.com/referrals/NTIwOTAwNzk 这样大家都能得到额外的 250MB 免费空间 :-)

Make You Organized

December 29th, 2008

手头事情太多?好记性不如烂笔头,于是开一个小文档,一条一条地写下来,或者安装一个便笺簿程式来记录,可是换台机器就看不到了。要是能有一个 online todo list manager 就好了。好吧,这就是 RTM 要帮助你的地方了。

RTM 是一个极简单的网站,提供单一的在线任务管理。用不着介绍。直接注册、登录,就可以开始了。

如果不喜欢每次都得打开浏览器来查看和管理自己的 todo list,下面这个名为 Tasque 的小工具就是你所需要的。

Tasque is a simple task management app (TODO list) for the Linux Desktop.

Tasque 包含在了 Ubuntu 8.10 的库中,直接

$ sudo apt-get install tasque

对于较低的版本 8.04 Hardy 和 7.10 Gutsy,可以使用 PPA 中的包。

运行它,选择 RTM 作为任务管理的后端,并给予 Tasque 访问你的 RTM 的帐号的授权就可以了。

如果你想从便携设备,比如 iPhone/iPod Touch, Windows Mobile, BlackBerry 上使用 RTM,你需要购买 RTM Pro service.