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

Collectd PostgreSQL Plugin

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