Posts

Showing posts from August, 2009

T-SQL Recursion

** Support SQL 2005 up # ใช้ในกรณีที่ข้อมูลเป็นลักษณะ หัวหน้าและลูกน้อง อยากรู้ว่าหัวหน้าคนนี้มีลูกน้องคือใครบ้างเป็นต้น WITH T_Reports (t_mitm,t_sitm,level) AS ( SELECT t_mitm, t_sitm, 0 as level FROM bom WHERE ltrim(rtrim(t_mitm)) = 'xx-xx' UNION ALL SELECT b.t_mitm, b.t_sitm, level + 1 FROM bom b INNER JOIN T_Reports as t ON t.t_sitm = b.t_mitm ) select * from T_Reports order by level,t_mitm อธิบาย หมายถึง การสร้างตารางเสมือน T_Reports แล้วทำการนำค่า จาก Query ที่ 1,2 ไปใส่ในตาราง T_Reports

วิธีการเปลี่ยนโซนของเวลา

# dpkg-reconfigure tzdata แล้วเลือกเป็น Asia > Bangkok

XWindows on Server

วิธีการทำให้ Ubuntu Server มี XWindows ครับ # sudo apt-get install ubuntu-desktop

ขั้นตอนแรกหลังจากติดตั้งเสร็จแล้ว

ให้ทำการอัพเดตก่อนที่จะติดตั้งอะไรเพิ่มเติม # sudo apt-get update

Send Mail by PHP Function

ยังเหลือกรณีที่เขียนโปรแกรมใช้ Function mail ใน PHP ยังไม่สามารถส่งเมลล์ได้ให้ทำการลงตัวนี้เพิ่มเข้าไป SMTP # apt-get install postfix แล้วจะสามารถส่งเมลล์ได้เลยครับ เขียน PHP ดังนี้ $to = " prompratan.n@rockworth.com "; $subject = "Test mail"; $message = "Hello! This is a simple email message."; $from = " someonelse@example.com "; $headers = "From: $from"; mail($to,$subject,$message,$headers); echo "Mail Sent.";

Installation and Configuration for Web Server & MySQL Server

Install PhpMyAdmin 1. ให้ทำการติดตั้ง Ubuntu 8.10 โดยทำตามขั้นตอนแล้วจะมีให้เลือก Package ที่จะทำการติดตั้งให้เลือก - OpenSSH Server เอาไว้ Remote - LAMP Server ติดตั้ง Apache, MySQL, PHP/Perl 2. Login เข้าไปตาม Users ที่ตั้งเอาไว้ และกำหนด Password root โดยใช้คำสั่ง #sudo passwd root 3. หลังจากที่ทำการติดตั้งเสร็จแล้วให้ทำการติดตั้งตัว phpMyAdmin เพื่อใช้ในการจัดการ MySQL ได้ง่ายขึ้นโดย #sudo apt-get update #sudo apt-get install phpmyadmin แล้วให้ทำการเลือก apache2 4. ทำการ Config phpMyAdmin ให้แก้ไข Bug 4.1 ไปที่ http://ipaddress/phpmyadmin 4.2 Login เป็น root แล้วไปที่เมนู Privileges 4.3 แล้วทำการลบ Users ที่มี Password เป็น NO ออกทั้งหมด ถ้าไม่ลบลองใส่ Users มั่วๆแล้วไม่ต้องใส่ Password จะสามารถเข้ามาเห็น Schema ของ DB ได้เลย 5. เข้าไปแก้ไข IP ของ MySQL ให้ถูกต้องโดยไปที่ /etc/mysql/my.cnf ให้แก้ไขตรงส่วนของ bind-address = 10.10.10.19 ส่วนนี้คือขั้นตอนการ Install Package แบบ Manual sudo apt-get install update – เป็นการ Update Server *** sudo

Change Owner

Changing the File Owner and Group A file's owner can be changed using the chown command. For example, to change the foobar file's owner to tux: user@host:/home/user$ sudo chown tux foobar To change the foobar file's group to penguins, you could use either chgrp or chown with special syntax: user@host:/home/user$ sudo chgrp penguins foobar user@host:/home/user$ sudo chown :penguins foobar Finally, to change the foobar file's owner to tux and the group to penguins with a single command, the syntax would be: user@host:/home/user$ sudo chown tux:penguins foobar Note that, by default, you must use sudo to change a file's owner or group.

Install Webmin

ใช้ในการจัดการ Server บนเว็บครับ 1. sudo aptitude install perl libnet-ssleay-perl openssl libauthen-pam-perl libpam-runtime libio-pty-perl libmd5-perl 2. wget http://garr.dl.sourceforge.net/sourceforge/webadmin/webmin_1.441_all.deb Now download the latest webmin using the following command or from http://www.webmin.com/download.html 3. sudo dpkg -i webmin_1.441_all.deb 4. https://your-server-ip:10000/

Add New Users

Command-line To add a user you must use the sudo command (for an explanation of what that means, see the RootSudo page). Here are the commands: To add a user. NOTE: do not use the useradd command. # sudo adduser To see the options for adding a user try the man command. # man adduserYou might also wish to create a new group for your users. # sudo addgroup To add a new user to a existing group you would do this: # sudo adduser audioTo add an existing user to an existing group you can use the same command: # sudo adduser

Setting DNS

sudo vi /etc/resolv.conf enter the following details EX1 search test.com nameserver 192.168.3.2 EX2 domain rockworth.local search rockworth.local nameserver 10.10.10.9 nameserver 10.10.20.9

Change IP Address [dhcp > static]

1. ไปที่ไฟล์ interfaces #sudo nano /etc/network/interfaces เดิม auto eth0 iface eth0 inet dhcp แก้เป็น auto eth0 #iface eth0 inet dhcp iface eth0 inet static address 10.10.10.251 netmask 255.255.255.0 broadcast 10.10.10.255 gateway 10.10.10.1 2. Restart Network โดย #sudo /etc/init.d/networking restart

วิธีการเปลี่ยน Password root

หลังจากที่ติดตั้งเสร็จเรียบร้อยแล้ว ให้ทำการ login เข้าสู้ระบบ # sudo su - # ใส่ password ที่ login เข้ามา # sudo passwd root # ใส่พาสเวิร์ดของ root ที่ต้อง

คำสั่งตรวจสอบว่าเน็ตตัดไปกี่ครั้ง

เป็นวิธีดูเป็น report ว่าเน็ตแต่ละสายมีการตัดและต่อใหม่ ตอนไหน เมื่อไร บอกเป็น เวลา - วันที่ ว่าแต่ละ ppp ได้ ip อะไรมา เปรียบเทียบเอาได้เลยว่ากี่ชั่วโมงตัดทีนึงครับ พิมพ์ cat /var/log/syswatch grep "detected" ใน putty เลยครับ อีกที่นึงดูผ่าน webconfig เลือกที่Reports > Logs >file = syswatch ( มีเป็น Choice ให้เลือก )filter = detected ( ตรงนี้พิมพ์เองครับ )แล้วก็คลิกที่ display ที่มา http://www.zealzonecafe.com/board/index.php?topic=291.0

เทคนิค Ghost XP ข้าม Spec

โดยปกติแล้วถ้าเราทำการ Ghost Harddisk ข้าม Spec เครื่องกันนั้น Windows จะออกอาการเอ๋อ บูตเครื่องแล้วเข้า Windows ไม่ได้หรือขึ้น Blue Screen อันเนื่องมาจาก Chipset ที่ควบคุม IDE หรือ Harddisk บน Mainboard ที่ Windows ทำการ Detect เจอตอนลง OS เปลี่ยนไป๋ จึงทำให้ Windows ที่เราอุตส่าหะ Ghost ขึ้นมาเอ๋อเหรอไป บางคนอาจจะแก้ด้วยวิธี Ghost ไปก่อนแล้วค่อยไป Remove Driver ออกใน Safe mode แล้วลง Driver ใหม่บางแหละ Ghost ไปก่อนแล้วบูทเครื่องด้วย CD Windows Install แล้วทำการ Install แบบ Repare ทับบ้าง วิธีการแบบนี้ก็ถือว่าเป็นการแก้ปัญหา (แบบใช้ความสามารถส่วนบุคคล ที่ผมคิดว่ามันอาจจะใช้เวลามากกว่าที่เรามานั่งลง Windows ใหม่เสียอีก อีกทั้งมันยังมีปัญหาตามมาให้ปวดกระบาลอีกแน๊ะ วิธีพวกนั้นสำหรับตัวผมจึงขอบ๊ายบายดีกว่า... จนวันนึง ซึ่งเป็นเช้ายามว่างของ Admin ตัวน้อยๆ คนนี้ ก็ได้พบกับคำตอบที่จะทำให้การลง Windows บนเครื่องใหม่ ง่ายดายมาก (โอ้วจ๊อด) จากที่เคยใช้เวลาลงให้รีบคลิ๊กรีบกรอกรีบลงโปรแกรมแค ่ไหนก็น่าจะเกิน 1 ชั่วโมงครึ่ง-2 ชั่วโมงครึ่ง อันนี้รวมโปรแกรมสารพัดที่ User ใช้งานด้วยนะ อาจจะ