kong - suksit dot com
June 26, 2009
Updated
อัพเดตเนื่องในโอกาสที่บล็อกหายจากอาการเน่า xD
Change log:
- เปลี่ยนจากใช้
seq เป็น built-in command ของ bash แทน
- เลิกใช้ cURL เปลี่ยนเป็นใช้ wget แทนทั้งหมด เนื่องด้วยความสามารถหลายๆ อย่าง
- เมื่อดาวน์โหลดแล้วจะทิ้งไฟล์ index.html ไว้ใน directory สำหรับตรวจสอบ timestamp กับเซิร์ฟเวอร์ ถ้าไม่เปลี่ยนก็ไม่ต้องดาวน์โหลดใหม่
- แก้บั๊ก
$base_dir มี space ในชื่อ
- แก้บั๊กลืมลบไฟล์ tmp_* เมื่อดาวน์โหลดเสร็จ
- เติมเลขศูนย์ข้างหน้าให้ไฟล์ที่ chapter น้อยกว่า 100 (ยกเว้น chapter 0) เพื่อให้ CDisplay โหลดไฟล์ได้ถูกต้องตามลำดับ
- เพิ่ม option -o ถ้าต้องการให้บันทึกว่าโหลดอะไรมาบ้างลงใน onemanga.log
- ตัด option -u ออก กำหนดให้ default action เป็นการ update เสมอ
คิดว่าความสามารถหลักๆ น่าจะครบแล้ว ถ้าไม่มีบั๊กก็จะถือเป็น 2.0 final ได้ในเร็วๆ นี้ สำหรับโค้ดก็ตามด้านล่างครับ
#!/bin/bash
#
# usage: onemanga [-dlo] [-c <first chapter>[+|-<last chapter>]] <manga name> [<manga name> ...]
#
trap "rm -f *.jpg tmp_*;" 0
base_url="http://www.onemanga.com"
base_dir=`pwd`
log="$base_dir/onemanga.log"
function calc() {
echo "scale=2; $*" | bc -q 2>/dev/null | cut -f1 -d.
}
function echoes() {
if [[ $2 -gt 0 ]]; then
eval "for i in {${3:-1}..$2}; do echo -n '$1'; done"
fi
}
function progressbar() {
width=20
current=$1
total=$2
percent=`calc "$current / $total * 100"`
stack=`calc "$current / $total * $width"`
stack=${stack:=0}
space=`calc "$width - $stack"`
echoes " " ${#percent} 3
echo -n "$percent% ["
echoes "#" $stack
echoes " " $space
echo "]"
}
while getopts ":c:dlo" op; do
case $op in
c)
CHAPTER=1
CHAPTER_ARG="$OPTARG"
;;
d)
USE_DIR=1
;;
l)
LATEST=1
;;
o)
LOG_FILE=1
;;
\?)
echo "unknown option: -$OPTARG" >&2
ERROR=1
;;
esac
done
shift $(($OPTIND - 1))
if [[ $CHAPTER -eq 1 && $LATEST -eq 1 ]]; then
echo "invalid option: -c and -l cannot be used at the same time" >&2
ERROR=1
fi
if [[ $ERROR -eq 1 ]]; then
exit
fi
if [[ $CHAPTER = "" && $LATEST = "" ]]; then
UPDATE=1
fi
if [[ $CHAPTER -eq 1 ]]; then
if [[ `expr index "$CHAPTER_ARG" ++` -gt 0 ]]; then
first_chapter=${CHAPTER_ARG%+*}
last_chapter="+"
elif [[ `expr index "$CHAPTER_ARG" -` -gt 0 ]]; then
first_chapter=${CHAPTER_ARG%-*}
last_chapter=${CHAPTER_ARG#*-}
else
first_chapter=$CHAPTER_ARG
last_chapter=$CHAPTER_ARG
fi
fi
for manga_name in "$@"; do
manga_name=${manga_name%/}
if [[ $USE_DIR -eq 1 ]]; then
mkdir -p "$base_dir/$manga_name"
cd "$base_dir/$manga_name"
fi
display_name=`echo $manga_name | sed "s/_/ /g"`
word_count=`echo $display_name | wc -w`
sort_key=$((word_count + 1))
local_chapter=`ls ${manga_name}_*.cbr 2> /dev/null | sort -r -n -k $sort_key -t_ | head -n1`
local_chapter=`basename "${local_chapter##*_}" .cbr`
if [[ $local_chapter -ne 0 ]]; then
local_chapter=`echo ${local_chapter} | sed "s/^0*//g"`
fi
echo -ne "\nopening $base_url/$manga_name..."
wget -qN --no-cache $base_url/$manga_name/
if [[ ! -f "index.html" ]]; then
echo -e "\b\b\b [ERROR]\nthe url seems to be invalid, or there may be a problem with your internet connection"
exit
fi
grep "ch-subject" index.html 2> /dev/null | grep "a href" | cut -f3 -d\/ > tmp_chapters
if [[ ! -s tmp_chapters ]]; then
echo -e "\b\b\b [ERROR]\ncannot extract chapters info from the url"
exit
fi
echo -e "\b\b\b [OK]"
latest_chapter=`head -1 tmp_chapters`
if [[ -n $local_chapter && ! $CHAPTER -eq 1 ]]; then
echo "local chapter: ${local_chapter} / latest chapter: $latest_chapter"
if [[ $local_chapter == $latest_chapter ]]; then
echo "you already have the latest chapter of $display_name"
continue
fi
fi
if [[ $LATEST -eq 1 ]]; then
first_chapter=$latest_chapter
last_chapter=$latest_chapter
fi
if [[ "$last_chapter" == "+" ]]; then
last_chapter=$latest_chapter
fi
if [[ $UPDATE -eq 1 ]]; then
if [[ $local_chapter == "" ]]; then
first_chapter=`sort -n tmp_chapters | head -n1`
else
index=`sort -n tmp_chapters | grep -nm1 $local_chapter | cut -f1 -d:`
first_chapter=`sort -n tmp_chapters | tail -n+$((index + 1)) | head -n1`
fi
last_chapter=$latest_chapter
fi
if [[ $CHAPTER -eq 1 || -z $local_chapter ]]; then
echo "from chapter: $first_chapter / to chapter: $last_chapter"
fi
index=`sort -n tmp_chapters | grep -nm1 $first_chapter | cut -f1 -d:`
last_index=`sort -n tmp_chapters | grep -nm1 $last_chapter | cut -f1 -d:`
CHAPTERS=`sort -n tmp_chapters | awk 'FNR >= '$index' && FNR <= '$last_index`
for chapter in $CHAPTERS; do
echo "downloading $display_name chapter $chapter"
echo -ne "\r\e[0K`progressbar 0 1` (initializing...)"
page_location=`wget -qO - $base_url/$manga_name/$chapter/ | grep -i "begin reading" | cut -f2 -d\"`
wget -qO tmp_page $base_url$page_location
PAGES=`grep -i "option value" tmp_page | grep -i -v "select manga series" | cut -f2 -d\"`
image_location=`grep -i "manga-page" tmp_page | cut -f4 -d\"`
image_location=${image_location%/*.jpg}
total=`echo $PAGES | wc -w`
i=0
for page in $PAGES; do
let i++
echo -ne "\r\e[0K`progressbar $i $total` ($i/$total)"
wget -q "$image_location/$page.jpg"
done
if [[ $chapter -ne 0 && ${#chapter} -lt 3 ]]; then
chapter=`echoes "0" ${#chapter} 2`$chapter
fi
cbr_file_name="${manga_name}_${chapter}.cbr"
echo -ne "\r\e[0K`progressbar $i $total` (packing files...)"
if zip -q $cbr_file_name *.jpg; then
rm -f *.jpg tmp_*
echo -e "\r\e[0K`progressbar $i $total` ($cbr_file_name)"
[[ $LOG_FILE -eq 1 ]] && echo "[`date +%c`] $cbr_file_name" >> "$log"
fi
done
done

pittaya - Random Digital Garbage
June 23, 2009
ข่าวจาก Jusci ที่ว่า โกดักยกเลิกสายการผลิตฟิล์ม Kodachrome แล้ว อ่านแล้วใจหาย เพราะฟิล์มรุ่นนี้จัดว่าเป็นของคลาสสิค ภาพดังๆ หลายภาพ ถูกถ่ายโดยฟิล์ม Kodachrome นี้ในสมัยที่กล้องฟิล์มรุ่งเรือง
เคยฝากเพื่อนที่ญี่ปุ่นซื้อมาให้เมื่อหลายปีก่อน ตอนนี้ก็ยังเก็บเอาไว้อยู่
กล่องหน้าตาเป็นแบบนี้ 36 รูป ISO 200
ราคาม้วนละ 850 เยน หมดอายุเดือน 5 ปี 2006
กลักฟิล์มสีดำ ฝาสีเขียว
ดูกันชัดๆ ว่าใช้น้ำยา K-14 ในการล้าง
สองม้วนนี้ถ่ายไปแล้วม้วนนึง แต่หาที่ล้างไม่ได้ เพราะต้องใช้น้ำยา K-14 ซึ่งในบ้านเราไม่มีที่ไหนรับล้าง ก็คงต้องเก็บไว้เป็นที่ระลึกอย่างงี้ต่อไป

kong - suksit dot com
June 23, 2009
ช่วงหลังๆ ใช้งาน WebUI ของ uTorrent บ่อยขึ้น เลยได้วิธีที่ทำให้มันใช้งานสะดวกขึ้นดังนี้
1. ทำ bookmark โดยใส่ username/password
วิธีทำก็เหมือนหัวข้อ สร้าง bookmark ใหม่ ใส่ url เป็น
http://user:pass@example.com:12345/gui
โดย user/pass คือชื่อผู้ใช้กับรหัสผ่านที่เราตั้งไว้ใน uTorrent คลิกทีเดียวเข้าหน้า WebUI ได้ทันที ไม่ต้องพิมพ์ให้เมื่อย (เหมาะสำหรับใช้กับคอมพิวเตอร์ส่วนตัวเท่านั้น)
วิธีนี้ทดลองแล้วใช้ได้กับ Firefox และ Chrome ส่วน IE8 บอกว่าไม่รู้จักโปรโตคอลนี้ Opera จะขึ้นมาให้ใส่ user/pass อีกรอบ ส่วน Safari เข้าใช้งาน WebUI ไม่ได้เลย
2. วิธีใช้ปุ่ม Add Torrent from URL
ถ้าเป็นไฟล์ .torrent ใน tracker ปิด ที่ต้องมีการล็อกอินก่อนเข้าใช้งาน จะต้องใส่ค่าคุกกี้ให้กับ uTorrent ด้วย โปรแกรมจึงจะสามารถดาวน์โหลดไฟล์ .torrent จาก tracker ได้ วิธีดูข้อมูลคุกกี้ขึ้นอยู่กับแต่ละเบราว์เซอร์ ถ้าไฟร์ฟอกซ์ก็จะอยู่ที่ Tools > Options > Privacy > Show Cookies… แล้วเลือก filter ตามโดเมนเนม
คุกกี้ส่วนใหญ่จะมีสองตัวคือ uid กับ pass ถ้าเป็นชื่ออื่นก็จำไว้ว่ามันใช้ชื่ออะไร เวลาจะ add URL เข้า uTorrent จะแตกต่างกันเล็กน้อยสำหรับ uTorrent ที่เป็นแอพพลิเคชันบนวินโดวส์ กับตัว WebUI ถ้าเป็นตัวแอพพลิเคชัน ให้ใส่ URL ของไฟล์ .torrent แล้วตามด้วย :COOKIE:<cookie info> แบบนี้
http://example.com/zzzz.torrent:COOKIE:uid=xxxx;pass=yyyyyyyyyyyyyy
ถ้าเป็น WebUI มันจะมีช่องแยกไว้สองช่อง คือ Torrent URL กับ Cookies ก็ใส่แยกกันโดยไม่ต้องมี :COOKIE: นำหน้า โดยในช่องคุกกี้ใส่เป็น uid=xxxx;pass=yyyyyyyyyyyyyy ได้เลย
3. ใช้ AutoHotkey ช่วยใส่ Cookie
จากข้อ 2. ถ้าถามว่ามันทำให้ใช้งานสะดวกขึ้นมั้ย แน่นอนว่าไม่สะดวก เพราะคงไม่มีใครมานั่งจำ hash ของรหัสผ่านยาวๆ แต่ที่ผมชอบ add Torrent from URL เพราะมันเสร็จในขั้นตอนเดียว ไม่ต้องโหลดไฟล์ .torrent มาไว้ที่เครื่องแล้วค่อย add เข้า WebUI เสร็จแล้วลบไฟล์ทิ้ง อะไรทำนองนี้
ในฐานะที่ใช้ AutoHotkey อยู่แล้ว ก็พบว่าเราสามารถใช้ AutoHotkey ช่วยใส่ cookie ให้เราได้ โดยใช้ความสามารถในการขยายข้อความ สำหรับสคริปต์ที่ใช้ก็ประมาณนี้ (สมมติว่าเป็น cookie ของ tracker ที่ชื่อ MyTracker)
:*:mtcookie::uid=xxxx;pass=yyyyyyyyyyyyyy
เวลาพิมพ์ mtcookie มันก็จะขยายออกมาเป็น uid=… ให้โดยอัตโนมัติ หมดปัญหาเรื่องการจำไปได้

pittaya - Random Digital Garbage
June 22, 2009
Paella เป็นอาหารสเปนชนิดหนึ่ง หน้าตาเหมือนๆ ข้าวผัดบ้านเรา บางคนก็เรียกกันว่าข้าวผัดสเปน แต่วิธีทำออกจะแตกต่างกันอยู่พอสมควร เนื่องในโอกาสที่ทีมชาติสเปนได้ผ่านเข้ารอบรอง ฟุตบอลคอนเฟดเดอเรชันคัพ ก็เลยทำ Paella กินเสียเลย
วิธีทำ ขั้นแรกเตรียมซีฟู้ดก่อน ประกอบด้วย หอยแมลงภู่ ปลาหมึก และกุ้ง
แกะเอาหัวและเปลือกกุ้ง ต้มในน้ำเดือด ใส่ใบกระวาน 1 ใบ ต้มประมาณ 10 นาที เพื่อทำน้ำสต็อกกุ้ง เสร็จแล้วตักออก ให้เหลือแต่น้ำ
เอาไวน์ขาวครึ่งถ้วย ตั้งไฟกลาง โยนหอยแมลงภู่ลงไป ปิดฝา ต้มให้เดือดประมาณ 3 นาที (ถ้าใช้หอยแบบมีเปลือกติดอยู่ด้วย จะดูน่ากินกว่า) เสร็จแล้วตักเอาแต่หอยพักไว้
เอา Saffron (หญ้าฝรั่น) ลงคั่วในหม้อให้มีกลิ่นหอม แล้วเติมน้ำสต็อกกุ้งจากตอนแรกลงไป
ต้มไปสักพัก จะเห็นว่าน้ำเริ่มมีสีออกเหลืองๆ เสร็จแล้วเอาไปพักไว้ก่อน
ใส่น้ำมันมะกอกในกระทะ เอาซีฟู้ดที่เตรียมไว้ลงผัดไฟกลางจนสุก เทใส่จาน พักไว้ก่อน
หันมาจัดการกับผักบ้าง เตรียมหอมสับ กระเทียมสับ แล้วก็พริกหวานสีแดง (ครึ่งเม็ดก็พอ)
ใส่น้ำมันมะกอกในกระทะเล็กน้อย เอากระเทียมกับหอมใหญ่ลงผัดให้มีกลิ่นหอม แล้วใส่พริกหวานตามลงไป
ตักข้าวสาร ใส่ลงไป 1 ถ้วยครึ่ง ผัดให้เข้ากัน
เติมน้ำสต็อกที่เตรียมไว้ คนให้เข้ากัน แล้วเอาซีฟู้ดใส่ตามลงไป ปรุงรสด้วยเกลือ พริกไทย ตามชอบ (ในรูปใส่หัวกุ้ง+เปลือกกุ้งลงไปด้วย เพราะชอบกิน)
ลดไฟเหลือไฟกลาง ค่อนข้างอ่อน เอาฝาปิดไว้ รอสิบนาที (ไม่มีฝาปิดกระทะ ต้องเอาจานใบใหญ่ๆ มาปิดแทน)
ข้าวสุกแล้ว!
ตักใส่จาน กินได้เลย
ความยากลำบากของเมนูนี้คือ ขั้นตอนเยอะ เตรียมของเยอะ เริ่มทำตอนสองทุ่มครึ่ง ได้กินเอาสี่ทุ่ม และอีกอย่างคือ Saffron หาซื้อค่อนข้างยาก ที่ซื้อมาได้จาก Foodland ราคา 180 บาท (ต่อ 1 กรัม!) ถ้าอยากได้ราคาถูกกว่านี้หน่อยคงต้องไปเดินแถวพาหุรัด
ปล. Paella ออกเสียงว่ายังไง เปญญ่า? แปอิญ่า? ใครรู้ช่วยบอกที

Foojan's space - Foojan's space
June 21, 2009
You Are My Sunshine
My only sunshine.
You make me happy
When skies are grey.
You’ll never know, dear,
How much I love you.
Please don’t take my sunshine away
kong - suksit dot com
June 18, 2009
Updated
Change log:
- เปลี่ยนการแสดงสถานะดาวน์โหลดเป็น progress bar
- แก้บั๊กเลข chapter เป็นทศนิยม
- ลบ temporary file ทิ้งทุกครั้งที่ออกจากสคริปต์
- ถ้าไม่ใส่ option อะไรเลย (เช่น
onemanga Zetman) จะเหมือนกับการใส่ -u (ถ้าโหลดครั้งแรกจะเริ่มจาก chapter 1)
สำหรับวิธีการใช้งาน ดูได้ที่โพสต์เดิมครับ ส่วนโค้ดก็ตามด้านล่างนี้ (ยิ่งเขียนยิ่งยาว =.=)
#!/bin/bash
#
# usage: onemanga [-dlu] [-c <first chapter>[+|-<last chapter>]] <manga name> [<manga name> ...]
#
trap 'rm -f *.jpg tmp_*;' 0
base_url="http://www.onemanga.com"
base_dir=`pwd`
function calc() {
echo "scale=2; $*" | bc -q 2>/dev/null | cut -f1 -d.
}
function progressbar() {
width=30
current=$1
total=$2
percent=`calc "$current / $total * 100"`
stack=`calc "$current / $total * $width"`
stack=${stack:=0}
space=`calc "$width - $stack"`
for i in `seq 1 $((3 - ${#percent}))`; do
echo -n " "
done
echo -n "$percent% ["
for i in `seq 1 $stack`; do
echo -n "#"
done
for i in `seq 1 $space`; do
echo -n " "
done
echo "]"
}
while getopts ":c:dlu" op; do
case $op in
c)
if [[ $LATEST -eq 1 ]]; then
echo "Invalid option: -c cannot be used with -l" >&2
exit
fi
if [[ $UPDATE -eq 1 ]]; then
echo "Invalid option: -c cannot be used with -u" >&2
exit
fi
CHAPTER=1
CHAPTER_ARG=$OPTARG
;;
d)
USE_DIR=1
;;
l)
if [[ $CHAPTER -eq 1 ]]; then
echo "Invalid option: -l cannot be used with -c" >&2
exit
fi
if [[ $UPDATE -eq 1 ]]; then
echo "Invalid option: -l cannot be used with -u" >&2
exit
fi
LATEST=1
;;
u)
if [[ $CHAPTER -eq 1 ]]; then
echo "Invalid option: -u cannot be used with -c" >&2
exit
fi
if [[ $LATEST -eq 1 ]]; then
echo "Invalid option: -u cannot be used with -l" >&2
exit
fi
UPDATE=1
;;
\?)
echo "Invalid option: -$OPTARG" >&2
exit
;;
esac
done
shift $(($OPTIND - 1))
if [[ $CHAPTER = "" && $LATEST = "" ]]; then
UPDATE=1
fi
if [[ $CHAPTER -eq 1 ]]; then
if [[ `expr index "$CHAPTER_ARG" ++` -gt 0 ]]; then
first_chapter=${CHAPTER_ARG%+*}
last_chapter="+"
elif [[ `expr index "$CHAPTER_ARG" -` -gt 0 ]]; then
first_chapter=${CHAPTER_ARG%-*}
last_chapter=${CHAPTER_ARG#*-}
else
first_chapter=$CHAPTER_ARG
last_chapter=$CHAPTER_ARG
fi
fi
for manga_name in "$@"; do
if [[ $USE_DIR -eq 1 ]]; then
mkdir -p $base_dir/$manga_name
cd $base_dir/$manga_name
fi
display_name=`echo $manga_name | sed "s/_/ /g"`
word_count=`echo $display_name | wc -w`
sort_key=$((word_count + 1))
local_chapter=`ls ${manga_name}_*.cbr 2> /dev/null | sort -r -n -k $sort_key -t_ | head -n1`
local_chapter=`basename ${local_chapter##*_} .cbr`
echo -n "opening $base_url/$manga_name..."
curl -s $base_url/$manga_name/ > tmp_home
grep "ch-subject" tmp_home | grep "a href" | cut -f3 -d\/ > tmp_chapters
if [[ ! -s tmp_chapters ]]; then
echo -e "\b\b\b [ERROR]\ncannot create chapter list from $base_url/$manga_name"
exit
fi
echo -e "\b\b\b [OK]"
latest_chapter=`head -1 tmp_chapters`
if [[ $LATEST -eq 1 || $UPDATE -eq 1 ]]; then
echo "local chapter: $local_chapter / latest chapter: $latest_chapter"
if [[ $local_chapter == $latest_chapter ]]; then
echo "you already have the latest chapter of $display_name"
continue
fi
fi
if [[ $LATEST -eq 1 ]]; then
first_chapter=$latest_chapter
last_chapter=$latest_chapter
fi
if [[ "$last_chapter" == "+" ]]; then
echo "starting chapter: $first_chapter / latest chapter: $latest_chapter"
last_chapter=$latest_chapter
fi
if [[ $UPDATE -eq 1 ]]; then
if [[ $local_chapter == "" ]]; then
first_chapter=`sort -n tmp_chapters | head -n1`
else
index=`sort -n tmp_chapters | grep -nm1 $local_chapter | cut -f1 -d:`
first_chapter=`sort -n tmp_chapters | tail -n+$((index + 1)) | head -n1`
fi
last_chapter=$latest_chapter
fi
index=`sort -n tmp_chapters | grep -nm1 $first_chapter | cut -f1 -d:`
last_index=`sort -n tmp_chapters | grep -nm1 $last_chapter | cut -f1 -d:`
CHAPTERS=`sort -n tmp_chapters | awk 'FNR >= '$index' && FNR <= '$last_index`
for chapter in $CHAPTERS; do
echo "downloading $display_name chapter $chapter"
page_location=`curl -s --range -1500 $base_url/$manga_name/$chapter/ | grep -i "begin reading" | cut -f2 -d\"`
curl -s $base_url$page_location > tmp_page
PAGES=`grep -i "option value" tmp_page | grep -i -v "select manga series" | cut -f2 -d\"`
image_location=`grep -i "manga-page" tmp_page | cut -f4 -d\"`
image_location=${image_location%/*.jpg}
total=`echo $PAGES | wc -w`
i=0
for page in $PAGES; do
let i++
echo -ne "\r\e[0K`progressbar $i $total` ($i/$total)"
wget -q "$image_location/$page.jpg"
done
cbr_file_name="${manga_name}_${chapter}.cbr"
echo -ne "\r\e[0K`progressbar $i $total` (packing files...)"
zip -q $cbr_file_name *.jpg && rm -f *.jpg
echo -e "\r\e[0K`progressbar $i $total` ($cbr_file_name)"
done
done

pittaya - Random Digital Garbage
June 18, 2009
Left to right : Mail, Firefox, Adium, TweetDeck, Azureus, Cyberduck, Gimp

Foojan's space - Foojan's space
June 13, 2009
ตื่นเช้ามาด้วยอาการดี๊ด้าว่าเมื่อวานได้ wireless router มาใหม่ไฉไลกว่าของเก่านานนม… แต่ว่าพอเปิดปุ๊ปทำไมมันใช้ไม่ได้ว่า พอกดเข้า net ปุ๊ปมีอันที่ router restart ตัวเองเฉยเลย ก็เลยโทรไป call center ของทรู แต่ว่า call center ตอบไม่ได้เค้าให้ "โทรใหม่" ไปอีกเบอร์นึงที่สามารถตอบปัญหาด้านเทคนิคได้… โทรไปเค้าก็ไม่ได้ให้ทำอะไรอะนะ ก็พยายามให้เข้าหน้า router set up admin mode… และนี่เป็นบางส่วนของบทสนทนา
พนักงานรับสาย: กรุณาเข้าไปที่ 192.168.1.1 ค่ะ แล้วใส่ password ว่า admin
นู๋ฟูอารมณ์ดี: เอ๊ะ ใส่แล้วมันก็ยังไม่ไม่ใช่หน้าจอ admin นะ… (ไม่มีเมนู admin ให้เห็นตามที่บอก)
พนักงานรับสาย: password ต้องใส่คำว่า admin นะค่ะ a-d-m-i-n
นู๋ฟูเริ่มกิ๊ก: สะกดเป็นค่ะ ใส่ใหม่แล้วก็ยังไม่ได้
พนักงานรับสาย: คุณพิมพ์ใน notepad แล้วค่อย copy ลงมาใส่ก็ได้นะคะ admin พิมพ์แล้วรึยัง
นู๋ฟูเริ่มปิ๊ด: [แล้วก็เริ่มนึกได้ว่าเมื่อวานนั่งอ่าน manual แล้วเหลือบเห็นว่า password นิหว่า ก็เลยลองพิมพ์ไปว่า password ปรากฎว่าเข้าได้]
คิดว่า password มันต้องเป็นคำว่า password นะค่ะ เห็นอ่านใน manual เจอ
พนักงานรับสาย: [คงเพิ่งรู้สึกตัวผิด] อ๋อ เป็นโมเด็มรุ่นแบบปลั๊กเดียวใช่มั้ยค่ะ ต้องพิมพ์คำว่า password p-a-s-s-w-o-r-d พิมพ์แล้วรึยังค่ะ
นู๋ฟูเริ่มปลง: … … [แล้วเหตุการณ์ก็ยังดำเนินต่อไป สุดท้ายคุยไปเกือบครึ่งชม ไม่ได้อะไรกลับมา... ... เสียเวลาจริงๆ]
จริงๆแล้วพอจับหลักได้ละ… เปิดใหม่ๆยังห้ามเล่น.. ทิ้งไว้ซักพักมันจะกลับมาใช้ได้เอง…
วันนี้เรื่องแปลกๆยังไม่หมดเท่านี้ค่ะ ตอนเย็นไปกิน giants มาตามเสียงลือเสียงเล่าอ้างมา แต่ว่าวันหยุดแบบนี้มันไม่ buffet นะซิ แต่ก็ยังอยากไปลอง… สรุปว่าร้านนี้มีหม้อ bibimbab หม้อเดียวมั้ง ทำเสร็จรอให้โต๊ะอื่นกินหมดก่อนแล้วค่อยเอาหม้อนั้นกลับไปทำมาต่อ… เกือบเอาหม้อเขวี้ยงหัวหัวหน้าร้านละ… แล้วมันก็จะติด blacklist ไปอีกนานแสนนาน (โชคดีที่มีน้ำแข็งใสสีแดงมาช่วยทำคะแนนตอนจบหน่อย)… (หรือว่าเราไม่ควรสั่งเมนูนั้นนะ)… แล้วก็ไม่อิ่ม เพราะงุกงิก ตอนแรกว่าจะไปล้างแค้นที่ไดโดม่อนต่อ แต่ว่าไปจบที่ร้านพิซซ่าและdelce แทน… ค่อยยังชั่วหน่อย…
kong - suksit dot com
June 11, 2009
CDisplay คือโปรแกรมสำหรับอ่าน manga/comic ที่เป็นไฟล์ .cbr, .cbz, .cbt, ฯลฯ ถือเป็นโปรแกรม comic reader ในดวงใจก็ว่าได้ เคยลองใช้ทั้ง Comical, ComicRack และ MangaMeeya แต่สุดท้ายก็กลับมาตายรังที่ CDisplay 1.8.5 ทุกที (เวอร์ชัน 1.8.5 ไม่มีใน official site แต่ Google หาดูได้)
ข้อเสียเพียงอย่างเดียวของ CDisplay คือ ไม่สามารถตั้ง shortcut ตามใจตัวเองได้ เช่น เวลาเปลี่ยนหน้าต้องใช้ปุ่ม PgDn/PgUp หรือเวลาโหลดไฟล์ถัดไปต้องใช้ Shift-L เป็นต้น
ในฐานะที่ใช้ AutoHotkey อยู่แล้ว เลยจัดการ remap key ซะใหม่ โดยกำหนดให้ใช้ปุ่ม Left/Right แทน PgUp/PgDn เวลาเปลี่ยนหน้า และใช้ปุ่ม Ctrl-Left/Ctrl-Right แทน Shift-K/Shift-L เพื่อโหลดไฟล์ก่อนหน้าหรือถัดไป สำหรับ script AutoHotkey ที่ใช้ก็สั้นๆ ประมาณนี้
#IfWinActive ahk_class TMainDisplayForm
Left:: Send {PgUp}
Right:: Send {PgDn}
^Left:: Send +k
^Right:: Send +l
#IfWinActive
เท่านี้ก็อ่าน manga ได้มีความสุขขึ้นเยอะ

dae - Nattee Niparnan
June 11, 2009
News and Announcement (latest first)
* (11-Jun-2009) Slide updates
Slides
* ( 3-Jun-2009) Intro (pretty sorry, I lost my first introductory slide. But you won’t find any of much value there anyway.)
* (10-Jun-2009) System of Linear Equation (pptx)
kong - suksit dot com
June 8, 2009
Updated
อัพเดตอีกรอบ เนื่องจากใช้สคริปต์เวอร์ชันก่อนแล้วรู้สึกว่า reliability ค่อนข้างต่ำ สาเหตุหลักก็คือการใช้ cURL โหลดหน้าเว็บเพจมาแบบเป็นส่วนๆ ถ้ามีการแก้ไขหน้าเว็บ เช่นเพิ่ม announcement หรือใส่ script จะมีโอกาสสูงมากที่เมื่อโหลดหน้าเว็บส่วนนั้นมาแล้วไม่เจอข้อมูลที่ต้องการ และทำให้ไม่สามารถดาวน์โหลด manga ต่อได้ ประกอบกับเพิ่งพบว่าวิธีที่ใช้ในสคริปต์เวอร์ชันเก่าค่อนข้างอ้อมโลก จริงๆ มันมีวิธีที่ง่ายกว่านั้น ไม่ต้องเรียก cURL บ่อยๆ และทำงานได้เร็วกว่าแบบเดิมเยอะ
จริงๆ จะว่าอัพเดตก็ไม่เชิง เพราะเขียนใหม่เกือบทั้งดุ้น เลยกำหนดให้เวอร์ชันนี้เป็น v2.x โดยถือว่าสคริปต์เวอร์ชันก่อนๆ อยู่ใน series 1.x ทั้งหมด ถ้าลองใช้แล้วเจอบั๊ก ติดปัญหา หรือมีข้อเสนอแนะในการปรับปรุง ก็คอมเมนต์ไว้ได้ครับ สำหรับซอร์สโค้ดก็ตามนี้
#!/bin/bash
#
# usage: onemanga [-d] [-l] [-u] [-c <first chapter>[+ | -<last chapter>]] <manga name> [<manga name> ...]
#
base_url="http://www.onemanga.com"
while getopts ":c:dlu" op; do
case $op in
c)
if [[ $LATEST -eq 1 ]]; then
echo "Invalid option: -c cannot be used with -l" >&2
exit
fi
if [[ $UPDATE -eq 1 ]]; then
echo "Invalid option: -c cannot be used with -u" >&2
exit
fi
CHAPTER=1
CHAPTER_ARG=$OPTARG
;;
d)
USE_DIR=1
;;
l)
if [[ $CHAPTER -eq 1 ]]; then
echo "Invalid option: -l cannot be used with -c" >&2
exit
fi
if [[ $UPDATE -eq 1 ]]; then
echo "Invalid option: -c cannot be used with -u" >&2
exit
fi
LATEST=1
;;
u)
if [[ $CHAPTER -eq 1 ]]; then
echo "Invalid option: -u cannot be used with -c" >&2
exit
fi
if [[ $LATEST -eq 1 ]]; then
echo "Invalid option: -u cannot be used with -l" >&2
exit
fi
UPDATE=1
;;
\?)
echo "Invalid option: -$OPTARG" >&2
exit
;;
esac
done
shift $(($OPTIND - 1))
if [[ $CHAPTER -eq 1 ]]; then
if [[ `expr index "$CHAPTER_ARG" ++` -gt 0 ]]; then
first_chapter=${CHAPTER_ARG%+*}
last_chapter="+"
elif [[ `expr index "$CHAPTER_ARG" -` -gt 0 ]]; then
first_chapter=${CHAPTER_ARG%-*}
last_chapter=${CHAPTER_ARG#*-}
else
first_chapter=${CHAPTER_ARG}
last_chapter=${CHAPTER_ARG}
fi
fi
for manga_name in "$@"; do
if [[ $USE_DIR -eq 1 ]]; then
mkdir -p ${manga_name}
cd ${manga_name}
fi
display_name=`echo ${manga_name} | sed "s/_/ /g"`
word_count=`echo ${display_name} | wc -w`
sort_key=$((word_count + 1))
local_chapter=`ls ${manga_name}_*.cbr 2> /dev/null | sort -r -n -k ${sort_key} -t_ | head -n1`
local_chapter=`echo ${local_chapter##*_} | cut -f1 -d\.`
echo "fetching information from ${base_url}/${manga_name} ..."
curl -s ${base_url}/${manga_name}/ > tmp_home
grep "ch-subject" tmp_home | grep "a href" | cut -f3 -d\/ > tmp_chapters
latest_chapter=`head -1 tmp_chapters`
if [[ ${local_chapter} -eq ${latest_chapter} && ! $CHAPTER -eq 1 ]]; then
echo "you already have the latest chapter of $display_name"
cd ..
continue
fi
if [[ $LATEST -eq 1 ]]; then
first_chapter=${latest_chapter}
last_chapter=${latest_chapter}
fi
if [[ "$last_chapter" = "+" ]]; then
last_chapter=${latest_chapter}
fi
if [[ $UPDATE -eq 1 ]]; then
if [[ $local_chapter == "" ]]; then
first_chapter=`sort -n tmp_chapters | head -n1`
else
index=`sort -n tmp_chapters | grep -nm1 ${local_chapter} | cut -f1 -d:`
first_chapter=`sort -n tmp_chapters | tail -n+$((index + 1)) | head -n1`
fi
last_chapter=${latest_chapter}
fi
index=`sort -n tmp_chapters | grep -nm1 ${first_chapter} | cut -f1 -d:`
last_index=`sort -n tmp_chapters | grep -nm1 ${last_chapter} | cut -f1 -d:`
CHAPTERS=`sort -n tmp_chapters | awk 'FNR >= '$index' && FNR <= '$last_index`
for chapter in $CHAPTERS; do
echo "downloading $display_name chapter $chapter"
page_location=`curl -s --range -1500 ${base_url}/${manga_name}/${chapter}/ | grep -i "begin reading" | cut -f2 -d\"`
curl -s ${base_url}${page_location} > tmp_page
PAGES=`grep -i "option value" tmp_page | grep -i -v "select manga series" | cut -f2 -d\"`
image_location=`grep -i "manga-page" tmp_page | cut -f4 -d\"`
image_location=${image_location%/*.jpg}
for page in $PAGES; do
echo "downloading $image_location/$page.jpg ..."
wget -q "$image_location/$page.jpg"
done
echo "creating CBR file ..."
cbr_file_name="${manga_name}_${chapter}.cbr"
zip ${cbr_file_name} *.jpg
rm *.jpg tmp_*
done
if [[ $USE_DIR -eq 1 ]]; then
cd ..
fi
done
วิธีใช้ก็เหมือนเดิม copy code ข้างบนไปใส่ไฟล์ ตั้งชื่ออะไรก็ได้ (ในตัวอย่างตั้งเป็น onemanga2) แล้วเซ็ต flag ให้ execute ได้ สำหรับ option ต่างๆ จะเปลี่ยนไปจากเวอร์ชัน 1.x ค่อนข้างเยอะ วิธีใช้เบื้องต้นมีดังนี้
ดาวน์โหลด chapter ที่ต้องการ
สามารถโหลดทีละ chapter, โหลดเป็นช่วง, หรือโหลดตั้งแต่ chapter ที่กำหนดจนถึง chapter ล่าสุด
onemanga2 -c 440 Naruto
onemanga2 -c 351-360 Bleach
onemanga2 -c 4+ New_Prince_of_Tennis
ดาวน์โหลดเฉพาะ chapter ล่าสุด
ใส่ option -l (latest) เข้าไปอันเดียวจบ
อัพเดตจากที่เคยดาวน์โหลดไว้
สคริปต์จะเช็คไฟล์ .cbr ในเครื่อง แล้วดาวน์โหลด chapter ที่ต่อจาก chapter ปัจจุบัน จนถึง chapter ล่าสุดในเว็บ
ดาวน์โหลดเป็น directory
สามารถใส่ option -d เพื่อดาวน์โหลดมาเก็บใน directory ตามชื่อ manga ได้
onemanga2 -d -c 450 Naruto
onemanga2 -dl Hajime_no_Ippo
onemanga2 -ud Eyeshield_21
ดาวน์โหลดทีละหลายๆ เรื่อง
สามารถใส่ชื่อ manga ได้มากกว่าหนึ่งเรื่องในการดาวน์โหลดแต่ละครั้ง มีประโยชน์มากตอนอัพเดตรายสัปดาห์ ถ้าโหลดโดยใช้ option -d ตลอด ก็ใส่ wildcard แทนชื่อ directory ทั้งหมดไปเลยก็ได้
onemanga2 -l Naruto Bleach Eyeshield_21 Vagabond
onemanga2 -ud *

dae - Nattee Niparnan
June 5, 2009
I have posted updated LaTeX class files for theses and dissertation of Chulalongkorn University. However, I have not written a manual for it yet. Instead, I provide my own dissertation as an example. The files can be used for both master and doctoral degree and also for either Thai or English language.
Click here for the file.
dae - Nattee Niparnan
June 5, 2009
You can find LaTeX class files for Theses and Dissertations of Chulalongkorn University here. This latex class was used by me and some of my colleagues and students, mostly in the Faculty of Engineering, to typeset our theses.
This class file, however, is not the official class file. In fact, there is no such thing as the official class file since the Graduated School of Chulalongkorn, to the best of my knowledge, has never sanctioned any latex class file. Anyway, thesis and dissertation using this class file PASSED the inspection (latest inspected thesis was dated March 2009) and that should be enough for everyone.
Additional Information
* These class files can be used for both master degree theses and the doctoral degree dissertations.
* It supports both Thai and English language.
* You need to set up your LaTeX to recognize Thai font. Here is my article how to do so. (English theses also require one front page in Thai.)
* Any bug and comment are strongly welcome. Please send it to me directly.
I have not finalized the manual of these latex class files. Instead, a user can look into the provided example dissertation.
click here to download the example dissertation.
The main latex file is dae_dissert.tex while the style file is chula.cls
pittaya - Random Digital Garbage
June 4, 2009
วันนี้เพิ่งลองเปลี่ยนมาใช้ Firefox 3.5 beta4 ซึ่งฟีเจอร์เด่นอันหนึ่งในเวอร์ชันนี้คือ การสนับสนุน Color Profile
แต่ปัญหาดันตามมาเมื่อ รูปภาพที่เอาขึ้นเว็บ ดันแสดงผลบน Firefox 3.5 ไม่เหมือนกับ browser ตัวอื่น เพราะในรูปดันมี color profile ติดมาด้วย ทำให้ Firefox 3.5 พยายามจะปรับสี เพื่อให้แสดงผลได้ถูกต้อง
วิธีแก้ไขง่ายๆ ก็คือปิดฟีเจอร์ Color Profile นี่ไปซะ จะได้มองเห็นสีสันเหมือนกับ browser ตัวอื่น แต่วิธีนี้มันออกจะมักง่ายเกินไปสักหน่อย เหมือนปิดหูปิดตา ไม่ยอมรับความจริง หลอกตัวเองไปวันๆ
วิธีที่ถูกที่ควร ในขณะที่ browser ส่วนใหญ่ในตลาดยังไม่สนับสนุน color profile ก็คือ เอาข้อมูล color profile ออกจากรูปนั้นไปซะ ลองทำโดยใช้ TheGimp อยู่นานสองนาน ก็หาวิธีไม่เจอ ลองใช้ Preview.app ดู ก็ยังทำไม่ได้ (หรือทำไม่เป็นเอง)
ค้นข้อมูลไปเรื่อยๆ ในที่สุดก็ได้ทางออกคือใช้คำสั่ง convert ของ ImageMagick ตามนี้
$ convert foo.png -strip bar.png
เรียบง่าย และสวยงาม
ปล. บน windows ทำยังไงไม่รู้เหมือนกันนะ

dae - Nattee Niparnan
June 4, 2009
—- Please visit the main webboard for any discussion and/or question. —-
You can download the syllabus here.
News (latest news first)
- (04-Jun-2009) Lab #1 is published.
- (04-Jun-2009) Syllabus is available.
Lab Documents
Here are the list of Lab documents
Lab 1 (05-Jun-2009) Download here
pittaya - Random Digital Garbage
June 2, 2009
นิยายเล่มใหม่ของ Murakami ชื่อว่า “1Q84” (เลข 9 ในภาษาญี่ปุ่น ออกเสียงว่า “คิว”) จะมีอะไรเกี่ยวกับ 1984 ของ George Orwell หรือเปล่า? ไม่อาจรู้ได้
รออ่านฉบับภาษาอังกฤษด้วยใจระทึก (ภาษาไทยคงรออีกนาน… หรือเปล่า?)
ปล. เพิ่งรู้ว่า Murakami ก็ใช้ Twitter กับเค้าด้วย
pittaya - Random Digital Garbage
June 1, 2009
เวลา copy ไฟล์ใหญ่ๆ ข้ามเครื่องใน network เดียวกันแล้ว ส่วนใหญ่เราก็มักจะใช้การ mount network drive ขึ้นมา หรือไม่ก็ copy ผ่านมาทาง SSH แต่วิธีพวกนี้มักจะช้า เพราะต้องเสีย overhead เรื่องของ encryption / overhead ของ protocol ทำให้ได้ความเร็วไม่มากเท่าที่มันควรจะเป็น
ไปเจอวิธีทริกการ copy อย่างว่องไวจาก MySQL Performance Blog จดไว้ซะหน่อย กันลืม (ทั้งสองเครื่องต้องมีโปรแกรม netcat (nc) อยู่ด้วย)
ที่เครื่อง source:
tar -cf - . | nc [target_ip] [port]
ที่เครื่อง target:
nc -l [port] | tar xvf -
วิธีการคือ ส่งข้อมูลดิบๆ ข้ามเครื่องแบบไม่ต้อง encode โดยใช้ netcat เป็นทั้งตัวรับและตัวส่ง ถ้าหากต้องการทำทีละหลายๆ ไฟล์ ใช้ tar ช่วยด้วยตามแบบในโค้ด ก็จะสะดวกดี

Foojan's space - Foojan's space
June 1, 2009
Spranq Eco Sans - I hope some of you might know what it is. But for those who don’t know it yet, this is a font designed to save the printer ink by 20% by putting bubbles inside but still you can read. Haha, actually I’m one of those paper destroyers i.e. love to print to see & touch the physical papers, especially to review the document. Finger cross, I wish I won’t forget to change to this font before printing next time ^___^..
Never be "Too Late", Better than "Never"
Foojan's space - Foojan's space
June 1, 2009
เมื่อหกเดือนก่อน คิดอะไรก็ไม่รู้ ดันไปสมัตรเรียนภาษาจีน เริ่มตั้งแต่ขั้นต้นเลยค่ะ เรียนทุกวันเสาร์ ตั้งแต่บ่ายหนึ่งยันหกโมงเย็น มีพักแค่สองครั้ง โย่ะ… คอร์สแรกนะฟิตสุดๆ ฟังไม่รู้เรื่องเลย แต่ก็พยาย้ามพยายาม คอร์สแรกเนี่ยชิวๆ สอบไปก็เกือบเต็ม ตอนนี้ผ่านมาสี่คอร์ส อยากจะร้องไห้ ยากจัง ระดับต้นมีห้าคลาส คอร์สหน้าก็จบระดับต้นแล้ว… ดีใจมักๆที่ได้หยุดเรียนตั้งสองอาทิตย์แนะ ตอนแรกนึกว่าได้อาทิตย์เดียว พอไปเช็คก็รู้ว่าได้หยุดอีกอาทิตย์นึงแนะ ดีจายยยยย…. ฮาฮา จะรอดมั้ยเนี่ย T___T สู้ตายค่ะ