Jul 30

สำหรับคนที่ต้องลบไฟล์คราวละมากๆ และ มีปัญหาในการลบไฟล์ วันนี้จดเพื่อใช้งานง่ายๆ นะครับ
- เพื่อความปลอดภัยในการลบไฟล์ ที่อาจจะเจอช่องว่างในชื่อไฟล์ หรือพวกอักขระแปลกๆ ให้ใช้
find /directory -name *abc* -print0 |xargs -0 rm
-print0 ใส่เพื่อมองไฟล์ 1 ไฟล์ที่มีช่องว่างเป็น file เดียว เหมือนกับการใส่ Double Quote
-0 ก็ใช้คู่กับ xargs เืพื่อใช้อ่านข้อมูลจาก find -print0

- อีกกรณี กรณีที่ ผลลัพธ์ จาก find ไม่มีข้อมูลส่งมาให้ใช้
find /directory -name *abc* -print0 |xargs -0 -r rm
ก็ใส่ -r เพิ่มไปใน xargs เพื่อยกเลิกการทำงานกรณีไม่มี result จาก command แรก

Tagged with:
May 15

A byte-order mark (BOM) is the Unicode character at code point U+FEFF (“zero-width no-break space”) when that character is used to denote the endianness of a string of UCS/Unicode characters encoded in UTF-16 or UTF-32. It is conventionally used as a marker to indicate that text is encoded in UTF-8, UTF-16 or UTF-32.

ref: Wikipedia

ถ้าเปิดไฟล์ utf-8 ด้วย less จะพบว่ามี เป็นคำแรกในไฟล์ ซึ่งก็คือ Byte-order mark ซึ่งบางระบบอาจจะใช้งานไม่ได้ วิธีการเอาออกใน VI จะง่ายมาก หลังจากเปิดไฟล์ด้วย VI แล้วให้ใช้คำสั่ง
:set nobomb
แล้ว save ไฟล์ Byte-order mark ก็จะหายไปแล้วครับ

Tagged with:
Apr 06

Make ISO image from CD/DVD is so easy in MacOS or Linux, Let’s go…

  • Insert CD/DVD Disk
  • drutil status
  • Vendor Product Rev
    HL-DT-ST DVDRW GWA4080MA BE39

    Type: DVD-ROM Name: /dev/disk1
    Sessions: 1 Tracks: 1
    Overwritable: 00:00:00 blocks: 0 / 0.00MB / 0.00MiB
    Space Free: 00:00:00 blocks: 0 / 0.00MB / 0.00MiB
    Space Used: 776:36:36 blocks: 3494736 / 7.16GB / 6.67GiB
    Writability:
    Book Type: DVD-ROM (v1)

  • unmount disk with
    diskutil unmountDisk /dev/disk1
  • Create ISO file with
    dd if=/dev/disk1 of=file.iso bs=2048
  • Wait until success then test your image file
Tagged with:
Sep 18

If use basic setting in Header from https you will get HTTP/1.0 so it cannot redirect to right host.
It’s very easy to set with Nginx you can use
[code lang="bash"]
proxy_set_header X-FORWARDED_PROTO https;
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
proxy_set_header Host $http_host;
[/code]

already use and sent you to correct host.

Tagged with:
Jun 21

ใช้ mysqltuner แล้วพบว่า จำเป็นต้อง optimize tables แต่จะทำไงให้ optimize ได้ทุกตารางล่ะ

ใช้คำสั่งนี้ได้เลยครับ
[code lang='bash']mysqlcheck -Aao --auto-repair -u root -p[password][/code]

-a, –analyze [Analyze given tables]
-o, –optimize [Optimize table]
-A, –all-databases [Check all the database]
–auto-repair [If a checked table is corrupted, automatically fix it. Repairing will be done after all tables have been checked, if corrupted ones were found]

หรือ จะใช้
[code lang='bash']mysqlcheck -uroot -p -ro –all-databases [/code]

-r = Can fix almost anything except unique keys that are not unique.

ก็จะสำเร็จเสร็จเรียบร้อย ที่เหลือก็แล้วแต่ปรับแต่งนะครับ

Tagged with:
preload preload preload