Sunday, December 29, 2013

how to block and punish users who download bittorrent in LAN

block it

iptables -I FORWARD -s -i eth2 -j DROP

Saturday, December 28, 2013

raspbmc (raspberry pi + xbmc) and remote controller

I had problem with raspbmc.  My remote controller of Samsung TV Series 5 didn't work.  The TV is connected with raspbmc with HDMI cable.  I found out later that it is because of my outdated version of HDMI cable (HDMI cable has versions!!!).  Replaced it with the new one with newer version, then I can use remote controller with raspbmc!

Thursday, December 26, 2013

apache mod qos

Want to control limit of request per each url and etc with apache?  Try mod_qos.

You can install it from debian's repository too.

Wednesday, December 25, 2013

How to reset password of user in TWiki

Simply go to /twiki/data/.htpasswd and replace the password field with the result from "htpasswd -d" ( Force CRYPT encryption of the password).  htpasswd is an Apache's tool.

Monday, December 16, 2013

kindle fails to look up dictionary

The problem is that I can't look up words from English dictionary with this specific book.  I manage to find out that this book's meta data has error.  It is set to be Spanish while, in fact, it has to be English.

Here is an easy fix.
  1. Download the book from as .azw format to your computer.
  2. Open Calibre (  Add this book to Calibre.
  3. Use Calibre to "edit metadata" of this book.  Change it from Spanish into English.
  4. Export this book (save to disk).
  5. Send the new azw file to you Kindle as a personal document (probably via Kindle's email).

Monday, November 25, 2013

apache with security

Ubuntu Linux

#### installation
  • apt-get install apache2-mpm-itk
  • apt-get install acl
  • set acl in /etc/fstab

    e.g. LABEL=cloudimg-rootfs   /        ext4   defaults,acl    0 0
#### instructions for setting up new virtual host

useradd --home /vhdocs/your_web --shell /bin/false your_web
# default permissions
chown -R ubuntu.your_web your_web
chmod -R o-rwx your_web
chmod -R g+rx your_web
chmod -R g-w your_web
setfacl -R -d -m "g:developers:rwx" your_web
setfacl -R -d -m "g:your_web:r-x" your_web

# allow read/write/execute to developers
setfacl -R -m "g:developers:rwx" your_web

# allow write to certain directories
setfacl -R -m "g:your_web:rwx" writable_dir

# everytime after deployment
setfacl -R -m "g:developers:rwx" *

cd /vhdocs/ ; git init

Saturday, November 23, 2013

Tuesday, November 12, 2013

windows มีปัญหา network connection แบบงงสุดๆ

ถ้าหากท่านอยู่ดีๆพบปัญหาว่า Windows ของท่านอยู่ๆเชื่อมต่อ network ไม่ได้ เข้าไปดูค่า network setting ก็ดูปกติดี หรือ บางครั้ง connection ทั้งหมดก็หายไปเฉยๆ อย่าเพิ่งตกใจ ให้ลอง install windows update แล้ว restart เครื่องดูนะครับว่าหายไหม

เหตุเป็นเช่นนี้ ดูเหมือนว่า windows จะมีปัญหาตรง windows update แม้เราจะเลือกว่าให้ download มาแต่อย่าเพิ่ง install แต่จะมีบาง update ที่ทำให้ windows เกิดปัญหากับ network ได้หากไม่ install แล้ว restart ข้าพเจ้าพบปัญหานี้ทั้งใน windows server 2003, windows xp, windows 7 และ windows 8 ตะรึงตรึง

Sunday, October 20, 2013

อุปกรณ์ไอทีราคาถูกที่สุด หาได้ที่ไหน

หลังจากสำรวจราคาอยู่นานไปพบร้านจริงใจมาร์เก็ต เข้าไปดูพบว่าสินค้าร้านนี้ราคาถูกที่สุดแล้ว สังเกตจาก priceza (ตัวอย่างราคา samsung galaxy note 3):

ว่า jingjaimarket ขายถูกสุดแถมมีประกันศูนย์ด้วย 1 ปี นอกจากนี้ยังมีสินค้าไอทีอื่นๆอีก และ น้ำหอม ที่ราคาถูกกว่าเจ้าอื่นๆโดยส่วนใหญ่


Saturday, August 17, 2013

how to create .pem for ejabberd

cat gd_bundle-g2.crt > ejabberd.pem

Friday, August 16, 2013

how to copy and paste text in vimperator

  • Find text you want using "/" and "n" (or "N" to go backward).
  • Enter caret mode with "c".
  • Press "v" to select (highlight) text.
  • Select text with vi's navigation keys such as hjklv.
  • Copy (yank) text with "y".
  • Now, you go to any text input field you want to place the text and use "f" to enter to that text field.  Press "ctrl+t".  Press "p".

Sunday, July 28, 2013

checkbox "run this program as an administrator" is greyed out on .bat file

Windows 7 (sucks)

You cannot check the checkbox "run this program as an administrator" of your .bat file in Windows 7.  It is greyed out.  An easy workaround is to create a shortcut from that .bat file.  Then, you can check that option on the shortcut instead!!! : )

Saturday, June 8, 2013

split multi pages pdf into mutiple jpeg files

convert -quality 100 -density 300x300 multi_pages.pdf single%d.jpg

Sunday, May 12, 2013

debian 7.0 64-bit and firefox

If you want to install Firefox (32-bit) on Debian 7.0 (64-bit), you have to install the 2 packages:
  • ia32-libs
  • ia32-libs-gtk

Tuesday, April 30, 2013

debian start-stop-daemon issue

Fresh installed debian, you may find empty (exit 0;) /sbin/start-stop-daemon file which causes you be unable to start sshd, for example.  To resolve this:

apt-get install --reinstall dpkg

Friday, April 26, 2013

how to change default kernel selection at boot time - linux

สุดท้ายแก้ไขไปพลางด้วยการ vi /etc/default/grub ใส่ DEFAULT="1>2" ตามด้วย update-grub ใช้ kernel 3.5.0-26 ไปก่อนดีกั่ว

Friday, April 19, 2013

how to record desktop screen in linux

ffmpeg -f x11grab  -s 1680x1050 -r 25 -i :0.0 -sameq live_streaming_issue.mpg

Tuesday, April 16, 2013

how to limit number of connections to server per second with iptables

# 2 hits per second per ip address

iptables -A INPUT -p tcp --dport 80 -i eth0 -m state --state NEW -m recent --set
iptables -A INPUT -p tcp --dport 80 -i eth0 -m state --state NEW -m recent --update --seconds 1 --hitcount 2 -j DROP

iptables -A INPUT -p tcp --dport 443 -i eth0 -m state --state NEW -m recent --set
iptables -A INPUT -p tcp --dport 443 -i eth0 -m state --state NEW -m recent --update --seconds 1 --hitcount 2 -j DROP

Sunday, March 31, 2013

how to change your dm-crypt passphrase

  1. Assuming your encrypted partition is /dev/sda5 (crypttab would say sda5_crypt)
  2. add new key: cryptsetup luksAddKey /dev/sda5
  3. reboot and test
  4. remove old key: cryptsetup luksRemoveKey /dev/sda5


Friday, March 29, 2013

how to mount read/write ntfs in macosx

Well .. i was facing same problem and i've found a solution that works perfectly for me and i can write on NTFS:

1- Install OSXFUSE == > The most important part is to check the compatibility layer within installation otherwise it wont work
2- Install fuse_wait pkg
3- Install ntfs-3g 2010.10.2 and remove the MacFuse from the customized installation (if you couldn't, just after installation, go to preference and remove the MacFuse)
4- Reboot your macbook, et Voila .. it'll work

i've got this info from this link

Hope that would help

Cheers, Soha

how to migrate VirtualBox

  1. delete all snapshots
  2. file > virtual media manager
  3. edit VirtualBox.xml

Saturday, March 23, 2013

how to limit number of connections to our server per period of time with iptables

sample - allow 2 hits once every 3 seconds

iptables -A INPUT -p tcp --dport 80 -i eth0 -m state --state NEW -m recent --set
iptables -A INPUT -p tcp --dport 80 -i eth0 -m state --state NEW -m recent --update --seconds 3 --hitcount 2 -j DROP

Wednesday, February 27, 2013

debian fresh install can't start services under /etc/init.d

If for any reason you can't start any services under /etc/init.d after a fresh installation of debian, you may try "apt-get install --reinstall dpkg"

Friday, February 15, 2013

iptables slow down http and https


-A INPUT -p tcp -m tcp --dport 80 -j ACCEPT
-A INPUT -p tcp -m tcp --dport 443 -j ACCEPT

Websites on the server will response very slowly.

But if you add:


 Websites will response fast as usual.

Saturday, February 9, 2013

how to mount samba fs to directory in linux

mount //some_server/share /home/grml/smbfs/share -o "user=share,password=****,uid=grml,gid=grml"

but if your password is complex (e.g. contains special characters), better use -o "credentials=/path/to/credential"

credential file format is:


On Debian 7.0, you will need to "apt-get install cifs-utils" first to get mount.cifs.