A sample text widget

Etiam pulvinar consectetur dolor sed malesuada. Ut convallis euismod dolor nec pretium. Nunc ut tristique massa.

Nam sodales mi vitae dolor ullamcorper et vulputate enim accumsan. Morbi orci magna, tincidunt vitae molestie nec, molestie at mi. Nulla nulla lorem, suscipit in posuere in, interdum non magna.

How to Export UTF-8 CSV File in PHP

I had problems with displaying UTF-8 characters in my exported CSV files. Unlike LibreOffice Calc and Google Docs, this happened on only MS Excel. Here is a small hack:

header("Content-Transfer-Encoding: binary");
header("Content-Length: " . strlen($str) ."; ");
header("Content-Disposition: attachment; filename=\"ourfilename.csv\"; ");
header("Content-Type: application/");
echo "\xEF\xBB\xBF"; // UTF-8 BOM
echo $str;

เริ่มเขียนโปรแกรมบน Android

App Inventor เครื่องมือในการพัฒนา Android App ของ google

เครื่องมือในการพัฒนาโปรแกรมบน Android

สรุปขั้นตอน เริ่มต้นเขียน android application


  1. Download โปรแกรม Eclipse – เป็นโปรแกรมที่เขียน android application แนะนำให้ใช้ตัวนี้ เพราะว่าคู่มือที่ google จัดทำ จะใช้ตัวนี้เกือบทั้งหมด
  2. Download JDK – เป็น Java environment สำหรับ developer (คนที่มี JRE ในเครื่องแล้ว ไม่พอนะครับ)
  3. Download Google SDK – เป็น environment ต่างๆ ที่ google เค้าจัดมาให้ รวมไปถึงตัว emulator ต่างๆด้วย
  4. ติดตั้งตัวเสริม ให้กับ Eclipse – เพื่อให้สามารถทำงานเชื่อมต่อกับ Google SDK ได้
  5. เริ่มเขียนโปรแกรมแรก ในชีวิต

ทั้งนี้ ช่วงท้าย จะมีแถมให้สองเรื่อง คือ การทำให้ emulator (ระบบจำลองโทรศัพท์ android) ที่ต่ำกว่า 2.2 สามารถอ่านตัวหนังสือภาษาไทยได้ กับอีกเรื่องคือการเอาตัวติดตั้ง ไปติดตั้งที่ android เครื่องจริง ซึ่ง ก่อนที่จะเริ่ม ผมแนะนำว่า ให้ใช้ internet ที่มีความเร็วหน่อยนะครับ เพราะว่าทั้งหมดนี้ ขนาดมันใหญ่มาก (น่าจะเกิน 2 GB) รวมทั้ง harddisk ที่จะใช้เก็บก็ด้วย แนะนำให้ใช้ drive ที่เหลือพื้นที่เกิน 5 GB ก็น่าจะอยู่ครับ ถ้าไม่ได้กระหน่ำเขียนอะไรเยอะแยะนะครับ



ทำให้ teamspeak ใช้ฐานข้อมูล mysql

I’ll use server terminal for all such commands. You should execute them from local server terminal or SSH connection such as OpenSSH server.

I’ll use bold font for commands, red bolded font for informations that needs edit to your preferences and orange bolded font for temporary things such as download address.

Firstly we need to download latest server package for linux from here, remember that it needs to match your server architecture – use i386 (x86) for 32-bit and amd64 for 64-bit. Also it would be cool to start teamspeak process as another user, just for server security. So… let’s do it.

root@archi:~# adduser teamspeak
root@archi:~# su teamspeak
teamspeak@archi:/root$ cd ~
teamspeak@archi:~$ wget
teamspeak@archi:~$ tar xvf teamspeak3-server_linux-amd64-
teamspeak@archi:~$ mv teamspeak3-server_linux-amd64 teamspeak
teamspeak@archi:~$ cd teamspeak
teamspeak@archi:~/teamspeak$ chmod +X ts3server_linux_amd64
teamspeak@archi:~/teamspeak$ chmod +X
teamspeak@archi:~/teamspeak$ nano ts3server.ini

In last command you can use your favourite text editor, I used nano.

Now paste below text to your text editor and save it as ts3server.ini.
You can edit red bolded text to your preferences.


Okey. Now we need mysql-server on our machine. If you already have MySQL server on other machine and you want to use it instead – skip this part and remember to change host and port in ts3db_mysql.ini. As part of this tutorial we’ll set up local mysql server.

teamspeak@archi:~/teamspeak$ su root
root@archi:/home/teamspeak/teamspeak# cd ~
root@archi:~# apt-get update && apt-get install mysql-server

You’ll be prompted for root password for MySQL server. This is NOT a password for your teamspeak mysql connection. We’ll use non-root mysql account for teamspeak.

Okay, MySQL Server should be running. Next…

root@archi:~# mysql -h localhost -u root -p
mysql> create database teamspeak;
mysql> grant ALL on teamspeak.* to teamspeak@localhost identified by 'your_password_for_mysql_connection';
mysql> exit

Let’s continue…

root@archi:~# su teamspeak
teamspeak@archi:/root$ cd ~/teamspeak
teamspeak@archi:~/teamspeak$ nano ts3db_mysql.ini

Now paste below text to your text editor and save it as ts3db_mysql.ini.


Okay. We’re nearly ready to go. Last (and probably hardest) part is to set up right libraries for teamspeak. Firstly let’s check actual status…

teamspeak@archi:~/teamspeak$ ldd

You should get similar output: => (0x00007fff8a7c8000) => not found => /usr/lib/x86_64-linux-gnu/ (0x00007f091a950000) => /lib/x86_64-linux-gnu/ (0x00007f091a6cd000) => /lib/x86_64-linux-gnu/ (0x00007f091a4b7000) => /lib/x86_64-linux-gnu/ (0x00007f091a130000)
/lib64/ (0x00007f091ae65000)

As we can see it’s missing libmysqlclient15 library. There are 2 ways to fix it. First one is just copying this library from older linux distros and paste it and second way is just to install missing package. We’ll use second way because it’s much easier.

Package is named libmysqlclient15off and it’s unavailable to install for latest distros. We need to download and install it manualy.

There are 2 main versions of this package. Ubuntu version and Debian version. For some reason Ubuntu version of libmysqlclient15off works much better on my both machines – ubuntu and debian. I’ll attach working links:

Ubuntu Hardy [5.0.96] (i386) –…untu3_i386.deb
Ubuntu Hardy [5.0.96] (amd64) –…ntu3_amd64.deb
Debian Lenny [5.0.51a] (i386) –…enny5_i386.deb
Debian Lenny [5.0.51a] (amd64) –…nny5_amd64.deb

Warning! libmysqlclient15off needs installed package mysql-common. If you have working MySQL Server on your machine it has been installed automatically. If you have remote MySQL Server install it using apt-get install mysql-common running as root.

If for some reason Ubuntu’s version won’t work for you just install Debian’s one. I’ll install Ubuntu’s amd64 version for my machine:

teamspeak@archi:~/teamspeak$ su root
root@archi:/home/teamspeak/teamspeak# cd ~
root@archi:~# wget
root@archi:~# dpkg -i libmysqlclient15off_5.0.96-0ubuntu3_amd64.deb

And that’s it! We’ve installed missing library for teamspeak. Let’s check if everything works fine:

root@archi:~# su teamspeak
teamspeak@archi:/root$ cd ~/teamspeak
teamspeak@archi:~/teamspeak$ ldd

Output: => (0x00007fff4b5f1000) => /usr/lib/ (0x00007f27ece0b000) => /usr/lib/x86_64-linux-gnu/ (0x00007f27ecb04000) => /lib/x86_64-linux-gnu/ (0x00007f27ec881000) => /lib/x86_64-linux-gnu/ (0x00007f27ec66b000) => /lib/x86_64-linux-gnu/ (0x00007f27ec2e4000) => /lib/x86_64-linux-gnu/ (0x00007f27ec0c7000) => /lib/x86_64-linux-gnu/ (0x00007f27ebe90000) => /lib/x86_64-linux-gnu/ (0x00007f27ebc78000) => /lib/x86_64-linux-gnu/ (0x00007f27eba60000)

Yep, It works just fine.

This step is optional. You don’t need screen software to run TeamSpeak but it can help you out if you like to have things running in seperate windows like myself. Screen is useful when we’re leaving our server in a background. If you wish to attach to the output just typescreen -r as user teamspeak. If you want to deattach it just hit CTRL+A+D.

teamspeak@archi:~/teamspeak$ su root
root@archi:/home/teamspeak/teamspeak# apt-get install screen

And let’s turn on our server…

root@archi:/home/teamspeak/teamspeak# cd ~
root@archi:~# su teamspeak -c 'screen -d -m -S ts3 /home/teamspeak/teamspeak/ inifile=ts3server.ini'

If you didn’t install screen use this command:

root@archi:/home/teamspeak/teamspeak# cd ~
root@archi:~# su teamspeak -c '/home/teamspeak/teamspeak/ inifile=ts3server.ini'







เข้าหัวไฟเบอร์แบบหัวบีบ (Impact Tools)



สอนการเข้าหัวไฟเบอร์แบบ E-Proxy

โปรแกรมที่เป็นแถบๆ เหมือน MAC

สร้าง Radius Account แบบหมดอายุนับจากวันแรกที่ใช้งาน


I’ve been experimenting with freeRadius for 2 weeks now, but I still havent got it to do the following:

I need to expire a specific time (could be different for each account) after their first login. This time is listed in the MySQL database under the attribute “Max-All-Session” in seconds. The server has a MySQL backend which is working correctly.

I’ve tried the following methodes (they will be described in detail below):

  • sqlcounter
  • expireonlogin
  • allowedperiod

Unfortunately non of the above are working correctly. I will explain them in detail now:

This is a basic module built in the “stock” version of freeradius. It calculated the maximum allowed time for an user account. Unfortunately it comes with 2 problems. The first (which sounds like a bug) is that on an account’s first login it always shows (and calculates) a incorrect time of more the 400 hours remaining.
Secondly it stops counting when a user logs out, or time-outs (disconnects), so if a user re-connects it will continue at the remaining time the user had when it disconnected.

sqlcounter expire_on_login
I found this code on the net. It’s supposed to calculate the remaining time and then write it as a Expire attribute in the database.
I included this code in the sql.conf file and added “expire_on_login” to the authorize section of the sites-available/default file.
I didn’t see this script make any changes to the database.

sqlcounter accessperiod
I also found this script on the web: here and here. I included that code in the modules{} section, and added “accessperiod” to the sites-available/default file in the authorize section.
This code however did do something, it created a Expire record in the database, but one month from the first login, and not even exactly, but exactly at midnight, always!

I’ve been google-ing non-stop for days now, with the above result. I’d really appreciate any help. If you want to do some anonymously (private) you can PM, or add me on MSN, or Skype.

# -*- text -*-
#  $Id$

#  Set an account to expire T seconds after first login.
#  Requires the Expire-After attribute to be set, in seconds.
#  You may need to edit raddb/dictionary to add the Expire-After
#  attribute.
#  This example is for MySQL.  Other SQL variants should be similar.
sqlcounter expire_on_login {
	counter-name = Expire-After-Initial-Login
	check-name = Expire-After
	sqlmod-inst = sql
	key = User-Name
	reset = never
	query = "SELECT TIME_TO_SEC(TIMEDIFF(NOW(), acctstarttime)) \
		 FROM radacct \
		 WHERE UserName='%{%k}' \
		 ORDER BY acctstarttime \
		 LIMIT 1;"