วันพุธที่ 20 พฤษภาคม พ.ศ. 2552

WordPress: How to using SyntaxHighlighter Evolved ?

คำถาม:
อยากจะแสดง Source Code ของโปรแกรมเช่น Delphi, JAVA บน WordPress ให้สวยงาม เหมือนใน Tool ที่พัฒนา จะำทำอย่างไร ?

แนวทาง:
SyntaxHighlighter Evolved ช่วยได้ในกรณีนี้ โดยมีขั้นตอนตามนี้
ติดตั้ง Plugin ของ WordPress ที่ชื่อว่า SyntaxHighlighter Evolved
  1. Download SyntaxHighlighter Evolved
  2. หลังจากนั้นติดตั้ง Plugin ลงบน WordPress พร้อม Activated Plugin
หลังจากนั้น การใช้งานตอนที่จะ Post
  1. ตัวอย่างที่จะ Post source code JAVA ให้ใช้ Tag [java] [/java] เช่น
[java]
/**
* The HelloWorldApp class implements an application that
* simply prints "Hello World!" to standard output.
*/
class HelloWorldApp {
public static void main(String[] args) {
System.out.println("Hello World!"); // Display the string.
}
}
[/java]
หลังจาก Preview ก็จะได้ตามภาพข้างล่าง



กรณีไม่สำเร็จ:

  • ให้ดูใน header.php ภายใน Tag
    จะต้องมี

  • ใน footer.php จะต้องมี วางไว้ตรงไหนก็ได้


* header.php และ footer.php อยู่ที่ Appreance -> Editor

อ้างอิง:

วันอังคารที่ 17 มีนาคม พ.ศ. 2552

Network : How to determine which program is using a given port ?

Question:
คือว่าการ์ดแลนกระพริบตลอดทั้งวัน เลยมีความสงสัยว่าโปรแกรมอะไรวิ่งอยู่ ณ ตอนนั้นก็นีกออกแค่คำสั่งเดียวคือ ใช้คำสั่ง netstat ใน command prompt แต่ผลได้ดังภาพ คือรู้แต่ port ที่วิ่งอยู่ แต่ไม่รู้โปรแกรมที่ใช้งาน port นั้นๆ



Solution:
ถ้าอยากรู้ว่า program ไหนวิ่งอยู่ port ไหน ใช้คำสั่ง netstat -a -n -p tcp -b ก็จะทราบได้ทันทีว่าโปรแกรมไหนใช้งาน port ไหนอยู่


Credit:

วันจันทร์ที่ 9 มีนาคม พ.ศ. 2552

JSF: How can I set the action and actionListener in Backing Beans ?

[ Set the action ]
public String button_action() {
Hyperlink hyperTmp = new Hyperlink();
// Create method expression
MethodExpression me = (MethodExpression)this.getApplication().getExpressionFactory().createMethodExpression(
getFacesContext().getELContext(), "#{Page1.LinkTest_action}", String.class,new Class[] {});

hyperTmp.setActionExpression(me);
}

public String LinkTest_action() {
// TODO: Process the action
}

[ Set the actionListener ]


public String button_action() {
Hyperlink hyperTmp = new Hyperlink();
// Create method expression
MethodExpression me = (MethodExpression) this.getApplication().getExpressionFactory().createMethodExpression(
getFacesContext().getELContext(), "#{Page1.
LinkTest_actionListener}", null, new Class[]{ActionEvent.class});
hyperTmp.setActionListenerExpression(me);
}

public void LinkTest_actionListener(ActionEvent actionEvent) {
Hyperlink hyperTmp = (Hyperlink) actionEvent.getComponent();
}

อ้างอิง