Sunday, November 20, 2011

สิ่งที่ได้จากช่วงน้ำท่วม

น้ำท่วมคราวนี้ทำให้ได้ความรู้ DIY เพิ่มมาบ้างพอสมควร ขอจดไว้หน่อยกันลืม

ประปา 
  • สงสัยมานานแล้วว่าท่อ PVC มันต่อเชื่อมยังไง ได้รู้สักทีว่ามันเชื่อมกันด้วยกาว ให้หาซื้อกาวทาท่อ (ในเน็ตชอบแนะนำ ยี่ห้อ ท่อน้ำไทย) มาทาท่อ PVC ตรงจุดที่จะเชื่อมกัน กดแน่นๆ รอแค่ 1 นาทีท่อก็จะติดกันแน่นพอสมควร ตามสูตรควรรอสัก 1 วันค่อยใช้ แต่มีคนบอกว่าช่างประปาบางคนรอแค่ 10 นาทีก็ใช้แล้ว
  • ท่อ PVC จะออกแบบมาให้เชื่อมกันได้อยู่แล้ว ถ้าท่อขนาดที่เข้ากันได้ ภายในจะมีขยักนิดหน่อยที่ไว้ให้เสียบท่อได้พอดี
  • ระบบประปาในบ้าน น้ำทิ้งจะทิ้งออกไปที่ท่อระบายน้ำ มันเรียกว่าท่อระบายน้ำแต่เอาเข้าจริงมันไม่ได้เป็นท่อๆแฮะ แต่เป็นเหมือนโพรงสี่เหลี่ยมเท่านั้นเอง อย่างที่บ้านจะมีท่อระบายน้ำรอบบ้าน (ไม่ดีในแง่กันน้ำท่วม เพราะรูเยอะมาก) แต่ปลายท่อจะเชื่อมออกไปที่โพรงท่อระบายน้ำใหญ่ของซอย (จริงๆแล้วกันแค่ตรงนี้ได้ก็กันได้ทั้งบ้าน อาจยกเว้นสวนถ้าต่อถึงดินโดยตรง) 
  • ท่อระบายน้ำในบ้าน จะต่อ PVC ไปแล้วปลายก็ไปทิ้งที่ท่อระบายน้ำใกล้ๆบ้าน กรณีของที่บ้าน เจอปลายท่อระบายน้ำทั้งหมด 3 จุดพอดี และ test แล้วพบว่าท่อบนพื้นมันออกท่อเดียวกันหมด ทำให้สามารถกันน้ำท่วมได้ง่ายๆ โดยเอา จุกปิด PVC แบบเกลียวนอก + เชื่อมท่อ PVC ด้วยกาว ไปเสียบปิดไว้ ถ้าเกิดน้ำจะท่วมก็เอาจุกปิดมาขันปิดเอา น่าจะเวิร์คกว่าไปปิดในบ้านแบบที่เขาชอบทำกันอีก เพราะเปิดปิดได้ และแรงดันน้ำน่าจะดันให้จุกปิดยิ่งแน่นกว่าเดิม (ไม่ได้ทดสอบ เพราะยังไม่ท่วม)
  • ถังส้วมใต้ดิน ก็มีท่อประปาตรงช่วงบนของถัง (!?) เพื่อระบายของเหลวจากส้วมออกมา (กากตกลงล่าง ซึมออกหรือไม่ซึมขึ้นกับประเภทถัง ถ้าแบบไม่ซึมก็ต้องเอารถสูบมาสูบเป็นระยะๆ) ส่วนที่ล้นออกมามันก็ลงท่อระบายน้ำนี่แหละ เพราะงั้นตามหลักการปิดปลายท่อนี้ได้ก็ป้องกันปัญหาน้ำล้นจากส้วมได้ (แต่เผอิญหาไม่เจอ)
  • ถ้าเอาท่อกันกลิ่น (แบบใต้ซิ้งค์ครัว หรืออ่างล้างหน้าในห้องน้ำ) ไปเสียบตรงปลายท่อระบายน้ำ น่าจะกันแมลงสาบได้แบบถาวรเพราะมันจะต้องว่ายน้ำเข้ามา แต่คงมีผลทำให้ท่อระบายน้ำระบายได้ช้าลง ไว้คงให้ช่างมาทำดีกว่า ทำเองเดี๋ยวเละ ไม่ค่อยถูกกับงานประปา
  • ไดรโว่สูบน้ำมีทั้งแบบดูดโคลนได้และดูดได้แต่น้ำ การใช้งานมันออกแบบมาให้จมน้ำลงไปเลยซัก 10-15cm แล้วห้อยปลั๊กไว้ด้านบน โดยเอาเชือกมาผูกหย่อนอีกที แต่เอามาใช้กับน้ำท่วมคงไม่ขนาดนั้น แค่เสียบปลั๊กก็ใช้งานได้ ท่อน้ำใช้ท่ออ่อนเป็นผ้าๆมาพันๆเอาได้ง่ายๆ
  • เครื่องกรองน้ำ ต้องเปลี่ยนไส้กรองทุก 2 ปี เปลี่ยนไส้คาร์บอนกับเรซิ่นทุก 1 ปี ล้างทุก 2-3 เดือน ส่วนไส้กรองก็ล้างเมื่อเริ่มตันด้วยน้ำ
ไฟฟ้า
  • แม้ว่าจะมีการแยกแผงวงจรไฟล่าง-บน แต่ถ้าน้ำท่วมเข้าแผงไฟหลักก็ซวยอยู่ดี กรณีที่บ้านจุดต่ำสุดอยู่แค่ 80-90 cm จากพื้น กันยากโคตร ทำให้รู้ว่าแยกแผงไฟหลัก ล่าง บน หรือไม่ก็เอาไปไว้ข้างบนทั้งหมดจะดีที่สุด (สายไปแล้ว)
  • ปิดแผงปลั๊ก/โทรศัพท์/ทีวี แกะฝามันออกมา ใช้ฟอยล์ห่ออาหารมาปิดหลายๆชั้น อาจจะปิดสก็อตเทปไปด้วยก็ได้ แล้ว เอาซิลิโคนยิงรอบๆ อันนี้ยังไม่ได้ทดสอบจริง แต่โดยหลักการน่าจะพอช่วยแก้ปัญหาสายไฟชื้นได้ (ไม่ได้แก้เรื่องน้ำเข้า แค่ไม่อยากให้ระบบไฟเสียหาย)
  • อย่าลืมดูมิเตอร์ไฟนอกบ้าน การไฟฟ้าบางทีชอบติดไม่สูงเพราะไม่ต้องปีนดู ปรากฏว่าไม่ถึงเมตร ก็มี
ก่อสร้างทั่วไป
  • (ไม่ได้ทดสอบ) สำหรับการอุดรูไม่พึงประสงค์แบบถาวร ดูเหมือนการใช้ Bosney ซึ่งเป็นกาวอุดรูรั่วกระเบื้องและปูน จะง่ายสุด เพราะไม่ต้องผสมปูน แกะมาทาๆได้เลย แห้งช้าแต่พอแห้งแล้วแข็งมากแบบปูนเลย ลองคร่าวๆแล้วน้ำไม่รั่ว ถ้าพื้นผิวใหญ่อาจต้องอุดรูด้วยอะไรสักอย่างก่อนทาเพราะกาวเหลวต้องมีพื้นผิวให้เกาะ (ตอนทำแบบด่วนๆ เอาทิชชู่ยัด เพราะได้ยินว่าช่างบางคนเอาทิชชู่ยัดก่อนยาซิลิโคน)
  • ซิลิโคน จริงๆแล้วมีหลายแบบ อคริลิค ซิลิโคน อะไรพวกนี้ เหมือนว่าซิลิโคนจะดีสุด มีทั้งเกรดถูก กับแพง (อย่างแพงมียี่ห้อ SONY ด้วย) มีหลายสี เวลาใช้ให้ใส่ในปืนยิง ตัดปลายออก แล้วกดๆเข้าไป พอยิงเสร็จให้คลายล็อกตรงปลายตัวดันไม่งั้นมันจะดันให้ไหลไม่หยุด เวลาใช้เสร็จ ถ้ามีอะไรอุดปลายได้ก็ดี ส่วนหัวท่อซิลิโคน พบว่า ไม่ต้องทำความสะอาดจะดีที่สุด ลองเอาไปล้างแล้วเหนียวหนึบล้างยากมากๆ แต่ถ้าปล่อยจนมันแห้งไปเลย ก็ดึงเศษออกมาได้ง่ายๆเลย กลายเป็นแท่งยางใหญ่ๆ
  • เครื่องแอร์นอกบ้าน (คอยล์ร้อน คอมเพรสเซอร์ แล้วแต่จะเรียก) ไม่หนักอย่างที่คิด ตอนนี้ใช้วิธีแขวนผนังสูงกว่าพื้น 1 เมตรไปหมดแล้ว ในการย้ายตำแหน่งทุกครั้งจะต้องไล่น้ำยาแอร์ออกหมดเสียเงินมากพอสมควร
  • ผ้าใบหาง่ายมากพอสมควร เมื่อเทียบกับกระสอบทราย
  • เวลาซื้อของที่มีห่อกันกระแทก เก็บๆไว้บ้างก็ดีเอามาใช้ได้ในยามนี้

Saturday, October 22, 2011

รวมแผนที่ช่วงน้ำท่วม

ตอนนี้ยังหาเว็บที่มันมีแผนที่รวมแบบดีๆไม่ได้เลย ต้องแยกกันดู เลยมาแปะลิ้งค์รวมไว้ก่อนจะลืม

Wednesday, September 29, 2010

Disable touchpad when USB Mouse connected on Ubuntu (Lucid)

Update: 7/11/2010 Fixed a bug that happened with my laptop. The xinput was reset periodically for some reason.

Update: 2/11/2010 Fixed it a bit to make it works better. Now it don't need fix device name.

I wrote a short script to disable touchpad when mouse attached in Jaunty, which never works for me anymore after Jaunty. The reason is that gconftool and synclient could not correctly set touchpad state (it works for a very short while, until Gnome or X enable it back again). I just found the solution for Lucid (and probably for Maverick). It's

#!/usr/bin/python


import dbus # needed to do anything
from dbus.exceptions import DBusException
import dbus.decorators # needed to receive messages
import dbus.glib # needed to receive messages
from dbus.mainloop.glib import DBusGMainLoop
import gobject # needed to loop & monitor
import os, re, time, sys

global add_action, remove_action, bus, hal_manager

_debug = True
device_added = []
touchpad_enabled = True
device_cap = 'input.mouse'

add_action = 'sleep 1s && xinput --list --short | grep -i touchpad | sed "s/^.*[[:space:]]*id=\\([0-9]*\\)[[:space:]]*.*$/\\1/g" | xargs -I id xinput --set-prop id --type=int --format=8 "Device Enabled" 0'
remove_action = 'xinput --list --short | grep -i touchpad | sed "s/^.*[[:space:]]*id=\\([0-9]*\\)[[:space:]]*.*$/\\1/g" | xargs -I id xinput --set-prop id --type=int --format=8 "Device Enabled" 1'
check_action = 'xinput --list --short | grep -i touchpad | sed "s/^.*[[:space:]]*id=\\([0-9]*\\)[[:space:]]*.*$/\\1/g" | xargs -I id xinput --list-props id | grep -qi "device.*enabled.*:[[:space:]]*0$"'

exclude_devices = ['usb_device_a5c_4503_noserial_if0_logicaldev_input']

def dprint(msg) :
    global _debug
    if _debug :
        sys.stderr.write(msg + '\n')
        sys.stderr.flush()

#@dbus.decorators.explicitly_pass_message
def add_device(*args, **keywords):
    check_and_run_add_action(args[0])

def check_and_run_add_action(device_path) :
    global device_added

    retval = False
    Path = device_path.split('/')
    dprint('device added == %s' % Path)

    if Path[-1] in exclude_devices :
        return retval

    device_obj = bus.get_object('org.freedesktop.Hal', device_path)
    device = dbus.Interface(device_obj, dbus_interface = "org.freedesktop.Hal.Device")
    cap = device.QueryCapability(device_cap)

    dprint('Device capability == %s' % cap)
    try :
        prop = device.GetPropertyString('info.subsystem')
    except DBusException :
        prop = None

    dprint('Property String == %s' % prop)

    if cap and prop and (prop == 'input') :
        device_added.append(Path[-1])
        dprint('Executing add_action')
        os.system(add_action)
        retval = True
    return retval
       
#@dbus.decorators.explicitly_pass_message
def remove_device(*args, **keywords):
    global bus, _debug, device_added

    Path = args[0].split('/')
    dprint('device removed == %s' % Path)

    try :
        if device_added :
            if Path[-1] in device_added :
                device_added.remove(Path[-1])
                dprint('Excuting remove_action')
                os.system(remove_action)
            else :
                # other device removed, run add action again to make sure
                # this workaround a bug in Lucid that device was periodically removed will reset enable flag
                os.system(add_action)
    except :
        dprint('Exception while removing device')
        if _debug :
            import traceback
            traceback.print_exc()

DBusGMainLoop(set_as_default = True)
bus = dbus.SystemBus()  # connect to system bus
hal_manager_obj = bus.get_object('org.freedesktop.Hal', '/org/freedesktop/Hal/Manager')
hal_manager = dbus.Interface(hal_manager_obj, 'org.freedesktop.Hal.Manager')

# Add listeners for all devices being added or removed
bus.add_signal_receiver(add_device, 'DeviceAdded', 'org.freedesktop.Hal.Manager',
                        'org.freedesktop.Hal', '/org/freedesktop/Hal/Manager')
bus.add_signal_receiver(remove_device, 'DeviceRemoved', 'org.freedesktop.Hal.Manager',
                        'org.freedesktop.Hal', '/org/freedesktop/Hal/Manager')

# Run remove action once to enable touchpad
dprint('Running removaction once')
os.system(remove_action)

# Find mouse first
dprint('Finding mouse first')
udis = hal_manager.FindDeviceByCapability(device_cap)
for udi in udis :
    dprint('Found device == %s' % udi)
    Path = udi.split('/')
    if check_and_run_add_action(udi) :
        break

# monitor
dprint('Start Mainloop')
loop = gobject.MainLoop()
try :
    loop.run()
except SystemExit, e :
    dprint('Got SystemExit exception %s' % e)
    raise e
except Exception, e :
    dprint('Got Exception from the loop')
    if _debug :
        import traceback
        traceback.print_exc()
    loop.quit()
    sys.exit(255)
The trick is to use xinput instead of gconftool/synclient!

Saturday, August 07, 2010

Extract and convert A_DTS to AC3

I got a problem again with my new video file. It contains A_DTS stream which is not recognizable with any player + tsMuxeR. According to this, I can use libdca to convert dts to wav and use aften to convert it to AC3.

mkvextract tracks /path/to/matroska.file.mkv 2:/tmp/dts.file.dts

dcadec -o wavall /tmp/dts.file.dts | aften - /tmp/ac3.file.ac3

mkvmerge -o /tmp/matroska.file.mkv /path/to/matroska.file.mkv /tmp/ac3.file.ac3
Another way is to use this to extract and remerge the stream automatically.

Tuesday, June 15, 2010

Correcting Video/Audio sync problem for .MOV file with Mencoder

The magic is
-mc 0 -noskip

Adding those 2 options to mencoder standard option makes the video/audio sync for my .MOV file (taken by Digital Camera) sync smoothly1

Monday, May 10, 2010

เปิดหน้า boot แบบสวยๆใน Lucid Lynx (Ubuntu 10.04)

ต้นตอปัญหาเกิดจากใช้ไดรเวอร์ NVIDIA Priprietary เช่นเคย หลักการคือ เราจะบังคับให้ Grub pass parameter ให้ kernel บูตโดยใช้ Vesafb แทน NVIDIA fb เพราะ NVIDIA fb ไม่ support อะไรบางอย่างที่ Plymouth ต้องใช้ตอนบูต (ทำให้ได้หน้าจอดำๆ และคำว่า Ubuntu แบบหยาบๆโผล่มา)

ต้นฉบับจาก http://news.softpedia.com/news/How-to-Fix-the-Big-and-Ugly-Plymouth-Logo-in-Ubuntu-10-04-140810.shtml
  • apt-get -y install v86d
  • แก้ /etc/default/grub
    • แก้ GRUB_CMDLINE_LINUX_DEFAULT="quiet splash nomodeset video=uvesafb:mode_option=1280x800-24,mtrr=3,scroll=ywrap"
    • uncomment + เพิ่ม GRUB_GFXMODE=1280x800
  • แก้ /etc/initramfs-tools/modules เพิ่ม "uvesafb mode_option=1280x800-24 mtrr=3 scroll=ywrap"
  • สร้าง /etc/initramfs-tools/conf.d/splash เพิ่ม "FRAMEBUFFER=y"
  • update-grub2
  • update-initramfs -u
  • หมายเหตุ: ทั้งหมดต้องทำด้วย root

Sunday, April 04, 2010

มหากาพย์ภูผามหานที

ว่างเว้นจากการอ่านนิยายจีนกำลังภายในไปนาน พอดีมีสัปดาห์หนังสือเลยฝากเพื่อนซื้อทั้งชุดมาเลย ได้แก่ 2 ภาคแรก + ภาค 3 จำนวน 2 เล่ม (ยังไม่จบ) อ่าน 2 ภาคแรกรวดเดียวจบ ไม่ได้อ่านนิยายจีนชุดยาวรวดเดียวแบบนี้มานานแล้ว ถือได้ว่าเฟิ่งเกอร้ายกาจ สมคำร่ำลือจริงๆ
ส่วนตัวแล้วรู้สึกว่าภาค 2 มีความคล้ายคลึงกับมังกรหยกภาค 2 อยู่หลายอย่าง เช่น
  • ตัวเอกทำอะไรนอกรีต เป็นตัวประหลาดในสายตาชาวบ้าน
  • เนื้อเรื่องแบ่งเป็นหลายช่วงอายุ ช่วงเด็ก ช่วงวัยรุ่น ช่วงวัยเกือบกลางคน จริงๆช่วงวัยรุ่นนี่มีช่วงย่อยๆอีก
  • พระเอกต้องแยกจากนางเอกช่วงวัยรุ่นด้วยสาเหตุพิสดารบางประการ (มังกรหยก - ตกหน้าผา, ภูผา - ติสต์แตก..... เอ้ย โดนสังคมประนาม ไม่กล้าอยู่ต่อ) สุดท้ายกลับมาอยู่ด้วยกันได้ก็ช่วงท้าย
  • พระเอกฉลาดมาก ฝึกวิชาสารพัดสารเพเยอะแยะไปหมด สุดท้ายคิดวิชาของตัวเอง
  • จบเรื่องด้วยฉากสงคราม (มังกรหยก - สงครามมองโกลและซ้องใต้, ภูผา - มองโกลบุกวังความลับฟ้า) ต่างกันตรงที่มังกรหยกโศกมาตลอดสุดท้ายก็ Happy แต่ภูผานี่โศกยันหน้าสุดท้ายเลย
  • พระเอกสุดท้ายใช้ดาบวิเศษ ออกแนวมืดๆทมึนๆ คล้ายๆเอี้ยก้วยที่ใช้กระบี่เหล็กดำ (คล้ายไหม?)
  • มี 3 ภาคเหมือนมังกรหยกซะด้วย (หรือจะมีภาคที่ 4? )
  • สนุกเหมือนกัน :)
เรื่องย่อต่างๆคงหาอ่านได้จาก Boolim Blog แต่สรุปสิ่งที่ผมได้จากการอ่านทั้ง 2 ภาคคือ
  • ปฐมบทฯ - เป็นนิยายจีนอ่านเพลินๆ สนุกๆ ไม่หวือหวามาก เนื้อเรื่องปูพื้นการประยุกต์คณิตศาสตร์มาใช้กับวิทยายุทธิ์นิดหน่อย ปรัชญาที่แฝงอยู่คงเป็นเรื่องของการไม่จองเวร ความโหดร้ายของศึกสงคราม
  • วีรกรรมฯ - เนื้อเรื่องสอดแทรกปรัชญาเกี่ยวกับความสมดุลย์ ธรรมชาติ ตลอดเรื่องนำเสนอความไม่สมบูรณ์พร้อมของสิ่งใดๆในโลก ในขณะที่เหลียงเซียวผู้ชาญฉลาดก็พยายามแสวงหาความสมบูรณ์พร้อม (การแก้แค้นให้สำเร็จ การแก้โจทย์เลขให้ครบ การไม่มีสงคราม การไม่มีอุทกภัย ฯลฯ) จนสุดท้ายก็คิดว่าได้ว่าดุลยภาพคือสิ่งที่สมบูรณ์ที่สุด (ทางสายกลาง???) คิดว่าตอนจบ แทนที่จะให้เหลียงเซียวสู้ตรงๆกับกงหยางหวี่สุดยอดฝีมือซึ่งน่าจะเก่งพอๆกันกับพระเอก กลับวางเรื่องให้สู้กับคู่เพลงกระบี่ไท่อีแยกประกายของกงหยางหวี่กับฮัวอู๋ซือ (ดูไป 2 รุม 1 โกงสิ้นดี) ดูไปคงต้องการสื่อว่าแม้สิ่งใดในโลกไม่สมบูรณ์พร้อม แต่ก็สามารถชดเชยกันเองเพื่อให้สมบูรณ์พร้อมได้
ตลอดเรื่องมีการใช้การอุปมาอุปไมยเทียบกับวัตถุ สิ่งของ เรื่องราวอยู่ตลอดเวลา ซึ่งผมคิดว่าเฟิ่งเกอทำได้ดีมาก มีวัตถุติดตาหลายอย่าง เช่น นกไม้ แมงเม่าบินเข้ากองไฟ อ่านแล้วเรียกน้ำตาได้พอประมาณทีเดียว

Wednesday, March 24, 2010

อ่านนิยายบน Android

ช่วงนี้งานอดิเรกเก่าในร่างใหม่กำลังกลับมา นั่นคือการอ่าน eBook บน HTC Hero (Android 1.5) นั่นเอง

ก่อนหน้านี้เคยทู่ซี้อ่านนิยายฝรั่งหลายเรื่องจนจบ บน Nokia 3110c ด้วย TCBR แต่ด้วยความเล็กของจอเลยปวดตาพอสมควร พอย้ายค่ายมาซบอก Android ก็ได้ฤกษ์ หานิยายมาอ่านบน Android ซะที และไหนๆมันก็เป็น Android ย่อมน่าจะมีโปรแกรมอ่าน eBook ที่เป็น eBook จริงๆหลายตัว พอเสาะหาก็ได้ความดังนี้
  • FBReader - น่าจะเป็นตัวที่ดีที่สุดเพราะเล็กและเร็ว หมุนหน้าจอได้ด้วย แถมมี Night Mode! support EPUB และ MOBI ไม่เชื่อมต่อกับระบบร้านค้าใดๆ ไม่ Support DRM
  • Aldiko - ดูไม่เลว รู้สึกว่าช้ากว่า FBReader อยู่ เหมือนว่าจะพยายาม Support ร้านค้าในตัวเอง แต่ตอนนี้มีแต่หนังสือฟรีให้โหลด Import EPUB เข้ามาอ่านได้
  • EReader - เป็นตัวอ่านตัวเดียวที่เชื่อมกับระบบร้านค้า หนังสือโหลดมาจาก ereader.com เนื่องจากยังไม่ได้ลองซื้อหนังสือ เลยไม่รู้ว่าเวลาอ่านเป็นยังไง โปรแกรมไม่มีใน Market แต่ลงตาม Instruction แล้วก็เวิร์คดี
และแน่นอนยังมีพวกตัวอ่าน PDF อีกหลายตัว แต่จากการทดสอบ พบว่าพวก ไฟล์ฟอร์แมตสำหรับ Ebook โดยเฉพาะจะจัดการตัดคำดีกว่า PDF ที่จะต้องมาย่อ ขยาย เรื่อยๆให้รำคาญ เรียกว่าถ้าเนื้อความในหนังสือส่วนใหญ่เป็น Text ก็หาไฟล์ที่เป็น Ebook format โดยเฉพาะมาจะดีกว่า

ปัญหาหลักยังคงเป็นเรื่องของ DRM ผมพลาดไปซื้อหนังสือมาเล่มหนึ่งจาก cyberread.com เป็น Format EPUB เพราะคิดว่าเป็นฟอร์แมตที่น่าจะดูดีที่สุด (iPad ใช้ด้วย :P ) ทำให้พบความจริงหลายๆอย่าง นั่นคือ
  • ถ้าซื้อฟอร์แมตไหนไปแล้ว เปลี่ยนฟอร์แมตไม่ได้ คืนเงินได้อย่างเดียว เพราะระบบการซื้อ Ebook จะผูกติดกับระบบบัตรเครดิต ไม่แน่ใจว่าไฟล์ Ebook แต่ละไฟล์ที่ได้มา Encrypt ด้วยข้อมุลบางอย่างของบัตรเครดิตด้วยหรือเปล่า
  • ถ้าซื้อ Epub จากเว็บทั่วไป ต้องอ่าน (โหลดไฟล์) ด้วย Adobe Digital Edition ซึ่งแปลว่าแนวโน้มสูงที่จะต้องอ่านบนหน้าจอคอมพิวเตอร์! ที่แย่คือ Adobe Digital Edition มีเฉพาะบน Windows.... แต่เดี๋ยวก่อน! ลงใน Wine ได้ครับ เวิร์คดีพอสมควร
  • ถ้าเอาไฟล์ที่ติด DRM ไปเปิดด้วย FBReader จะทำให้ FBReader crash ทันที
  • สุดท้ายต้องไปหาตัว Crack DRM ไฟล์ EPUB มาใช้ ก็จะอ่านด้วย FBReader ได้
สรุปแล้วถ้าหาหนังสือแบบไร้ DRM ไม่ได้ สงสัยต้องซื้อผ่าน eReader.com ลูกเดียว

หวังว่าอีก 2-3 ปี ศึกนี้จะจบ หวังว่าจะจบแบบ MP3 ที่่สุดท้ายก็ขายแบบ no DRM

ไม่งั้นคงต้องหวังให้ Google ทำ Book store + DRM Reader แบบ Multi platform เอ่อ แต่ก็ต้องกลายเป็นทาส Google แทนอยู่ดี

Saturday, February 27, 2010

Xenosaga Episode I

ช่วงนี้ผมขุดเอาเกมส์เก่าบน PS2 มาเล่น หนึ่งในเกมส์ที่ผมอยากเล่นมาตลอดแต่ไม่มีเวลา นั่นก็คือซีรียส์ Xenosaga
Xenosaga เป็นเกมส์ไตรภาคแนว RPG-Adventure-SciFi-Fantasy ซึ่งทำโดยทีมคนที่สร้างเกมส์ Xenogears บน PS ผมเองประทับใจพอสมควรกับเกมส์ Xenogears มาตลอด โดยเฉพาะในส่วนของเนื้อเรื่องและเพลงประกอบ (เพลงประกอบเกมส์นี้ จะชอบโดนเอาไปเป็นเพลงแบ็กกราวนด์ของพวก Spot สารคดีเกี่ยวกับในหลวงในวิทยุ Radio Thailand News เห็นได้ชัดถึงความอลังการของเพลง) แต่เพราะว่า Xenogears จัดจำหน่ายโดย Square (ปัจจุบันคือ Square-Enix) ในขณะที่ Xenosaga จัดจำหน่ายโดย Namco (ตอนนี้เป็น Bandai-Namco ไปแล้ว คือทีมพัฒนาเดิมได้แยกตัวจาก Square ไปตั้งบริษัท Monolith-soft และทำเกมส์ให้ Namco) Xenosaga เลยกลายเป็นเกมส์ที่อารมณ์เดียวกับ Xenogears แต่ว่าอยู่บนเนื้อเรื่องกันคนละจักรวาลกัน และมี Element หลายๆอย่างในเกมส์ เช่น Zohar ที่ถูกนำมาใช้ใหม่ ตอนที่เขียนอยู่นี้ผมเล่น Xenosaga Episode I จบแล้ว และกำลังเล่น Episode II เลยอยากจะจดเก็บไว้หน่อยว่ารู้สึกยังไงบ้าง สำหรับเนื้อเรื่องคงไม่ต้อง Note ไว้ เพราะ หาอ่านได้จาก Xenosaga Wiki อยู่แล้ว
  • เกมส์ให้อารมณ์แบบ Star-Trek ผสมคุจากุ (!?? ไม่รู้จะเทียบยังไง ผมไม่ค่อยอ่านนิยาย Scifi รู้จักแค่นี้) คือ Element ในส่วนของ Sci-fi นั้นผมว่าทำได้ดีทีเดียว ในขณะเดียวกันก็มีพวกเรื่องลึกลับ เหนือธรรมชาติมาปนเยอะพอสมควร
  • Element ที่น่าสนใจในเกมส์
    • U.M.N. (Unus Mundus Netweork) - วิธีการสื่อสารทางไกล ใช้ทั้งในการสื่อสาร รวมไปถึงการ "Gate Jump" ง่ายๆก็คือการวาร์ป วอร์ปไดรว์ โฟลด์ หรืออะไรก็แล้วแต่ที่
      จะเรียกในเรื่องอื่นๆ ไอเดียของ Xenosaga จะบอกว่า U.M.N. นั้นมีองค์กรคอยควบคุมเส้นทางอยู่ น่าจะคล้ายๆกับพวกกรมทางหลวงอะไรประมาณนั้น เวลาจะ Gate Jump หรืออะไรต้องขออณุญาตก่อน
    • GNOSIS - เป็น Alien ปริศนาที่ไปมากันเป็นกลุ่ม ดูเหมือนจะไม่มีความฉลาด แต่ที่สำคัญคือมันอาศัยอยู่ใน Space-Time คนละอันกับที่มนุษย์อยู่ ทำให้มนุษย์ไม่สามารถทำร้ายได้ คือเหมือนสู้กับวิญญาณ โจมตีแล้วทะลุผ่านไปเฉยๆ แต่ GNOSIS สามารถทำร้ายมนุษย์ได้ (ทำเหมือนสิงคน คือถ้าโดนจับแล้วเหมือนจะโดนดูดพลังชีวิต) คนที่โดนจับแต่ไม่ตาย อาจจะกลายเป็น GNOSIS ได้ ซึ่งเป็นปมที่เรื่องทิ้งไว้อีกอย่าง เพราะตัวเอกเคยโดนจับแล้ว แต่กลับไม่กลายเป็น GNOSIS
    • Realian - คิดว่า Realian คืออารมณ์ประมาณ Coordinator ใน Gundam Seed หรือเป็นพวก Bio-made Android หรือพวกมนุษย์ Cloning อะไรทำนองนั้น ในยุคของ Episode I นี่ Realian ถูกใช้งานกันอย่างแพร่หลายมาก Realian ส่วนใหญ่จะถูกผลิตออกมาเพื่องานเฉพาะทาง เช่น การต่อสู้ การสื่อสาร ในยุคของ Episode I นี้ Realian จะมีสิทธิ์เหมือนมนุษย์ ซึ่งเป็นผลพวงจากสงครามที่เกิดขึ้นก่อน Timeline ของ Episode I นี้ ซึ่งดูเหมือนจะเป็นการปฏิวัติของพวก Realian ต่อมนุษย์
    • Hilbert Effect - เป็นปรากฎการณ์ที่จะทำให้ GNOSIS มาอยู่ใน Space-Time เดียวกับมนุษย์ ง่ายๆคือสู้กันได้ มีแต่ Realian รุ่น 100 และ KOS-MOS ที่สร้างปรากฎการณ์นี้ได้ KOS-MOS สามารถสร้างปรากฎการณ์นี้ได้ในวงกว้างขนาดทั้งกองทัพ
    • Android (KOS-MOS) - ตัวเอกอีกคนของเรื่องซึ่งเป็น Man-made Android น่าตกใจว่า Timeline ของเรื่องที่เกิด 4000 ปีหลังจากปี ค.ศ. 2000 แต่เทคโนโลยีการสร้าง Android แบบเหมือนคนจริงกลับยังไม่ก้าวหน้ามากนัก เข้าใจว่าเพราะมี Realian ใช้แทนแล้ว (น่าจะอารมณ์เดียวกับ Data ใน Star Trek Next Gen) KOS-MOS เป็น Android ที่บริษัท Vector สร้างขึ้นเพื่อเป็นอาวุธต่อต้าน GNOSIS โดยเฉพาะ
  • การเล่าเรื่องของเกมส์ทำได้ดีมาก ฉาก movie หลายๆฉากผมดูแล้วตื่นเต้นเหมือนดู Anime ดีๆจริงๆ (ทั้งๆที่ภาพห่วยพอดู ต้องเห็นใจเกมส์เก่าเกือบ 10 ปี)
  • ใน Episode I นี้พวกเรื่องลึกลับยังดูไม่เข้ากับเนื้อหาเป็นเนื้อเดียวกันมากนัก คิดว่าคงค่อยๆคลายปมมากขึ้นเรื่อยๆ
  • ผมชอบตอนที่ตัวเอก (Shion) บอกว่า "I understand any of this... เพราะว่าตูก็ไม่เข้าใจเหมือนกันเฟ้ย! เป็นจุดที่แสดงชัดว่าคนแต่งเรื่องไม่พยายามยัดเยียดความเข้าใจแบบแปลกๆ ที่การ์ตูนญี่ปุ่นหลังๆชอบยัดๆมาให้คนดู (นึกภาพ Evangelion) แบบว่างงว่ะ แต่เอาเหอะ อย่างน้อยตัวละครในเรื่องมันยังพูดแบบนี้ ก็หวังว่าสุดท้ายมันจะคลี่ปมให้รู้เรื่องจริงๆ
  • เกมส์แต่ละเกมส์จะมี Element ของเนื้อเรื่อง กับ Element ของตัวเกมส์ ซึ่งบางทีเหตุผลจะขัดกัน (เช่น จบดันเจี้ยนต้องมีบอสขวางเสมอ หรือไอเทมทำไมถึงได้แชร์กับระหว่าง Party ที่อยู่กันคนละที่?) ถ้าเป็นอารมณ์การ์ตูน Element พวกนี้จะต้องมีคำอธิบายเสมอ เช่น จักระ เน็น คอสโมแต่ในเกมส์จะเหมือนละไว้ในฐานที่เข้าใจ ว่าทำไมตัวละครใช้เวทย์ได้ ทำไมถึง Summon เรียกหุ่นยนต์ยักษ์แนว Yuusha ออกมาได้ ผมคิดว่า Episode I แยกส่วนของตรงนี้ออกจากกันได้ดีพอสมควร ในขณะที่ก็ไม่ทำให้ Gameplay จืดชืดเกินไป
  • ตัวเกมส์เอาวิทยาศาสตร์เป็น Background ของสิ่งที่ดูเป็นไสยศาสตร์ พอจะมีเหตุผลทางวิทยาศาสตร์ประกอบกล้อมแกล้มได้เสมอ แต่ช่วงหลังๆของเกมส์ ดูตัวละครมันเริ่มยิงแสงๆสู้กันใหญ่ หวังว่าจะมีเหตุผลประกอบ ที่ไม่ใช่แบบว่าการใช้เวทย์ยิงแสงใส่กันมันเรื่องปกตินะ

Friday, January 08, 2010

Complete guide สำหรับการ Convert หนัง HD ทีเป็น MKV มาเล่นบน PS3 พร้อมมี Subtitle ไทย

ขอจดทิ้งไว้จะได้ไม่ลืม มันลืมๆรายละเอียดทุกทีเลยเวลาจะทำ อันนี้เป็นวิธีการที่ทำแล้วสำเร็จบน Ubuntu Linux 9.10 (Karmic Koala) แต่จริงๆจะทำบน Windows ก็ได้ (ง่ายกว่าด้วย) โดยเอาหนังวางไว้บน External HDD อะไรก็ได้ที่ใหญ่พอ

อันนี้เป็นวิธี Convert หนัง HD ใน Format MKV (H264+DTS|AC3) ให้เป็น Format ที่เล่นได้บน PS3 พร้อม Subtitle ภาษาไทย

สั้นๆก่อน จริงๆแล้วการเล่นหนัง HDบน PS3 มันมี 2 ทาง ทางแรกคือไฟล์ MP4 ซึ่งพวก Anime Fansub จะชอบแจกแบบนั้น MP4 ใช้ได้ดีและมีซับไตเติ้ลแยกได้ (ไม่แน่ใจว่าภาษาไทยเวิร์คหรือเปล่านะ) แต่ปัญหาหลักคือไฟล์ MP4 มันต้องเป็นไฟล์ๆเดียว ทำให้ไฟล์วีดีโอยาวๆ 2 ชม. จะไม่สามารถเก็บลงบน External HDD ที่เป็น FAT32 (ขนาดไฟล์สูงสุด 4GB) ได้ ซึ่งปกติหนัง 720p ที่เป็น H264 MKV มักจะขนาดประมาณ 6GB ถ้า 1080p ก็ 8GB หรือมากกว่านั้นอีก ทำให้ไม่มีทางเลือก ต้องเล่นด้วยฟอร์แมต AVCHD เท่านั้น เพราะ AVCHD เป็นฟอร์แมตลักษณะเดียวกับ DVD (VIDEO_TS, AUDIO_TS) คือเป็นไฟล์หลายๆไฟล์แยกกัน แต่รวมเป็นวีดีโอเรื่องเดียว ทำให้เราแยกไฟล์เป็นไฟล์ย่อยๆที่เล็กกว่า 4GB ได้ (หวังว่าปัญหานี้คงจะหมดไปเมื่อ exFAT กลายเป็นที่นิยมนะ)

อีกปัญหาของชาวไทยคือ Subtitle ถ้าไม่ติดเรื่อง Subtitle หรือคิดว่าอ่าน Subtitle อังกฤษก็ได้ ก็สบาย ไม่ต้องทำอะไรมาก แต่ถ้าจะอ่าน Subtitle ไทย ทางเลือกจะเริ่มจำกัด อย่างแรกคือจะใช้วิธีแกะ Subtitle จาก Subtitle ที่เป็นรูปภาพนี่ทำไม่ได้ เพราะ OCR Software ของไทยยังไม่ดีพอ เอา OCR ฝรั่งมา Learn ก็ไม่ได้ เพราะภาษาเรามีการตัดคำไม่เหมือนภาษาอังกฤษ ทางเลือกเลยเหลือแค่ ต้องหา Subtitle ดีๆ ใน Format ที่เป็นภาพ ซึ่งส่วนใหญ่ก็จะต้องมาจากตัวหนังของจริง อาจจะมาจาก DVD หรือ Blueray Disc (BD) ก็ได้ หรือบางทีจะมีมือเทพที่มาแปลแบบดีมาก หรือไม่ก็มานั่งพิมพ์บทแปล จากเสียงพากย์ทั้งหมด มาแปลแล้วแจกตามเน็ต ถ้าเป็นอย่างหลังเอามาเป็น Text Subtitle พวก SRT ก็ได้ แหล่งหา Subtitle ดีๆ ก็เช่น 1080ip.com และ thaidvico.com

นิดนึงคือ ตัวไฟล์ MKV นั้น ควรจะที่ Resolution ตรง หรือใกล้เคียงกับ Resolution ที่ต้องการ เช่น 1280x720 หรือ 1980x1080 เพราะว่า PS3 จะไม่ปรับให้ตัวภาพอยู่ตรงกลางจอ ถ้าเกิดว่า Resolution ของภาพไม่พอดี ส่วนใหญ่ความกว้างจะพอดี แต่ความสูงจะน้อยไป เช่น 1980x800 สิ่งที่เกิดคือภาพจะเด้งไปชนขอบบนเสมอ ตรงด้านล่างจะเป็นแถบดำขนาดใหญ่ ถ้าไม่ซีเรียสก็ไม่เป็นไร

โปรแกรมที่ใช้
  1. SmartLabs tsMuxeR - ใช้แยกและรวม Stream ในไฟล์ MKV ให้เป็น Format AVCHD สามารถรวม Subtitle stream แบบ SUP (BD Subtitle) ดาวน์โหลดเวอร์ชัน Windows หรือ Linux ตามสะดวก โปรแกรมเป็นแบบคอมไพล์แล้ว (ไม่ใช่ Open Source) แต่รันได้ปกติบน Karmic
  2. BDSup2Sub - อันนี้ใช้ Convert subtitle ใน Subpicture Format (.idx, .sub) ซึ่งถอดออกมาจาก DVD ให้กลายเป็น .SUP ซึ่งเป็น Format ที่ tsMuxeR support โปรแกรมเป็น Java เพราะฉะนั้นถ้าจะรันบน Ubuntu ต้องลง sun-java6-bin ก่อน (sudo apt-get -y install sun-java6-bin)
  3. iconv - คำสั่ง iconv ไว้ convert character encoding ในกรณีที่ไฟล์เซฟมาเป็น tis-620 (windows-874) ให้กลายเป็น UTF-8 (Linux ส่วนใหญ่จะทำงานเฉพาะกับ UTF-8 ถ้าไม่ใช่นี่จะมีปัญหาร้อยแปด)
  4. สคริปต์ Python เปลี่ยนชื่อไฟล์ที่ผมเขียนเอง เพราะ PS3 AVCHD รับเฉพาะไฟล์ที่ชื่อไฟล์เป็นแบบ Dos 8.3 เท่านั้น ถ้าบน Windows จะมีโปรแกรมชื่อ AVCHDME ใช้แทนกันได้ Content ใน สคริปต์เป็นเช่นนี้


#!/usr/bin/python

import os, re
from optparse import OptionParser

usage = '%prog [options] /path/to/avchd/dir'

opt_parser = OptionParser(usage=usage)
opt_parser.add_option('-d', '--debug', dest='debug', action='store_true', default=False, help = 'debug')

options, args = opt_parser.parse_args()

def dosname(file) :
name_map = [
('index.bdmv', 'INDEX.BDM'),
('MovieObject.bdmv', 'MOVIEOBJ.BDM'),
(re.compile(r'(?P.*)\.clpi', re.IGNORECASE) , '.CPI'),
(re.compile(r'(?P.*)\.m2ts', re.IGNORECASE) , '.MTS'),
(re.compile(r'(?P.*)\.mpls', re.IGNORECASE) , '.MPL'),
]
for src, dst in name_map :
if type(src) == type('') :
if file == src :
return dst
else :
mo = src.match(file)
if mo :
return mo.group('name') + dst
return None

def avchdme(src_path, debug) :
'''Convert file name to AVCHD with Dos short file name style for PS3'''

for ent in os.listdir(src_path) :
full_path = os.path.join(src_path, ent)
if os.path.isdir(full_path) :
avchdme(full_path, debug)
else :
newname = dosname(ent)
if newname :
src = full_path
dst = os.path.join(src_path, newname)
if debug :
print 'renaming %s to %s' % (src, dst)
else :
os.rename(src, dst)

for arg in args :
avchdme(arg, options.debug)

เอาสคริปต์มาเซฟเป็นไฟล์ชื่อ ps3me ที่ไหนก็ได้ (แนะนำ /usr/local/bin) อย่าลืม chmod a+x ด้วยจะได้รันได้ กระบวนการทั้งหมดจะใช้เวลาประมาณ 10-15 นาที แล้วแต่ขนาดไฟล์ ไม่มีการ Re-encode ไฟล์ใหม่จึงไม่เสียเวลามาก เท่าที่ลองดู พบว่าเวลาจะสัมพันธ์กับขนาดไฟล์เป็นหลัก

วิธีการทำ
  • ต่อ External HDD เข้ากับเครื่อง ซึ่งต้อง Format เป็น FAT32 เท่านั้น (ถ้าจะ Format บน Ubuntu ก็ใช้ mkfs.vfat ได้) และสร้าง Directory AVCHD ไว้ที่นอกสุด
  • ไฟล์ต้นฉบับแนะนำให้เก็บไว้บนคอมพิวเตอร์ แต่ไฟล์ปลายทางเราจะให้เขียนลงบน External HDD เลย ถ้าให้ทั้งอ่านเขียนลงบน HDD เดียวกันจะนานมาก
  • ถ้า Subtitle เป็นไฟล์ภาพ (.idx, .sub) ซึ่งจะมาคู่กัน
    • เปิด BDSup2Sub ซึ่งดาวน์โหลดมาเป็นไฟล์ .jar ด้วย Java
    • java -jar BDSup2Sub.jar
    • กด Load Subtitle file .idx หรือ .sub ก็ได้
    • ตรง Convert Resolution เลือก Format ของหนังให้ตรงกับที่ต้องการ (1080p หรือ 720p) โปรแกรมจะปรับขนาดของ Subtitle ให้ด้วย นอกนั้นทิ้งไว้คงเดิม กด OK
    • ตามประสบการณ์ พบว่าต้อง Move subtitle ทั้งหมดเนื่องจากเวลารวมแล้วจะตกขอบ ให้ไปตรง Edit->Move All Captions ตรงแกน X เลือก move to center (ดูเหมือนไม่มีผลอะไร แต่พบว่าบางที Subtitle ไปตกซ้ายสุดของจอจนตกขอบก็มี) ตรงแกน Y เลือก Keep Y Position ก็ได้ ถ้าเอาชัวร์ ให้กด move outside bounds แล้วใส่ Offset Y ไว้ที่ 50 เสร็จแล้วกด Move All
    • ตรง Windows หลัก กดเลือก Output Format เป็น SUP(BD) นอกนั้นทิ้งไว้คงเดิม
    • กด File->Save/Export โปรแกรมจะเซฟไฟล์เป็น .sup ให้ จำ Path เอาไว้
  • ถ้า Subtitle เป็นไฟล์ text (.srt)
    • ลองเปิดไฟล์ด้วย gedit ดู ถ้าพบว่าอ่านไม่ออก จะต้อง Convert ด้วย iconv ก่อน โดย
    • iconv -f tis-620 -t utf-8 -o destinatino_subtitle_file.srt source_subtitle_file.srt
    • ที่เหลือปล่อยให้ tsMuxeR จัดการทั้งหมดเลย
  • เรียกคำสั่ง tsMuxerGUI (./tsMuxerGUI)
  • กด Add ไฟล์ MKV รอสักเล็กน้อย จะ List stream มาให้เราดูว่ามีอะไรบ้าง
  • ถ้าจะ add subtitle ที่เป็น .sup ให้กด add อีกที แล้วเลือกไฟล์ .sup ของเรา ตรง Language เลือกเป็นภาษาไทย (tha พิมพ์ tha ติดกันเลยก็ได้)
  • ตรง Split & Cut ให้เลือก Split by size very แล้วใส่ 4GB
  • ถ้ามี Text Subtitle ให้ไปที่ tab subtitles แล้วเลือก Font บน Ubuntu แนะนำ Norasi ดีกว่า
  • ตรง Vertical Position ให้ติ้กตรง Bottom of Screen แล้วใส่ offset สัก 50 เพื่อจะได้ไม่ตกจอ
  • ตรงกรอบ Output เลือก AVCHD Disk แล้ว Browse directory ปลายทาง โดยเลือก /AVCHD ของ External HDD ไว้
  • กด Start Muxing แล้วรอๆๆ ไม่นานมาก พอเสร็จแล้วจะมี directory BDMV และ Certificate โผล่มาใน /AVCHD
  • เอาสคริปต์ ps3me มารัน โดยสั่ง ps3me /media/Mobile/AVCHD ทีนึง สคริปต์จะเปลี่ยนชื่อไฟล์ให้เป็น Dos 8.3 filename compat
  • เสร็จแล้วอย่าลืม Safe Remove Hardware
ทดสอบโดยการเอา HDD เสียบที่ PS3 ไปตรง Video จะเห็น USB Disk โผล่มา กด O เลือก AVCHD แล้วจะเล่นหนังทันที กดปุ่มสามเหลี่ยม เพื่อเปิด Subtitle (ภาษาไทยจะเป็น Other ตามลำดับที่ใส่ใน tsMuxeR) หรือเปลี่ยน Audio Channel ได้

Wednesday, September 02, 2009

Disable touchpad when USB Mouse connected on Ubuntu (Jaunty)

Do you have problem with Synaptics touchpad Palm detection? Do you accidentally touch the touchpad while typing? On Windows Vista, there is an option to disable touchpad when USB Mouse connected, but how to do that on Ubuntu? Here's how I 'properly' did it on my Ubuntu 9.04 (Jaunty).
  • Create a Dbus signal handler script using Python. Here's the script
#!/usr/bin/python

global DeviceName, AddAction, RemoveAction, bus, hal_manager

#DeviceName = 'usb_device_15ca_c3_noserial_if0_logicaldev_input'
DevicePattern = r'usb_device.*_input'
DeviceCap = 'input.mouse'
AddAction = '/usr/bin/gconftool --set --type=bool /desktop/gnome/peripherals/mouse/touchpad_enabled false'
RemoveAction = '/usr/bin/gconftool --set --type=bool /desktop/gnome/peripherals/mouse/touchpad_enabled true'

import dbus # needed to do anything
import dbus.decorators # needed to receive messages
import dbus.glib # needed to receive messages
import gobject # needed to loop & monitor
import os # needed to
import re, time

DeviceRe = re.compile(DevicePattern, re.IGNORECASE | re.DOTALL)

#@dbus.decorators.explicitly_pass_message
def add_device(*args, **keywords):
Path = args[0].split('/')
device_obj = bus.get_object('org.freedesktop.Hal', args[0])
device = dbus.Interface(device_obj, dbus_interface = "org.freedesktop.Hal.Device")

cap = device.QueryCapability(DeviceCap)

if cap and DeviceRe.match(Path[-1]) :
os.system(AddAction)

#@dbus.decorators.explicitly_pass_message
def remove_device(*args, **keywords):
Path = args[0].split('/')
try :
device_obj = bus.get_object('org.freedesktop.Hal', args[0])
device = dbus.Interface(device_obj, dbus_interface = "org.freedesktop.Hal.Device")
cap = device.QueryCapability(DeviceCap)
except :
# assume true, since device might be already removed
cap = True

if cap and DeviceRe.match(Path[-1]) : # Device found
os.system(RemoveAction)

bus = dbus.SystemBus() # connect to system bus
hal_manager_obj = bus.get_object('org.freedesktop.Hal', '/org/freedesktop/Hal/Manager')
hal_manager = dbus.Interface(hal_manager_obj, 'org.freedesktop.Hal.Manager')

# Add listeners for all devices being added or removed
bus.add_signal_receiver(add_device, 'DeviceAdded', 'org.freedesktop.Hal.Manager',
'org.freedesktop.Hal', '/org/freedesktop/Hal/Manager')
bus.add_signal_receiver(remove_device, 'DeviceRemoved', 'org.freedesktop.Hal.Manager',
'org.freedesktop.Hal', '/org/freedesktop/Hal/Manager')

# Run remove action once to enable touchpad
os.system(RemoveAction)
time.sleep(1)

# Find mouse first
udis = hal_manager.FindDeviceByCapability('input.mouse')
for udi in udis :
Path = udi.split('/')
if DeviceRe.match(Path[-1]) : # Check if this is our prefer mouse
os.system(AddAction)
break # no need to keep looking

# monitor
loop = gobject.MainLoop()
loop.run()
  • If you wonder how I got the HAL path of USB mouse, try connecting your mouse and do "lshal", look for "Mouse" and see how your path looks like. Change the path properly if the default one is not match.
  • Add the script to run when log-in by going to System->Start up Applications
  • Log-out and re-Log-in again. That's it.
Another way to do this is to handle it in UDEV. However, I found that GNOME will always try to enable it back that way. Besides, UDEV is run by root, but touchpad setting is per-user. Disabling Touchpad permanently (in Mouse setting) and use synclient to control touchpad is another way to go.

Saturday, August 01, 2009

View a movie on PS3 with decent Subtitle

Most of the method I found when I search for "AVCHD Subtitle .sub" which point me to either mkv2vob or tsMuxer. Most of them refer to text base subtitle (.srt) file which is good for English base subtitle. But for me I'm Thai. If possible, I would love to have the method that works for picture-base Thai subtitle. Don't ask why I am not converting this file to text base subtitle, there is no free good Thai OCR available to do that (yet).

And at last I found it. With the following toolchain you can create an AVCHD content to be played on PS3 with subtitle on/off capability, using picture-base subtitle taken from Bluray disc!
  • BDSup2Sub - Use this tool to convert .sub and .idx distributed in the Internet back to PGS .sup file (BD subtitle). Don't forget to change the resolution. I think it should be possible too to take this from a BD movie directly (but I rarely found anyone distribute subtitle file in .sup format, since .sub works well computer-base player like VLC or Media Player Classic).
  • tsMuxer - As with normal AVCHD creation, use tsMuxer to mux MKV video and audio stream, then select add and add .sup subtitle file created above. If you have a compatible MKV (H264+(AC3 or DTS)), the conversion takes only about 5-10 minutes. I would recommend writing directly to your external hard drive where you will use to plug to PS3, since speed here depend mostly on hard drive speed.
  • AVCHDMe - After the the creation of AVCHD, use AVCHDMe to make sure that the created AVCHD is playable on PS3. Mostly this only concern 8.3 file name, so I guess just renaming the file manually may work.
With this, I can view HD content with decent translation on screen. The only problem I face is that the movie has been pushed back up to top of screen, leaving a blank black panel on the bottom (instead of black panel on both top and bottom). Other than that, everything seems fine.

Tuesday, March 17, 2009

MBPurple 0.2.1 for PortableApps

New Microblog-Purple for Pidgin 2.5 PortableApps, where you can store your Pidgin on thumbdrive and bring it wherever you go, is released! Download it here

Thanks to rottnkorpse for very quick help!

Sunday, March 15, 2009

Adium port for MBPurple released!

Thanks for @jsippel for your hard work. Now the first release of Adium port for #mbpurple is here (base on 0.2.1). Enjoy!

Friday, March 13, 2009

Using PS3 to view MKV with Thai Subtitle

No, the subject is misleading. Actually I found no viable solution for viewing MKV on PS3 properly. Many will thought that I found a way to do this on Linux, but no.

The problem is sound driver. It seems that with latest mplayer-ps combination with spu-medialib, HD MKV can be viewed without any problem. (not to mention that latest mplayer now has improve x264 support + multi-thread decode on ffmpeg!). However, sound driver for any PS3-base Linux support only 2 channels!

The method I am using right now is very simple. I use mkv2vob to translate the MKV file into AVCHD-compatible format on my 80GB USB HDD. mkv2vob also handle size-limit on FAT32 by separating file into small pieces. The only problem lies in subtitle. I want the thai subtitle to be displayed on PS3!

The solution is to use SSA sub, with Thai font specified in SSA, and then use mkv2vob with "load subtitle file" enabled!. I tested this with Eagle Eye and it worked well! Thai subtitle displayed correctly on my TV screen!

The only problem is that movie screen is not in the middle of my TV. I saw on some forum said that this was because the size of original MKV file is not exact 720p or 1080p. Anyway it is a very minor point, at the least we have lots of space for subtitle.

Friday, January 23, 2009

PackageManagerCheatsheet - Naked Ape Wiki

PackageManagerCheatsheet - Naked Ape Wiki

This page include Debian, Red Hat, Sun package management cheatsheet.

Wednesday, December 10, 2008

Faxing in Ubuntu

Today, I have a mission to send out as many fax as possible to attract customer with my laptop and modem. I don't have much choice, Windows used to have good faxing support but that's gone from Vista (fax only available in Vista Business or Ultimate), so Hardy is my only quick choice now (not mentioning other commercial software for Windows).

efax command line works well and can send fax, but I have some problem on converting postscript printed file into tiffg3, because all page is not being converted, some part is being cropped. And I don't want to use command line all the time. Anyways I will document how to do that here.
  • Have your file ready in PS format, easiest way is to use "print to file" option in Print menu of Oo.O.
  • Use ghostscript to convert from PS to Tiffg3, format accepted by efax program
    gs -q -sDEVICE=tiffg3 -dNOPAUSE -sOutputFile=letter-%03d.tiff invitation_cmu.ps < /dev/null
  • You'll get letter-001.tiff - letter-00x.tiff, counted by number of pages in the PS file. Last, use efax to send it out
    efax -t  file...
I search again and found that gfax might be my helper. Anyways, gfax is not working with my mode, although I told gfax to use efax. I don't sure why, but from quick search it seems that some initialize modem command might not compatible with my modem. And there is no debugging or customize initialize command configuration available. So I try efax-gtk next. And efax-gtk works quite well on my Dell XPS M1330 Modem!
  • efax-gtk can send out single/multiple PS file by itself. I just need to change modem initialize command a bit. The key is
    .... M1L3
    Command in the latter part of Modem Init command dialog box. Also, the modem reset command is not working well, so I replaced it with hang-up command
    H
    Note that all command will always being prefixed with "AT", as normal modem command. Ah... I miss the AT command
  • Next, I don't want to just use efax-gtk. I want to print form OO.O directly to efax-gtk!. That can be easily done. First, add a new printer through system-config-printer GUI utility. Select "New Printer" -> "AppSocket/JetDirect" and specify "localhost" and port "9900" in the diaglog box (Yes, efax-gtk is also a network server)
  • Next printer type is "Generic", and model is "Raw Queue", which means we'll just get PS file from printing. After that, name the printer anything meaningfull.
  • Now open efax-gtk and leave it run in tray, then print directly to the new printer. After a while, a efax-gtk dialog will appear to ask for telephone number. It works!

Sunday, December 07, 2008

Office2007 on my hardy




Just want to mention that the instruction here is really working, even with my Office 2007 Thai Edition (btw, licensed to my organization).

(The transparent floating windows in the middle is Compiz effect on gimp whole screenshot acquire)

Saturday, November 22, 2008

20th Centry Boy - Part I

Just finished watching 20th Century Boy movie adaptation from the very famous manga with the same name.

I'm one of the fan of this series. Actually I really admire Mr. Naoki Urasawa in his talent on almost every Manga. I red 20th, Monster, and now still reading Pluto. He's quite amazing.

Anyways, my impression with 20th CB Part I is not good. I think the movie is suit more for manga fan, but for the people never read the manga version, I think they'll get confuse. Note that, this comment came directly from the one watching the movie with me. She never read the manga version. Oh, and she likes Death Note movie adapation, so there's nothing against Japanese movie.

I personally thought that the movie is OK, because I'm the fan. I reconsidered it and thought that the movie miss so many points in manga. Of course this is unavoidable since it is a very long manga. But many good points, that shouldn't be missed out, were missing ( I will try to recall it since the last time I red the manga is around 1 year ago) Some of these were
  1. The movie could not convince audience enough to believe that someone like "Friend" might exist. The "Friend" organization and Yumin party looked so unrealistics. I thought this is partly because the very fast pace of movie.
  2. The appearance of Fukube was so few. I think movie cut out the scene about teacher-ask-for-who-bend-spoons off. So the "Psychic" plot is all blown out.
  3. Otcho appearance was too short and weightless. I didn't see why he should come back to Japan. In manga, he spent a lot of time in Thailand, and there are lots of flashback on him. In movie, I didn't feel anything when he said "I'm Shokun" in the end. But the phrase really move me when I red manga.
  4. The cut is a bit confusing. Flash back and flash forward is not well handle enough.
  5. No explanation about robot at all. No details about the kidnapped professor that made the robot (he didn't appear at all in the movie). I thought most audience in theater feel that the robot is actually a robot (actually it is a big car dressed like robot). Anyways the robot in the movie looks cool enough. I think I understand immediately how they make it "looks like" robot.
  6. In manga, up until the point where movie ends, I feel that "Friend" is brilliant in the way how he cheat and fake to make people belive him. Up to this point, the only real thing was the deadly virus. In movie, this point is not well handle enough. The "Friend seminar" scene made me think that people attended the ceremony were all dumbasses who believe that "Friend" is real thing. And Friend looked unreal and unconvincing.
  7. Nothing much said about the burglar "God". His name never even being mentioned in the movie.
  8. I think the ending should adapt exactly like the ending of part I in manga (the scene where Kanna bring flower to pay respect to Kenji and scene flash to Yumin party come up to get the honourary at UN). I personally think that, in mang, this was being handle this very well. The ending in movie didn't make me feel like "I wanna watch the 2nd part!".
  9. I thik the actor taking the role of "Kenji" is too handsome :P. Anyways this is not that big deal.
  10. I did't think they had to insert the "Otcho in the jail" scene at all. It could be left for 2nd part.
  11. The joint before and after "Kenji-decision-to-go-against-Friend" was not well handled enough. I recall that Kenji lives for many years underground and train himself to go against Friend. He did try to recruit his childhood friend as ally. In movie, it seems as if it happened just after his convenient store was set on fire, if people not paying attention to the date appeared on screen.
  12. The scene where "Friend" confronted with "Kenji" on the robot. "Friend" appearred on the big structure, the same one in Osaka Expo. In movie, there was no explanation about this structure at all. Actually there was no explanation about Expo at all too, just a bit mentioned about Osaka. For foreigner like me, they wouldn't undrestand what really is the structure.
(That's all I can think of for now)

Anyways, if my memory is correct, the song that Kenji sang on the road is "that song", right? I think the song is nice.

Also, I don't sure about this, but I think the theather that I watch intentionally cut out some part of movie to make the length a bit shorter. I notice that from incontinuous dialog in many scenes. For example, the very first scene where manga writer talk with Otcho has been cut a bit. In my watch, after he ask if Otcho is human, he suddenly talking about his manga. There are other points like this in the movie as well. Anyways I think that mostly 5-10 minutes has been cut off. I will wait for DVD version to see if this is true or not. If this is not true, then the editing of this movie has some problem.