Development
Random Alfred Extensions
0Random Alfred extensions I made just to kill off boredom. They turned out to be surprisingly useful!
Launch IDLE
Python bundled with Max OSX do have IDLE (Python IDE) but you need to invoke it directly from terminal. Make this command into Alfred extension make life a lot easier.
Translate with Bing
Sometime, I just need a quick English translation of some random text in any language (that Bing recognize) and don’t want to fire up web browser totally for that. This extension translate a message with Bing Translator and display result quickly with Growl notification. Really convenient.
Quickly add new task to Toodledo with Alfred
13I’ve been using Toodledo as my GTD solution for years. It’s an amazing productivity tool. Even though most people prefer Thing or Omnifocus, none offers powerful web API as well as wide range of notification and syncronization options. Toodledo also have great customer support which is a huge plus too.
Last month, Alfred (The most useful piece of software I’ve ever bought! Thanks, Andrew!) released a new update with included the long-awaited extension feature.
Recursively Delete Files and Directories with PHP
2คุณเคยประสบปัญหากับไฟล์ที่สร้างโดย PHP แล้วไม่สามารถลบได้ผ่าน FTP หรือ SSH ใช่หรือไม่? ผมขอแนะนำ Unlinker ซึ่งเป็น PHP Script ที่จะ Recursive เข้าไปลบ File และ Directory ทั้งหมดที่อยู่ใน Level เดียวกันและต่ำกว่าครับ ซึ่ง Script ตัวนี้ผมเขียนไว้เมื่อนานมาแล้ว ตั้งแต่เพิ่งเริ่มศึกษา PHP ใหม่ๆ (ดังนั้น Code เลยดูไม่ค่อยสวยเท่าไหร่) แต่พบว่ามันก็ยังมีประโยชน์อยู่เรื่อยๆ เวลาต้องทำงานกับระบบไฟล์ด้วย PHP หรือเวลาที่ CMS ทั้งหลายมันดันสร้างไฟล์ไม่พึงประสงค์ออกมา เลยเอาลองมาแจกดู เผื่อจะมีประโยชน์กับคนอื่นบ้างครับ
เวลาจะใช้ก็โยนมันไปไว้บน Server แล้วเรียก Script นี้ จากนั้นกดปุ่มยืนยันอีกรอบนึง แค่นี้ก็เรียบร้อยแล้วครับ ไม่ต้องแจ้งให้ Admin คอยลบอีกต่อไป
Random Thoughts on Web Application Development
2
อาทิตย์นี้หมดมุกครับ ปั่นแต่งานๆๆ (ฮว้ากกกกกกกกก) เลยจับเกร็ดเล็กเกร็ดน้อยที่นึกขึ้นมาได้ระหว่างทำงานมาเขียนรวมกันซะเลย
- Deadline ไม่ใช่ข้ออ้างที่จะเขียน Code ให้สกปรก ถึงจะทำงานตาม Requirement เสร็จออกมาได้ แต่เราจะต้องเสียใจอีกในไม่ช้าแน่นอน
- ในการเขียน Web App ความเป็นระเบียบของ Code นั้นสำคัญมาก เพราะมันเป็นอะไรที่เขียนได้ไม่มีวันเสร็จ เราต้องอยู่กับมันไปอีกนาน ถ้า Code เริ่มเละจะพาลไม่อยากยุ่งด้วยเอา
- ถึงจะเกลียดการ Hack (Code) แค่ไหน แต่หลายๆ ครั้งมันก็จำเป็น อย่างน้อยก็ Comment พร้อมลงชื่อไว้หน่อยว่าเรา Hack อะไรไป จะทำให้ชีวิตมีความสุขขึ้น เมื่อต้องกลับมาอ่าน Code ตัวเองในอีกหลายเดือนต่อมา
- ออกแบบระบบไว้ดี มีชัยไปกว่าครึ่ง
- การออกแบบระบบที่ดี ไม่ใช่แค่ให้มันทำงานตาม Requirement ได้ Optimize ที่สุดเท่านั้น แต่ต้องให้มันรองรับการเปลี่ยนแปลงในอนาคตด้วย
- เวลาเก็บ Log นอกจากจะบอก State ของโปรแกรมแล้ว บอกว่า Error อยู่ใน Class ไหน, Method ไหน จะช่วยให้การตามหาจุดที่ต้องแก้ไขทำได้สะดวกขึ้น
- อย่าสักแต่เก็บ Log แต่ต้องนึกถึงวิธีที่จะเอาข้อมูลจาก Log ออกมาดูใน Context ที่ต้องการด้วย ไม่งั้นก็จะกลับไป Debug ด้วยการ Print นู้นนี่มาดูอีกเหมือนเดิม
- เสียเวลาสักหน่อยเขียนระบบให้ Web Application เมลล์หาเราเมื่อเกิด Error จะช่วยให้เรา Support ปัญหาต่างๆ ได้สะดวก และทันท่วงทีขึ้นเยอะ
- อย่าเชื่อใจ Code ชาวบ้านมาก Code ที่ดูเป็นระเบียบไม่ได้แปลว่ามันเวิร์ค แต่แปลว่าเราจะทำความเข้าใจและเข้าไปทำให้มันเวิร์คได้ง่ายขึ้น
- การใช้ Framework ช่วยงานเราได้เยอะก็จริง แต่ต้องใช้ให้เป็นด้วย ไม่งั้นจะกลายเป็นเสียเวลา Implement Feature ที่ Framework มีให้อยู่แล้วไป
- ORM ช่วยให้ชีวิตง่ายขึ้นก็จริง แต่สุดท้ายเวลา Deadline ใกล้เข้ามา และติดปัญหา Performance เราก็เขียน Optimized Query Hack แทรกเข้าไปอยู่ดี
- คำที่ว่าเกลียดอะไรมักได้สิ่งนั้นนี่ท่าจะจริง ผมบ่นเรื่อง PHP ได้เป็นวันๆ แต่สุดท้ายมันดันเป็นภาษาที่ผมชำนาญมากกว่า Python สุดรักไปซะแล้ว (ต้องจับมันทำ Project อยู่ตลอดนี่นะ)
- อย่าเชื่อใจ Garbage Collection ของ PHP เด็ดขาด ทำลาย Object แบบ Manual ซะตั้งแต่ต้น จะช่วยประหยัดเวลาที่ต้องมาแก้ไข Memory Leak ทีหลังได้เยอะ หลายครั้งที่ผมได้ Memory กลับมาเป็นร้อย MB ด้วยคำสั่ง unset($unused_var) เพียงบรรทัดเดียว
เริ่มรู้สึกว่ายิ่งบ่นยิ่งมัน มีเรื่อยให้บ่นได้เรื่อยๆ ดูท่าว่าคงได้เขียนบ่นแนวๆ นี้ต่ออีกเป็นซีรีส์แหงๆ ใครมีอะไรจะบ่นเพิ่มเติมก็เขียนทิ้งไว้ใน Comment ได้นะครับ
PyCLIPS Windows Binary for Python 2.6
5I (and my friends) have to develop an expert system for my AI class. My team decided that we will use CLIPS and Python with PyCLIPS as an interface since it’s still being actively maintained. The only problem is that the current Windows binary is too old and only support Python 2.5.
So, I’ve successfully (in fact, accidentally) compiled PyCLIPS 1.0.7.348 with some version of MinGW on my friend‘s machine. The package was tested with Python 2.6 but it should work fine on any Python 2.x too. I won’t created an installer since it’s too much of a hassle. Just drop the package in your site-packages directory and you are good to go. Don’t forget to install CLIPS beforehand.
Download: pyclips-1.0.7.348-clips-6.24.win32-py2.6-unofficial.zip
P.S. I really want to use PyCLIPS icon as a leading image but it’s too small. :(


