Archive for the ‘Uncategorized’ Category
Framework Learning Curve
เมื่อกี๊เพิ่งเจอปัญหากับ Rails นิดหน่อยเกี่ยวกับ CSRF InvalidAuthenticityToken exception
ในหนังสือใช้ตัวอย่างนี้ แต่เวลาเขียนทดลองจริงมีอีกปัญหานึง .. สำหรับ framework ที่วิ่งเร็วปรู๊ดอย่างรวดเร็ว เอกสารที่ update ตามไม่ทันก็ทำให้การเรียนรู้ยากขึ้นไปอีกสำหรับ beginner ได้เหมือนกัน
ช่วยกันแปล พัฒนาไทยให้ก้าวไกลขึ้น
อ่านเจอบล๊อกของคุณ wiennat แล้วรู้สึกว่าโดนใจ
จากประสบการณ์ส่วนตัวที่ผ่านมาทำให้เห็นได้มากว่าปัญหาเรื่องภาษาเป็นกำแพงมหึมาที่ทำให้การพัฒนาในด้าน IT ของไทยไปได้ช้ามากๆ และไม่ค่อยมีคุณภาพ … เนื่องจากภาษาอังกฤษไม่ใช่ภาษาแม่ของเรา และ software ต่างๆถูกพัฒนาโดยใช้ภาษาอังกฤษเป็นหลัก ไม่ว่าจะเป็นภาษาที่ใช้เขียน โปรแกรมที่ใช้เขียน เอกสารประกอบ ฯลฯ ทำให้เวลาเราต้องการค้นหาข้อมูลเชิงลึกสามารถทำได้ยาก เพราะเวลาจะหาก็อาจจะไม่รู้หาโดยใช้คำว่าอะไร และหามาก็มีแต่ภาษาอังกฤษ ทำให้อ่านไม่รู้เรื่องอีก
ปัญหาที่ผมคิดว่าใหญ่กว่าคือผู้นำทางความคิดด้านไอที่ส่วนใหญ่ก็ใช้ภาษาอังกฤษเพื่อสื่อความรู้ใหม่ๆเป็นหลัก ยิ่งไม่สามารถติดตาม trend ที่มีประโยชน์ หรือซึมซับแนวคิดของบุคคลเก่งๆ ยิ่งแย่
พออ่านไม่รู้เรื่องก็อาจทำให้ท้อ ท้อก็ทำให้หยุดเรียนรู้สิ่งใหม่ๆ หยุดขวนขวาย รับส่ิงที่มีตามมีตามเกิด … การแก้ปัญหาผ่านการแปลก็เป็นการแก้ปัญหาทางหนึ่งที่ยั่งยืน ถึงแม้ว่าจะใช้เวลาและกำลังคนมาก แต่ก็น่าลองทำ
ผมขอเป็นเสียงสนับสนุนการแปลเอกสาร software ต่างๆเป็นภาษาไทยด้วยคนละกัน และใครๆที่อยากมีส่วนร่วม จะมากจะน้อยผมว่าก็ทำประโยชน์ให้ส่วนรวมได้ทั้งนั้น … Let’s do it
เซ็ทค่า Leopard Terminal สำหรับภาษาไทย
export LC_ALL=en_US.UTF-8
export LANG=en_US.UTF-8
แก้สองค่านี้แล้ว Mercurial command line work ภาษาไทยยังไม่เจ๊ง และ commit log ภาษาไทยของ svn work
Setting up Virtual Hosting on Leopard
This is how I set up virtual hosting to point to a “virtual” domain on my localhost for development and testing.
The problem actually comes from having to set RewriteBase as mentioned in the previous post. This is very inconvenient, as the .htaccess being deployed in production will be different from the .htaccess on my machine. The one on my machine requires a RewriteBase to /~Me/cake, whereas the one on the production server does not require this.
Since all files are under version control, setting RewriteBase and undoing the changes when deploying is not much fun at all.
After digging around, I found one (probably overengineered) solution. Hell, it works now, so this is a reminder in case I need to do all this again.
- First thing is to enable virtual hosting in /private/etc/apache2/httpd.conf by uncommenting the line “Include /private/etc/apache2/extra/httpd-vhosts.conf”.
- Then edit httpd-vhosts.conf. The setting looks something like:
NameVirtualHost *:80
<VirtualHost *:80>
DocumentRoot “/Library/WebServer/Documents”
</VirtualHost>
<VirtualHost *:80>
DocumentRoot “/Users/Me/Sites/cake/”
ServerName production
</VirtualHost>
The first VirtualHost block is the default host. I added this so that the old behavior works (as recommended in Apache’s documentation).
The second VirtualHost is the new “virtual” domain for local use. The domain name is “production”, so I can access the special web site using “http://production/”.
Since “production” is a domain name I made up, I must define a special lookup in /private/etc/hosts by adding a line to the file: “127.0.0.1 production”. What this means is when the OS looks up the domain “production”, it will resolve to IP 127.0.0.1.
Restart Apache by “sudo apachectl restart” and that should do it. Pointing to “http://production” should now show your CakePHP app site. RewriteBase is no longer needed. Deploying should be a bit easier.
MissingController in CakePHP if file with same name exists in root
Just found out that you can get a MissingController error from CakePHP if you have a file with the same name as the controller file in the root directory.
E.g. If you have a controller called CompanyInfosController (in /app/controllers/company_infos_controller.php), and you also have another file called /company_infos.php.
When this condition occurs, instead of $html->link(‘title’, ‘/company_infos’) calling the CompanyInfosController class action, it seems the framework does a redirect to the controller called RedirectController instead.
Haven’t looked into the code, dunno why.
Fixing CakePHP Tutorial 403/404 problems in Leopard
In case your newly created CakePHP site looks weird without any styling, try enabling the mod_rewrite (see “8.5 A Note on mod_rewrite“).
You might get a 403 Forbidden error when changing the AllowOverride directive to all. If you get one, open the Console and see Apache’s error log. It might be because you haven’t added FollowSymLinks option. Try adding that and the configuration should look something like:
<Directory “/Users/John/Sites/cake”>
Options Indexes MultiViews FollowSymLinks
AllowOverride All
Order allow,deny
Allow from all
</Directory>
Now, if everything works fine after that, cool. If you’re getting a 404 Not Found error saying something like:
The requested URL /Users/John/Sites/cake/app/webroot/ was not found on this server.
Chances are because you’re using Web Sharing in Leopard and your site is located in your <home>/Sites directory. If that’s so, try adding the RewriteBase directive to your .htaccess file in Cake’s root directory. The file should now look something like this:
<IfModule mod_rewrite.c>
RewriteEngine on
RewriteBase /~John/cake
RewriteRule ^$ app/webroot/ [L]
RewriteRule (.*) app/webroot/$1 [L]
</IfModule>
Hopefully that’ll fix the problem.
Current understanding of various technology
Service -> Higher-level API, uses one or more DAOs to load/save object (graph)
v
Dao -> consistent CRUD APIs for all objects/tables
v
ORM -> provides mapping and persistent management
==
Spring:
- brings all the different parts together (plug and play style)
- core -> dependency injection
- data -> DI for DAO layer, transaction/session management, etc
- config -> DI for configuration
EntLib:
- a family of libraries
- entlib objectbuilder -> dependency injection
- entlib daab -> similar to DaoManager in iBatis, but more like a library
does not use IDao interface but rely on IDbCommand instead
- entlib config -> probably similar to the config lib in spring, nhibernate, etc
(but genericized into a new library)
Castle project:
- a suite of libraries, mixing functionalities from Spring + Hibernate
- activerecord -> nhibernate attribute + active record pattern
- microkernel -> dependency injection
- windsor -> spring core or entlib objectbuilder + entlib config block
apache log4net:
= entlib logging block
Using Only External Monitor with MacBook Pro Closed on Windows XP
In Leopard, you can use only your external monitor for display by closing the MacBook Pro lid to put it to sleep, and then click on the connected mouse or keyboard to wake it up. When the notebook wakes up, only the external display will used, and the notebook screen will stay off.
In Windows, the default behavior does not seem to work. The problem I’m having is that after waking up the MacBook Pro, its screen is still on even when the lid is closed.
I just found a solution today. The fix is to use the NVidia nView Desktop Manager installed with BootCamp.
-
Go to Start -> Control Panel -> NVIDIA nView Desktop Manager
-
In the Desktop Management tab, click Enable to enable the nView Desktop Manager.
-
Click OK. You should see a small NVidia icon in your taskbar notification area (lower right corner of your screen).
-
Right click on the NVidia icon in the taskbar notification area, and then select nView Display Settings -> Single display -> <Your external monitor name>.
After setting to Single display on your external monitor, Windows XP should display everything in the external screen and turns the MacBook Pro screen off.
You can now close the MacBook Pro lid (which will put it to sleep), and then click your external mouse to wake it up again to get the behavior like Leopard.
ไม่สามารถสร้างสิ่งเดียวกันได้โดยการใช้วิธีการต่างกัน
ไปอ่านเจอ SvN blog เรื่อง Stanley Kubrick quotes เข้าแล้วเจอประโยคที่ชอบอยู่ประโยคนึงของสแตนลีย์ คิวบริกที่เป็นผู้กำกับหนังเรื่อง Eyes Wide Shut ที่ว่า
[On the topic of period costuming] What is very important is to get some actual clothes of the period to learn how they were originally made. To get them to look right, you really have to make them the same way.
เป็นไทยก็ประมาณว่าการเตรียมเสื้อผ้าสำหรับหนังพีเรียดประมาณพวกหนังเก่าๆหน่อยอย่าง Troy หรือพวกหนังเก่าสไตล์ยุโรปเช่น Sense and Sensibility…คิวบริกพูดว่าสิ่งที่สำคัญมากๆคือคุณต้องหาเสื้อผ้าจริงๆจากยุคเก่าๆนั้นมาเพื่อเรียนรู้ว่ามันถูกตัดเย็บอย่างไรด้วยวิธีการและวัสดุอะไร การที่คุณจะทำเสื้อผ้าสำหรับหนังให้ดูดีนั้นคุณจำเป็นที่จะต้องตัดเย็บ[เสื้อผ้า]ด้วยวิธีเดียวกับที่ทำกันเมื่อสมัยก่อน
สิ่งที่คิวบริกพูดทำให้ผมนึกถึงแนวคิดการทำงานและพัฒนา
ถ้าเราแค่ลอกแต่แบบเสื้อผ้าภายนอก ตัดมาก็อาจดูไม่สวยเท่า ไม่พอดีตัว ไม่ได้เก็บรายละเอียด ไม่เรียบร้อยคล้ายๆกันทางภายนอก แต่ต่างกันในแก่นแท้ ในรายละเอียด ในวิธีการตัดเย็บ
แต่ก็ไม่ใช่ไปลอก process เค้ามานะครับ Winston Churchill เคยพูดไว้ว่า “The short road to ruin is to emulate the methods of your adversary”
น่าจะเรียนรู้วิธีที่เค้าทำ เข้าใจวิธีที่เค้าทำ รู้ข้อจำกัด ข้อดี ข้อเสีย แล้วก็ apply ให้เข้ากับของเราจะดีกว่า เมื่อถึงแก่นก็จะเข้าใจธรรมชาติของสิ่งที่เราต้องทำ