วันเสาร์ที่ 3 พฤศจิกายน พ.ศ. 2555

Python? Django?

ช่วงนี้ Python กำลังรุมเข้ามา รวมทั้งคำถามต่าง ๆ มากมาย
ส่วนตัวแล้วใช้งาน Python ทำงานอยู่แล้ว  มันไม่ได้มีอะไรพิเศษมากมาย ไปกว่า ภาษาอื่น ๆ เท่าไหร่ แต่ที่ผมสนใจคือ ความเรียบง่าย และการจัดการที่เป็นระเบียบ มันเรียบง่าย แบบ "Simple is all complexities behind"

มันเป็นระเบียบจนบางคน บอกว่ามันเกินไปด้วย

แต่สำหรับผมที่เคยใช้ C PHP Java ผมคิดว่าสิ่งที่สำคัญของการพัฒนาร่วมกันคือ coding standard ซึ่งถ้าเป็นภาษาอื่น ๆ นั้น เวลาพัฒนาต้องมากำหนดกันให้รัดกุมเลยทีเดียว

อีกสิ่งหนึ่งที่สำคัญคือ Document on Coding หรือไม่ก็คู่มือการใช้งาน เพราะการพัฒนาอะไรขึ้นมานั้น ถ้าหากมีที่ไปที่มาได้แล้ว การดำเนินการต่อโดยตนเองหรือผู้อื่น นั้น ก็จะเป็นอะไรที่ง่ายต่อการเข้าใจได้

เพราะว่าหากเรากำลังพัฒนาอะไรซักอย่าง แล้วสามารถมีคนนำไปใช้ต่อได้นั้น ย่อมเป็นประโยชน์ไม่มากก็น้อย

เมื่อกล่าวถึงตรงนี้ ก็ขอ รวบรวมสิ่งที่ผมได้จากประสบการณ์ในการทำงานพัฒนาระบบ ดังนี้


  1. กำหนดไปให้แน่นอนเลยว่าเราจะพัฒนาอะไร
  2. ในสิ่งที่จะพัฒนานั้น สามารถแยกเป็นส่วนย่อย ๆ ได้หรือไม่ ถ้าได้ก็กำหนดให้แต่ละส่วนแยกออกจากกัน และสามารถรวมกันได้ในภายหลัง (http://en.wikipedia.org/wiki/Separation_of_concerns)
  3. จากส่วนต่างๆ ที่แยกออกมาจากกันนั้น ก็ให้ทำในแต่ละส่วนให้ดีที่สุด
  4. ถ้าหากในส่วนย่อย ๆ ใดมีคนที่เคยทำไว้แล้ว ให้นำกลับมาใช้ หรือนำมาปรับปรุงให้ดีขึ้น
  5. กำหนดอายุของระบบที่เราจะพัฒนา เช่น 5 ปี 10 ปี เพราะว่าไม่มีอะไรยืนยาว หรือไม่ก็กำหนดไปเลยว่าเมื่อถึงเวลาที่มีเทคโนโลยีอะไรที่ดีกว่า ก็แนะนำให้ลองเปลี่ยนแปลงดู
  6. นึกถึงคนอื่นที่ต้องมาสานต่อด้วย
  7. ทำทุกอย่างให้ง่าย เข้าใจง่าย อ่านง่าย ไว้

และสิ่งที่ผมเขียนไว้ ผมจะลองทำดูกับ django ที่ผมกำลังทำระบบอยู่
ref: http://en.wikipedia.org/wiki/Separation_of_concerns

วันศุกร์ที่ 2 พฤศจิกายน พ.ศ. 2555

ผ่านไปอีกวัน

มันผ่านไปด้วยอาการหืดหอบ

  1. ถ้าเป็นเมื่อ 5 ปีที่แล้ว ตัดสินใจได้เลย
  2. สิ่งที่ผมคิดจะทำ เหมือนกันกับที่ท่านกำลังจะทำ
  3. python มันยังครองโลกต่อไปอีก
  4. ชีวิตมีอะไรมากกว่างาน

วันพุธที่ 31 ตุลาคม พ.ศ. 2555

What make me here?

Life has no boundaries
...
Thank for พระพุทธเจ้า to give me the way to do
Thank to my family for living
Thank for my teacher to teach
Thank for friend to completed me
Thank for other to support me
...

Favorit
Music: Classic, Soundtrack,
Band: X-Japan, Within Temptation,
Movie: ET, Star war, Beautiful mind,
Cartoon: Ghibli
Country: Thailand, Japan, Germany,
Hobby: Traveling, Book, Movie,

Far Future
50-year old
A little house on High mountain
2 dogs run around me
A few farm
Fresh air

Near Future
Contribute my knowledge to community

Next
MQ i don't want to "lost" anything
Twisted Matrix "amazing project"

Migrate
PHP to Python
SQL to ORM
html to template
Web page to Web Application
Horizontal to Vertically
Everyone is user for system
"in Band, very skilled and less skilled musician need to adopt together"

Platform
2012
We need other platform
Codeigniter.... no
Cake PHP ... no
Zend ... no
Symfony ... no
Java? ... no
Python ... yes
django ... yes
"Simple is more complexities behind"

Software Project Management
2007
Flag ship, CRM
Project management on Trac
Revision control on SVN
{{Applications}}
CRM, Case management, Knowledge management
Sales Management, Marketing Management
Email Mass Marketing
Business Inteligent
{{Application}}
We'd get our platform?
Hosting service
Customization service
Software as service
Cloud service
Python
django, my hero
"Service on Software"

Size Does Matter
2006
Fast growing database, web application was delivered to biggest TV response company
AIX RS/600 was amazing in Thailand
PostgreSQL on AIX, Possible here!
... Now our system serve more than 150GB of data...
... more than 500 users concurrent ...
"Big Huge Giant"

Software Engineering
2003
Requirement analysis
Design
Documentation
Develop
Project management
Implement
Maintain
Version control was implement
CVS SVN
Software Test
Software Quality
"Imagine is more important"

Coding Era
2001
Open source came back
PHP + PostgreSQL+ Apache
First software/service served for businesses
All software written for web, web page!
"team work"

Telephony Network
2001
Move to PABX system
Where voice and data merge here!
Business applications, CRM, messaging system, monitoring software were introduced
Many software are integrated together to complete requirement
"meeting, meeting, business!"

Work!
2000
1-year computer networks, internet servers
ATM, Router, Switch had been setup to serve user
Some on MCU to make meeting over network
We served 600 users with single mail server! with Linux Debian
Open source begin!
Python first introduced
"i'm hungry to know more"

Big Moves
1999
Rosenheim, Germany was next moves
Signal Processing in Big Firm, Siemens
Linux first come in to my life
Environment change
Vision changes
Attitude changes
Life changes
Explore Resenheim
"2nd miracle, Amazing! Incridible"

University
1999
Electrical Engineering Department
Computer/Communication was my major
Digital Image processing using DSP was my project
i fork here
"First miracle, it happend all the time."

Technical School
1996
Knight Rider brought me here
"Time and Time to wait and go for get it"

Next School
1993
Math-Sci was my major here
Music, was my hobby
Trumpet, French-horn were my next instruments in school band
"in a Band, very skilled and low skilled musician need to adopt together"

School
1990
My school was near Wat
I had to walk to school from home every day
I played music on last 3 year in first school
My first instrument was melodeon
"music is one of meditation"

Childhood
I was the second child of three children
We lived close to Wat
I have to learn Buddhism without knowing it
"know nothing means know everything"

Begin
1977
I was born on 10 April
Male
Bangkok, Thailand was my birth place
"a Child can make things"

วันอาทิตย์ที่ 21 ตุลาคม พ.ศ. 2555

PHP Spreadsheet_Excel_Writer with text format

ในการสร้าง Excel ด้วย PHP นั้น ผมก็ใช้  Spreadsheet_Excel_Writer  เพื่อช่วยสร้าง Excel  
ปกติแล้ว เราก็กำหนด Format ของ ตัวเลข วันที่ ค่าเงิน จาก function setNumFormat() แต่พอต้องการแสดงหมายเลขโทรศัพท์ โดยเฉพาะที่ขึ้นต้นด้วย "0" ก็จะมีปัญหาที่เวลาแสดงใน excel แล้ว เลข "0" จะหายไปทำให้แสดงค่าผิดพลาด 

ค้นหาไปก็หลาย ๆ ที่แล้วก็บอกว่าให้ช้ setNumFormat('@') ตามนี้ (http://pear.php.net/manual/en/package.fileformats.spreadsheet-excel-writer.spreadsheet-excel-writer-format.setnumformat.php) แต่พอนำไปใช้งานก็ยังเป็นปัญหาอยู่

สุดท้ายก็ต้องไปแก้ที่ต้นทางเลยคือที่ Worksheet.php ตามนี้ (http://pear.php.net/bugs/bug.php?id=3514) หรือไม่ก็ไปใช้ writeString() แทน write() ที่ทำการตรวจสอบค่าทีหลัง 

แต่ผมใช้การกำหนด setNumFormat('@') เป็นอย่างนี้แล้วก็ไปเพิ่ม

function write($row, $col, $token, $format = null)
    {
        // leading zero or string format
        if ($format->_num_format=='@') // || preg_match("/^0/", $token))
               return $this->writeString($row,$col,$token,$format);


 สุดท้ายก็ขอขอบคุณ opensource ไว้เพราะว่าทำให้เราแก้ไขได้เอง และศึกษาเข้าไปในส่วนต่าง ๆ ได้อีก

วันเสาร์ที่ 15 กันยายน พ.ศ. 2555

Zimbra Collaboration Suite AdministrationZ

Zimbra Collaboration Suite Administration

ปลายสัปดาห์นี้ ต้องทำหน้าที่แทนน้องที่บริษัท เพื่อมาเรียนเรื่อง "Zimbra Collaboration Suite Administration" ณ มหาวิทยาลัยเกษตรศาสตร์ บางเขน โดยเรื่องนี้เป็นหนึ่งในโครงการ OSS4CORP โดยเจ้าภาพในการจัดงานเป็น SIPA นั่นแหละ จำได้ว่าแต่ก่อนเคยไปเรียนที่ SWPARK เหมือนกัน แต่ด้วยสถานที่ของ SWPARK เอง จึงยังดูไม่ค่อยดีเท่าไหร่  แต่มาครั้งนี้เนื่องจากโครงการนั้นมาใช้สถานที่ ณ มหาวิทยาลัย เกษตรศาสตร์ หลาย ๆ อย่างได้รับการปรับปรุงอย่างมาก

โดยส่วนตัวแล้ว ปกติใช้งาน postfix เป็น mail server และได้ทำการกำหนดค่าและติดตั้งระบบเองทั้งหมดตั้งแต่ mail server spam antivirus webmail เรียกได้ว่ากว่าจะใช้งานระบบได้ก็กินเวลาไปหลายวันเหมือนกัน เพราะว่านาน ๆ ทำที

ตัว Zimbra เองไม่ได้เป็นการพัฒนาระบบใหม่ตั้งแต่ mail server จนกระทั้ง web mail แต่หากเป็นการรวบรวม software หลาย ๆ ตัวเข้ามาเป็น Collaboration ซึ่งก็เป็นแนวทางที่ดี สำหรับหลาย ๆ คนที่คิดว่าจะเริ่มทำอะไรเองทั้งหมด Zimbra เองเป็นการนำ software ที่มีจุดเด่นแต่ละตัวมาประกอบกัน โดยรวบรวมการจัดการไว้ที่ Zimbra เองและในส่วนของการติดต่อกับผู้ใช้งานนั้น ก็มีพร้อมสำหรับผู้ใช้งานด้วย

ในการนำไปใช้งานนั้น หากเป็นองค์กรที่มีจำนวนผู้ใช้งานไม่มาก ผมก็คิดว่ายังไม่เหมาะสม เนื่องจาก Zimbra มีความสามารถเกินที่ใช้งานเกินไป และที่สำคัญ หากต้องติดตั้งใช้งานแล้ว ต้องมีเครื่องServer ที่รองรับด้วย ผมจึงแนะนำให้ไปใช้บริการที่เป็นลักษณะ cloud จะดีกว่า

แต่หากเป็นการนำไปใช้งานในองค์การระดับกลางถึงใหญ่ ซึ่งมีกำลังในการติดตั้งและมีผู้ดูแลระบบเอง ผมก็เห็นด้วย เพราะว่าระบบได้ออกแบบให้ใช้งานในหลาย ๆ ส่วนแทนระบบ Mail ในองค์กร ได้ดี 

ในส่วนตัวไม่มีอะไรใหม่ในการใช้งาน แต่คิดว่าจะเป็นประโยชน์มากต่อการนำไปใช้งานและนำไปพัฒนาระบบในส่วนของแนวคิดในการพัฒนาระบบเป็นอย่างดี



วันพฤหัสบดีที่ 2 สิงหาคม พ.ศ. 2555

Pentaho 3.8 Linux PostgreSQL. A Guilde to getting start with postgresql-8.4 on Mac

Pentaho 3.8 Linux PostgreSQL. A Guilde to getting start with postgresql-8.4 on Mac


After i configure many Pentaho BI on many machines. I have to do it again today for teach my student how to install and getting start on postgresql.

References


  1. http://www.prashantraju.com/2010/12/pentaho-3-7-with-mysql-postgresql-oracle-and-sql-server/
  2. https://docs.google.com/document/edit?id=1OnvHYsa-nYgwP8bjqRqjP5Vy-gLI5xomOHZtOvA00Ns&pli=1
  3. http://wiki.pentaho.com/display/ServerDoc2x/Configuring+for+PostgreSQL
  4. http://interestingittips.wordpress.com/2011/05/05/complete-pentaho-installation-on-ubuntu-part-2/
(1) and (2) are good articles to starting.
(3) and (4) are more articles to set after you see error about system listener.

Introduction

About

I assume you have installed java and postgresql on your system. And have privilege to create new database. 
Please follow (1) and (2) if you have not complete with Java and Postgresql

Deploying Platform

For me it is a good way to get everything pack into one source. So i download pentaho-source from here 3.8.0-stable

I want to setting my BI in my home directory so i extracted source to my home directory and change name to bi-3.8

wattana@localhost:/home/wattana/bi-3.8$

The following directories show have contents like these.

bi-3.8
|-- administration-console
|-- bi-server-ce

PostgreSQL Java Connector

You have to download postgresql java connector from here http://jdbc.postgresql.org/ . Then put java connector to library path like these.

wattana@localhost:/home/wattana/bi-3.8/biserver-ce/tomcat/lib/postgresql-8.4-703.jdbc4.jar
and
wattana@localhost:/home/wattana/bi-3.8/administration-console/jdbc/postgresql-8.4-703.jdbc4.jar


Configuring PostgreSQL Database

If you follow (2) you must edit script to run on postgresql. You can ask me for postgresql backup archive.!

to create databases run this command

wattana@localhost:/home/wattana $ su                                                    
wattana@localhost:/home/wattana $ su - postgres
postgres@localhost:/var/lib/postgersql $ createuser -d -s -P wattana      # create super user for database
# then create databases
wattana@localhost:/home/wattana $ createdb -U wattana shark
wattana@localhost:/home/wattana $ createdb -U wattana quartz
wattana@localhost:/home/wattana $ createdb -U wattana hibernate
wattana@localhost:/home/wattana $ createdb -U wattana sample data

After you created database you must open script files from (1)  and edit them correctly for postgresql

wattana@localhost:/home/wattana $ psql -U wattana -d hibernate < hibernate.sql wattana@localhost:/home/wattana $ psql -U wattana -d quartz < quarz.sql wattana@localhost:/home/wattana $ psql -U wattana -d shark < shark.sql wattana@localhost:/home/wattana $ psql -U wattana -d hibernate < sampledata.sql


Here you can now follow (2). It's perfect!

After that if you start pentaho by 
wattana@localhost:/home/wattana/bi-3.8/biserver-ce# ./start-pentaho.sh

you may get error about system listener error,


When trying to access the Pentaho BI platform (http://localhost:8080), if you have this error
Error while trying to execute startup sequence for org.pentaho.platform.scheduler.QuartzSystemListener
Then you’ll find a file pentaho.xml in biserver-ce/tomcat/conf/Catalina/localhost/
Replace the contents (or modify the settings) with the same from biserver-ce/tomcat/webapps/pentaho/META-INF/context.xml
Hope it helps someone.

You can follow (4) to solve this.

















วันพฤหัสบดีที่ 23 กุมภาพันธ์ พ.ศ. 2555

Auto-responder บน Postfix กับ Virtual Domain

ตามชื่อเลยครับ Auto-responder หรือบางคนก็เรียกว่า auto reply  ปกติแล้วการทำ auto-reply มันจะง่ายมากถ้าหากเป็นการติดตั้ง postfix แบบ domain เดียว เพราะค่า configure ต่าง ๆ สำหรับแต่ละ user ก็จะเป็นการกำหนดค่าของแต่ละ user ใน home directory นั่นเอง

แต่พอเป็น Virtual Domain/ User เราก็ต้องมาศึกษากันอีกทีว่าทำอย่างไร

พูดถึง Postfix พอเราไปดูก็จะพบว่า การใช้งาน Autoresponse ไม่ได้พูดถึงมานานแล้ว ก็คงเป็นเพราะว่าเดี๋ยวนี้เป็นการติดต่อแบบ realtime คือใช้งานผ่าน มือถือ social network แล้ว

แต่ก็ขอเขียนไว้ที่นี่ถึงวิธีการสักหน่อยเผื่อต้องใช้งาน auto-reply กันจริง ๆ

เริ่มจาก หน้านี้ http://workaround.org/ispmail/etch ก็จะพูดไว้ว่ามีคนทำ add-on ไว้เหมือนกันที่ http://www.remofritzsche.ch/goldfish/  แต่ก็อยากให้ไปอ่านต่อที่ http://eugenesklyar.com/roundcube-autoresponder-goldfish-autoreply-plugin เพื่อติดตั้ง plug-in ของ roundcube เพื่อเปิดให้ user ทำการกำหนดค่าเองได้ด้วย

พอผมมาดูก็ปรากฏว่าต้องมีการแก้ไขบางอย่างอีกนิดหน่อยกว่าจะใช้งานได้

แก้ไขไฟล์ autoresponder.php (ที่ได้จาก http://www.remofritzsche.ch/goldfish/ ตอนนั้นเป็น Version 1.0-STABLE)


/* General */
    $conf['cycle'] = 5 * 60;
   
    /* Logging */
    $conf['log_file_path'] = "/var/log/autoreply";
    $conf['write_log'] = true;
 
   
    # This query has to return the path (`path`) of the corresponding
    # maildir-Mailbox with email-address %m
    $conf['q_mailbox_path'] = "SELECT CONCAT('/home/vmail/', SUBSTRING_INDEX(email,'@',-1), '/', SUBSTRING_INDEX(email,'@',1), '/Maildir/') as `path` FROM virtual_users WHERE `email` = '%m'";
   
    # This query has to return the following fields from the autoresponder table: `from`, `to`, `email`, `message` where `enabled` = 2
    $conf['q_forwardings'] = "SELECT * FROM `autoresponder` WHERE `enabled` = 1 AND `force_enabled` = 1;";
   
    # This query has to activate every autoresponder entry which starts today
    $conf['q_enable_forwarding'] = "UPDATE `autoresponder` SET `enabled` = 1 WHERE `from` >= CURDATE();";
   

ภายหลังจากของใช้งานจาก /usr/bin/php autoresponder.php แล้วก็จะพบว่ามีการส่ง email ออกไปแล้วตามกำหนดค่าของ $conf['cycle'] คือเป็นการกำหนดว่าจะทำการส่ง auto-reply ให้กับ email ที่ส่งเข้ามาหา user คนนี้ไม่เกิน 5 นาที (5x60 วินาทีนั่นเอง)


วันอังคารที่ 14 กุมภาพันธ์ พ.ศ. 2555

ระบบต่อไป อะไรเอ๋ย?

ระบบต่อไป... อะไรเอ๋ย?

ดูเหมือนช่วงนี้วุ่น ๆ กับการติดตั้งเพื่อใช้งานระบบ นี่ก็พึ่งจะได้ระบบ Survey มาใช้งาน ด้วยระยะเวลาอันน้อยนิด

ต่อมาคงเป็นระบบประมาณนี้

http://www.postgis.org/documentation/casestudies/2008-09-rento/





แนวคิดแบบนี้จะติดตามมาอีกเยอะในอนาคต เช่น



  • จากตรงนี้ โรงหนังที่กำลังจะฉายเรื่อง Titanic ณ เวลา 14:00 น. มีที่ไหนบ้าง โดยใช้เวลาเดินทางไม่เกิน 30 นาที
  • ข้าวขาหมู อร่อย ๆ ที่ยังไม่เคยไปกิน และมีเพื่อนอยู่ใกล้ ตรงนั้น (จะได้ชวนกันไป)