2008/07/28

cairo 1.6.4 jpeg I/O support patch


Hello all,

This is an unofficial patch to cairo 1.6.4 that addes jpeg I/O support to cairo.

The original patch( to an older version of cairo) is not mine.
Please take a look at src/cairo-jpeg.c for credit(s).

Installation:
1. ./configure --enable-jpeg; make; make install as usual, or better
2. autoreconf to adapt the changes in configure.in to your enviroment.

For more information, please use diff against the standard release cairo-1.6.4

ABIs added ( similar to PNG ) :
cairo_get_default_jpeg_parameter
cairo_surface_write_to_jpeg
cairo_image_surface_create_from_jpeg
cairo_image_surface_create_from_jpeg_stream

To download, click the link below:
http://www.hn.is.uec.ac.jp/~vuhung/patches/cairo-1.6.4.jpeg-patch.tar.gz

2008/07/23

A better average


double variance(long long *x, int n)
{
double m = x[0];
double s = 0;
int i;
for (i=0; i double m_new = m + (x[i] - m)/(i+1);
s = s + (x[i] - m)*(x[i] - m_new);
m = m_new;
}
return s / (n - 1);
}

double mean(long long *x, int n)
{
double m = x[0];
int i;
for (i=0; i m = m + (x[i] - m)/(i+1);
}
return m;
}

double stddev(long long *x, int n)
{
return sqrt(variance(x, n));
}

long long times[30];

printf("mean: %f stddev: %f\n", mean(times, 20), stddev(times, 20));

2008/06/04

OpenCV: Rebuild the library with Windows, GTK+ 2.x

To fix: Install latest gtk+2.x ( 2.12.9 as of now ).

Remove all the *Windows functions,


#include 
#include

#define MAX_CLUSTERS (32) /* NX^ */

#include
#include

static struct rusage rusage_before;
static struct rusage rusage_after;

void
startTimer(void)
{
getrusage(RUSAGE_SELF, &rusage_before);
}


float
stopTimer(void)
{
long tsec, tusec;

getrusage(RUSAGE_SELF, &rusage_after);

tsec = rusage_after.ru_utime.tv_sec - rusage_before.ru_utime.tv_sec;
tusec = rusage_after.ru_utime.tv_usec - rusage_before.ru_utime.tv_usec;

return (tsec + ((float)tusec) / 1000000.0);
}

int
main (int argc, char **argv)
{
int i, size;
IplImage *src_img = 0, *dst_img = 0;
CvMat *clusters;
CvMat *points;
CvMat *color = cvCreateMat (MAX_CLUSTERS, 1, CV_32FC3);
CvMat *count = cvCreateMat (MAX_CLUSTERS, 1, CV_32SC1);

// (1)
if (argc != 2 || (src_img = cvLoadImage (argv[1], CV_LOAD_IMAGE_COLOR)) == 0)
return -1;

size = src_img->width * src_img->height;
dst_img = cvCloneImage (src_img);
clusters = cvCreateMat (size, 1, CV_32SC1);
points = cvCreateMat (size, 1, CV_32FC3);

// (2)sNZls
for (i = 0; i < size; i++) {
points->data.fl[i * 3 + 0] = (uchar) src_img->imageData[i * 3 + 0];
points->data.fl[i * 3 + 1] = (uchar) src_img->imageData[i * 3 + 1];
points->data.fl[i * 3 + 2] = (uchar) src_img->imageData[i * 3 + 2];
}

// (3)NX^O
startTimer();
cvKMeans2 (points, MAX_CLUSTERS, clusters, cvTermCriteria (CV_TERMCRIT_EPS + CV_TERMCRIT_ITER, 10, 1.0));
printf( "finished making cmapped pix: %7.3f secs\n", stopTimer());

// (4)eNX^lvZ
cvSetZero (color);
cvSetZero (count);
for (i = 0; i < size; i++) {
int idx = clusters->data.i[i];
int j = ++count->data.i[idx];;
color->data.fl[idx * 3 + 0] = color->data.fl[idx * 3 + 0] * (j - 1) / j + points->data.fl[i * 3 + 0] / j;
color->data.fl[idx * 3 + 1] = color->data.fl[idx * 3 + 1] * (j - 1) / j + points->data.fl[i * 3 + 1] / j;
color->data.fl[idx * 3 + 2] = color->data.fl[idx * 3 + 2] * (j - 1) / j + points->data.fl[i * 3 + 2] / j;
}

// (5)NX^F`
for (i = 0; i < size; i++) {
int idx = clusters->data.i[i];
dst_img->imageData[i * 3 + 0] = (char) color->data.fl[idx * 3 + 0];
dst_img->imageData[i * 3 + 1] = (char) color->data.fl[idx * 3 + 1];
dst_img->imageData[i * 3 + 2] = (char) color->data.fl[idx * 3 + 2];
}

#if 0
// (6)\CL[I
cvNamedWindow ("src", CV_WINDOW_AUTOSIZE);
cvShowImage ("src", src_img);
cvNamedWindow ("low-color", CV_WINDOW_AUTOSIZE);
cvShowImage ("low-color", dst_img);
cvWaitKey (0);

cvDestroyWindow ("src");
cvDestroyWindow ("low-color");
#endif

cvReleaseImage (&src_img);
cvReleaseImage (&dst_img);
cvReleaseMat (&clusters);
cvReleaseMat (&points);
cvReleaseMat (&color);
cvReleaseMat (&count);

return 0;
}



[vuhung@teriyaki c]$./kmeans
OpenCV ERROR: Unspecified error (The function is not implemented. Rebuild the library with Windows, GTK+ 2.x or Carbon support)
in function cvNamedWindow, window.cpp(71)
Terminating the application...
called from cvUnregisterType, cxpersistence.cpp(4933)
Terminating the application...
called from cvUnregisterType, cxpersistence.cpp(4933)
Terminating the application...
called from cvUnregisterType, cxpersistence.cpp(4933)
Terminating the application...
called from cvUnregisterType, cxpersistence.cpp(4933)
Terminating the application...
called from cvUnregisterType, cxpersistence.cpp(4933)
Terminating the application...
called from cvUnregisterType, cxpersistence.cpp(4933)
Terminating the application...
called from cvUnregisterType, cxpersistence.cpp(4933)
Terminating the application...
called from cvUnregisterType, cxpersistence.cpp(4933)
Terminating the application...
called from cvUnregisterType, cxpersistence.cpp(4933)

2008/05/20

Movie conversion

[vuhung@aoclife tmp]$ time ffmpeg -i ~serendipity/public_html/Dress.avi Dress.flv
FFmpeg version SVN-r13202, Copyright (c) 2000-2008 Fabrice Bellard, et al.
configuration: --prefix=/home/vuhung
libavutil version: 49.6.0
libavcodec version: 51.57.0
libavformat version: 52.13.0
libavdevice version: 52.0.0
built on May 20 2008 16:41:31, gcc: 4.1.2 20070626 (Red Hat 4.1.2-14)

Seems stream 0 codec frame rate differs from container frame rate: 23.98 (65535/2733) -> 23.98 (2997/125)
Input #0, avi, from '/var/www/home/serendipity/public_html/Dress.avi':
Duration: 01:50:49.10, start: 0.000000, bitrate: 883 kb/s
Stream #0.0: Video: mpeg4, yuv420p, 700x272 [PAR 1:1 DAR 175:68], 23.98 tb(r)
Stream #0.1: Audio: mp3, 44100 Hz, stereo, 112 kb/s
File 'Dress.flv' already exists. Overwrite ? [y/N] y
Output #0, flv, to 'Dress.flv':
Stream #0.0: Video: flv, yuv420p, 700x272 [PAR 1:1 DAR 175:68], q=2-31, 200 kb/s, 23.98 tb(c)
Stream #0.1: Audio: adpcm_swf, 44100 Hz, stereo, 64 kb/s
Stream mapping:
Stream #0.0 -> #0.0
Stream #0.1 -> #0.1
Press [q] to stop encoding
frame=159365 fps=184 q=31.0 Lsize= 466006kB time=6646.9 bitrate= 574.3kbits/s
video:174077kB audio:287049kB global headers:0kB muxing overhead 1.058247%

real 15m14.908s
user 14m6.105s
sys 0m15.406s
[vuhung@aoclife tmp]$ ls -lh Dress.flv
-rw-rw-r-- 1 vuhung vuhung 456M 5月 20 16:58 Dress.flv
[vuhung@aoclife tmp]$ ls -lh ~serendipity/public_html/Dress.avi
-rw-rw-r-- 1 serendipity serendipity 701M 4月 17 11:58 /var/www/home/serendipity/public_html/Dress.avi
[vuhung@aoclife tmp]$

2008/05/16

Tip with getrusage



#include

# getrusage is a POSIX funtion
# http://www.opengroup.org/onlinepubs/000095399/functions/getrusage.html

static struct rusage rusage_before;
static struct rusage rusage_after;

void
startTimer(void)
{
getrusage(RUSAGE_SELF, &rusage_before);
}


l_float32
stopTimer(void)
{
l_int32 tsec, tusec;

getrusage(RUSAGE_SELF, &rusage_after);

tsec = rusage_after.ru_utime.tv_sec - rusage_before.ru_utime.tv_sec;
tusec = rusage_after.ru_utime.tv_usec - rusage_before.ru_utime.tv_usec;

return (tsec + ((l_float32)tusec) / 1000000.0);
}

2008/04/01

strstr test

[vuhung@g++]$gcc -Wall strstr.c
[vuhung@g++]$./a.out
p1 = ,Ten,2, toi
p2 = ,Ten,2, toi
p1 = ,2, toi
p2 = Ten,2, toi
p1 = 2, toi
p2 = , toi
p1 = (null)
p2 = toi
[vuhung@g++]$cat strstr.c
#include
#include

int main()
{
unsigned char *p1;
unsigned char *p2;

unsigned char string[20] = ",Ten,2, toi";

p1 = string;

p2 = strstr(p1, ",");

printf("p1 = %s\n", p1);
printf("p2 = %s\n", p2);

p2++;
p1 = strstr(p2, ",");

printf("p1 = %s\n", p1);
printf("p2 = %s\n", p2);

p1++;
p2 = strstr(p1, ",");

printf("p1 = %s\n", p1);
printf("p2 = %s\n", p2);

p2++;
p1 = strstr(p2, ",");

printf("p1 = %s\n", p1);
printf("p2 = %s\n", p2);

return 0;

}

2008/03/04

Will 'free' return the memory Immediately to the OS ?

> Will 'free' return the memory Immediately to the OS ?

It depends on how your free() is implemented.

Most libc's use a complex algorithm to do memory manangement,
in order to get the speed, maybe they won't give the memory
to OS immediately after free().

The C std just can guarantee that after your free(), that
memory block can be used for further malloc().

2008/02/18

Tính trung lập và chính xác của wikipedia

Tính trung lập và chính xác của wikipedia không phải bao giờ cũng có thể tin được . Đặc biệt với những vấn đề phi kĩ thuật, sự xác định tính đúng sai phụ thuộc quá nhiều vào người viết là khó kiểm chứng . Mình đọc entry viết về Lê Lợi ở vi.wikipedia.org và thấy điều này . en.wikipedia.org cũng gặp vấn đề tương tự. Cơ bản việc so sánh những chi tiết lắt nhắt của Lê Lợi và Lưu Bang cũng làm mất tính bách khoa của entry này rồi .

Entry về HCM

http://vi.wikipedia.org/wiki/H%E1%BB%93_Ch%C3%AD_Minh

cũng bị khóa vì có quá nhiều nhiều luồng ý kiến trái ngược nhau. Không ai đủ trung lập để viết về HCM . Nếu đọc kĩ sẽ thấy rất nhiều câu chữ ngô nghê trong entry này .

Thử xem nhé

http://vi.wikipedia.org/w/index.php?title=H%E1%BB%93_Ch%C3%AD_Minh&action=history
http://vi.wikipedia.org/w/index.php?title=H%E1%BB%93_Ch%C3%AD_Minh&diff=1021547&oldid=1021135
( Lẫn văn nói, F*** )
http://vi.wikipedia.org/w/index.php?title=H%E1%BB%93_Ch%C3%AD_Minh&diff=1021135&oldid=1019123
( Link tới Vũ Thư Hiến và BBC bị xóa )
http://vi.wikipedia.org/w/index.php?title=H%E1%BB%93_Ch%C3%AD_Minh&diff=next&oldid=884898
( Một số chi tiết cụ thể về Cải cách ruộng đất bị xoá )

2008/02/14

/usr/lib/libstdc++.so.6 : version 'GLIBCXX_3.4.9' not found (required by my_app) :

/usr/lib/libstdc++.so.6 : version 'GLIBCXX_3.4.9' not found (required by my_app) :

because: libstdc++.so.6 is not compartible with the libstdc++.so we have used to compile my_app:

fix:

export LD_LIBRARY_PATH=/where/the/lib/folder/of/gcc/is:$LD_LIBRARY_PATH

Solaris guile installation

[vuhung@ guile-1.8.3]$uname -a
SunOS 5.10 Generic_127111-05 sun4v sparc SUNW,SPARC-Enterprise-T5220 Solaris

[vuhung@ guile-1.8.3]$./configure --prefix=$HOME --with-gnu-ld LIBS=-L$HOME/lib CFLAGS=-I$HOME/include

make:

numbers.c: In function `scm_log':
numbers.c:6015: error: `_Complex_I' undeclared (first use in this function)
numbers.c:6015: error: (Each undeclared identifier is reported only once
numbers.c:6015: error: for each function it appears in.)
numbers.c: In function `scm_exp':
numbers.c:6081: error: `_Complex_I' undeclared (first use in this function)
gmake[3]: *** [libguile_la-numbers.lo] Error 1

downgrade to guile-1.6.4

./configure --prefix=$HOME --with-gnu-ld LIBS=-L$HOME/lib CFLAGS=-I$HOME/include
make
make install

GNU file ( with magic lib ) vs Solaris standard file command

[Solaris file ]

[vuhung@soltest02 UnitTestLinux]$/usr/bin/file -v
/usr/bin/file: オプションが正しくありません -- v
使用法: file [-dh] [-M mfile] [-m mfile] [-f ffile] <ファイル> ...
file [-dh] [-M mfile] [-m mfile] -f ffile
file -i [-h] [-f ffile] <ファイル> ...
file -i [-h] -f ffile
file -c [-d] [-M mfile] [-m mfile]

[vuhung@soltest02 UnitTestLinux]$file output/real/real_18.png
output/real/real_18.png: PNG イメージデータ

[ GNU file ]

[vuhung@soltest02 UnitTestLinux]$~/bin/file --version
file-4.23
magic file from /export/home/vuhung/share/file/magic

[vuhung@soltest02 UnitTestLinux]$~/bin/file output/real/real_18.png
output/real/real_18.png: PNG image data, 800 x 600, 8-bit colormap, non-interlaced

SPARC Enterprise T5220 multithreading benchmark(仮)

[vuhung@ ]$make clean; time make
real 17m9.996s
user 16m43.709s
sys 0m22.620s

[vuhung@ ]$make clean; time make -j 8
real 2m15.245s
user 16m22.220s
sys 0m21.046s

[vuhung@ ]$make clean; time make -j 64
real 1m37.810s
user 23m30.976s
sys 0m31.164s

[vuhung@ ]$make clean; time make -j 128
real 1m36.545s
user 23m38.538s
sys 0m31.378s

[vuhung@ ~]$uname -a
SunOS 5.10 Generic_127111-05 sun4v sparc SUNW,SPARC-Enterprise-T5220 Solaris

[vuhung@ ~]$prtdiag
システム構成: Sun Microsystems sun4v SPARC Enterprise T5220
メモリーサイズ: 32640 M バイト

========================= CPU ===============================================

CPU CPU
Location CPU Freq Implementation Mask
------------ ----- -------- ------------------- -----
MB/CMP0/P0 0 1167 MHz SUNW,UltraSPARC-T2
MB/CMP0/P1 1 1167 MHz SUNW,UltraSPARC-T2
MB/CMP0/P2 2 1167 MHz SUNW,UltraSPARC-T2
MB/CMP0/P3 3 1167 MHz SUNW,UltraSPARC-T2
MB/CMP0/P4 4 1167 MHz SUNW,UltraSPARC-T2
MB/CMP0/P5 5 1167 MHz SUNW,UltraSPARC-T2
MB/CMP0/P6 6 1167 MHz SUNW,UltraSPARC-T2
MB/CMP0/P7 7 1167 MHz SUNW,UltraSPARC-T2
MB/CMP0/P8 8 1167 MHz SUNW,UltraSPARC-T2
MB/CMP0/P9 9 1167 MHz SUNW,UltraSPARC-T2
MB/CMP0/P10 10 1167 MHz SUNW,UltraSPARC-T2
MB/CMP0/P11 11 1167 MHz SUNW,UltraSPARC-T2
MB/CMP0/P12 12 1167 MHz SUNW,UltraSPARC-T2
MB/CMP0/P13 13 1167 MHz SUNW,UltraSPARC-T2
MB/CMP0/P14 14 1167 MHz SUNW,UltraSPARC-T2
MB/CMP0/P15 15 1167 MHz SUNW,UltraSPARC-T2
MB/CMP0/P16 16 1167 MHz SUNW,UltraSPARC-T2
MB/CMP0/P17 17 1167 MHz SUNW,UltraSPARC-T2
MB/CMP0/P18 18 1167 MHz SUNW,UltraSPARC-T2
MB/CMP0/P19 19 1167 MHz SUNW,UltraSPARC-T2
MB/CMP0/P20 20 1167 MHz SUNW,UltraSPARC-T2
MB/CMP0/P21 21 1167 MHz SUNW,UltraSPARC-T2
MB/CMP0/P22 22 1167 MHz SUNW,UltraSPARC-T2
MB/CMP0/P23 23 1167 MHz SUNW,UltraSPARC-T2
MB/CMP0/P24 24 1167 MHz SUNW,UltraSPARC-T2
MB/CMP0/P25 25 1167 MHz SUNW,UltraSPARC-T2
MB/CMP0/P26 26 1167 MHz SUNW,UltraSPARC-T2
MB/CMP0/P27 27 1167 MHz SUNW,UltraSPARC-T2
MB/CMP0/P28 28 1167 MHz SUNW,UltraSPARC-T2
MB/CMP0/P29 29 1167 MHz SUNW,UltraSPARC-T2
MB/CMP0/P30 30 1167 MHz SUNW,UltraSPARC-T2
MB/CMP0/P31 31 1167 MHz SUNW,UltraSPARC-T2
MB/CMP0/P32 32 1167 MHz SUNW,UltraSPARC-T2
MB/CMP0/P33 33 1167 MHz SUNW,UltraSPARC-T2
MB/CMP0/P34 34 1167 MHz SUNW,UltraSPARC-T2
MB/CMP0/P35 35 1167 MHz SUNW,UltraSPARC-T2
MB/CMP0/P36 36 1167 MHz SUNW,UltraSPARC-T2
MB/CMP0/P37 37 1167 MHz SUNW,UltraSPARC-T2
MB/CMP0/P38 38 1167 MHz SUNW,UltraSPARC-T2
MB/CMP0/P39 39 1167 MHz SUNW,UltraSPARC-T2
MB/CMP0/P40 40 1167 MHz SUNW,UltraSPARC-T2
MB/CMP0/P41 41 1167 MHz SUNW,UltraSPARC-T2
MB/CMP0/P42 42 1167 MHz SUNW,UltraSPARC-T2
MB/CMP0/P43 43 1167 MHz SUNW,UltraSPARC-T2
MB/CMP0/P44 44 1167 MHz SUNW,UltraSPARC-T2
MB/CMP0/P45 45 1167 MHz SUNW,UltraSPARC-T2
MB/CMP0/P46 46 1167 MHz SUNW,UltraSPARC-T2
MB/CMP0/P47 47 1167 MHz SUNW,UltraSPARC-T2
MB/CMP0/P48 48 1167 MHz SUNW,UltraSPARC-T2
MB/CMP0/P49 49 1167 MHz SUNW,UltraSPARC-T2
MB/CMP0/P50 50 1167 MHz SUNW,UltraSPARC-T2
MB/CMP0/P51 51 1167 MHz SUNW,UltraSPARC-T2
MB/CMP0/P52 52 1167 MHz SUNW,UltraSPARC-T2
MB/CMP0/P53 53 1167 MHz SUNW,UltraSPARC-T2
MB/CMP0/P54 54 1167 MHz SUNW,UltraSPARC-T2
MB/CMP0/P55 55 1167 MHz SUNW,UltraSPARC-T2
MB/CMP0/P56 56 1167 MHz SUNW,UltraSPARC-T2
MB/CMP0/P57 57 1167 MHz SUNW,UltraSPARC-T2
MB/CMP0/P58 58 1167 MHz SUNW,UltraSPARC-T2
MB/CMP0/P59 59 1167 MHz SUNW,UltraSPARC-T2
MB/CMP0/P60 60 1167 MHz SUNW,UltraSPARC-T2
MB/CMP0/P61 61 1167 MHz SUNW,UltraSPARC-T2
MB/CMP0/P62 62 1167 MHz SUNW,UltraSPARC-T2
MB/CMP0/P63 63 1167 MHz SUNW,UltraSPARC-T2

2008/02/04

Fast, Fixed Point Square Root Computation ?

I did test your magic_sqrt but the time to execute sqrt() and magic_sqrt() are almost the same with my environment:

Linux, RHEL 4., x64, Xeon 3.2G x 2, 4MB memory gcc (GCC) 3.4.6 20060404 (Red Hat 3.4.6-3), glib 2.3.4.

Here is the code:

[vuhung@ g++]$gcc -lm sqrt.c
[vuhung@ g++]$./a.out
sqrt time = 0.025689
magic sqrt time = 0.026223
[vuhung@ g++]$cat sqrt.c
#include
#include
#include
#include

float magic_sqrt (float number)
{
long i;
float f = 1.5, x = number/2, y = number;
i = * ( unsigned long * ) &y;
i = 0x5f3759df - ( i >> 1 );
y = * ( float * ) &i;
y = y * (f - x*y*y);
return number * y;

}

int main()
{
long i;

long NUM = 1000000;
float x;

double real, real_begin;
struct timeval tv;
gettimeofday (&tv, NULL);
real_begin = tv.tv_sec + (double) tv.tv_usec * 1e-6;

for(i = 0; i < NUM; i++)
x =sqrt(i + 0.01);

gettimeofday (&tv, NULL);
real = (tv.tv_sec + (double) tv.tv_usec * 1e-6);
printf (" sqrt time = %f\n", real - real_begin);


gettimeofday (&tv, NULL);
real_begin = tv.tv_sec + (double) tv.tv_usec * 1e-6;

for(i = 0; i < NUM; i++)
x = magic_sqrt(i + 0.01);
gettimeofday (&tv, NULL);
real = (tv.tv_sec + (double) tv.tv_usec * 1e-6);
printf ("magic sqrt time = %f\n", real - real_begin);

return 0;

}
http://www.qoheleth.uklinux.net/blog/?p=139
http://themanaworld.org/tmwservdox/mathutils_8cpp-source.html

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/