Monday, December 22, 2008

My first shell script

I'm the one of English Premiere league fans but my dorminitory doesn't provide TV channel for it. So I have to find out my own. Fortunately, there are several pirate channel available on the internet in the shape of p2p client. One of that is Sopcast

Sopcast provides very easy using application for Windows OS user but it's not me. For Linux user there are a program that can invoke by command line and you have to use your own media player to play it yourself (In fact, there are someone writing linux's front-end Sopcast but it's not work in the way I want)

My problem is that I can't remember the command to run it. Every weekend, I have to open README file of Sopcast for the program running instruction. So I decided to write a script to handle it automatically. And it's also my first shell script ever. Here it is.
#!/bin/sh

echo Start Sopcast at $1
/usr/local/bin/sp-sc $1 3908 8908 > /dev/null &
echo Waiting for Sopcast starting
sleep 10
vlc http://localhost:8908/tv.asf
From now on, any other weekend, no README file. This makes me love not-Windows OS more and more.

Saturday, December 20, 2008

VIM - tab size & tab to space setting

to change tab size use this command
:set ts=n
(n=expected size ,ts=tabstop)

to change tab to space use this command
:set et
(et = expandtab)

also invoke it together like this
:set ts=4 et

if you want permanent changing, add command above to file named .vimrc (normally is at your home folder)

Monday, December 15, 2008

FreeBSD Assignment#1 Answer

หลังจากหมดเขตส่งแล้ว(00.00 12/15/2008) ก็เอางานมาโพสหน่อยละกัน อาจจะไม่มีประโยชน์สำหรับคนอื่นเท่าไหร่ แต่ก็เผื่อมาอ่านผ่านๆ ตา แล้วค่อยไปค้นเนื้อหาเต็มต่อละกัน

เป็นงานย่อความของลิงค์ต่อไปนี้
- http://www.freebsd.org/cgi/man.cgi?query=tuning
- http://www.freebsd.org/doc/en/books/handbook/configtuning-kernel-limits.html
- http://silverwraith.com/papers/freebsd-tuning.php
- http://www.freebsd.org/doc/en/books/handbook/configtuning-disk.html
- http://www.freebsdonline.com/content/view/521/515/

ให้ cover หัวข้อต่อไปนี้
- What is the target subsystem being tuned?
- Why tune the target subsystem?
- How? That is, briefly, what is the approach used to tune the subsystem?

เข้าไปดูได้เลยที่ link นี้ http://docs.google.com/Doc?id=dcmk32tk_17ggmd5xf4

Tuesday, December 9, 2008

Fragment Size

From my assignment of FreeBSD class, I wanna know the meaning of "fragment size". Because of there no an explanation in the first Google result page so I write this blog for you. ^^

Fragment size is a threshold whether this file will hold full block size allocation or not. If the allocating file size more than fragment size, it will get full block size. If not, it will store in the minimum necessary number of contiguous fragments.

credit : File-System Fragment Size

Sunday, December 7, 2008

[TinyOS 1.x] Lesson4

  • From "IntOutput = IntToRfmM;" The equal sign (=) means interface IntOutput provided by current file is equivalent to the implementation in IntToRfmM (mostly use in interface provided configuration file)
  • Can look how to send and receive via radio at IntToRfm and RfmToInt respectively. (Too much detail to make a summary. Just look at the code can get the idea)

This blog is summarized from Lesson 4: Component Composition and Radio Communication

[TinyOS 1.x] Lesson3

  • Task declared syntax is
task void taskname(){}
  • Task dispatched syntax is
post taskname();
  • Task can post from command event or another task. It's better to use series of small tasks

This blog is summarized from Lesson 3: Introducing Tasks for Application Data Processing

Tuesday, December 2, 2008

[TinyOS 1.x] Lesson2

  • In uses brackets can declare interface ?? as ???; to perform as another instance of an ?? interface.
  • ADC is also in tos/interfaces
  • Components declaration can also us as
  • "Ased interface" in module can wire in configuration.
  • parameterized interface is a multiple instance of an interface that parameterized at runtime. It can express like this. SenseM.Timer -> TimerC.Timer[unique("Timer")];
  • Because of this line "provides interface Timer[uint8_t id];" means Timer provide 256 different instances one for each uint8_t value
  • unique() function uses to generate unique 8-bit number. The group of unique can specify by use the same String as the parameter of the function
This blog is summarized from Lesson 2: Event-Driven Sensor Acquisition

Monday, December 1, 2008

[TinyOS 1.x] Lesson1

This blog series "TinyOS 1.x" is for helping me to remember the knowledge that I have learned and forget it later since it's not an everyday used language (And also because I still didn't get all its concepts) You know today is the third time that I will start read its tutorial again. What I wanna tell you is that this blog series may be useless for you guy because it's just for my memo. Let's start then...
  • There is an interface. That the users must implement events and the provider must implement commands.
  • An application consists of components. Each component has configuration(wiring) and module(implementing)
  • There're 2 threads of execution - tasks(not preempt another), Hardware event handlers(preempt another) declared with async keyword.
  • In configuration file
configuration [name]{}
implementation {
[components declaration]
[wiring] Main.StdControl -> ??.StdControl; ..
}
  • Main.StdControl.init() is the first executing command of any application.
  • StdControl interface is at tos/interfaces/StdControl.nc
  • Timer is at tos/interfaces/Timer.nc
  • SingleTimer is at tos/lib/SingleTimer.nc
  • BlinkM.Leds -> LedsC is really shorthand for BlinkM.Leds -> LedsC.Leds
  • In module file
module [name]{
provides{[interface that is wired in configuration]}
uses{[interface that wire to in configuration]}
}
implementation{
command..
event..
..
}
  • Timer is an interface for fire event at interval time

this blog is summarized form TinyOS Tutorial Lesson 1: Getting Started with TinyOS and nesC

Tuesday, November 11, 2008

Share files between Linux host & Linux guest on Virtualbox

Make Virtualbox know which folder you want to share
Devices -> Shared Folders -> Add New Shared Folder
Fill shared folder destination and its name for calling in the guest (Also tick read only or permanent as you wish)

In the guest's terminal
Create folder somewhere you want which the name as what you defined.
Use this command
sudo mount -t vboxsf [folder's name] [the path where the folder is at]


credit : Sharing Folders Between Host and Guest

Sunday, November 9, 2008

How to get USB work in Intrepid

The work around to enable USB in Intrepid is different from Hardy.

The way to do that is to add this below line in the bottom line of /ect/fstab file

#usbfs
none /proc/bus/usb usbfs devgid=46,devmode=664 0 0

that is it!

credit : Intrepid/Virtualbox/USB

Thursday, October 30, 2008

Mount ISO image on Ubuntu

Mount
sudo mount -o loop -t iso9660 [ISO image] [Mount point]

Unmount
sudo umount [Mount point]

Friday, September 5, 2008

Swappiness - รับค่าโอกาสในการไปใช้ swap แทน ram

เนื่องจากผมรัน vmware player แล้วรู้สึกว่าช้ามากจึงไปเช็คที่ Gnome System Monitor ในตอนแรกมองข้ามไป ว่า vmware ไม่ได้กิน resource อะไรเลย แต่ก็งงว่า ที่ตัว process ของ vmware นั้นบอกว่าใช้ memory กว่า 400 MB แต่ทำไม ram ของเราถูกใช้ไปแค่ 400 MB เช่นกัน หงุดหงิด กับสปีดของ vmware อยู่นาน ก็เพิ่งจะได้สังเกตดว่า จริงๆ แล้ว ram ที่ตัว vmware เราใช้นั้นไปอยู่บน swap ซะหมดเลย (มิน่าหละ ทำไมทำอะไรแต่ละที Hard disk ทำงานหนักเหลือเกิน)

จึงทำการหาวิธีการจัดการกับ swap จนไปพบว่าเราสามารถปรับแต่โอกาสในที่จะให้เจ้า Ubuntu ของเราไปวาง memory ไว้บน swap ได้ ด้วยค่า swappiness นี่เอง ซึ่งปกติจะตั้งไว้ที่ 60 แต่จริงๆ เค้าแนะนำไว้ที่ 10 (ยกเว้น งาน server ที่เค้าบอกว่าน่าจะ 60) ตามนี้เลย

ถ้าต้องการตรวจสอบค่า swappiness
cat /proc/sys/vm/swappiness

ถ้าต้องการเปลี่ยนค่า swappiness ชั่วคราว
echo 10 > /proc/sys/vm/swappiness

ถ้าต้องการเปลี่ยนค่า swappiness ถาวรเปลี่ยนค่าที่ไฟล์นี้
gksudo gedit /etc/sysctl.conf
โดยเพิ่มบรรทัดนี้ เข้าไป
vm.swappiness=10
แล้วทำการ reboot


จาก Performance tuning with ''swappiness''

ปล. พบว่าถึงแม้ว่าจะตั้งค่าเป็น 0 ในบางโอกาส OS ก็ยังไปใช้ swap อยู่ดี

Friday, August 29, 2008

Google Keyword Suggestions

ประโยชน์ มีดังนี้
  • เพิ่มเติมจากคำที่เราพิมพ์ผ่านมาให้เลือก (เพื่อความ specific ของคำค้นหา)
  • เดาการพิมพ์ผิด
  • ลดจำนวนครั้งการพิมพ์
จาก At a loss for words?

Thursday, July 24, 2008

เทคโนโลยีเบื้องหลัง Google ranking

หลักการของระบบ search ของ Google มีดังนี้
  • เข้าใจหน้าเว็บ ว่าเป็นนั้นคือเว็บอะไร อยู่ที่ไหน ฯลฯ
  • เข้าใจคำ search แก้คำสะกดผิด, แปลคำที่มีความหมายใกล้เคียงกัน, การขยายความกันและกันของคำ search
  • เข้าใจผู้ search ว่าอยู่ที่ใดบนโลก ต้องการผลแบบใด, ความสนใจ-ชอบ ส่วนบุคคล, แก้ความเข้าใจผิด, หาคำเดียวกันบนภาษาอื่น
จาก Technologies behind Google ranking

Collectd PostgreSQL Plugin

I couldn't find this link when searching with google https://www.collectd.org/documentation/manpages/collectd.conf.html#plugin-postgresql