Saturday, December 27, 2008

some tips

  1. "\ls" will use the raw "ls" instead of the aliased one
  2. in Android, if two projects with the same package name are created in Eclipse, they are not going to co-exist on the emulator, the later-installed apk will overwrite the earlier one.
  3. resue damaged hard drive:
    dd bs=512 conv=noerror,sync if=/dev/hda of=/some_dir/foo.image
    Also can use gzip or bzip2 to compress.
  4. FAT32 can only allow a maximum file size of 4GB. So when doing the data rescue with a destination of FAT32 partition, it will show "stdout: file too large" when the image file reaches 4G. It's not the gzip or bzip2 problem. Solution is to change the file system. BTW: better stay away from HFS, an Apple monoply file system, except some frenetic apple fans who are using HFS for all their drives.
  5. On an Apple iBook G4, hold down 'Option' key when it boots, will let you choose the boot media. If having trouble ejecting a disc, ultimate solution is to restart the computer while holding down the trackpad button.
  6. The hfsplus file system is supported in linux kernel, which has to be selected. The location is 'File systems -> Miscellaneous filesystems -> Apple xxxx support'.
  7. To burn an toast image under windows: use daemon-tools to mount the toast image, then use DVD burn software to copy from the virtual device to the destination DVD-RAM. Windows is not able to read files from the toast image.
  8. convert dmg file to iso (under mac os x)
    hdiutil convert /path/to/filename.dmg -format UDTO -o /path/to/savefile.iso
    It will add a .cdr suffix. Just rename it to iso.
  9. xargs with blank space in file name. The GNU xargs (used on Linux) has a -0 (zero) option; this means the pathnames it reads are separated by NUL characters instead of whitespace. GNU's find (also used by Linux) has a -print0 operator that puts a NUL between pathnames instead of a newline. Use them together like this:
    find . -type f -mtime +7 -print0 | xargs -0 rm
    Here is a good article on find/xargs.

Tuesday, November 18, 2008

The art of font selection.

Recently I am reading the manual of latex-beamer, because I want to use it for presentation. There is a chapter called `Guidelines for Creating Presentations' in beameruserguide.pdf, which is worth reading line by line. Besides guide lines for presentation, it describes cons and pros of various fonts and how to select appropriate ones. There is art in font selection. Well, everyone who has played with linux desktop optimization will agree. But it is still interesting to read the user guide.

For example, in the small caps part, it first states the disadvantage of uppercase text.
Text typeset in small caps is harder to read than normal text. The reason is that we read by seeing the “shape” of words. For example, the word “shape” is mainly recognized by seing one normal letter, one ascending letter, a normal letter, one descending letter, and a normal letter. One has much more trouble spotting a misspelling like “shepe” than “spape”. Small caps destroy the shape of words since shape, shepe and spape all have the same shape, thus making it much harder to tell them apart. Your audience will read small caps more slowly than normal text.


Then it adds
This is, by the way, why legal disclaimers are often written in uppercase letters: not to make them appear more important to you, but to make them much harder to actually read.

Wednesday, October 15, 2008

Great Article on Linux dd command

Author: AwesomeMachine @ LinuxQuestions.org

original link

I followed the instructions to create an image for my windows drive. It's killing me to reinstall xp.

creating backup image
dd if=/dev/hda1 | bzip2 > /home/winxp.image.bz2
restoring image
dd if=/home/winxp.image.bz2 | bunzip2 | dd of=/dev/hda1

Compiz Fusion: a not recommend configuration

UPDATE: Hooooray!! The border is on after I add the `decoration` plugin to the very last line of /usr/bin/compiz-start. Also I change this file to use `emerald` instead of `gtk-window-decorator` and it works!!!! So I know one thing, can't fully trust `ccsm` and always turn to reliable command line. Oh, if `emerald --replace` has no output, no error, it's probably means it's working. Compiz fusion rocks! Even better if I can have a better video card~



Compiz Fusion is not working perfectly on my gentoo. First of all, no window border. After several days googling, I gave up. A note, if `emerald --replace` or `gtk-window-decorator --replace` is working fine, then that's the compiz configuration problem. My case is that these two commands does nothing, no output, no change, no error. But I can live with that.

Second problem that took me a long time is the configuration. The setting in `ccsm` does not take effect and even cause a compiz segmentation error. Then I used a brute force configuration. Not recommended, only for desperate people.

  1. gain root privilege
  2. use `ccsm` to determine which plugins should be needed, the plugin name can be found in Preferences | plugins list.
  3. modify the last line of /usr/bin/compiz-start, delete "gconf", add all the plugins you want to enable. Backup before change.
  4. modify the corresponding xml files in /usr/compiz to change the behavior, remember to make backup file before change. And be careful.
  5. add all the compiz fusion related packages to package.mask to prevent from any modificaton.
  6. compiz-start and good luck. Check the error output in case the xml format is messed up.


APPENDIX: /etc/X11/xorg.conf
Section "ServerLayout"
Identifier "Layout0"
Screen 0 "aticonfig-Screen[0]" 0 0
InputDevice "Keyboard0" "CoreKeyboard"
InputDevice "TouchPad" "AlwaysCore"
InputDevice "Mouse1" "CorePointer"
EndSection

Section "Files"

FontPath "/home/fonts"
FontPath "/usr/share/fonts/100dpi"
FontPath "/usr/share/fonts/cyrillic"
FontPath "/usr/share/fonts/wqy-bitmapfont"
FontPath "/usr/share/fonts/75dpi"
FontPath "/usr/share/fonts/default"
FontPath "/usr/share/fonts/misc"
FontPath "/usr/share/fonts/Type1"
FontPath "/usr/share/fonts/ttf-bitstream-vera"
FontPath "/usr/share/fonts/corefonts"
FontPath "/usr/share/fonts/zh-kcfonts"
FontPath "/usr/share/fonts/util"
# FontPath "/usr/local/share/fonts"
# FontPath "/usr/X11R6/share/fonts"

EndSection

Section "Module"
Load "freetype"
# Load "xtt"
Load "extmod"
Load "glx"
Load "dri"
Load "dbe"
Load "record"
Load "xtrap"
Load "type1"
Load "speedo"
EndSection

Section "InputDevice"
Identifier "Mouse1"
Driver "mouse"
Option "Protocol" "IMPS/2"
Option "Emulate3Buttons"
Option "ZAxisMapping" "4 5"
Option "Device" "/dev/input/mice"
EndSection

Section "InputDevice"
Driver "synaptics"
Identifier "TouchPad"
Option "Device" "/dev/input/mouse0"
Option "Protocol" "auto-dev"
Option "LeftEdge" "1700"
Option "RightEdge" "5300"
Option "TopEdge" "1700"
Option "BottomEdge" "4200"
Option "FingerLow" "25"
Option "FingerHigh" "30"
Option "MaxTapTime" "180"
Option "MaxTapMove" "220"
Option "VertScrollDelta" "100"
Option "MinSpeed" "0.09"
Option "MaxSpeed" "0.18"
Option "AccelFactor" "0.0015"
Option "SHMConfig" "on"
EndSection


Section "InputDevice"
Identifier "Keyboard0"
Driver "kbd"
Option "XkbModel" "pc104"
Option "XkbLayout" "us"
EndSection

Section "Monitor"

### Comment all HorizSync and VertSync values to use DDC:
Identifier "Monitor0"
HorizSync 31.5 - 64.3
VertRefresh 60.0 - 90.0
DisplaySize 331.8 207.3 ## for 15.4", DPI=98
EndSection

Section "Monitor"
Identifier "aticonfig-Monitor[0]"
Option "VendorName" "ATI Proprietary Driver"
Option "ModelName" "Generic Autodetecting Monitor"
Option "DPMS" "true"
EndSection

Section "Device"
Identifier "Card0"
Driver "radeon"
Card "ATI Graphics Xpression"
EndSection

Section "Device"
Identifier "aticonfig-Device[0]"
Driver "fglrx"
# BusID "PCI:2:0:0"
Option "DesktopSetup" "horizontal"
Option "VideoOverlay" "on"
Option "UseFastTLS" "2"
Option "EnablePrivateBackZ" "on"
Option "DynamicClocks" "on"
Option "XAANoOffscreenPixmaps" "true"
Option "TexturedVideo" "On"
Option "DRI" "true"
Option "MonitorLayout" "LVDS,AUTO" #Enable Externel Monitor
EndSection

Section "DRI"
Mode 0666
EndSection

Section "Extensions"
Option "Xvideo" "Enable"
Option "Composite" "Enable" ## critical
EndSection

Section "Screen"
Identifier "Screen0"
Device "Card0"
Monitor "Monitor0"
DefaultDepth 24
SubSection "Display"
Viewport 0 0
Depth 24
Modes "1280x800" "1024x640"
EndSubSection
EndSection

Section "Screen"
Identifier "aticonfig-Screen[0]"
Device "aticonfig-Device[0]"
Monitor "aticonfig-Monitor[0]"
DefaultDepth 24
SubSection "Display"
Viewport 0 0
Depth 24
Modes "1280x800" "1024x640"
EndSubSection
EndSection

Section "ServerFlags"
# Option "DontVTSwitch" "True" # kills the Ctrl+Alt+F(1-6) virtual terminal switch commands
# Option "DontZap" "True" # kills the Ctrl+Alt+Backspace command
EndSection


Sunday, October 12, 2008

Gentoo troubleshootings

After 3 and half days. I got gentoo upgraded on my acer 5102WLMi. Gentoo is a great distro. Love it. Now audio is working, but still not camera.

The Name:
The Gentoo species is the fastest swimming penguin.
Hardware specification
    1. Processors : AMD Turion 64x2 TL50 (1.60GHz, 512K L2 cache)
    2. Chipset: ATI RS480
    3. Displays: 15.4" WXGA (1280 x 800 resolution)
    4. Graphics Card: ATI Radeon Xpress 1100
    5. Optical Drive: DVDRW
    6. Sound Card: integrated, snd-hda-intel, realtek
    7. Wireless Networking: Atheros AR5005G 802.11abg
    8. MMC reader: ENE Technology Inc SD/MMC Card Reader
    9. I/O Ports : 3 USB 2.0, Audio jacks, 15-pin monitor connector, PCMCIA slot.
Useful links
  1. Gentoo documentation
  2. audio setup: http://gentoo-wiki.com/HARDWARE_Acer_Aspire_5102WLMi
  3. articles with gentoo tag: http://kunxi.org/
  4. Google
Notes:
  1. when upgrading, first emerge update all packages, resolve blockings(uninstall or upgrade, if circular blocking, --nodep). Then revdep-rebuild.
  2. use "equery" to look at installed packages
  3. gcc-config, kernel-config, etc to choose from different slots.
  4. make.conf, package.keywords, package.mask, package.unmask, package.use, ...
  5. if use "startx", add "gnome-session" to .xinitrc, else X will not load gnome.
  6. firefox+flash

    sudo echo "net-www/netscape-flash" >> /etc/portage/package.unmask
    sudo emerge -av netscape-flash nspluginwrapper

  7. firefox+mplayerplug-in (UPDATE: "emerge adobe-flash" will do the job)
    sudo echo "net-www/mplayerplug-in -firefox divx quicktime realmedia wmp" >> /etc/portage/package.use
    ## Make sure no browser running
    sudo emerge -av mplayerplug-in

    ln -s /usr/lib/nsbrowser/plugins/mplayerplug-in.so $HOME/.mozilla/plugins/mplayerplug-in.so
  8. cp936 support is not default in kernel, so need to add support in kernel.
    File Systems --->
    DOS/FAT/NT Filesystems --->
    Native Language Support
  9. teTeX set up, "latex" does not come with the package automatically, seems there are a lot of high-level TeX users.
    emerge -av tetex
    texconfig confall ## check all the output
    texconfig rehash
    texconfig init ## will generate all other binaries: latex, omega,...
    emerge -av app-emacs/auctex ## a must-have package for emacs+latex
    emerge -av emacs-update ## as the package suggest
  10. use TuxOnIce to do hibernate and hibernate-ram, just follow this HOWTO. Work like a charm. ATTENTION: if the lid-and-battery script is used, DO NOT put the code directly in `/etc/conf.d/local.conf'. It will run forever and will not act as a child. Instead, paste the script code into a file, say `/etc/lid_battery_suspend', do a `chmod u+x /etc/lid_battery_suspend.sh', and then add one line `/etc/lid_battery_suspend.sh &' to `/etc/conf.d/local.conf'.
    HOWEVER, after one suspend/hibernation, this script will be stopped and not be loaded. An alternative way is to let acpi take care of this. Look at /etc/acpi/events and change the actions for lid and battery. Then restart acpid service. Well, you take the risk.
  11. clean gnome desktop, use gconf-editor (looks like register table in Windows), find apps \ nautilus \ desktop, uncheck, uncheck, uncheck. Nice pure wallpaper.
  12. HOWTO take compiz screen shot: open gimp, go to File > Aquire > Screenshot. You can set a delay of however many seconds to give yourself time to get the cube in the right position. Hold it there until the PC's speaker beeps.
  13. HOWTO_NTP, NTP (Network Time Protocol) is used to synchronize your system's time with an online server.
    echo "net-misc/ntp caps" >> /etc/portage/package.use
    emerge -av ntp
    vi /etc/conf.d/ntp-client # can change the OPTS, change time servers
    /etc/init.d/ntp-client start # start sync
    #rc-update add ntp-client boot # optional
    ntp-client is only a wrapper of ntpdate program. If need to sync automatically, need to start ntpd. Ahh, before setting NTP, check /etc/localtime, if not in the right time zone, copy or link corresponding zone file from /usr/share/zoneinfo/.
  14. (Nov 16,2008) Well, alsa packages(alsa-driver, alsa-lib, alsa-headers, alsa-util) 1.0.18 update is not working and I cannot figure out why, the sound card can not be found. So I downgraded back to 1.0.17, but the alsa-lib remains 1.0.18. And it's back to work! Mask them at once.
xorg-x11 troubleshooting:
  1. "xauth: error in locking authority file /home/usrname/.Xauthority", will result in a dark screen with cursor usable after "startx", but nothing shows up. And the command window keeps prompting:
    xlib: connection to :0.0 refused by X server
    xlib: no specified protocol
    The solution is to use
    xauth -b quit
    to break existing lock, also check the permission of .Xauthority.
  2. ati-drivers
    fglrx(0): incompatible kernel module .......
    update ati-driver, even with the ~ keyword
  3. cannot startx, the error shows
    Synaptics DeviceOn Called
    Can't initialize SocketServer
    Failed to initialize Panel Agent

    It's probably because you have deleted or modified the /tmp directory, please check the permission of this directory, or just do a sudo chmod 777 /tmp.
hibernate troubleshooting:
  1. The Problem: hibernate works under text mode. But under X mode, it resumes at the "Going Atomic" step and gives an error saying
    another suspend already in progress?
  2. The Solution:
    The error in 'Going Atomic' is probably because you need to increase the
    allowance we make for drivers allocating memory during the atomic copy.
    Assuming you're using the hibernate script, this is done by editing
    /etc/hibernate/suspend2.conf. If you cat /sys/power/tuxonice/debug_info
    after an attempt at hibernating, the last line will say something like:

    - Extra pages: 1069/500.

    This means that 1069 pages were needed, but we only allowed for 500. In
    that case, you'd want to add something along the lines of

    ProcSetting extra_pages_allowance 2000

    to /etc/hibernate/suspend2.conf.

    (courtesy from http://lists.tuxonice.net/pipermail/tuxonice-users/2008-February/000202.html)

Wednesday, October 08, 2008

VIM tricks and tips

Efficient Editing With vim

Use Vim Like A Pro


Two important concepts in
vi:

marks and registers.

marks: start with ` and '
ma        set mark '''a''' at current cursor location
'a jump to line of mark a (beginning of line)
`a jump to position of mark a
d'a delete from current line to line of mark a
d`a delete from current cursor position to position of mark a
c'a change text from current line to line of mark a
y`a yank text to unnamed buffer from cursor to position of mark a
'' jump back (to line where jumped from)
`0 jump to position in last file edited (when exited Vim)
`` jump back (to position where jumped from)
:marks list all the current marks

registers start with ", use "* register to communicate with system clipboards.
There are nine types of registers:
1. The unnamed register ""
2. 10 numbered registers "0 to "9
3. The small delete register "-
4. 26 named registers "a to "z or "A to "Z
5. four read-only registers ":, "., "% and "#
6. the expression register "=
7. The selection and drop registers "*, "+ and "~
8. The black hole register "_
9. Last search pattern register "/

ATTENTION: 26 named registers, upper case is used to append contents, not different registers.

registers manual

fast notes for registers:

When you copy and cut stuff, it gets saved to registers. You can pull stuff from those registers at a later time.

 :reg     - show named registers and what's in them
"5p - paste what's in register "5

You can also record a whole series of edits to a register, and then apply them over and over.

 qk       - records edits into register k
(q again to stop recording)
@k - execute recorded edits (macro)
@@ - repeat last one
5@@ - repeat 5 times

"kp - print macro k
(e.g., to edit or add to .vimrc)
"kd - replace register k with what cursor is on

Tips And Tricks

The * and # Keys

In normal mode you can use * and # to search for the word under the cursor. * search forwards, # backwards.

The . Key

Also useful is the . key. In normal mode it repeats the last change. Very useful for XML editing and where you have to do similar stuff.

The % Key

Pressing the % key in normal mode while being on a parenthesis or a similar construct jumps to the opposite parenthesis. There are a couple of plugins that extend that functionallity but the default behavior is usually good enough for most of the programming languages.

The <> Keys

When working with Python you often have to indent or outdent a couple of lines. Just mark them using the visual mode and press > to indent them. press 4< to outdent them 4 steps etc.

Advanced Undo Features

Vim has a different system of undoing changes. The normal undo is u in normal mode and ^r is redo. But what happens if you undo a few things and then change something? A normal editor forgets about the new changes. It's not possible to redo that again.

In Vim it's different. Vim starts a new undo branch. Using :undolist you can have a look at the possible undo states. With :earlier 20s / 1m / 2h you can then go back 20 seconds, one minute etc. Traveling forward in time works using :later and a timedelta as argument.

The Search Feature

I really like the firefox search feature. Just hit "/" and you can search in the current file and get the results in real time. That works with vim exactly the same. All you have to to is to either add :set incsearch into your vimrc or type it into the command prompt. Using n you can go to the next result. If you want to have all the search results highlighted use :set hlsearch. Hiding the results works using :nohl

Closing XML Tags

If you have the closetag.vim plugin installed (link above) you can add this to your vimrc in order to get the feature working: autocmd FileType html,xhtml,xml source ~/.vim/scripts/closetag.vim (update the path to your installation and your filetypes of course) Once this is done you can close open tags using ^_.

Regexp Replacement after Search

If you searched for a text using /foo and you now want to replace the found results with something you don't have to write this regexp again. Just do :%s///replacement/g and is automatically replaced with the last search regular expression.

Using Bookmarks

Bookmarking in vim is darn easy. If you are on the current line just bookmark it with mX where X is a lowercase letter from a to z. Go to that mark using 'X where X is the same letter again. Using '' you can jump back to the position you were before jumping to the bookmark. You can get the list of bookmarks using :marks.

The Vim File Browser

The Vim File browser is a nice thing. If you open a file using :e and that file is a directory you get a nice file browser for the files in that directory. If you are a python developer you probably want to filter some files out (*.pyc etc). Add this to your vimrc: let g:explHideFiles='^\.,.*\.pyc$' This hides pyc files as well as hidden files.

The Wildmenu

The best vim feature is the wildmenu. Add a set wildmenu to your vimrc and discover the possibilities of filesystem surfing ^^ Enter :e in the command line and press ^D. Vim will show you all possibitilites in a nice little window. By entering the start of a filename and pressing tab it completes for you then. If it was a folder you can now press ^D again to get the contents. Once you finished the command this window will disappear again and you can continue working. Works of course for all commands not only the open command.

Vim Completion Features

Last tip but maybe the most powerful one :). If you have vim7 and omni completion for your language you can use ^X^O to get the completion similar to intelli sense or how it's called. Note that the default color (pink) can be overridden in the theme. In my fruity.vim file i use this to get white letters on a dark red background: hi Pmenu guifg=#ffffff guibg=#cb2f27

Also nice is ^N. It looks up all used words in the open buffers and presents then in a dropdown completion. Useful if you have long variable names and don't remember them. Just type in the start of the variable name and press ^N. Vim will either complete it or show the list of possibilities.

Thursday, February 14, 2008

罗大佑 -- 告别的年代









告别的年代----罗大佑

风轻轻的吹,
夜沉沉的醉.
谁又在午夜的远处里想念着你,
远处的午夜的梦里相偎依
仰望着蓝色的天边的回忆,
好像你无声的临别的迟疑.
每一次手牵着手像在守护着你,
守护着仅剩的潇洒和犹豫.
每一次凝视的眼神的凝聚,
羽化成无奈的离愁的点滴.

道一声别离,
忍不住想要轻轻地抱一抱你.
从今后姑娘我将在梦里早晚也想一想你.
告别的年代,
分开的理由,
终不须诉说出口.
亲爱的让我快见你一面,
请你呀点一点头.

黄色的蓝色的白色的无色的你,
阳光里闪耀的色彩真美丽.
有声的无声的脸孔的转移,
有朝将反射出重逢的奇迹.
风轻轻的吹,
夜悄悄的睡.
夜沉沉的醉.



appendix:
Embedding Windows Media Player WMA

Tuesday, February 12, 2008

pdflatex and pdfpages are your friends

when you wanna insert multi-page external pdf files to the current latex file or merge several multi-page pdf files into one single pdf file.

Refrash filename database

teTeX
Run:
texhash
web2c
On a current web2c distribution, texhash ought to work; if it doesn't, run mktexlsr
fpTeX
Click Start-> Programs-> Texlive-> Maintenance-> Rebuild ls-R filenames databases, or open a "command" window and run texhash
MikTeX
On a MikTeX distribution earlier than v2.0, click Start-> Programs-> MikTeX-> Maintenance-> Refresh filename database

or get a DOS window and run:
initexmf --update-fndb

On a MikTeX distribution v2.0 or later, do:
Start-> Programs-> MikTeX 2-> MikTeX Options, and press the Refresh now button (Update filename database in earlier versions of MikTeX).

Friday, February 08, 2008

宾克斯的酒 -- 热情海贼版本

尾田大神One Piece第488话, 宾克斯的酒, 热情海贼汉化,演绎版本按照沧海一声笑填词,挺好.

====[[[[宾克斯的酒]]]]====


演绎版本

哟霍霍霍霍 哟霍霍霍霍

送你杯,宾克斯的酒
迎风破浪任我遨游
夕阳好,汹涌浪潮
歌声豪壮气势如涛

离港口,莫回呀头
纵歌一曲不念乡愁
波光粼粼,男儿之道
扁舟驶向,天涯海角

啦...啦...

送你杯,宾克斯的酒
大海上我独领风骚
立舰桥,发长啸
骷髅旗帜分外妖娆

雷电怒,风雨急
巨浪起舞啊我吹笛
好男儿,艰险不避
明日自然云开雨霁

哟霍霍霍霍 哟霍霍霍霍

送你杯,宾克斯的酒
昨夜今宵梦里寻不到
岸上的人儿,越来越小
纵然永别你莫懊恼


送你杯,宾克斯的酒
放声高歌乐陶陶
人生苦短,福祸难料
更要在今宵畅饮欢笑

直译版本

哟霍霍霍 哟霍霍霍 X4

我给你送去,宾客斯的酒
海风,自由自在,随波逐流
海潮的对面,夕阳夺目
鸟在空中回翔歌唱

再见了港口,纺织品之乡
大着嗓门唱起,出航的歌曲
金银色波光粼粼,化作了飞沫
我们向前行,直到海角

- -

我给你送去,宾客斯的酒
我们海贼,纵横大海
浪做枕头,船做睡袋
帆就是旗帜,骷髅当球踢

暴风雨来了,海荒千里
波浪在跳舞,我们也敲鼓
谁要是胆怯了就完蛋了
又不是说看不见明天的太阳了

哟霍霍霍,哟霍霍霍 x4

我给你送去,宾客斯的酒
梦里是今天还是明天
和挥手的那个人影,已经不能再会
别那么烦恼,明天会有明月

我给你送去,宾客斯的酒
大着嗓门唱起,大海的歌曲
反正不管是谁,早晚也是白骨一堆
没有尽头,没有目标,笑话而已

Tuesday, January 29, 2008

无法规避, 巨大的孤寂.

我一个人.我一个人.我一个人.

树欲静而风不止,子欲养而亲不待.

Saturday, January 12, 2008

Everything on Solaris 10 with a user account

If getting used to GNU/Linux, using pure unix is suffering. To make things worse, I only have a regular user acount. Hands are really tight. Not until now do I appreciate GNU tools, very smart and powerful.


1. make pdflatex.fmt
pdftex -ini -fmt=pdflatex.fmt latex.ltx


2. install AucTeX for emacs
./configure --prefix=/home/cps536-n1.07/elisp # install package
--with-lispdir=/home/cps536-n1.07/elisp # install auctex.el
--with-texmf-dir=/home/cps536-n1.07/texmf-local/ # put config in texmf

make; make install


note: if pdflatex is not working, to compile auctex, just open $auctex-install-dir/preview/latex/Makefile.in, and delete lines that test pdflatex.

3. make TAGS of linux kernel with i386 platform, under emacs
cd $Linux-kernel-dir;
find include/linux/ fs/ init/ ipc/ kernel/ lib/ mm/ net/ arch/i386/ -type f -iregex .*\.[csh] -exec etags -a '{}' -o kernel-TAGS \;
Useful hot keys:
M-. tag
Find first definition of tag (find-tag).
C-u M-.
Find next alternate definition of last tag specified.
C-u - M-.
Go back to previous tag found.
C-M-. pattern
Find a tag whose name matches pattern (find-tag-regexp).
C-u C-M-.
Find the next tag whose name matches the last pattern used.
C-x 4 . tag
Find first definition of tag, but display it in another window
(find-tag-other-window).
C-x 5 . tag
Find first definition of tag, and create a new frame to select the
buffer (find-tag-other-frame).
M-*
Pop back to where you previously invoked M-. and friends.
4. The purpose of __init:

__init tells GCC to put the function in a special section. These functions are
only used during booting, and are removed from memory after boot (see the
"Freeing unused kernel memory: 200k freed" or similar boot message.

5. Funny. If adding "exec bash" in .cshrc, I cannot login to OpenWindows, while change it to "bash", everything is OK. Still wonder when it executes .cshrc.

6. read entire file using c:
  fseek(input, 0L, SEEK_END);  /* Position to end of file */
lFileLen = ftell(input); /* Get file length */
rewind(input); /* Back to start of file */
fread(str, lFileLen, 1, input);