2008/01/25

configure.in for libiconv ( iconv ) checking.




As the title states, use this with your autoconf and automake under
both Linux ( where iconv_open() is a libc built-in function )
and Solaris ( where iconv_open() is a part of GNU libiconv ).

#
# Checks for iconv
#
AC_MSG_CHECKING([for a usable iconv])
ICONV_LIBS=""
AC_TRY_LINK([#include ],
[iconv_open ("from", "to");],
[use_iconv=1],
[use_iconv=0])
if test x$use_iconv = x1; then
AC_MSG_RESULT([libc])
else
# try using libiconv
fontconfig_save_libs="$LIBS"
LIBS="$LIBS -liconv"

AC_TRY_LINK([#include ],
[iconv_open ("from", "to");],
[use_iconv=1],
[use_iconv=0])

if test x$use_iconv = x1; then
ICONV_LIBS="-liconv"
AC_MSG_RESULT([libiconv])
else
AC_MSG_RESULT([no])
fi

LIBS="$fontconfig_save_libs"
fi
AC_SUBST(ICONV_LIBS)
AC_DEFINE_UNQUOTED(USE_ICONV,$use_iconv,[Use iconv.])

2008/01/22

Solaris Vim multibyte( Japanese, Chinese, Korean ) support

This also includes Linux and other platforms if you needmultibyte( Japanese, Chinese, Korean ) support for vim.

wget vim-7.1.tar.gz
tar xvzf vim-7.1.tar.gz
cd vim71
--prefix=$HOME \
--enable-multibyte \
--enable-cscope \
--with-features=huge

2008/01/16

Add a text to a PNG file


#if 0
png_text text_ptr[1];
text_ptr[0].key = "userInfo";
char png_userInfo[100];
sprintf(png_userInfo, "%d", m_userInfo);
text_ptr[0].text = png_userInfo;
text_ptr[0].compression = PNG_TEXT_COMPRESSION_NONE;
png_set_text(png_ptr, info_ptr, text_ptr, 1);
#endif

2008/01/13

FutureNet CR-110 Pro Router configuration

show config

nat 2 192.168.254.016 192.168.254.016 * * 000.000.000.000
nat 127 * * * * 000.000.000.000
main 0 ip 222.151.076.136
main 0 mask 255.255.255.224
main 0 gateway 222.151.076.129
main 0 dhcp off
main 0 autodns on
main 0 secdns 210.224.177.140
main 0 pppoe on
admin password ********
dhcp client 0 0002b35d1040 192.168.254.001
dhcp client 1 0002b38d1dbd 192.168.254.002
dhcp client 2 0002b35d101b 192.168.254.003
dhcp client 3 0000e2864dc9 192.168.254.004
dhcp client 4 0002b38d1dc0 192.168.254.005
dhcp client 5 0003936953e0 192.168.254.006
dhcp client 6 000cf1a4b1b9 192.168.254.007
dhcp client 7 00094157c00f 192.168.254.008
dhcp client 8 0015609910d3 192.168.254.009
dhcp client 9 000a4810de69 192.168.254.010
dhcp client 10 00164111e07d 192.168.254.011
dhcp client 11 00029e053f09 192.168.254.012
dhcp client 12 0050da89d4f4 192.168.254.013
dhcp client 13 00065b37e7a3 192.168.254.014
dhcp client 14 00c09fd9b526 192.168.254.015
dhcp client 15 000d60e8d839 192.168.254.016
dhcp client 16 00096b5267bf 192.168.254.017
dhcp client 17 0013a9087c6c 192.168.254.018
pppoe 1 use on
pppoe 1 id aad92338@BIG
pppoe 1 password ********
pppoe 1 connectondemand off
pppoe 1 idletimeout 0
pppoe 1 maxtimeout 0

----------------

show routetable

Dynamic Routing
Destination Gateway Interface Met
---------------- --------------- --------- ---
192.168.254.000/24 Ether 1 1
default Ether 0 1
000.000.000.000/0 Ether 0 1

Static Routing
Destination Gateway Interface Met

CR 100 Pro Router.

2008/01/07

Endianess conversion

Endianness maybe a pain in the ass if you don't know it, and you have to work on multi platforms like Linux x86 and Solaris Sparc.

And here is a tip ( quick hack, quit easy ) to convert the endianness .


[vuhung@soltest01 perl]$od -x useable.dat |head
0000000 7561 6d69 2800 0b00 0100 0000 0100 0100
0000020 6400 6700 6197 7155 90a4 c065 3e49 0000
0000040 dd6d 0000 0404 3501 0000 0040 0103 0100
0000060 0200 0000 0100 0100 6400 6800 6197 7155
0000100 90a4 c065 3e49 0000 dd6d 0000 0404 3401
0000120 0000 0040 0103 0100 0300 0000 0100 0100
0000140 6400 6900 d925 5d15 2429 7019 f824 0100
0000160 74b7 0100 0404 3401 0000 0000 0103 0100
0000200 0400 0000 0100 0100 6400 6a00 7709 5805
0000220 4a0a 5d06 e093 0400 d0dd 0600 0404 3501
[vuhung@soltest01 perl]$od -x useable.dat.big | head
0000000 6175 696d 0028 000b 0001 0000 0001 0001
0000020 0064 0067 9761 5571 a490 65c0 493e 0000
0000040 6ddd 0000 0404 0135 0000 4000 0301 0001
0000060 0002 0000 0001 0001 0064 0068 9761 5571
0000100 a490 65c0 493e 0000 6ddd 0000 0404 0134
0000120 0000 4000 0301 0001 0003 0000 0001 0001
0000140 0064 0069 25d9 155d 2924 1970 24f8 0001
0000160 b774 0001 0404 0134 0000 0000 0301 0001
0000200 0004 0000 0001 0001 0064 006a 0977 0558
0000220 0a4a 065d 93e0 0004 ddd0 0006 0404 0135
[vuhung@soltest01 perl]$cat endian-convert.pl
#!/usr/local/bin/perl

($ifile, $ofile) = @ARGV;

open(IN, "$ifile");
open(OUT,">$ofile");
while(read(IN,$buf,2)){
$buf = unpack("n",$buf);
$buf = pack("v",$buf);
print OUT $buf;
}
[vuhung@soltest01 perl]$

gdb on ( Open ) Solaris 10

If you try to install gdb 6.6 as what is described gdb's README file, you will get compilation error when you "make", in tui module.

The tip: disable tui and compile gdb only!


wget ftp://ftp.sunfreeware.com/pub/freeware/SOURCES/gdb-6.6.tar.gz
tar xvzf gdb-6.6.tar.gz
cd gdb-6.6/gdb
./configure --prefix=$HOME --disable-tui
make
make install

2007/12/18

Chứng minh định lý trong wikipedia

Đây là một đề tài mở ở slashdot.

http://ask.slashdot.org/comments.pl?sid=39...mp;cid=21716520

Mình nghĩa diendantoanhoc có thể làm là:

Tham gia dịch ( bước 1 ) những định lý bằng tiếng Anh ra tiếng Việt . Và sau đó tham gia soạn bài mới ( bước 2 ) cho wikipedia nếu có khả năng .

Xin nói thêm về wikipedia cho những bạn chưa biết ( xác suất .099% biggrin.gif ): Wikipedia là một từ điển bách khoa lớn nhất trong lịch sử, tự do, mở ( bất kì ai cũng có thể đóng góp ), và phi lợi nhuận .

-> Tiếng Anh http://en.wikipedia.org/
-> Tiếng Việt http://vi.wikipedia.org/

2007/12/09

60 seconds science

60 seconds science ( http://www.60secondscience.com/ ) là một website của tạp chí Scientific America . Nội dung cover chủ yếu là sinh học . Một số topics nhỏ nói về những vấn đề khác như IT, thiên văn.

60 seconds science bao gồm những đoạn video, hay mp3 ngắn - thường dưới 3 phút - nói về những vấn đề khoa học tương đối phổ thông, có tính giáo dục cao, kích thích não phải và trái hoạt động hihi

2007/12/06

SeLinux: make http://host/~username visible

1133 cd home/
1134 ls -Z /home/
1135 chown -R user_u:object_r:user_home_dir_t nhocquay
1136 chcon user_u:object_r:user_home_dir_t nhocquay
1137 cd nhocquay/
1138 ls -Z /home/vuhung/public_html/
1139 ls -Z /home/vuhung/
1140 chcon user_u:object_r:httpd_sys_content_t public_html/

2007/12/02

mkfs ext3: aoclife new harddisk

[root@aoclife ~]# mkfs
mkfs mkfs.cramfs mkfs.ext2 mkfs.ext3 mkfs.msdos mkfs.vfat
[root@aoclife ~]# fdisk -l /dev/sdb

Disk /dev/sdb: 73.4 GB, 73407820800 bytes
255 heads, 63 sectors/track, 8924 cylinders
Units = cylinders of 16065 * 512 = 8225280 bytes

Disk /dev/sdb doesn't contain a valid partition table
[root@aoclife ~]# mkfs
Usage: mkfs [-V] [-t fstype] [fs-options] device [size]
[root@aoclife ~]# mkfs -t ext3 /dev/sdb
mke2fs 1.39 (29-May-2006)
/dev/sdb is entire device, not just one partition!
Proceed anyway? (y,n) y
Filesystem label=
OS type: Linux
Block size=4096 (log=2)
Fragment size=4096 (log=2)
8962048 inodes, 17921831 blocks
896091 blocks (5.00%) reserved for the super user
First data block=0
Maximum filesystem blocks=0
547 block groups
32768 blocks per group, 32768 fragments per group
16384 inodes per group
Superblock backups stored on blocks:
32768, 98304, 163840, 229376, 294912, 819200, 884736, 1605632, 2654208,
4096000, 7962624, 11239424

Writing inode tables: done
Creating journal (32768 blocks): done
Writing superblocks and filesystem accounting information: done

This filesystem will be automatically checked every 31 mounts or
180 days, whichever comes first. Use tune2fs -c or -i to override.

2007/11/29

High rated RTS gamers: skill or talent?

Let's clarify a keyword the original poster wrote: talent[1] . It has two meaning: gift[2] and/or skills[3]

Gift is something lies under your ADN, it is "premade" and you can't archive it no matter how you pratice.

Skill is something gets improved with the time you are working on it.

I agree with most of the comments so far that "skill" is need to archive 2k. But to reach 2.3k+, you have to do be gifted.

I also talked to some 2.2k ( sometimes 2.3k but falls back to 2.2k soon ) and they complain that they lacks of something they don't know. And he can't win daut or Chris in every map and civ.

Wikipedia also has a short but densed article about RTS[4] which if you read carefully, you will find that the key factors that make a gifted/skilled RTS gamer:

1. Micromanagement ( Yes, it is management, requires experience ( knowhow ), sometimes a a little research to the game )
2. Macromanagement ( Yes, it is management, requires experience ( knowhow ), sometimes a a little research to the game )

Both are important but IMO, macromanagement are more important: It is the capacity to adapt econ/armies to various situations. Where and how to attack. Help or contribute. I also strongly recommend reading "The art of war" by Sun Tzu[5].


[1] http://en.wikipedia.org/wiki/Talent
[2] http://en.wikipedia.org/wiki/Intellectual_giftedness
[3] http://en.wikipedia.org/wiki/Skill
[4] http://en.wikipedia.org/wiki/Real-time_strategy#Gameplay
[5] http://en.wikipedia.org/wiki/The_Art_of_War

2007/11/20

wget sucks up Internet

[vuhung@aoclife suriken]$ jobs
[2]- Running wget --no-parent --wait=1 --random-wait --limit-rate=100K -r -p -U Mozilla http://www15.atwiki.jp/suriken/ >&/dev/null & (wd: /var/www/html/aoc/misc)
[3]+ Running wget --no-parent --wait=1 --random-wait --limit-rate=100K -r -p -U Mozilla http://www.mrfixitonline.com/aok >&/dev/null & (wd: /var/www/html/aoc/misc)

2007/11/14

Compile/Run icc with cairo

Hi all,

I've tried icc 10.1 Pro with cairo ( http://cairographics.org/releases/cairo-1.4.10.tar.gz )

the installation went smooth as follows:

CentOS 5.
[vuhung@aoclife cairo]$ uname -r
2.6.18-8.el5
[vuhung@aoclife cairo]$ rpm -qa | grep glibc
glibc-2.5-12
glibc-headers-2.5-12
glibc-common-2.5-12
glibc-devel-2.5-12
[vuhung@aoclife cairo]$

yum install libstdc++.so.5
tar xvzf l_cc_p_10.1.008.tar.gz
cd l_cc_p_10.1.008
./install
#serial number: VJFV-MP9H3R5J
cat "source /opt/intel/cc/10.1.008/bin/iccvars.sh" >> ~/.bash_profile

icc now can run.

Then,

cd ~/usr/src/cairo-1.4.10
./configure --without-xlib --disable-xlib CC=icc
make;
make install

And when I tried to compile icc with cairo ( hello.c ):

icc -o hello `pkg-config --cflags --libs cairo` hello.c

I got the error:

icc -o hello `pkg-config --cflags --libs cairo` hello.c
/tmp/icck8ycA8.o: In function `main':
hello.c:(.text+0x1c): undefined reference to `cairo_image_surface_create'
hello.c:(.text+0x24): undefined reference to `cairo_create'
hello.c:(.text+0x80): undefined reference to `cairo_move_to'
hello.c:(.text+0x91): undefined reference to `cairo_destroy'
hello.c:(.text+0xa2): undefined reference to `cairo_surface_destroy'

where:

[vuhung@aoclife cairo]$ pkg-config --cflags --libs cairo
-I/usr/local/include/cairo -I/usr/include/freetype2 -I/usr/include/libpng12 -L/usr/local/lib -lcairo

Yes, icc couldn't find some API. Because I am new to icc, I don't know how icc creates and links the libraries.

If in the steps above, I replace icc with gcc, everything will be fine.



-----------cut here ------------
#include

int
main (int argc, char *argv[])
{
cairo_surface_t *surface;
cairo_t *cr;

surface = cairo_image_surface_create (CAIRO_FORMAT_ARGB32, 240, 80);
cr = cairo_create (surface);

cairo_select_font_face (cr, "serif", CAIRO_FONT_SLANT_NORMAL, CAIRO_FONT_WEIGHT_BOLD);
cairo_set_font_size (cr, 32.0);
cairo_set_source_rgb (cr, 0.0, 0.0, 1.0);
cairo_move_to (cr, 10.0, 50.0);
cairo_show_text (cr, "Hello, world");
cairo_destroy (cr);
cairo_surface_write_to_png (surface, "hello.png");
cairo_surface_destroy (surface);

return 0;
}

--------------------------------


Install Intel C++ Compiler 10.1 on Centos 5

エラー: 依存性の欠如:
libstdc++.so.5 は intel-icc101008-10.1.008-1.i386 に必要とされています
libstdc++.so.5(GLIBCPP_3.2) は intel-icc101008-10.1.008-1.i386 に必要とされています


yum install libstdc++.so.5
wget http://registrationcenter-download.intel.com/irc_nas/861/l_cc_p_10.1.008.tar.gz
tar xvzf l_cc_p_10.1.008.tar.gz
cd l_cc_p_10.1.008
./install
#serial number: VJFV-MP9H3R5J
cat "source /opt/intel/cc/10.1.008/bin/iccvars.sh" >> ~/.bash_profile

icc now can run.