วันจันทร์ที่ 26 กันยายน พ.ศ. 2554
Socket
InetAddress
ในคลาส InetAddress นั้นไม่มี public constructor แต่มี public static factory methods สำหรับสร้าง instance ของคลาส เช่น
public static InetAddress getLocalHost() throws UnkhowHostException;ซึ่งจะให้ InetAddress ของเครื่องที่ทำงาน หลังจากนั้นอาจจะใช้
public String getHostName();
public String getHostAddress();
Tomcat Http Server and Servlet Container
โดยทั่วไป servlet containers แบ่งออกเป็น 2 ประเภท ตามความสัมพันธ์กับ http server คือ
1. Standalone Servlet Container เป็น Servlet Container ที่ติดมากับ http server นั้นเลย
2. Add-on Servlet Container เป็นโปรแกรม Servlet Container ที่เราสามารถ plug-in กับ http server ที่ไม่มี servlet container โดยตรง เช่น Tomcat servlet container
ตอนที่ servlets ถูกพัฒนาขึ้นเป็นรุ่น 1.0 นั้น http server ส่วนใหญ่ยังไม่มี servlet container จึงยังไม่สามารถทำงาน servlet ได้ ดังนั้น Sun microsystem จึงต้องสร้าง Java Web Server ออกมาเป็นแม่แบบของ http server ที่มี servlet container แบบ standalone ให้นักพัฒนาโปรแกรมใช้สร้างและทดสอบ servlet รวมท้้งเป็น http server ที่ใช้งานได้จริงด้วย และต่อมาได้พัฒนาโดยโครงการ Jakarta-Tomcat ได้พัฒนา Tomcat ซึ่งเป็น servlet container แม่แบบสำหรับ servlet รุ่น 2.0
วันพุธที่ 22 มิถุนายน พ.ศ. 2554
Derivation
- นำสัญลักษณ์เริ่มต้น(start symbol) S เป็นจุดเริ่มต้นของการกระจายวากยสัมพันธ์ และกำหนดให้สายสัญลักษณ์บนตัวขวามือของโปรดักชั่น S เป็น "สายอักขระก่อกำเนิด" (สายอักขระก่อกำเนิด อาจประกอบด้วย Terminal Symbol หรือ Non-Terminal Symbol)
- ดำเนินกิจกรรมกระจายสายอักขระก่อกำเนิด โดยการเลือกโปรดักชั่น A-->aBb ที่สอดคล้องกับสัญลักษณ์ไม่สิ้นสุด A บนสายอักขระก่อกำเนิด เพื่อนำตัวประกอบขวามือของโปรดักชั่นมาแทนที่สัญลักษณ์ A บนสายอักขระก่อกำเนิด
- ดำเนินกิจกรรมกระจายสายอักขระจนกระทั่งไม่สามารถนำโปรดักชั่นใดมากระจายสายอักขระได้อีก จากนั้นตรวจสอบว่า สายอักขระที่ถูกผลิดตรงกับประโยคที่นำมาตรวจสอบหรือไม่
Java Thread
public class ThreadShowName extends Thread{
public static void main(String args[]){
ThreadShowName thread1,thread2;
thread1 = new ThreadShowName();
thread2 = new ThreadShowName();
thread1.start();
thread2.start();
}
public void run(){
int pause;
for(int i=0;i<10;i++){
try{
System.out.println(getName()+" being executed.");
pause = (int)(Math.random()*3000);
sleep(pause); //0-3 seconds
}
catch(InterruptedException interruptEx){
System.out.println(interruptEx);
}
}
}
}
วันอาทิตย์ที่ 19 มิถุนายน พ.ศ. 2554
The Lexical Analysis Driver (Scanner)
For lexical analysis , we can consider the input source program as a long sequence of characters with two pointers: a current pointer and a lookahead pointer.
When lexical analysis begins to find the next token, current and lookahead both point to the same character:
In the algorithm , four actions will be performed on these pointers:
1.GetChar : Moves the lookahead pointer ahead one character and returns.
2.Retract : Moves the lookahead pointer back one character.
3.Accept : Moves the current pointer ahead to the lookahead pointer.
4.Return : Returns a token consisting of a class and value , as well as performs any actions associated with that state , e.g., installing an identifier into the name table.
The driver program scans the input program and consults the entry at Table[State,InputChar] for the new state. The entry at Table[State,InputChar] consists of a new state and perhaps an action to be performed before moving to the new state:
Algorithm : Driver for Lexical Analysis
WHILE there is more input
InputChar := GetChar
State := Table[0,InputChar]
WHILE State <> Blank
InputChar := GetChar
State := Table[State,InputChar]
ENDWHILE
Retract
Accept
Return token = (Class,Value)
ENDWHILE
In the algorithm for the lexical analysis driver , retract is neccessary when a token is found because the algorithm will have scanned one character too far.
วันอังคารที่ 14 มิถุนายน พ.ศ. 2554
CWM?
CWM คือตัวอักษรย่อมาจาก Clock Work Mod โดยสำหรับท่านที่กำลังจะเริ่มเล่น CWR สิ่งที่ต้องมีในเครื่องท่านก็คือ MAGLDR 1.13 ในเครื่องก่อน และอีกอันนึงที่สำคัญสำหรับการอัพรอมคือ CWR Partition Size แล้วเราจะรู้ได้ยังไงว่า รอมที่เราจะลงใช้ Partition Size เท่าไหร่ ก็ดูตามนี้เลย หลักๆมันมี 3 แบบ (ยกเว้นแต่บางอันคนทำรอมจะกำหนดเป็นแบบอื่นซึ่งเค้าจะต้องบอกไว้)
- Partition Size 150 MB เหมาะสำหรับพวก Base Rom ทั้งหลาย เช่น CyanogenMod , AOSP และ MIUI
- Partition Size 250 MB เหมาะสำหรับพวก Standard SENSE Rom ทั้งหลาย เช่น Rom ที่ได้มาจาก HTC Desire หรือ Evo
- Partition Size 400 MB เหมาะสำหรับพวก Rom ขนาดใหญ่ เช่น Rom ที่ได้มาจากรุ่น Desire HD รวมถึงรอมที่ต้องการ data2sd
ส่วนวิธีการติดตั้งก็คือ
- โหลด Partition Size ที่ต้องการจะติดตั้งมา
- แตกไฟล์ไว้ในเครื่องและเข้า USB Flasher ใน MAGLDR 1.13 เอาไว้
- รัน DAF.exe แล้วทำตามขั้นตอน
- หาโหลด rom ที่ต้องการแบบ zip มาแล้วโยนลง SD
- หลังจากติดตั้งเสร็จเครื่องจะรีบูทใหม่,กดปุ่ม Power ค้างไว้ และเลือก AD Recovery จากหน้าเมนู
- Recovery ก็จะโหลดขึ้นมาแล้วหล่ะ