Archive for June, 2009


SEO Strategies(1) – from “Building Findable Website”, Aaron Walter

读书时做的笔记,懒的翻译成中文了。这是第一部分,明天有时间研究一下Microformat.

1. Strictly follow the standards of W3C. You can validate your web page by the tool at: http://validator.w3c.org/.

2. Decrease the ratio of markup to content, improve the page load time and improve the communication of the information hierarchy of your page.

3. Image Replacement:

Replace the img tag which shows the logo or the most important information of this page with a <h1> tag. The content of <h1> tag will be the details introduction of the page or the logo, with indentation to place that can not display on the screen, and a background image setted to be the real image file with its name renamed to be more meaningful. This strategy can only be used once for any certain page since it is better to limit the <h1> tag into only once for a page.

4. Signals of Quality:

1) Number of inbound links to the page from reputable sources, which is the way Google does.

2) Web standards are not 100 percent gurantee of top page ranking, but important to it. Therefore pages should follow the standards as closely as possible.

5. Highly valued tags for search engines:

1) <title>, keep it concise and natural. <title> page title | organization or site name | short keyword-rich phrase </title>

2) <strong> and <en>, elevating certain part of the content’s ranking within the information hierarchy

3) <a>, title attribute inside <a> tag, and also include target keywords in the link labels. An inbound link with the same keyword in the label as your site target is extremely effective.

6. Meta:

1) keywords in <meta> is useless, while description is still important. Limit the characters in <description> between 100 to 150 which is better for search engines to display.

2) use lang for multilingual site, like <meta name=”description” lang=”en-us” content=”" /> and <meta name=”description” lang=”zh-cn” content=”" />

3) No need to use robots in tag. <meta name=”robots” content=”all” />

4) Never use refresh attribute since it might be penalized for bait-and-switch strategy.

5) Always include content-type.

6) Use <meta name=”robots” value=”noindex,nofollow” /> to prevent certain page be indexed by the search engine.

Add class=”robots-nocontent” to those tags that you wish to hide like ads.

7. Making Images Visible:

1) When the image is just used for decoration, apply it to css file as a background.

2) Always use alt attribute to give short introduction of the image

3) If alt is not long enough, use longdesc instead, which can link to a footnote to have more details.

Java查漏补缺3-Swing中的文本绑定监听

在做简单的Swing开发中,会经常遇到这样的情况,需啊监听文本框的内容的变化。比如一个最简单的例子就是如果登陆框中用户名和密码都不为空的时候,登陆按钮才被激活。

在查看事件的时候,很多人第一眼看到的就是InputMethod下面的caretPositionChanged和inputMethodTextChanged。无论从文档还是从函数名字来看,这两个函数似乎都是我们所需要实现的方法。可惜当你填满了里面的内容,DEBUG的时候,会发现无论如何你改变你的输入框的内容,根本都不会触发这两个事件。在Sun的论坛上,有个人回了这样一句话来解决这个问题:“A component will only receive input method events from input methods if it also overrides getInputMethodRequests to return an InputMethodRequests instance.”

不愿意为这个问题多纠结,给出解决方案就是使用DocumentListener。这个接口提供了三个方法来侦听所绑定的文本的内容。对于我们需要的监听对象,直接添加这个侦听器,并实行其中的方法即可。

Document doc1 = jTextFieldId.getDocument();
doc1.addDocumentListener(new DocumentListener() {
            String name;
            String pwd;

            public void insertUpdate(DocumentEvent e) {
                name = jTextFieldId.getText();
                pwd = new String(jPasswordFieldPassword.getPassword());
                if(!name.equals("") && !pwd.equals("")){
                    jButtonSignIn.setEnabled(true);
                } else {
                    jButtonSignIn.setEnabled(false);
                }

            }

            public void removeUpdate(DocumentEvent e) {
                name = jTextFieldId.getText();
                pwd = new String(jPasswordFieldPassword.getPassword());
                if(!name.equals("") && !pwd.equals("")){
                    jButtonSignIn.setEnabled(true);
                } else {
                    jButtonSignIn.setEnabled(false);
                }
            }

            public void changedUpdate(DocumentEvent e) {

            }
        });

墨大考场

这考场的资历可不是一般小地方能够比的,大,老,高。

在此鄙视一下iPhone的照相功能,用手触碰的直接结果就是照片极度容易虚。为什么它就不能在侧面加一个键呢?还是w910i好用。。。

直接上照片吧。

我的座位往前看,那是林立的脑袋。。。然后蓝色的后面是厕所,上面红色的是暖气?

右半边的侧玻璃,有教堂的感觉吧。。。

向左边看过,一望无际的同学在默默等待考试的结束

中间部分的考场,我至少在这坐过2次。

一侧的考场,请忽略掉路人。。

最后一张,从外面看。。网上找的,考试的时候,门口就是密密麻麻的人群

iPhone升级

1. 将iTunes升级到最新版本,目前的最新是8.2。我的电脑上的版本是8.0,打开iTunes程序,会自动检测到有最新版本问是否需要升级。直接点升级下载即可。大小为74.1MB。
2.打开最新版本的iTunes之后,系统会自动检测到有最新的iPhone OS 3.0下载,点击下载后会在Application中开始download。大小为230.1MB。在选择的过程中,它有两个选项,分别是只下载不安装盒下载后安装。我选择的是后者,下载完成以后,iPhone开始自动同步。
3.大约过了20-30分钟,所有的都自动完成了。升级后的iPhone,原来的程序全部都没有了,需要自己再次更新。多出来了一个程序叫做Voice Memos,大概应该是录音用的吧。
总之,如果是原版正常机器,升级是十分简单而且没有任何风险的。

Java查漏补缺2 - 等于判断

基础的只是大家都很清楚,对于原始类型如int, float,直接用==就可以比较。对于Class类型的,在Java中使用的是reference的比较,因此需要使用的是equals.

Integer a1 = new Integer(1);
Integer a2 = new Integer(1);
System.out.println(a1==a2); //false
System.out.println(a1.equals(a2)); //true

因此在上述代码中,尽管使用的看上去就是int,但是因为实际已经使用了Integer,所以单纯使用==是不能比较的。

对于自己定义的类型,如果直接使用equals来比较,将会同样返回非期望的值。因为新定义的类,一般不会去重写equals的方法,而会直接调用其父类的equals方法,将也是直接比较reference。如果我们需要比较自定义的类型的时候,只需要重写equals方法就可以了。

class MyClass{
        private int count;
        public MyClass(int a){
            this.count=a;
        }

    @Override
    public boolean equals(Object obj) {
        MyClass newmc = (MyClass)obj;
        return this.count==newmc.count ? true : false;
    }

MyClass m1 = new MyClass(1);
MyClass m2 = new MyClass(1);
System.out.println(m1==m2);
System.out.println(m1.equals(m2));

Java查漏补缺1-Binding时间

在编程语言中,有两种binding方式,一是在compile期间binding,被称作Early-binding,一种是在execute期间binding,被称作Late-binding。
在Java中,更多的采用的是Late-binding这种方式。要做一个比较好的解释,可以看看关于继承的例子。以下这段代码显示了一个很简单的继承关系,父类是Shape,子类是Circle和Rectangle,其中分别实现了各自的draw()方法。

public class Shape {
    public void draw(){
        System.out.println("Draw shape");
    }
}

public class Circle extends Shape{
    public void draw(){
        System.out.println("Draw circle");
    }
}

public class Rectangle extends Shape{
    public void draw(){
        System.out.println("Draw rectangle");
    }
}

public class Test {
    public static void main(String[] args){
            Shape shape = new Shape();
            shape.draw();
            Shape shape1 = new Rectangle();
            shape1.draw();
            Shape shape2 = new Circle();
            shape2.draw();
        }
}

在以上的示例中,我们在main函数中看到生成了三个分别是以上三个类的实例,但是它们共用了同样的Shape声明。这也就是Java最重要的多态的之所在。不过不是本文的重点,略过。我们发现既然三个实例享有同样的声明,在编译期间,编译器是无法判断到底每一个实例属于的是哪一个类,需要调用的是哪一个draw方法。而在执行期间,run-time会自动根据new关键字对应的类型,将其binding上。这就是所谓的late-binding。在传统的大多数非OOP语言中,early-binding占据绝大多数。总之,early-binding意味着在程序编译期间,运行时系统将确定需要调用的函数的地址,而late-binding则会在系统运行时根据当时情况动态决定。(在C++中,也支持类似的late-binding,不过需要显示的加以virtual关键字)

试一下各种插件显示代码效果如何

测试代码:

public class Test{
    public static void main(String[] args){
        System.out.println("Hello World");
    }
}

博客更新情况

近两天对博客进行了很多功能和样式上的改进,有些可以直接看出下效果,有的还需要等待时日检验。

1)添加Now Reading模块,可以查看当前阅读的书籍和已经阅读的书籍。

2)添加Tag Cloud模块,采用滚动的球状模型,视觉感不错,但是在处理中中文上还存在一定的问题,因为没有FLASH,没有办处理锯齿状问题。会在接下来几天找到机会解决这一问题。

3)调整了整个博客的链接格式,将原来的动态地址调整为静态链接,链接格式为/category/post-name。同时也改变了tag等的链接名称。方便搜索引擎。

4)加强了回复模块功能,可以针对回复进行回复。

5)添加了sitemap自动生成模块,并自动更新到各大搜索引擎。

所有的更新都要感谢提供widgets的这些作者们,wordpress的确是个强大的东西,还有更多更多值得研究的。下一步把英文博客也要进行改版。

放松

考完了试,觉得人一下就松懈下来,想紧都紧不起来。昨天在Baillieu,本想找个位置好好做点事情的,但是放眼望去,所有的位置都被占据了,大家都在热火朝天的紧张复习之中。也是哪像我,考试才开始3天,就已经结束了3/4,只剩下最后一门开卷只有30分还在遥远的两周以后?

于是,吃喝睡逛成了主题,当然不是逛街,只是逛逛各种网站。虽然平常忙里偷闲也不停歇,但这几天算是吧我这一两个月落下的都补齐了。PS:不要想得太离谱,我指的是Travelling类型的网站。

同时尝试着开发了一下iPhone的程序,目前正在继续调试之中,随时会有成果汇报。

死神来了

不是要讨论这部电影,是看到了今天的新闻的第一反应。AF447这架班机,一共有5个人逃脱幸免遇难。其中的一对夫妻,昨天在奥地利发生了车祸,女的当场死亡,男的重伤。这不是和电影里面的情节很相似吗?

那这是不是有可能法航的残骸也是假的,然后其实很多乘客都去了另一个时空,正在海岸边安营扎寨由一个白人医生指挥呢?

再提一点,那几个中国的本溪某企业的领导们,据说他们的行程是里约到巴黎到香港到沈阳。从巴黎转机没话可说,但是到香港是第一天上午,从香港回沈阳的航班是第二天下午还是商务舱。大家都能知道些什么了吧。虽然背后说死去的人不是那么好,但是。。。想想那个所谓的新奥尔良市长多么内敛啊。

再就是我9月份回国的飞机,本来是777-300ER的,已经比较满意了。现在突然一下给我改成了A380,还真是觉得喜出望外啊。本来在逛飞友论坛的时候,看到有人发帖子说新航从下个月起,从新加坡到香港的飞机中的一班改由A380执飞,心里就在默默的祈祷是我那班。上官网一查,果然而且我这次是两个A380来回都是。运气相当不错,赞!完全的不需要我年底从悉尼专门去坐A380了。

Older Entries
  • English Version

    • Cannot read Chinese? Please take a look at my English site, hope you can find more you need there!
  • 感谢支持

  • twitter

    facebook

    linkedin

  • Categories