Pinyo's Programming and Software Notes

Monday, May 28, 2007

Installing and Configuring CDT in Eclipse

(May 28, 2007)

Today, I tried to use CDT to develop a very simple program, HelloWorld. However, I encountered so many difficulties: cannot debug (error launching session) and weird exit value: -1073741515 (no output occurred, program terminated immediately). Oh, my OS is Windows XP 32 bits, and this blog is intended for Windows system only.

However, program was built successfully, but I could not run it by double clicking on its executable file. It said "cannot find cygwin1.dll". Thus, I went to update environment variables PATH by appending C:\cygwin\bin. This solved the problem, and I could run the program from outside Eclipse environment.

For debug problem, it can be fixed by deleting spawner.dll in directory:

C:\eclipse_32\plugins\org.eclipse.cdt.core.win32_3.1.0.200606261600\os\win32\x86

This is due to CDT bug in Windows box. Thanks to http://max.berger.name/howto/cdt/ar01s04.jsp#configuring.

But, I still could not run the program without debugging inside Eclipse. My program terminated immediately after I ran it. Eclipse displayed exit value: -1073741515. I tried copy the cygwin1.dll to the executable directory. Then, every thing seemed fine. The real problem is after I updated system variable, I did not restart Eclipse to allow it re-read system variables. Namely, after updating any system variables, we need to restart applications to make the change effective.

Labels: ,

Friday, March 16, 2007

Yahoo! UI Library
(Mar 16, 2007)

การสร้างเว็บอินเตอร์เฟซบางอย่างเป็นเรื่องที่ค่อนข้างซับซ้อน โดยเฉพาะ tree และ menu bar แต่เรื่องทุกอย่างก็อาจจะง่ายขึ้นถ้าหากเรารู้จักใช้ไลบรารี ที่เค้าผลิดมาไว้ให้แล้ว และในที่นี้จะขอพูดถึง Yahoo! UI Library

ไลบรารีอันนี้มีของให้เลือกใช้เยอะมาก ยิ่งไปกว่านั้นมันยังมีลิขสิทธิ์แบบ BSD ซึ่งถือว่าเป็นแบบที่เปิดกว้างมาก เราสามารถเอาไปใช้ได้โดยไม่ต้องห่วงเรื่องข้อจำกัดการใช้มากนัก ส่วนในบทความนี้จะขอเขียนบางอย่างไว้กันลืม ซึ่งก็คือลักษณะทั่วๆไปของการใช้งาน

ในคอมโพเนนต์ส่วนใหญ่ที่มีอยู่ในไลบรารีจะต้องถูกประการ id และ class เช่น
แต่นั่นยังไม่สามารถทำให้มันปรากฎออกมาได้จริง เพราะจะต้องมีโค้ดจาวาสคริปต์มาทำการสร้างและเรียกใช้มันขึ้นมาจริงๆเสียก่อน และขั้นตอนนี้จะขาดไปไม่ได้เลย ซึ่งก็ขอให้ดูจากตัวอย่างที่ทาง Yahoo! ให้มา โดยจาวาสคริปต์ที่ว่าจะอยู่ตรงต้นๆไฟล์ตามปรกติ

นอกจากนี้ยังอยากให้สังเกตด้วยว่า id ที่ประกาศที่จริงก็เหมือนกับชื่อตัวแปร ดังนั้นจะซ้ำกันไม่ได้ เป็นต้นว่า ถ้าหากเราต้องการแสดงต้นไม้สองต้น เราก็ต้องประกาศ id ต้นไม้ทั้งสองให้ต่างกันไปเลย และ id นี่แหละที่จะต้องถูกนำไปใส่อยู่ในจาวาสคริปต์เพื่อให้การแสดงคอมโพเนนต์สามารถทำได้โดยสมบูรณ์ และขอให้จำเพิ่มเติมด้วยว่าในกรณีที่คอมโพเนนต์ต่างๆมันไม่ปรากฏออกมาส่วนใหญ่ก็เพราะตั้งค่า id ซ้ำบ้างหรือลืมจัดจาวาสคริปต์สำหรับมัน

Labels: , , , ,

Tuesday, January 02, 2007

Garuda-Font Rendering Problem in Windows XP
ปัญหาการแสดงผลฟอนต์การูดาในวินโดวส์เอ็กซ์พี
(Jan 2, 2006)

Rendering hint of Garuda font (downloadable from LTN) may be not complete or good enough to render this font on the screen, esp. on LCD screen, as we can see from the following figure. In the figure, some characters, such as จ, obviously has rendering problem. They are not smooth.Microsoft ClearType technology can help about this. We can enable this feature as shown in http://www.microsoft.com/typography/links/news.aspx?NID=2241. After we enable the feature, the problem will be gone.

Friday, December 15, 2006

Start Learning MFC from the Ground Up
(Dec 15, 2006)

I start learning MFC today from the most basic things. The first things I want to make note is some simple, yet important functions:
1. TextOut() [CDC] put string to a window
2. CBitMap::LoadBitMap()
3. ShowWindow() [CWnd]
4. AfxMessageBox()

However, when I tried to build a simple MFC program, I found it was difficult to get to the point if we used 'New-project Wizard' and asked it to create MFC program. The best way for this is
  1. Start with Win32 Application
  2. Go to project properties and change 'Use of MFC' to shared or static library (depending on your own preference)
Strictness of Microsoft compiler is increased from the last few years. Old MFC books may have some codes that does not work. Most of them are string constants. We can use CString( "problematic string constants" ) to solve the problem.

Wednesday, November 22, 2006

หัดใช้ OpenOffice.org
(Nov 22, 2006)

วันนี้หัดใช้ OpenOffice นิดหน่อย โดยเฉพาะเรื่องของสมการ
พบว่า

1. การใส่สมการมีลักษณะคล้าย LaTex แต่มีข้อดีตรงที่มันมีการแสดงผลรูปสมการออกมาให้เห็นทันที

2. เวลาที่เราเลื่อนเคอร์เซอร์ไปที่สูตรแบบ LaTex OpenOffice ก็จะตีกรอบให้ด้วยว่ามันตรงกับตรงไหนของผลลัพธ์

3. จากข้อสอง ในทางกลับกัน ถ้าเราไปคลิกที่ผลลัพธ์ มันก็จะเลื่อนเคอร์เซอร์ตรงสูตรไปให้เราด้วย ซึ่งทำให้การทำงานค่อนข้างจะสะดวกขึ้นมากเมื่อเทียบกับ WinEdt

4. การทำฟอนต์ตัวหนาต่างกับ LaTex พอสมควร ใน OpenOffice เราจะใช้ bold{A} โดยไม่มี \ นำหน้า แต่ใน LaTex เราใช้ \mathbf{A} ในความเห็นของเราตรงนี้ OpenOffice ทำได้ดีกว่า

5. จาก OpenOffice Wiki (http://wiki.services.openoffice.org/wiki/FAQ:Formula) เราพบว่ายังไม่มีระบบการทำ alignment โดยตรง แต่สามาระใช้ matrix หรือ phantom เข้ามาแก้ไขได้อย่างสวยงาม (เราชอบวิธี matrix เพราะเป็นธรรมชาติกับเราดี) ดังนี้ [เอามาจากหน้า FAQ]
matrix{
alignr x+y # {}={} # alignl 2 ##
alignr x # {}={} # alignl 2-y
}


แต่เราก็ยังไม่เข้าใจอยู่ดีว่าทำไมเวลาจะใช้เครื่องหมายเท่ากับเราต้องใช้ {}={} แทนที่จะเป็น = เฉยๆ เรื่องนี้คงต้องศึกษากันต่อไป

6. เราได้เรียนรู้การใช้คำสั่ง stack ที่เอาไว้ซ้อนตัวอักษร พร้อมกับทำให้รู้ว่ามันเป็นวิธีที่จะทำให้ใช้วงเล็บปีกกาใหญ่ได้อย่างแยบยล ดังนี้ [เอามาจากฟอรัมที่ openoffice.org]

left none
stack{{bold{y[0] = a_0 x[0]}} #
{bold{y[1] = a_1 x[1]+ a_1 x[0] + b_1 y[0]}} #
{bold{y[2] = a_0 x[2]+ a_1 x[1] + a_2 x[0] + b_1 y[1] + b_2 y[0]}}
} right rbrace

7. ตอนที่เราจะทำให้เกิดการนับสมการใน Writer เราก็ทำได้ด้วยการพิมพ์ fn จากนั้น higlight มันแล้วกด F3 เพื่อให้เกิดการแปลงเป็น autotext สมการก็จะนับไปเรื่อยๆ ถ้าต้องการให้นับตามบท ก็ให้ดับเบิลคลิกไปที่ตัวเลขนั้นแล้วก็เปลี่ยน Level ไปเป็นค่าที่ควรจะเป็น (ยังไม่แน่ใจว่าทำงานได้จริงรึเปล่า)

8. Comment ในสมการใส่ได้โดยใช้ %%

9. ถ้าต้องการใส่ข้อความลงในสมการ หรือ อักขระที่เป็นคำสงวนก็ให้ใช้ " " มาครอบส่วนนั้นๆไว้ เช่น ใช้ "#" เพื่อแสดงเครื่องหมาย # ในสมการ

10. อักขระพิเศษ เช่น lambda ให้ใช้ %lambda

11. คู่มือ math แบบด่วนจี๋ของ OO.org = http://documentation.openoffice.org/manuals/oooauthors2/0111GS-GettingStartedWithMath.pdf

12. ถ้าจะใช้เศษส่วน (fraction) ใช้ a over b

Friday, November 17, 2006

Tracking IP Address from E-Mail Header
(Nov 18, 2006)

เราพบว่าสามารถที่จะแทร็คที่มาในระดับ ISP จาก e-mail header ได้ โดยขั้นแรกเราจะต้ัองให้ mail client แสดงหัวเมล์มาให้หมด (พวก google, yahoo, และ hotmail ก็ทำได้เหมือนกัน) จากนั้นก็หาว่า เมล์นี้ได้รับมาจากไหนเป็นที่แรก (มันอาจจะส่งต่อๆกันมาเรื่อยๆ) เมื่อรู้แล้วก็ลองใช้ software บนเน็ตสองอันนี้คือ

http://aruljohn.com/cgi-bin/track.cgi
หรือลองจาก http://aruljohn.com/cgi-bin/track.cgi

แต่มันก็จะแทร็คไปถึงได้แค่ระดับ ISP เท่านั้นนะ ต่อจากนั้นก็คงต้องเป็นหน้าที่ของตำรวจแล้วล่ะถ้าอยากรู้มากกว่านั้น

Monday, November 13, 2006

Anatomy Software:
(Nov 13, 2006)

I am interested in this anatomy software: ADAM Interactive Anatomy 4 (http://www.adam.com/aia/index.html). Well, if I find another similar software, I will add it in this blog.

Note: JourneyEd offers this software at about 80 USD.