Monday, December 8, 2014

thunderbird (icedove on debian) and /tmp/ issue

Thunderbird has a flaw. When you open attachment directly from it, it
saves the file under /tmp/ with read permission to the world. Any other
users on the same machine can read it freely.

To fix this, you must set the tmp directory for thunderbird manually
like the line below.

$ TMP=~/tmp/.icedove icedove -P default -no-remote > /dev/null 1>&2 &

Monday, November 24, 2014

How To Backup BootSector/MBR for Windows Boot

Backup the BootSector/MBR

Some guides show only taking the first 512 bytes (MBR), others show the
first 63 blocks (MBR + Bootloader).

# dd if=/dev/sda of=/mnt/storage/sda.mbr bs=512 count=1
# dd if=/dev/sda of=/mnt/storage/sda.vbr bs=512 count=63

Friday, November 21, 2014

how to delete samba session on windows

control keymgr.dll

พอลบ user แล้วก็ใช้คำสั่ง net use ดูว่าเราค้างอยู่ในแชร์ไหนของ samba ก็ delete ออก
อย่างเมื่องเช้าค้างอยู่ใน folder share ก็ใช้ net use \\samba\share /delete

Sunday, November 16, 2014

how to permanently set max_user_watches of inotify in debian

add the following lines:

> fs.inotify.max_user_watches=200000

into this file: /etc/sysctl.d/local.conf

Saturday, November 15, 2014

how to get serial number of harddisk on dell server

Dell server uses PERC controller so...

smartctl -a -d megaraid,$a /dev/sda

$a is 0, 1, 2 and 3 for disk #0, #1, #2 and #3, expectively

Sunday, November 9, 2014

rsync

useful rsync command line

rsync -avz --delete --append src/ dst

Sunday, October 26, 2014

Thursday, October 23, 2014

debian missing firmware issue when installation

You have to put all directories

e.g. RTL8192E, RTL8192SU, rtl_nic and rtlwifi

into a vfat formatted usb drive. Then upon installation of debian,
it will ask you to insert it. You have to take off the usb drive
with debian installation software. Insert the usb drive with this firmware.
Next. Next. Then take off the usb drive with this firmware. Insert the
usb drive with debian installation software.

*** important ***

Then, you will encounter this error:

There was a problem reading data from the CD-ROM. Please make sure
it is in the drive. If retrying does not work., you should check
the integrity of your CD-ROM.

Failed to copy file from CD-ROM. Retry?

You have to ctrl+alt+f2 (switch to another console).

Then, mount /dev/sdc1 /cdrom, assuming the installation usb drive is
/dev/sdc1.

Switch back to the previous console. Go.

Friday, October 10, 2014

transmission-daemon

transmission-daemon -g /home/debian/.config/transmission-daemon transmission-remote -l
transmission-remote -t all -S # stop

Wednesday, August 27, 2014

pre-revprop-change for svnsync

#!/bin/sh

USER="$3"

if [ "$USER" = "root" ]; then exit 0; fi

echo "Only the syncuser user may change revision properties" >&2
exit 1

Thursday, July 31, 2014

how to factory reset lenovo a369i

All other how-to s I find from Google don't work.

The instructions below is proven to work by myself.
  • Turn off your phone.
  • Take battery off.
  • Insert battery.
  • Press power key, volume down key and volume up key and hold them together at the same time.
  • Your phone boots into "meta something" mode.
  • Press power key 1 time.
  • Press volume down multiple times until you reach "wipe data/factory reset".
  • Press volume up key 1 time.
  • Press volume down multiple times until you reach "yes".
  • Press volume up key 1 time.
  • Wait until "data wipe complete".
  • Press volume down or up or power button (sorry I forgot).
  • Choose reboot system now.
  • Press volume up key 1 time.


Tuesday, June 17, 2014

Thursday, June 12, 2014

using memcache for php session

สรุป พอคนเข้าเว็บเยอะ php บน debian หรือ ubuntu ไปเรียกใช้ "fuser" ในการจัดการไฟล์ session ที่หมดอายุ ซึ่งมีประสิทธิภาพต่ำมาก ต้องเปลี่ยนไปใช้ memcache แทน ฉะนั้น ปัญหาจึงหาย และ จำไว้เป็นบทเรียน


Thursday, June 5, 2014

a working iptables firewall rules

#!/bin/bash

# eth0 is connected to the Internet
# eth3 is network B

# flush all chains
iptables -F
# flush all chaines in nat table
iptables --table nat -F

# default policies
iptables -P OUTPUT ACCEPT
iptables -P FORWARD DROP
iptables -P INPUT DROP

# allow unlimited traffic on loopback
iptables -A INPUT -i lo -j ACCEPT
iptables -A OUTPUT -o lo -j ACCEPT

# {{{ packet forwarding
# allow packet forwarding for the entire LAN
iptables -A FORWARD -i eth3 -o eth3 -j ACCEPT # network B

# masquerade
iptables --table nat --append POSTROUTING --out-interface eth0 -j MASQUERADE

# allow packet forwarding from internal network to the internet
# and allow packet forwarding from the internet to internal network
# if the packet is established or related from the internal network
iptables -A FORWARD -i eth3 -j ACCEPT # network B
iptables -A FORWARD -i eth0 -m conntrack --ctstate ESTABLISHED,RELATED -j ACCEPT
# }}} packet forwarding

# ssh
iptables -A INPUT -i eth0 -p tcp -s external_ip_0,external_ip_1 --dport 22 \
  -j ACCEPT

# mosh
iptables -A INPUT -i eth0 -p udp -s external_ip_0,external_ip_2 \
  --dport 60000:61000 -j ACCEPT
# }}}

# allow incoming packets from related or established existing trusted
# connections so that we can connect to the Internet from this gateway
iptables -A INPUT -i eth0 -m conntrack --ctstate ESTABLISHED,RELATED -j ACCEPT

Wednesday, June 4, 2014

apt-offline how to

update and upgrade

apt-offline set apt-offline.sig
apt-offline get apt-offline.sig -d [directory] --threads 5

apt-offline install [directory]
apt-get upgrade

install package

apt-offline set debian-install.sig --install-packages mc hdparm
apt-offline get debian-install.sig -d [directory] --threads 5

apt-offline install [directory]
apt-get install mc hdparm

misc

apt-key exportall | gpg --no-default-keyring --import --keyring /etc/apt/trusted.gpg

http://www.debian-administration.org/article/648/Offline_Package_Management_for_APT

http://blog.sleeplessbeastie.eu/2014/01/30/how-to-manage-packages-on-an-off-line-debian-system/

Sunday, May 25, 2014

how to configure wrt54grl with firmware dd-wrt to release more that 253 client ip addresses

hardware model: wrt54gl
firmware: dd-wrt v24-sp2 (10/10/09) mini

page:setup >
- dhcp server: disable
- Use DNSMasq for DHCP: enable
- Use DNSMasq for DNS: enable

page:services > services >
- DNSMasq: enable
- Local DNS: enable
- additional dnsmasq options, enter
  dhcp-range=lan,172.18.0.10,172.18.2.255,255.255.252.0,1440m
  dhcp-option=6, 8.8.8.8, 8.8.4.4

verifification, page:administrations > commands >
- cat /tmp/dnsmasq.conf

should see:

interface=br0
resolv-file=/tmp/resolv.dnsmasq
dhcp-range=lan,10.12.0.254,10.12.3.254,255.255.252.0,1440m
dhcp-option=6, 8.8.8.8, 8.8.4.4

how to recover broken/damaged/bricked wrt54gl router

If you accidentally damage your wrt54gl, for example, by directly upgrading stock router with Standard Generic instead of Mini Generic (and then follow by Standard Generic), you can recover your router as follow.
  1. Download stock firmware from linksys's website.
  2. Using tftp to flash the firmware.  Execute these commands in tftp:
    > binary  > rexmt 1  > timeout 60  > put dd-wrt.vXX_XXX.XXX
  3. Hard reset the router: Power on + push reset button for 30 seconds, Power off + still keep pushing the reset button for 30 seconds and Power on + still keep pushing the reset button for another 30 seconds.

references

Friday, May 23, 2014

fail to determine the codename of the release

alt + f2
mount /dev/sdc1 /cdrom
alt + f1

This is a bug.  Debian installer expects files under /cdrom/.

Saturday, April 5, 2014

how to convert mp4 into mp3 with ffmpeg

$ ffmpeg -i เพลง\ Cookie\ Run.mp4 -f mp3 -ab 192000 -vn cookierun.mp3

Friday, April 4, 2014

Monday, March 31, 2014

lenovo g500s - LAN driver issue

22:04 <p...> apt-get install linux-headers-$(uname -r)
22:04 <p...> แล้วโหลดนี้มา
http://www.kernel.org/pub/linux/kernel/projects/backports/stable/v3.13.2/backports-3.13.2-1.tar.xz
22:05 <p...> make defconfig-alx
22:05 <p...> make
22:05 <p...> make install
22:05 <p...> modprobe alx ไม่ก็ restart ครับ

Sunday, March 30, 2014

resize image

for file in *.png
do
  convert -quality 20 $file ${file%%png}jpg
done;

Thursday, March 6, 2014

เว็บต่างๆไม่ใช้ subdomain แต่ตั้ง domain name ใหม่เยอะๆแทน จิบ้าตาย

กว่าเราจะเชื่อใจโดเมนเนมอย่าง uob.co.th หรือ krungsri.com ก็ใช้เวลาเนิ่นนาน ฉับพลัน เขาก็มีโดเมนเพิ่มเติมของเขา uobcyberbanking.com เอย krungsrionline.com เอย และ อื่นๆอีกมากมาย ทั้งหลายเว็บไซต์ทั้งธนาคาร ห้างร้าน ต่างๆ ทำไมเขาไม่ใช้ subdomain แทนหนอ บริษัทเดียวกันแท้ๆ ต้องมานั่งลุ้นเอง ว่าใช่เว็บของบริษัทปลายทางที่ต้องการจะเข้าจริงหรือเปล่า ด้วยการหาข้อมูลเพิ่มเติิมบ่อยไป จิบ้าตาย

Monday, March 3, 2014

บัตรเครดิต เลขหน้าบัตร 16 หลักต่างหากที่สำคัญ และ อันตรายที่สุด

อยากจะถือโอกาสนี้ที่เพิ่งได้ทดลองรูดบัตรเครดิตไปแจ้งให้เพื่อนๆทราบเพื่อเป็นประโยชน์แก่ทุกท่าน "บัตรเครดิต เลขด้านหลังสามหลักไม่ได้สำคัญที่ สุด เลขด้านหน้าสำคัญกว่าอีก ไม่ใช่ไปเข้าใจผิด หรือ โดนคนไม่รู้ให้ข้อมูลผิด หรือ โดนหลอก ว่าไม่เป็นไรค่ะ ส่งแค่หน้าบัตรมาก็พอ หักเงินไม่ได้ แบบนี้คือผิดหมด" เพิ่งแจ้งให้เพื่อนๆทราบอีกคร้งวันนี้เพราะได้ข้อมูลมาใหม่จากการทดลองด้วยตนเอง ก่อนหน้านี้ไม่ได้บอกเกรงเป็นข้อมูลเก่า คือ เมื่อประมาณ 8 ปีก่อนผมพัฒนาโปรแกรมที่ต้องมีการ หักเงินจากบัตรเครดิตโดยใช้ api ของ ธนาคารแห่งหนึ่งในแคนาดา ทำให้ได้ทราบว่า แค่เลขหน้าบัตร 16 หลักอย่างเดียว ไม่ต้องกรอกข้อมูลอื่นใดก็หักเงินได้แล้ว โดยข้อมูลอื่นๆนั้นเป็น optional ทางเว็บไซต์จะเลือกตรวจอะไรเพิ่ม เติมก็ได้เช่น เลขสามหลักด้านหลังบัตร, วันออกบัตร, วันหมดอายุบัตร, ชื่อแซ่, ที่อยู่ และ อื่นๆ แต่ไม่จำเป็นต้องตรวจ ... แค่เพียงเว็บส่วนใหญ่เลือกที่จะตรวจหลายอย่าง แต่ก็มีอีกหลายเว็บที่ไม่ตรวจ ผ่านมา 8 ปี ล่าสุดลองรูดบัตรเครดิตกับเว็บไซต์ในญี่ปุ่น ก็พบผลลัพธ์เช่นเดียวกัน จึงขอยืนยันมา ณ ที่นี้ อย่าให้ข้อมูลเลขบัตร 16 หลัก กับใครโดยเข้าใจผิดคิดว่าเขาหักเงินไม่ได้นะครับ นี่ส่งผลให้ระบบจองโรงแรมที่ชอบให้สแกนหน้าบัตรเครดิตแล้วส่งอีเมล์แบบไม่เข้ารหัสไปให้เอย, พวกรายงานการใช้บัตรเครดิตของบางธนาคารเช่น ktc ที่ส่งจดหมายกระดาษมาทางบ้านพร้อมระบุเลขบัตรครบ 16 หลักให้เป๊ะๆบนหัวรายงานเลยมาให้ ทุกเดือนเอย... พวกนีี้ อันตรายหมดนะครับ ทางที่ดีเลิกใช้เสียดีกว่า ไปใช้ธนาคารอื่น ลดความเสี่ยง ส่วนโรงแรมก็ใช้โทรศัพท์บอกเลข ครึ่งนึง อีกครึ่งอีเมล์เอา ไรงี้ ตามความเหมาะสมนะครับ จะทำอะไรก็แล้วแต่ จะไม่เพิ่มความปลอดภัยก็ตามสะดวก เพียงผมอยากให้ทุกคนได้รับรู้ ได้มีสติ แม้จะยังคงทำเหมือนเดิมคือส่งไปทางอีเมล์แบบไม่เข้ารหัสเพราะโรงแรมใช้ encrypted email ไม่เป็น หรือ ใช้ธนาคารเดิม แต่ก็อยากให้มีสติรับรู้ว่ามันเอาเงินเราได้เลยนะ ไม่ใช่ไม่รู้ ครัช

Wednesday, February 26, 2014

TXT_DB error number 2

TXT_DB error number 2 when generating openvpn client certificates

You may have followed the openvpn quick start instructions either from the online tutorial or using the README file in easy-rsa where it asks you to go through these steps:

[edit vars with your site-specific info]
source ./vars
./clean-all
./build-dh
./pkitool --initca
./pkitool --server myserver
./pkitool client1
 and then you get
failed to update database TXT_DB error number 2
at the last step. I did and a web search mostly turned up suggestions to run ./clean-all again. But this article was the key. It's about openssl, but openvpn's easy-rsa is just a front-end to openssl. The important observation is that every certificate must have a unique CN in the database. In the file vars, this is controlled by KEY_CN. You left the settings read in from vars unchanged between generating the server cert and the client cert. You could edit vars before generating the client certificate and re-source vars, or you could do this before generating each client key.
KEY_CN=someuniqueclientcn ./pkitool client1
and you will stop getting that TXT_DB error.


I'm a bit surprised that the documentation for openvpn hasn't been updated to make this clear.


NB: It is also affected by the setting unique_subject = yes in the file keys/index.txt.attr, but I prefer not to go against the default setting.


http://blog.kenyap.com.au/2012/07/txtdb-error-number-2-when-generating.html

Tuesday, February 25, 2014

how to install canon mp287 scanner driver in debian linux

  • install MP280series_scanner_driver.tar.gz from canon's official website
  • sane-find-scanner
  • /lib/udev/rules.d/60-libsane.ruled
    add
    ATTRS{idVendor}=="04a9", ATTRS{idProduct}=="1746", ENV{libsane_matched}="yes"
  • run scangearmp

ไว้อาลัย TOT 3G

รู้สึกเสียใจมาก TOT 3G จะปิดตัวแล้ว ใช้มานาน 2 ปีกว่า ชื่นชอบมาก เน็ต 2Mbps เต็มตลอด ไม่จำกัดปริมาณ เพียงเดือนละไม่เกินหนึ่งพันบาท เชื่อว่าที่คุณภาพดีเป็นเพราะคนรู้จักน้อย คนใช้น้อย ทำให้ไม่มีคนมาแย่งผมใช้ (ทฤษฎีดังจะกล่าวต่อไป) แต่ด้วยเหตุเดียวกันนี้กลายเป็นทำให้ผมต้องสูญเสียมันไป ... แต่ถ้ามันดัง ก็น่าจะกลายพันธฺุ์เป็นเน็ต 3G ด้อยคุณภาพเหมือนเจ้าอื่นๆเช่นกัน *เพราะ* (ทฤษฎีที่ผมตั้งเอง) บริษัท A ลงทุน X บาท สร้างระบบเพื่อรองรับผู้ใช้งาน N คน ต่อมามีผู้ใช้งานมากขึ้นเป็น 2*N แต่ A จะไม่เพิ่มทุนเพื่อสร้างระบบ กล่าวคือ ระบบที่ถูกออกแบบมาให้รองรับผู้ใช้เพียง N แต่กลับถูกเอามาใช้กับผู้ใช้มากถึง 2*N ผลของทฤษฎีนี้คือ หากอยากได้เน็ตดีๆใช้งาน ต้องหมั่นหา ISP ที่มีลูกค้าน้อยๆ หรือ ระบบเน็ตแบบใหม่ที่ผู้ใช้ยังไม่เปลี่ยนมาเยอะ แล้วลองใช้ ถ้าดีก็ให้ใช้ไปจนกว่าจะเจ๊งแบบทีโอที หรือ ถ้าไม่เจ๊งแต่มีผู้ใช้เพิ่มขึ้นเน็ตก็จะห่วยลง ก็ถึงเวลาต้องหาเจ้าใหม่ที่ผู้ใช้น้อยๆอีกครา เป็นวัฏจักร แต่ถ้าจะมีบริษัท B ที่เพิ่มระบบรองรับผู้ใช้ที่เพิ่มขึ้นได้... เราก็คงไม่ต้องคอยเปลี่ยนเจ้า หรือ เปลี่ยนเทคโนโลยีอะไรกันบ่อยๆแบบนี้

http://www.blognone.com/node/53742

Thursday, February 13, 2014

Thursday, January 2, 2014

all of a sudden my kindle cannot connect to wifi anymore

Don't be panic.  Please make sure your wifi channel is not set to auto and is set to anything not higher than 11.