June 2009

AJAX Framework Survey

There are a lot of AJAX frameworks available. How to choose it?
So I need to survey and evaluate which framework will suit my applications.

I am starting by selecting some from Google AJAX Libraries API such as

  • jQuery (& jQueryUI)
  • MooTools
  • dojo
  • YUI

and this is how this story begins...

Additional libraries

  • Ext JS

How to let the browser know about our RSS-feed

If we need to inform user's browser to know about rss feed services in our website, try this code in head section of page.

<link href="http://www.semicolon.in.th/rss.xml" title="semicolon.in.th RSS" type="application/rss+xml" rel="alternate"/>

Google Web Elements -- cool widget for your web!

To get familiar with Google Web Elements, just take a look at http://www.google.com/webelements/

We can easily add google widgets in our website such as Calendar, Custom Search, Conversation, Maps by using the Google Web Elements.

Thank you again, Google!

Ubuntu LiveCD Customization

Reference: https://help.ubuntu.com/community/LiveCDCustomization

Start up preparation (normal environment -- Can be skipped to "Prepare and chroot", if files are prepared.)
Install required tools

sudo aptitude install squashfs-tools genisoimage
sudo modprobe squashfs

Prepare working base

mkdir ~/live
mv ubuntu-9.04-desktop-amd64.iso ~/live
cd ~/live

Extract original CD content

mkdir mnt

HTTP Basic Authentication

Today, I have to find the way to authenticate my application with web server via HTTP basic authentication. And this is how it is done.

1. Pack username and password into this format

username:password

such as

janitor:topsecret

2. Then encode it with base64 so that our sample will become

amFuaXRvcjp0b3BzZWNyZXQ=

3. Add "Authorization" header to HTTP session

Authorization: Basic amFuaXRvcjp0b3BzZWNyZXQ=

References
http://en.wikipedia.org/wiki/Basic_access_authentication

PHP: Performance tips (translated and rearranged based on code.google.com)

Tip จากพี่ใหญ่ใจดี Google ครับ
ต้นฉบับ: http://code.google.com/speed/articles/optimizing-php.html
ผู้เขียน: Eric Higgins, Google Webmaster

PHP Performance Tips

  • อย่า copy ตัวแปรอย่างไร้ประโยชน์
    ในบางครั้งมือใหม่ PHP จะพยายามทำให้ code ดูสะอาดอ่านง่ายขึ้นด้วยการ copy ค่ามาใส่ตัวแปรที่ชื่อสั้น ๆ ซึ่งทำให้เปลือง memory เพิ่มขึ้นอีกเท่าหนึ่ง และแน่นอนทำให้ช้าลงด้วย จากตัวอย่างด้านล่าง ถ้า user ส่ง description ขนาด 512kB เข้ามาทาง textarea จะทำให้กิน memory ถึง 1MB เลยทีเดียว
    BAD: $description = $_POST['description']; echo $description;
    

Common Practice: SQL

  • ไม่ควร Update Field ที่อยู่ใน Search Criteria ของ UPDATE statement เช่น
    UPDATE INVOICEDETAIL SET ITEMNO = ITEMNO + 1 WHERE ITEMNO BETWEEN 5 AND 10

    เนื่องจากทำให้เกิดความไม่แน่นอน (Doubt) ของ query