Older blog entries for zhaoway (starting at number 294)

open source answer to unit test: don't.

let me explain. ;)

in a sense, open source is about lowering the development cost, and unit test is more work to do.

one way to lowering deveopment cost, for open source projects, is to let users help testing. then as developers, we should: 1. help users do testing; 2. make every bit of your program testable by users.

the way to help users do testing for us, is to write attractive docs. e.g. write usage docs in ezines. saving the time to write test cases, use the time to write interesting tutorials. write more tutorials.

the way to export every bit of our program so they're testable by users, is to write libs. structure our programs as a bunch of libs plus a small executable. write more docs about the api. see point 1 above.

so. the open source answer to unit testing is: write more libs, write better docs.

that's the open source way to do it. i'm serious. ;)

unit testing is for corporate lusers. ;)

24 Feb 2005 (updated 25 Feb 2005 at 02:28 UTC) »

finally got the idea of how to implement my own avl tree lib. it's different from Ben Pfaff's libavl, and mine will definitely be slower. i'm confident in that aspect. ;) me just got a different way to structure the function-calls' in my lib.

(why reinvent the wheel, and badly?) (i stared at my display for ten minutes trying to get a clever answer but failed. i humbly left this question to the reader.)

another news is that, i'm beginning to adopt Fefe's practice in his dietlibc and libowfat to organize my own program source. namely, one function per file, and write a manual page alongside.

Update: Ankh has a precise description about one public-API function per file and doc alongside.

23 Feb 2005 (updated 23 Feb 2005 at 10:11 UTC) »

new card: nvidia geforce 4.

reason: nvidia's driver doesn't work with my geforce 2.

reason justified: same software. GF2, x can't start. GF4, x works.

shame: i rewarded this irresponsible company another 200 dollars.

stupid: i bought a Cg book a few weeks ago.

i hope this company goto hell.

--

终于有时间按照来医的指点,把中文字体又设置了一遍。How to make Debian support Chinese. clear instructions. easy to follow. thanks. ;)

i was thinking to implement a (rather confusing) rwlock mechanism in my program, then i read in Ben Pfaff's libavl about the concept of generation. hoho. i love this diligent documenter. ;) it's not exactly a match of rwlock. but it's nevertheless very interesting. and almost did the job. ok, now you know i'm really an amateur to joy about such trivial things. ;)

on the other hand, yesterday's delight about my new understanding of the centipede game turns out to have rather serious problems itself. heheheh.

the centipede game has troubled me for more than one year, and this afternoon i finally saw a light through the tunnel. it's pretty amazing. but i'm still far away from the blue sky. ;)

i'd like to find a good reference on the web about the centipede game of game theory, but it seems to have great difficulty to differentiate itself from a certain computer arcade game. :D

i'm reading through Daniel S. Christiansen's microeconomics with calculus. his pdf is simply beautiful. (i'm not knowledge enough to judge the contents of the text.)

i'm also reading through a game theory book (in pdf). there're really many free stuff on econ on the net. (last time i found many free stuff by googleing parent directory and pdf heeheehee) but whenever i came to a bookstore, i simply find there're far far more books. and the covers and thickness always impress me and implies to me far better qualities within.

recently i set a rule for my self. only reading books. do not read papers. it's more efficient reading. only reading books. before that i was eager to reading numerous papers on the internet simple because they're free. but i know now that i can't even finish reading a small portion of the best books. then why bother with papers. even if the author write really brilliant papers, chances are she will later on write better books to explain things more clearly and in better ways.

just don't read papers. the saved time could be spent on book.

20 Feb 2005 (updated 20 Feb 2005 at 11:01 UTC) »

now i'm really wasting my time, ;)

put in ~/.bashrc

wwwcat()
{
    xtitle "netcat"
    if [[ "${2}" == "" || ! -f "${2}" || ! -r "${2}" ]]; then
        echo "Usage: wwwcat PORT FILE"
        echo "PORT is TCP port number on which you must be able to listen"
        echo "FILE is a normal local file readable by you"
        echo "Example: 1. wwwcat 8000 pr0n.gif"
        echo "         then open your browser visit http://localhost:8000"
        echo "         2. while true; do wwwcat 8000 pr0n.gif; done"
        echo "         this can serve more clients one after another"
        return
    fi
    resp="HTTP/1.0 200 OK"
    cont_type="Content-Type: "`/usr/bin/file -bi ${2}`
    cont_length="Content-Length: "`/usr/bin/stat -c%s ${2}`
    echo -e ${resp}"\n"${cont_type}"\n"${cont_length}"\n" | /bin/cat - ${2} | /bin/nc -l -p ${1}
}

i suck. i know. ;)

这好像是以前carlos告诉我的嘞。

put in ~/.bashrc

pdfbrk()
{
    xtitle "pdftk"
    if [ ! -f ${2}.pdf ]; then
        echo "Usage: pdfbrk NUMBER FNAME"
        echo "NUMBER is the total number of all pages"
        echo "FNAME is basename of a PDF without .pdf"
        echo "Example: pdfbrk 1978 dictionary"
        echo "Suppose dictionary.pdf has 1978 pages in total."
        echo "Output will be dictionary.1-13.pdf"
        echo "               dictionary.11-23.pdf"
        echo "               etc."
        return
    fi
    for i in `/usr/bin/seq 1 10 ${1}`; do
        j=$(($i+12))
        if [ $j -gt ${1} ]; then
            j=end
        fi
        /usr/bin/pdftk ${2}.pdf cat $i-$j output ${2}.$i-$j.pdf
    done
}

to help me read big pdf files on screen. i just easily got tired after every 10 pages. ;)

谢谢来医的指点!我差不多是第三次忘记了怎么在Debian下面安装字体。回头我就试试看这些字体。看看效果如何。再次感谢!^_^

scons has a new version out.

scons is a replacement for make, but make is really not a problem waiting to be solved. the problem is the autotools which are good and old. the fault of autotools is it is oh so very hard to learn and at the end you can port your programs to what? aix? hp-ux? and a zillion i-can't-name-it dinosaurs. what i really care is native windows and a couple of linux and maybe solaris and mac os x. all i want is build with their native build tools instead of gnu-pull-me-all-out.

so scons is python, if we say make is shell programming. with python, yeah itself is a portable programming environment, you can do some portability things, at least by hand, for now. and scons will grow, i have confidence in this project. in the near future, i believe you won't have to do that much work by hand at all. it's just a matter to accumulate some more snippets of good scripts.

that being said, to do a similar tool in scheme or lisp or whatever one of those less popular programming languages is not that much meaningful. because the concern here is about portability. if the programming language itself is not a portable and versatile programming environment. then cowsay: mooo... ;)

285 older entries...

New Advogato Features

New HTML Parser: The long-awaited libxml2 based HTML parser code is live. It needs further work but already handles most markup better than the original parser.

Keep up with the latest Advogato features by reading the Advogato status blog.

If you're a C programmer with some spare time, take a look at the mod_virgule project page and help us with one of the tasks on the ToDo list!