木曜日, 4月 30, 2009

水曜日, 4月 29, 2009



SystemTap How-toは古い資料ですけども、大変参照になります。

例として、Fedora 10 - Disk IO



as -o test.o test.s
ld -s -Ttext 0 --oformat binary -o test test.o


as -o test.o test.s
objcopy -O binary test.o test

Using as
Documentation for binutils 2.19

    日曜日, 4月 26, 2009

    USB Image Tool

    USB Image Tool

    Running Minix on Bochs

    Running Minix on Bochs

    Intel x86 Assembly Language in Minix

    Some Notes on the "Who wrote Linux" Kerfuffle, Release 1.5

    Minix documentation

    Minix boot documentation
    Minix network documentation

    The Minix Operating System (Minix 2 support)
    The MINIX 3 Operating System


    Turn off Minix?

    When you see a prompt like "d0p0s0>_", it means you are in the "boot
    monitor", the Minix bootstrapper. The boot monitor is a very simple
    program capable which does not keep any volatile information (unlike Minix
    itself). So, if your system is dead in the boot monitor, you can at least
    safely power off.
    shutdown -x 'off'

    木曜日, 4月 23, 2009


    1. 電源ONとともにCPUが起動する。このときはリアルモードである。
    2. ROMのBIOSコードを実行する。
    3. フロッピーディスクの先頭セクタ512バイトをメインメモリの0x0000:0x7c00に読み込んでその先頭にジャンプする。
    4. ここから先は読み込まれた512バイトのブートコードに全ておまかせである。

    ブートコードは0x7c00番地に読み込まれてから実行されるのであって、そこでブレークポイントをブートコードの開始番地である0x7c00に設定する。 (これも面白かった)
    <bochs:1> lb 0x7c00

    See Using Bochs internal debugger for internal debugger commands

    Difference Between gdb+bochs and bochsdbg

    1. 将bochs的源码解压到/usr/src/bochs-2.3.7文件夹中(For Example)
    2. cd /usr/src/bochs-2.3.7
    3. ./configure --enable-debugger --enable-disasm
    4. make all
    5. make install
    6. 在编译安装完成后使用将安装到/usr/local/bin目录下的bochs改名为bochsdbg
      mv /usr/local/bin/bochs /usr/local/bin/bochsdbg

    • 建立能够与gdb通信进行源码级调试的bochs,与上部分相同,进入bochs的源码目录,重新配置编译,加入stub for gdb模块,使其能够与gdb通信,执行以下命令:
      cd /usr/src/bochs-2.3.7
      ./configure --enable-gdb-stub
      make all
      make install

    • 要使用gdb进行调试需要修改bochs的配置文件,将
      gdbstub: enabled=1, port=1234, text_base=0, data_base=0, bss_base=0

    • 另开一个终端窗口,以下命令打开gdb:
      >gdb <内核二进制文件>
      (gdb) target remote localhost:1234


    bochs-debugger and bochs-gdb in Fedora
    • bochs-debugger with the builtin debugger (--enable-x86-debugger --enable-debugger)
    • bochs-gdb with the gdb stub (--enable-x86-debugger --enable-gdb-stub)

    水曜日, 4月 22, 2009


    1. Virtual Floppy Drive
    2. RawWrite for Windows
      See also chrysocome.net download and ここ
    3. dd for windows
    4. The Netwide Assembler
      Create Boot image:
      nasm xxx.asm -o xxx.bin -f bin



    1. msgattrib

    2. msgcat
      $ msgcat  -s sort.pot # ソート

    3. msgcmp

    4. msgcomm

    5. msgconv

    6. msgen

    7. msgexec

    8. msgfilter

    9. msgfmt

    10. msggrep

    11. msginit

    12. msgmerge
      $ msgmerge  -U orig.po  new.pot        # マージ

    13. msgunfmt

    14. msguniq

    火曜日, 4月 21, 2009

    Character Encoding and Windows Console woes

    Character Encoding and Windows Console woes

    chcp 65001
    mode con cp select=65001

    How to Enable More Fonts for Windows Command Prompt
    change standard fonts on windows console
    Necessary criteria for fonts to be available in a command window

    HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows NT\CurrentVersion\Console\TrueTypeFont

    sys.stdout のエンコードを変更する

    sys.stdout のエンコードを変更する

    >>> sys.stdout = codecs.getwriter('utf-8')(sys.stdout)

    >>> sys.stdout = io.TextIOWrapper(sys.stdout.buffer, encoding='utf-8')

    木曜日, 4月 16, 2009



    Sen - 形態素解析ライブラリ
    Pythonのようなスクリプト言語で形態素解析をする時、Mac + Python + MeCabスクリプト言語のバインディングを参照してよいでしょう


    水曜日, 4月 15, 2009

    Building JCC on Linux Platform


    JCC is a Python extension written in Python and C++. It requires a Java Runtime Environment to operate as it uses Java's reflection APIs to do its work. It is built and installed via distutils or setuptools.
    1. Edit setup.py and review that values in the INCLUDES, CFLAGS,DEBUG_CFLAGS, LFLAGS and JAVAC are correct for your system. These values are also going to be compiled into JCC's config.py file and are going to be used by JCC when invoking distutils or setuptools to compile extensions it is generating code for.
    2. At the command line, enter:
      $ python setup.py build
      $ sudo python setup.py install

    Installing PyLucene

    For the Impatient Ones

    1. pushd jcc
    2. <edit setup.py to match your environment>
    3. python setup.py build
    4. sudo python setup.py install
    5. popd
    6. <edit Makefile to match your environment>
    7. make
    8. sudo make install
    9. make test (look for failures)

    Removing old kernels using yum

    Removing old kernels using yum
    [root@localhost ~]# yum install yum-utils
    [root@localhost ~]# package-cleanup --oldkernels

    火曜日, 4月 14, 2009

    Switch Java Runtime Environment between OpenJDK and Sun Java onFedora 10

    Personal Fedora 10 Installation Guide

    To install Java SE Runtime Environment (32-bit example):
    $ sudo sh jre-6u12-linux-i586-rpm.bin
    $ sudo /usr/sbin/alternatives --install /usr/bin/java java /usr/java/default/bin/java 20000 (applies to both 32-bit and 64-bit users)
    $ sudo /usr/sbin/alternatives --install /usr/lib/mozilla/plugins/libjavaplugin.so \
    libjavaplugin.so /usr/java/default/plugin/i386/ns7/libjavaplugin_oji.so 20000 (The Mozilla/Firefox browser plugin for 32-bit users) or $ sudo /usr/sbin/alternatives --install /usr/lib64/mozilla/plugins/libjavaplugin.so \
    libjavaplugin.so.x86_64 /usr/java/jre1.6.0_12/lib/amd64/libnpjp2.so 20000 (For 64-bit users)

    Switch back to OpenJDK
    $ sudo /usr/sbin/alternatives --config java
    $ sudo /usr/sbin/alternatives --config libjavaplugin.so (or for 64-bit)
    $ sudo /usr/sbin/alternatives --config libjavaplugin.so.x86_64

    Archive Manager

    1. Xarchiver - A GTK+2 only lightweight archive manager
    2. File Roller - GNOME 向けの書庫マネージャです。
    3. PeaZip

    月曜日, 4月 13, 2009

    comparing the GCJ and JCC PyLucene flavors on an Ubuntu forum

    Comparing the GCJ and JCC PyLucene flavors on an Ubuntu forum
    Here is the answer as to ubuntu forum post about PyLucene


    Handbrake has been one of the more user friendly tools available on Windows and Linux for ripping DVD's and converting them to mp4 format. However , handbrake has been available on Linux as a command line application and did not support converting videos to lets say a format that could be easily played on Portable Meda Players. Handbrake with version 0.9.3 on Linux is available with a GTK+ based graphical frontend and supports a number of different video formats as source, allowing one to convert these video formats into format suitable to be played on your PMP's like Apple iPod.

    cscope, ctags, & vim

    cscope, ctags, & vim

    ctags can be used to browser the definition of a variable (e.g., a function, variable, or macro).
    cscope can be used to explore the call site of a definition (e.g., all function calls, all variable uses, all macro uses).

    Choice of tool:
    • C: Use cscope + ctags
    • C++ or anything else: Use just ctags. It has the benefit of
      knowing about class names, where as cscope does not and will not
      know the difference between namespc1::bob and namespc2::bob.

    Installing and removing software on Mandriva

    Installing and removing software

    ,See also Mandriva Linux Rpmdrake and URPMI HOWTO and Unofficial Mandriva Linux 2008.1 Starter Guide
    Set up these public repositories
    1. Run the Software Media Manager: open the Mandriva Control Center, and go to the Software Management tab.
    2. Click the link titled 'Configure media sources for install and update'.
    3. Click 'yes' when asked if it is OK to continue.
    4. Now click the 'Add...' button on the right hand side of the new screen.
    5. When asked whether to add 'Update sources only' or 'Full set of sources', click 'Full set of sources'.
    6. Click 'Yes' in reply to the question about the mirror list.
    7. When the mirror list appears, choose a mirror close to your geographical location. Wait for the process to complete.

    When in console, using urpmi.update (maybe?)

    日曜日, 4月 12, 2009

    ODFDOM Samples

    ODFDOM is an OpenDocument (ODF) framework. It's purpose is to provide an easy common way to create, access and manipulate ODF files, without requiring detailed knowledge of the ODF specification. It is designed to provide the ODF developer community an easy lightwork programming API, portable to any object-oriented language.

    Some ODFDOM Samples

    odf4j sample

    Here´s the modified code which actually works:

    package org.openoffice.odf.tools;

    import java.util.Vector;
    import javax.swing.table.DefaultTableModel;
    import org.openoffice.odf.spreadsheet.SpreadsheetDocument;

    public class Test {

    public static void main(String[] args) throws Exception {

    SpreadsheetDocument doc = new SpreadsheetDocument();
    DefaultTableModel model = new DefaultTableModel();

    model.addColumn("Column A");
    model.addColumn("Column B");

    Vector row = new Vector();
    row.add( "foo" );
    row.add( new Integer( 1 ) );
    model.addRow( row );

    doc.addSpreadsheet( "Test1", model, false );

    doc.save( "test.ods" );


    jOpenDocument A pure Java library for OASIS Open Document files manipulation

    Mozilla Developer Center

    Mozilla Developer Center

    Mark Finkle’s Weblog XUL Explorer或いはXUL Explorer

    XULRunner tutorial

    New Linux Cross Reference (LXR) site

    New Linux Cross Reference (LXR) site

    Wine Cross Reference

    See also Linux Cross Reference setup on ubuntu

    木曜日, 4月 09, 2009

    QEMU Cheat Sheet

    QEMU Cheat Sheet

    build a bootable ISO image file of linux system and use it on VMs

    Install and use VirtualBox on Linux
    1. install virtualbox
      $ apt-get install virtualbox-ose
    2. add the current user to the group vboxusers
      $ adduser $USER vboxusers
    3. insert the relative modules to kernel
      $ /etc/init.d/vboxdrv start
    4. start virtualbox, follow the prompt, and boot a system from the iso file
      $ virtulbox

    Use Qemu to boot iso file
    1. installed first
      $ apt-get install qemu
    2. boot the iso file
      $ qemu -m 128M -cdrom minios.iso -boot d -no-kqemu
      or boot a floppy image file
      $ qemu -m 64 -boot a -fda boot.img -no-kqemu
    3. to speed up the qemu, please install kqemu, the basic steps are:
      $ sudo apt-get install kqemu-source kernel-package linux-source build-essential
      $ cd /usr/src/linux
      $ sudo module-assistant prepare kqemu
      $ sudo module-assistant build kqemu
      $ sudo module-assistant install kqemu
      $ sudo depmod -a
      $ sudo modprobe kqemu
      $ sudo mknod /dev/kqemu c 250 0
      $ sudo chmod 666 /dev/kqemu

      now, there is no need to use the -no-kqemu option when using qemu and the
      running speed of qemu will be accelerated.

    Build the network between VMs and the HOST system/Internet

    Boot linux kernel with Qemu
    1. create a virtual disk image file
      $ qemu-img create -f qcow linux.img 1G

      In this command the -f option is for the disk image format. The following formats are supported: vfat, vpc, bochs, dmg, cloop, vmdk, cow, qcow, and raw, depending on the OS. See also: .img and .iso. The supported filesystem formats are abbreviations for:

      • vfat - Virtual VFAT
      • vpc - Virtual PC
      • bochs - BOCHS filesystem
      • dmg - macintosh Disk iMaGe
      • cloop - linux Compressed LOOP
      • vmdk - vmware Virtual Machine DisK format
      • qcow - Qemu Copy-On-Write
      • raw - RAW filesystem (no special format)
      • cow - user mode linux Copy-On-Write

    2. boot the kernel using qemu with the -S option
      sudo qemu -s -S -no-kqemu -kernel ../SSS/arch/i386/boot/bzImage -hda linux.img -append "root=/dev/hda"(See also Breakint at boot startup on qemu)
    3. switch it to the qemu command line via typing the
      following command to start the gdb server:
      $ gdbserver 1234
    4. start a new terminal on your HOST system and execute gdb to
      debug the linux kernel.
      $ gdb /path/to/vmlinux
      (gdb) target remote localhost:1234

    一种方便的Linux内核调试方法:VirtualBox + KGDB

    How To Patch Running Linux Kernel Source Tree

    How To Patch Running Linux Kernel Source Tree

    # cd linux-2.6.xx.yy
    # patch < fix.vmsplice.exploit.patch -p1

    See also:How to: Compile Linux kernel 2.6,How to: Compile Linux kernel modules



    • MBR
      $sudo od -tx1z -Ax -N 512 /dev/sda
    • パーティションテーブル解析
      $ od -tx1 -Ax -N 64 -j 446 /dev/sda
    • ブートセクタの逆アセンブラ
      objdump -D -b binary -d -mi386 boot.bin
      $sudo od -tx1z -Ax -N 512 /dev/sda

    火曜日, 4月 07, 2009



    20 of the Best Free Linux Books

    20 of the Best Free Linux Books

    make oldconfig && make prepare

    make oldconfig && make prepare

    Printing background in Internet Explorer

    Printing background in Internet Explorer

    As georgelawrence-ga stated:
    The aproach I took was to paint the grey "background" as an image and
    not as a background at all. I Googled around and found a simple grey
    gif. (If you use this approach, you'll of course want to serve this
    from your own servers.) Then I position the text of the header
    directly over the grey image. This way the "print backgound colors"
    setting of the browser doesn't matter, because the background's not a
    background at all.

    <div style="height:1.4em;overflow:hidden">
    <div style="height:1.4em"><img style="height:100%;width:100%"
    <div style="height:1.4em;position:relative;top:-1.4em;;margin-left:2px;margin-top:2px">Header
    <tr><td>In the table cell of the header above there are 3 divs...</td></tr>
    <tr><td>1) The first one encloses the next two</td></tr>
    <tr><td>2) The next one contains a grey gif which is streched to fill
    the div</td></tr>
    <tr><td>3) The next one is positioned on top of the previous one and
    contains the text</td></tr>
    <tr><td>Note, some versions of IE ignore the overflow css setting when
    <tr><td>This causes a bit of unwanted space underneath the header.</td></tr>
    <tr><td>Firefox doesn't seem to have a problem with it.</td></tr>

    月曜日, 4月 06, 2009



    圧縮しながら 100MB ずつ分割して出力する

    $ 7za a -m0=BZip2 -v100m dirname.7z dirname
    -m0 は圧縮方法の指定。
    LZMA  重いが圧縮率が高い
    BZip2 バランスがいい
    Deflate 軽いが圧縮率が低い

    圧縮をかけずに 100MB ずつ分割しながら出力する (高速)

    $ 7za a -mx=0 -v100m dirname.7z dirname
    -mx= で圧縮レベルを指定する。0 だと圧縮しない。


    $ cat myfile.7z.001 myfile.7z.002 myfile.7z.003 > myfile.7z
    $ 7za x myfile.7z

    Compress file(s) to split rar archive

    rar a -m5 -v5M -R myarchive /home/

    rar - starts the program
    a - tells program to add files to the archive
    -m5 - determine the compression level (0-store (fast)...3-default...5-maximum(slow))
    -v5M - determine the size of each file in split archive, in this example you get files with size 5MB (if you wanted files of 512kB size you would write -v512k)
    myarchive - name of the archive you are creating
    /home/ - is folder of the files you wish to add to the archive

    任意のRAR断片ファイル boo.bar が何volume目なのかは % unrar l boo.bar か % unrar v boo.barで調べることができる。表示されるvolume番号は "1" が先頭となる
    % unrar x foo.rar
    foo.rarがvolume 1 です

    Extract the split multiple .rar files:
    choose ANY .rar file such as xxx.part002.rar
    $ unrar e MetalGuitar.part002.rar

    Git を使ってソース・コードを管理する

    Git を使ってソース・コードを管理する

    gitをHTTP Proxy経由で利用したい場合の対処法


    GCC Inline Assembler

    OpenBSD kernel hack memo
    GCC Inline Assembler


    Brennan's Guide to Inline Assembly

    日曜日, 4月 05, 2009

    Linux Assembler

    Assembler Command-Line Syntax
    • Compiling
      1. AT&T-syntax
        as -a --gstabs -o x.o x.s
        -o option specifies what to call the object file, i.e. machine-code file, which is the primary output of the assembler.
        -a option tells the assembler to display to the screen the source code, machine code and segment offsets side-by-side, for easier correlation.
        -gstabs option tells the assembler to retain in x.o the symbol table, a list of the locations of whatever labels are in x.s, in the object file.
      2. Intel syntax
        nasm -f elf -o x.o -l x.l x.s

        -f option instructs the assembler to set up the x.o file so that the
        executable file constructed from it later on will be of the ELF format,
        which is a common executable format on Linux platforms.
        -l option
        plays a similar role to -a in as, in that a side-by-side
        listing of source and machine code will be written to the file
    • Linking
      • ld -o x x.o

    • see the corresponding assembly language of a C program
      • gcc -S y.c




    msgmerge --sort-by-file


    msgmerge --sort-output

    KDE taskbar setting on Fedora

    Settings here in the [/root/ | ~].kde/share/config/plasma-appletsrc file


    木曜日, 4月 02, 2009


    How To generate a .xlsx using Open XML SDK without loading any .xml

    How To generate a .xlsx using Open XML SDK without loading any .xml


    Subversion Binary Packages

    Some Stand-alone clients I am using
    1. QSvn
      QSvn is a GUI Subversion client for Linux, UNIX, Mac OS X and Windows. It is a real client not a GUI wrapper for the command line client from Subversion.
    2. RapidSVN
      Multi-platform GUI front-end for the Subversion revision system.
      C:\Documents and Settings\UserName\Application Data\Subversionのserversファイルのglobalセクションを編集
      http-proxy-host = server_name
      http-proxy-port = port
    3. Silk SVN

    Desktop-integrated clients
    1. TortoiseSVN

    Linux上でsubversion を proxy 経由で使う

    vi ~/.subversion/servers

    http-proxy-exception = プロキシを通さないホスト名
    http-proxy-host = プロキシサーバのホスト名
    http-proxy-port = プロキシサーバのポート番号

    将Debian Lenny 5.0安装到优盘

    将Debian Lenny 5.0安装到优盘

    Debian Lenny的USB-HDD版本下载地址

    dd if=debian-live-500-i386-lxde-desktop.img of=/dev/sdb

    cfdisk /dev/sdb

    mkfs.ext3 /dev/sdb2 -L live-rw


    水曜日, 4月 01, 2009

    Tomcat5 - server.xml

    Tomcat5 - server.xml


    ◎ Variables substitution in server.xml and web.xml in Tomcat as posted ${user.home} and other server.xml tags accepted by Tomcat?
    As replied by Rainer

    The answer depends on the exact version you are using. All version 5.5
    and 6 Tomcats and recent version 4.1 Tomcat supports resolving
    ${somevariable} in server.xml by looking at system properties automatically.

    Some properties are set during Tomcat startup, like catalina.home and
    catalina.base. Others you can set yourself by either adding to the
    commandline "-Dsomevariable=somevalue" or adding to the end of
    ◎ Use different server.xml file in Tomcat configuration
    ./tomcat.sh start -f /var/tmp/server-${USER}.xml

    Linux Kernel 2.6 のフレームバッファ

    Linux Kernel 2.6 のフレームバッファ