WordPress的Permalinks与guid

这几天研究wordoress的时候,纠结在Permalinks和guid究竟有什么区别,官方对于这两个东西的解析是这样的:

Permalinks:

Permalinks are the permanent URLs to your individual weblog posts, as well as categories and other lists of weblog postings. A permalink is what another weblogger will use to link to your article (or section), or how you might send a link to your story in an e-mail message. The URL to each post should be permanent, and never change — hencepermalink.

guid:

(string) A link to the post. Note: One cannot rely upon the GUID to be the permalink (as it previously was in pre-2.5), Nor can you expect it to be a valid link to the post. It’s mearly a unique identifier, which so happens to be a link to the post at present.

据此,所以我认为Permalinks就是文章的链接,而guid只不过是一个唯一标识,也可能是pre-2.5以前的遗留物…所以如果你需要得到文章的链接,也就是需要获得permalink,而不是guid,因为它甚至可能不是一个合法的链接。

在Google里搜了很久,发现guid几乎只在WordPress的RSS中用到,在WordPress的fr:Marqueurs de Modele里可以找到这个函数

Description:
Affiche le nom d’une ou plusieurs catégories auxquelles appartient l’article au format RSS (en anglais). Ce marqueur doit être utilisé à l’intérieur de la Boucle.

Utilisation:
<?php the_category_rss(‘type’) ?>

在官方的Forums里(http://wordpress.org/support/topic/70616)也看到有一位高人这样描述:

Simply put, the GUID can be thought of as an unique ID — WP uses URIs and if you happen to change your URI, the GUID will not update because simply put, it does not need to.

However ‘sloppy’ this may appear it will not matter because as an example where the GUID appears in your RSS2 feed you will note: isPermaLink="false" which as stated by the spec:

isPermaLink is optional, its default value is true. If its value is false, the guid may not be assumed to be a url, or a url to anything in particular. (http://blogs.law.harvard.edu/tech/rss#ltguidgtSubelementOfLtitemgt)

So fear not, the GUIDs in your DB (though they may look sloppy because of a URI change) will not hurt you 🙂

另外当需要把blog迁移域名的时候也需要修改guid。

我们在WordPress的”设置”->”固定链接”里可以找到对Permalinks的设置,不过需要对配置文件作一些修改,否则一般情况下都会出现404错误,我在这里做一个总结:

1. WrodPress的.htaccess文件要开放写权限,这个可通过FTP工具进行设置

2. 在Apache的httpd.conf文件中找到LoadModule rewrite_module modules/mod_rewrite.so,取消前面的#

3. 同样在httpd.conf中查找指向WordPress安装目录的Directory tag,对其中的AllowOverride参数设置为FileInfo,关于AllowOverride的详细介绍,可参见http://www.phperz.com/server/Apache/102H05320092053.html

One of the JavaIdioms, “Double Brace Initialization”

Objects created by DoubleBraceInitialization will never be equal to objects created without it. So you would never use this for any class that needs a nontrivial equals(Object)method.

public class DoubleBraceInitialization {
    
    private String str;

    public DoubleBraceInitialization() {
        str = "double brace initialization";
    }
    
    /**
     * @return the str
     */
    public String getStr() {
        return str;
    }

    /**
     * @param str the str to set
     */
    public void setStr(String str) {
        this.str = str;
    }

    /* (non-Javadoc)
     * @see java.lang.Object#hashCode()
     */
    @Override
    public int hashCode() {
        final int prime = 31;
        int result = 1;
        result = prime * result + ((str == null) ? 0 : str.hashCode());
        return result;
    }
    /* (non-Javadoc)
     * @see java.lang.Object#equals(java.lang.Object)
     */
    @Override
    public boolean equals(Object obj) {
        if (this == obj) {
            return true;
        }
        if (obj == null) {
            return false;
        }
        if (getClass() != obj.getClass()) {
            System.out.print("Because " + this.getClass().getName() + "is different from " + obj.getClass().getName() + " , so answer is ");
            return false;
        }
        DoubleBraceInitialization other = (DoubleBraceInitialization) obj;
        if (str == null) {
            if (other.str != null) {
                return false;
            }
        } else if (!str.equals(other.str)) {
            System.out.print("Because str in " + this.getClass().getName() + "is different from " + obj.getClass().getName() + "'s, so answer is ");
            return false;
        }
        return true;
    }

    public static void main(String[] args) {
        DoubleBraceInitialization dbi1 = new DoubleBraceInitialization() {{
                this.setStr("double brace initialization");
        }};
        DoubleBraceInitialization dbi2 = new DoubleBraceInitialization();
        
        System.out.println("dbi1 vs dbi2 : " + dbi1.equals(dbi2));
    }
}

Standard out print:
Because DoubleBraceInitialization$1is different from DoubleBraceInitialization , so answer is dbi1 vs dbi2 : false

References:http://www.c2.com/cgi/wiki?DoubleBraceInitialization

Taste of String

String is always a popular topic in java. Beyond all question String is an object type. But sometimes it seems like a basic data type. Many website emphasize we should identify between one situation when we use String a = “abc” and the other when String a = new String(“abc”).

Why I say String sometimes looks like a basic data type. Let’s see a simple example first:

Continue reading Taste of String

互联网常见Open API文档资源(转)

      所谓的开放API(OpenAPI)是服务型网站常见的一种应用,网站的服务商将自己的网站服务封装成一系列API(Application Programming Interface,应用编程接口)开放出去,供第三方开发者使用,这种行为就叫做开放网站的API,所开放的API就被称作OpenAPI(开放API)。

      网站提供开放平台的API后,可以吸引一些第三方的开发人员在该平台上开发商业应用,平台提供商可以获得更多的流量与市场份额,第三方开发者不需要庞大的硬件与技术投资就可以轻松快捷的创业,从而达到双赢的目的,开放API是大平台发展、共享的途径,让开发者开发一个有价值应用,付出的成本更少,成功的机会更多。今天,OpenAPI作为互联网在线服务的发展基础,已经成为越来越多互联网企业发展服务的必然选择。下面我就列举一些常见网站服务的Open API文档资源索引。

Continue reading 互联网常见Open API文档资源(转)

深圳留学生创业大厦

前天去了一趟那里,感觉那里就是一个高科技产业园区,用6122c照了一些照片留念。给我最大感触的是那里有很多间大学的研究生院,也许只有这样的的后备力量支持,才能够使一个园区提升质的层次。

留学生大厦在这里:

查看大图
这个地方出没的人差不多除了园区的工人以外没有外人,一到上班时间,或者偶尔会发现一个人,很可能他会向你问路,他不是本地人。

Continue reading 深圳留学生创业大厦

Wanna be Your Code

If you are a programmer.

If you hearts have bounded together.

I’m not advertising for ms. But if you match the conditions above, you may share the feeling with me…

(To watch the movie you have to Install Silverlight(windows, mac) and knowledge about Persian Password if you want to know more)


Get Microsoft Silverlight

Treasure everything you have.

Google gone

This is a memorible day. Once I use Google to search information for at least 10 times everyday. He’s now finally gone.

Almost each dormate and dormates in the next dormitory just know baidu when I first in this school. But now they believe Google is better then Baidu and they all turned to use Google now. I told them Baidu is only for the guy who know nothing but entertaments and jokes. They just hang around the internet with no purpose.

Something is true from the fact that if you want to find the official information, you have to be more patient to look for it from the result provided by baidu. But Google is different. There is no other explaination for the question why baidu don’t put the most official information on the first place. Because baidu don’t consider you should know facts from origin. It may want you to tell the true or express your opinion upon other opinion. But can it possible to tell the true from this stupit way?

I always in favour of the attitude of Google towards the internet information. The pure information should provide for anyone first because you and me have the right to know what is a thing on earth.

In any case, the good new is you can still access to Google from the domain of HK, called the new Google home. Once upon a time, many and many strong men have devote themselves into this game making a wonderful situation in China with many new technoledge.

Now, http://www.google.cn/music/homepage is still remain normal when I’m writing this page. Can this address remind you the history of www.google.cn? Let’s pray for god and stay together around this site: http://www.google.com/prc/report.html.

Down

看了一个以前同学的博客,很漂亮的一个人,很丰富的阅历,当过校干部,当过乘务员,去过支教,去过亚乒赛和国际精英赛的组委会接待部,去过新东方当老师,去过很多次实习,还去过很多地方旅游…从我认识ta开始,一直以来ta都是很勤奋的人,在不断进取不断努力,从高考到现在,中学的时候很多老师都表扬ta多么的勤奋,经常给我们展示ta的作业有多工整,ta博客上有一段话:

我总是想,我现在要很努力很努力地去变得更好,变得更优秀,

等以后,我不要爸爸妈妈再为我失望,

不要再让爸爸这么辛苦地为我们付出,我要让爸爸妈妈过得更好。

却突然发现,这几年来,我一直在跑,一直在跑,

总是有一个声音在告诉我,当你休息的时候,不要忘了别人还在奔跑。

于是我没有停下,我不敢停下,一直地,一直地跑。

每个假期收到大家的短信说聚会什么的,总是因为各种各样不同的事情在外面忙活。

还没开始放寒假,就已经在思考春节后要做什么,要给自己一个怎样的安排才是最充实的。

却已经忘了,原来自己,已经好久好久没有好好地放一个长假了……

原来自己,真的好累好累。

总有一个声音在告诉我,当你休息的时候,不要忘了别人还在奔跑。这句话很适合我,现在,曾经,未来。

生活中有很多诱惑,很久以前听说过打哈欠可以传染,不久以前又有科学家发现懒惰也可以传染。不进取,没有决断,不够果断。

这么长时间以来,我除了在做自己感兴趣的事情以外似乎什么事都没干,有人说做感兴趣的事情的时候进步得最快,也最轻松,最快乐。

今天上课的时候老师说,平时自己辛辛苦苦专研出一个课题要去发表,要申请贷款,得到的只有一点儿报酬,刚能够生活,相反,有些人付出的劳动不大,思考得也并不多,但得到的确是用也用不完。这就是不同。

人各有志,但是走进社会,就需要有很好的展示能力,最后老师说,其实,没有什么职位是不一样的。

是对自己的安慰,还屈服于社会现状…

爸爸妈妈经常说要保重身体,“人一睁眼一闭眼就过去了”,然而有人却说,你轻轻划过的一生,究竟给社会留下了什么,是雁过无痕吗?

四年的时候就快过了,这一站,很多人,很多事都不同了,为了自己为了别人,继续努力。

20100311

很拥挤的桌面依然放着三件东西。