Archives - Show All

  • 2009
    • June
      • Return page_count(page) - !!page_has_private(page) == 2 discussion
        06/18/09
        (15:34:44) vincentinsz: 287 static inline int is_page_cache_freeable(struct page *page)
        288 {
        289 return page_count(page) - !!page_has_private(page) == 2;
        290 }

        (15:35:21) vincentinsz: this function eventually returns 0 or 1, right?
        (15:36:35) qunying: not

      • kernel virtual address to size caculation chat log
        06/11/09
        I had an interesting chat with my friend qunying about how to caculate the hex presentation of address to a size:

        (14:29:56) vincentinsz: on x86 32bit the kernel image located at physical address 1MiB, which translate to 0x00100000, but how 0x00100000 equals 1M, how to caculate it?
        (

    • May
      • Learning Linux Kernel series 1 - Buffer Head
        05/28/09
        First I read:

        A nasty file corruption bug - fixed
        http://lwn.net/Articles/215868/

        The header for buffer head is include/linux/buffer_head.h


        defines maxmum disk sectores/blocks as 8 per page, PAGE_CACHE_SIZE normally is the same size of PAGE_SIZE as 4k
    • April
    • February
      • Use vim and cscope to read large C source code project
        02/25/09
        Vim is my favourite editor, I often use vim to read open source C code, Later, I found cscope is quite good tool to jump back and forth between different C source files to better understand how those C sources connect together in a large open source C code project.

        cscopes_maps.vim can b

    • January
      • Asterisk App DISA usage and programing control
        01/29/09
        DISA: Direct Inward System Access, application allows someone from outside the telephone switch (PBX) to obtain an <emphasis>internal</emphasis> system dialtone and to place calls from it as if they were placing a call from within the switch.
        Sampel Extension Usage:

        exte

  • 2008
  • 2007
    • December
      • IP PBX IP04 experiment
        12/07/07

        I have been playing around the leading-edge IP PBX IP04 box a while, when it is shipped to me, it is fully working IP PBX, two FXO, two FXS. It did not satisfy my curiosity though, so I take a step further, destroyed the firmware, cross rebuild the firmware, flashed the nand, compiled the zap

    • November
    • September
      • OpenBSD spamd + Soekris = greylist appliance
        09/20/07

        My OpenBSD transparent bridge works perfect to protect my email server (MTA) from spam-bot attack. It runs on a lower end pc, so the question is, can I implement this solution as an anti-spam appliance which I can bring it anywhere, plug it in and it just work? After couple of days of googling

      • something about atime
        09/14/07
        http://kerneltrap.org/node/14148

        Here is a useful info I quote from slashdot:

        quote begin:
        Stopping and Starting a disk causes the most wear on the disk. When in an idle state the spinning disk has fully lubricated bearings and is using just a tiny amount of energy. Strap

      • OpenBSD + spamd
        09/06/07
        Lately, there seems burst of spam bot attack, I see rising of spamhous blacklist queries from Postfix maillog, this does raise the network traffic and spamhous is blocking heavy queries even from small site.

        OpenBSD spamd http://www.openbsd.org/spamd/ is the right tool to combat spam bot

    • August
      • Cyrus-Imapd misbehave on OS X Panther server?
        08/15/07
        While setting up a new user from Panther server, the user mailbox is not created automatically, leads to non-delieverble email to this user. it has always been working and why suddenly stops working as usual.run cyradm -u cyrus localhost and sam the_user_mailbox id all always give me system I/O err

      • Festvial + Perl Asterisk AGI
        08/14/07
        I coded up a simple math subtraction addition script game using Asterisk Perl AGI library, this script will call Festival app to read question and answers to callers, check the script here:

        http://bl0g.blogdns.com/asterisk/math.agi

      • Festival + Asterisk
        08/09/07
        Just setup text2speech software festival to work with asterisk, festival should be patched to work with asterisk, but there is simple way to patch it, read the festival.README in asterisk source contrib directory.

        start festival first, then add extension in asterisk:

        [incoming

    • June
      • voipstunt config for my home asterisk
        06/30/07
        With following config, I can make cheap long distance voip call to China

        sip.conf

        [voipstunt]
        type=friend ; (or "peer" if we don't need incoming call)s
        host=sip.voipstunt.com

      • My newer version of SpamAssassin P0f plugin
        06/07/07
        http://bl0g.blogdns.com/spamassassin/p0f-analyzer.pm
        http://bl0g.blogdns.com/spamassassin/p0f-analyzer.cf
        http://bl0g.blogdns.com/spamassassin/p0f-analyzer.pl
        http://bl0g.blogdns.com/spamassassin/p0f-ppc.pm
        http://bl0g.blogdns.com/spamassassin/p0f-x86.pm
        http://bl0g.blogdns.

      • file utility upgrade
        06/05/07
        Amaivsd security alert:

        http://www.amavis.org/security/asa-2007-3.txt

        when I upgrade file-4.20 to file-4.21 on Fedora core 3, run file command complains:
        "file: version mismatch (4 != 2) in `/usr/local/share/file/magic.mgc'"

        link old magic.mgc mak

    • April
      • SpamAssassin Malformed UTF-8 character
        04/27/07
        Running latest SpamAssassin-3.2.0-rc3 with some SARE rules will generate tons of "Malformed UTF-8 character...", here is the relevant bug summary:

        http://issues.apache.org/SpamAssassin/s

        There are multiple ways to avoid this problem in the bug report. My simple way wo

      • cdrecord on Yellow dog linux
        04/12/07
        run cdrecord --scanbus, it gives me:

        scsibus0:
        0,0,0 0) 'SONY ' 'DVD RW DW-Q28A ' 'KAS7' Removable CD-ROM
        0,1,0 1) *
        0,2,0 2) *
        0,3,0 3) *
        0,4,0 4) *
        0,5,0

      • My initial TWiki setup
        04/02/07
        https://macli.homelinux.com/twiki/

      • Set thunderbird as default firefox mail client
        04/02/07
        http://kb.mozillazine.org/Default_mail_client

    • March
    • February
      • Compiling clamav on Yellow Dog Linux 4.1
        02/13/07
        Enviroment:

        Power Mac G5 dual core
        Yellow Dog Linux 4.1
        gcc.ppc 3.4.4-2.ydl.2
        zlib-1.2.3

        It compiles ok, but whenever I run clamd, it always complains:
        ...
        R_PPC_REL24 relocation at 0x0ff8f650 for symbol `whatever' out of range
        ...

    • January
      • My patch to parselog Parse.pm
        01/26/07
        --- /usr/src/parselog-0.09/lib/Log/Parse.pm 2005-07-07 06:52:49.000000000 -0700
        +++ /home/vincent/code2007/Parse.pm 2007-01-26 15:27:51.562065760 -0800
        @@ -485,13 +485,9 @@
        line => '',
        @_,
        );
        + #Oct 23 03:57:51 star amavis

      • My patch to add average spam/clean email rate to parselog.cgi
        01/26/07
        --- /usr/src/parselog-cgi-0.04/bin/parselog.cgi 2005-07-20 05:53:27.000000000 -0700
        +++ parselog.cgi 2007-02-01 09:49:27.000000000 -0800
        @@ -29,6 +29,7 @@
        my $base = $ENV{SCRIPT_NAME} || '';
        my $path = $ENV{PATH_INFO} || shift(@ARGV) || '';
        $

      • Perl one-liner to check if OS is big endian or littel endian
        01/18/07
        perl -MConfig -e '($Config{byteorder} == 1234) ? print "$^O is little endian\n" : print "$^O is big endian\n"

        linux are in little endian (right to left)

        Network byte order,Darwin is big endian (left to right)

      • Perl multi pattern grep
        01/08/07
        Here is my little Perl multi pattern grep script modifed from <<Advanced Perl Programming>>

        #!/usr/bin/perl
        use strict;
        use warnings;

        open my $fh, '<', pop(@ARGV) or die "Could not open $ARGV[-1]:$!";

        my $code = 'whil

      • mrt to show ip route and packet loss
        01/03/07
        Lately, because of Taiwan earth quake, the fabric cable broke between North America and South East Asia, mrt it a good tool to show route and network traffic jam for this case:

        # mtr --interval=5 www.chinaunix.net

        Host Loss

      • Perl one-liner caculator
        01/03/07
        perl -e 'while (defined ($s = <>)) { $result = eval $s; $@? print "invalid string: \n $s" : print $result, "\n"; }'

  • 2006
    • December
      • VLC Command Line to Stream USB Webcam
        12/21/06
        The command line interface for VLC seems a little bit comlex, after playing it a bit, I conculded following working command line:

        vlc v4l:// :v4l-vdev='/dev/video0' :v4l-adev='/dev/dsp' --sout '#duplicate{dst=display, dst=std{access=http, mux=asf, url=ip:port}}�

      • Watch live video of office server room from home with open-source software running on old hardware
        12/14/06
        I happen to have an old iMac G3 and usb Logitech quickcam pro4000. I used carbon clone copy to install Mac OS X 10.3 on the iMac G3 thinking of run streaming server on it.

        I could run free program quicktime broadcaster and Darwin Streaming Server offered by Apple, but it only works with

    • November
    • October
      • Linksys NSLU2 and Asterisk PBX system initial setup
        10/27/06
        So the NSLU2 is flashed with unslung linux firmware, I followed the http://www.nslu2-linux.org/wiki/Unslung/Asterisk and http://www.nslu2-linux.org/wiki/Unslung to initally set up my first open source asterisk pbx system. I tried the softphone xlite from my powerbook to ibook labtop, it did not work

      • SpamAssassin Chinese rules
        10/26/06
        I trimmed some chinese rules from geewhiz to run fast with spamassassin

        http://bl0g.blogdns.com/rules/99_geewhizg_mcli_zh.cf
        http://bl0g.blogdns.com/rules/50_scores

      • Lower end network attached storage - Linksys NSLU2
        10/25/06
        I got my brand new Linksys NSLU2, yay! I spent half day to read the documentation on http://www.nslu2-linux.org/ and successfully flashed the firmware and boot the box up from external USB Lacie drive
        There is some trouble when I try to usling to the external usb drive. everytime when I boot

      • Perl Obfuscated code for fun
        10/20/06
        Today, I played the original came code which print camel picture. http://perlmonks.org/?node=camel+code

        I just quckly turned the program shape into a chinese character zhong, and obviously it will print out chinese character zhong :)

        Check the code http://bl0g.blogdns.com/code2

      • Perl buffer suffering
        10/19/06
        Wonder what $| =1 in Perl means? here is a great link to learn Perl buffering

        http://perl.plover.com/FAQs/Buffering.html

      • Debugging SpamAssassin with timestamp
        10/19/06
        I just learned from amavisd-new developer Mark I could run command below to check the timestamp of each SA running debugging lines:

        su clamav -c 'spamassassin -t -D <test.msg' 2>&1 | perl -MPOSIX -MTime::HiRes -n -e '
        BEGIN {$|=1;

      • Perl one-liner to split mbox
        10/15/06
        perl -pe 'BEGIN { $n=1 } open STDOUT, ">$ARGV.$n" and $n++ if /^From /' MailBox

        which will split mbox format file MailBox to single email file. there is more one-liner from http://sial.org/howto/perl/one-liner/

      • Running OS X and Windows on Mac Intel
        10/11/06
        Just got an Macbook to test run OS X and Windows XP SP2. There is tip which may help other users to install Windows:

        1. Boot into Mac OS X.
        2. In BootCamp Assistant, remove the Windows partition.
        3. Reboot per request.
        4. In BootCamp Assistant, repartition for Windows.
      • AWSTATS setup on OS X Tiger Server
        10/06/06
        Setup AWSTATS on OS X Tiger Server is plain easy. Check this link for step by step setup
        http://www.afp548.com/article.php?story

        But there is one thing bite me - the Apache log format. Apache's default combined log format is like this:

        LogFormat "%h %l %u %t \&q

      • Use SpamAssassin Message.pm module to fetch email attachment
        10/02/06
        Here is a little script I wrote to fetch email attachment. If user got spam and forward it as attachment to me, I could use this script to rip the attachment and feeds it to sa-learn, the bayes learning engine of SA.

        #!/usr/bin/perl
        use strict;
        use warnings;

        use Mail:

      • Re-queueing quarantined spam
        10/02/06
        I happen to know that one amavisd user misfiltered 10000 emails as spam, and want to release them. How that could be achieved. Here is the relevant discussion link:
        http://marc.theaimsgroup.com/?l=amavis-

        The following both solutions are that we get mail_id from the quarantined *.gz

    • September
      • Amavisd-2.3.3 and SA's sa-update
        09/28/06
        If system are running on Amavisd-new-2.3.3 and SA version older than 3.1.5. the rules updated by sa-update will not accessed by amavisd unless add one line code to Mail::SpamAssassin->new( LOCAL_STATE_DIR => '/var/lib',). The relevant discussion link:
        http://www.mail-archive.co

      • P0f - Passive OS fingerprinting tool
        09/25/06
        I normally use nmap to profile a remote system, but I found a lightweight sniffing tool p0f - passive os fingering tool http://lcamtuf.coredump.cx/p0f.shtml which gather all kinds of profiling information about a remote system. Here is how I run it on my email server to profile all the remote syste

      • Run free webserver and email server at home
        09/24/06
        I have beening running webserver at my home linux computer for two years http://pingpongit.homelinux.com . I am using DynDNS http://www/dyndns.com free dynamic dns services to resolve my home dynamic IP.

        I need to run a dynmaic dns update client to update the record once my IP changed. I

      • My initial internal view of amavisd-new :)
        09/20/06
        I spent a little time to read the Amavis and Amavis::AV package section of Amavisd-new-2.3.3. It has two ways to call clamav which is configured in /etc/amavisd.conf, calling Mail::CLamAV is memory hungry, talking to clamav unix socket is much more efficient :

        !!!Note: the Line number wh

      • Customizing SpamPD
        09/05/06
        I am still cutomizing SpamPD and hope to add virus scan engine features...

      • Spam/Virus quarantine management with Amavisd-new and MailZu
        09/05/06
        I have been running Amavisd-new for 2 years which works pretty well. But I have a very inconvienent way to release a false positive email to users. I decided to experiment open source MailZu and let user do their quarantine management. MailZu requires that Amavisd-new log mail information to SQL dat

    • August
      • SAMSUNG 256MB 800MHZ ECC 184PIN RAMBUS MEMORY
        08/30/06
        Today, I finally got the order of SAMSUNG 800MHZ ECC for the odd computer I got from my friend. What I mean odd computer is that the mother board only take pair ECC RAMBUS memory, and each time if I unplugged memory, I have to unplug the video card too, then plug memory card and video card back in o

      • Pine for Mac OS X
        08/09/06
        I tried Pine for couple of days now. I feel I hooked with pine :). Compiling Pine on Mac OS X takes a little bit effort. This link http://www.madboa.com/geek/pine-macosx/ showed me a shell script to patch Pine on OS X, I spent a little extra effort to patch the filepara patch from http://www.math.wa

      • IP address in canonical decimal
        08/03/06
        Ever think of IP address 137.82.2.215 in internal can be written as 2303853271 in base 10. 137 = 0x89 82 = 0x52 2 = 0x2 215 = 0xD7, put them together is 0x895202D7 in base 16, and perl -e 'print hex '\x895202D7', "\n" ' will be 2303853271 in base 10. Apache1.3.* seem

    • July
      • Octal and Octet
        07/31/06
        The octal numeral system is the base-8 number system, and uses the digits 0 to 7.

        Octal numerals can be made from binary numerals by grouping consecutive digits into groups of three (starting from the right). For example, the binary representation for decimal 74 is 1001010, which groups i

      • Upgraded Mail::SpamAssassin 3.1.4, Clamav 0.88.3. Installed gnugpg on Mac OS X server
        07/31/06
        The email spam filter hasn't been running for a while on the email server. Today, I finally upgraded all the component, and tested working fine

      • Upgrade SpamAssassin 3.1.1 to SpamAssassin 3.1.4
        07/27/06
        There is spamassassin rule lint info after upgrading from 3.1.1 to 3.1.4, if running spamassassin -Dinfo --lint on command line, you will see info line like :

        [24649] info: rules: meta test COMBO_IMAGEONLY1 has dependency 'MIME_HTML_ONLY_MULTI' with a zero score
        [24649] in

      • What is Mail::SpamAssassin::DnsResolver for?
        07/27/06
        From the perldoc DESCRIPTION section of DnsResolver.pm, it says :" This is a DNS resolution engine for SpamAssassin, implemented in order to reduce file descriptor usage by Net::DNS and avoid a response collision bug in that module.", what this description really refered to is bugs:
        <

      • Perl Module installation from CPAN
        07/26/06
        Today, when I am testing the latest SpamAssassin 3.1.4 release, I get a note "optional module missing: IO::Socket::SSL". while I run the command "perl -MIO::Socket::SSL -e 'print $IO::Socket::SSL::VERSION", it gives me version 0.96 and I do have this module. coincidently, I

      • ClamAV upgrade on Fedora
        07/25/06
        Upgrade ClamAV is plain easy on Fedora, backup ClamAV config file and downloaded the latest ClamAV source. ./configure --prefix=/usr/local, make, make install will do the installation in /usr/local. make sure the old config file consistent with new config file. be careful with the clamav unix socket

      • Logrotate on Debian
        07/25/06
        I have been running apache webserver on an lower end old PC (PII450/192RAM/10GHD) for two years now and it never gave me problem.
        But today I found out my apache log file never got rotated since I upgrade apache to apache2 with openssl and WebDav support. After couple of minutes of poking arou

      • PHP Fatal error: Call to undefined function: mysql_pconnect()
        07/24/06
        Today, while I am trying to access the webcalendar from browser, nothing shows up, no error message. why would it suddenly stop functioning? my first instinct is to look for some clue from the log /var/log/httpd/ssl_error_log, ha, I see a PHP Fatal error: "Call to undefined function: mysql_pco

      • Search two files with similar content by Perl
        07/19/06
        Sometimes I need to compare two similar files and get to know what entry is in file1, what entry is in file2, I have tried read each file and loop through the files line by line and compare the lines with regex, but it turned out to be very dumb idea and I never got it working. After reading mo

      • A Perl tip to replace strings, symbols..
        07/19/06
        perl -pi'.orig' -e 's/oldstring/newstring/g' fileA, fileB...the i argument is backup option, fileA, fileB will be backed up as fileA.orig, fileB.orig. Ever have format problem with '\r','^M', '\n' after transfering files between windows/mac/linux.

      • Wonder how to get two way packets from tcpdump?
        07/18/06
        Such a simple question, silly me. run tcpdump on both end and specify the src host and dst port or src port.

      • MySQL setup hassle
        07/18/06
        While fiddling with mysql setup, the new mysql command client connect to the new mysql server fine, but not old mysql command client, so I have to make symbolic link to the new mysql command client like ln -s /usr/local/mysql/bin/mysql /usr/bin/mysql, same as mysqladmin...

        I thought the a

      • Floppy on Fedora Core 3
        07/13/06
        Today, I tried to dd if=boot.img of=/dev/fd0 bs=1024 conv=sync; sync , but I always got error message "dd: opening '/dev/fd0', read-only file system". then I fdformatted /dev/fd0 and did the dd command again, it works

      • Apple ical does not support ssl over http
        07/12/06
        While testing WebDav and iCal setup, it seems iCal does not know what https is. iCal works fine with http. From macosxhints someone mentioned that iCal does not support ssl, it sucks.
        Mozilla sunbird support standard .ics files and runs on Mac/Windows/Linux, so you could share your calendar c

      • Back to work from vacation
        07/10/06
        I went to Victoria and Nanaimo with my wife and couple of friends during Canada Day. we had a lot of fun there, watching live concert, fireworks, playing cards near beaches, watching sunset...

    • June
      • WebCalendar tip
        06/22/06
        Today, while reading the manual of WebCalendar, I found out that I can recover the the default admin user of WebCalendar database by excuting sql

        INSERT INTO webcal_user ( cal_login, cal_passwd, cal_lastname,
        cal_firstname, cal_is_admin ) VALUES
        ( 'admin', '21232

      • 中文测试
        06/19/06
        测试一下是否能中文显示

      • SPHPBlog is a great simple blog software ! :-)
        06/19/06
        I could set this blog site up within 5 minutes on my PowerBook , SPHPblog is simple and great!