Friday, March 31, 2006

[Linux]XWindows bootstrap

Environment: Fedora Core 5, GNOME
Just simply log the tracing result.

After you boot, the default runlevel is graphics. (How to know the default runlevel? check /etc/inittab.). The sequence are as the following:
1. Kernel
2. /etc/rc.d/rc.sysinit
3. /etc/rc.d/rc, the scripts in /etc/rc5.d/
4. /etc/rc.local (Actually is /etc/rc.d/rc.local)
5. prefdm. It bring the default desktop manager up.(How to know what the default desktop manager is? Check /etc/sysconfig/desktop)
6. After you signed in, gdm execute /etc/X11/xinit/Xsession
7. /etc/X11/xinit/xinitrc
8. /etc/X11/xinit/xinitrc-common
9. The scripts in /etc/X11/xinit/xinitrc.d/. And one of the scripts named xinput.sh will bring IME up.
10. Finished.

Why did I trace the bootstrap? Because after I upgraded Fedora Core 4 to Core 5 several days ago, my GNOME is dead. I saw only a simple terminal.
I tried several ways, and I still don't know why.
After I traced hardly today, I found the problem.
That's because BaseXsession is set to /etc/X11/xdm/Xsession in /etc/gdm/custom.conf.
After you logined, gdm will execute this script, and xdm/Xsession just run a simple terminal, so I saw a simple terminal.
Orz...

Reference:

Tuesday, March 28, 2006

[Linux]Upgrade FC4 to FC5

My distribution in company is Fedora Core 4. Fedora recently released Core 5, so I want to upgrade my Fedora Core 4.
I think there are really lots people like me, just use yum to upgrade without download iso files.

This artile is very clear:How to upgrade from FC4 to FC5 via yum?

The major steps:
  1. Download fedora-release-5-5.noarch.rpm, then install it
  2. Upgrade yum first: yum update yum
  3. And upgrade whole distribution: yum upgrade


You may meet dependency problems in step 2 and step 3. If you met, you can refer to this article, it provide a perl script to resolve dependency problem.
My way is to record this packages, remove them. After upgraded, install them back.

Now I had upgraded my distribution to Fedora Core 5, the next thing is adjusting my configuration~

Reference:

Friday, March 24, 2006

[Note]vimrc and shortcut keys

After I refered to several articles, I adjust the final vimrc. I post vimrc in the end of this post for future reference.

References:

If you are reading the C/C++ source code, you can use ctags to generate tags for C/C++ source code.
Usage:
ctags -R

Then, you can use
set tags=your_tag_file

to load tags. When you want to see where the identifier and functions is, you can press g ctrl+] or ctrl+] to jump.
If you wanna return, press ctrl+t.
If you wanna find the matched quote, press % (shift+5).
ctags can also generate tags file for c# source code.
Reading source code is not boring anymore. I should accepted Irene's advice 3 years ago.

Beside, Vim can coordinate with Vim Intellisense, vim is really powerful...

The following is vimrc

" Inherit gvim win32 settings
set nocompatible
source $VIMRUNTIME/vimrc_example.vim
source $VIMRUNTIME/mswin.vim
behave mswin

" Hide mouse cursor when you are typing
set mousehide

" Load tags automatically.
set tags=./tags,tags

" Don't backup.
set nobackup

" Auto indent / Indent
set autoindent
set cindent

" show ruler
set ruler

" Highlight matched quote
set showmatch

" tab
set shiftwidth=4
set tabstop=4

" syntax highlight
syntax on

" expand tab to space.
" set et
" opposite
" set noet

" The following setting is copied from here: http://edt1023.sayya.org/vim/node10.html
" 使用 :update 代替 :w,以便在有修改時才會存檔,注意,這和 vi 不相容。
map <F2> :up<CR>
map <F3> :up<CR>:q<CR> " 存檔後離開
map <F4> :q!<CR> " 不存檔離開
map <F5> :bp<CR> " 前一個 buffer 檔案
map <F6> :bn<CR> " 下一個 buffer 檔案
" 單鍵 <F7> 控制 syntax on/off。倒斜線是 Vim script 的折行標誌
" 按一次 <F7> 是 on 的話,再按一次則是 off,再按一次又是 on。
" 原因是有時候顏色太多會妨礙閱讀。
map <F7> :if exists("syntax_on") <BAR>
\ syntax off <BAR><CR>
\ else <BAR>
\ syntax enable <BAR>
\ endif <CR>
" 按 F8 會在 searching highlight 及非 highlight 間切換
map <F8> :set hls!<BAR>set hls?<CR>
" Toggle on/off paste mode
map <F9> :set paste!<BAr>set paste?<CR>
set pastetoggle=<F9>
map <F10> <ESC>:read !date<CR> " 插入日期
map <F11> :%!xxd<CR> " 呼叫 xxd 做 16 進位顯示
map <F12> :%!xxd -r<CR> " 回復正常顯示

" The default function.
set diffexpr=MyDiff()
function MyDiff()
let opt = '-a --binary '
if &diffopt =~ 'icase' | let opt = opt . '-i ' | endif
if &diffopt =~ 'iwhite' | let opt = opt . '-b ' | endif
let arg1 = v:fname_in
if arg1 =~ ' ' | let arg1 = '"' . arg1 . '"' | endif
let arg2 = v:fname_new
if arg2 =~ ' ' | let arg2 = '"' . arg2 . '"' | endif
let arg3 = v:fname_out
if arg3 =~ ' ' | let arg3 = '"' . arg3 . '"' | endif
if &sh =~ '\<cmd'
silent execute '!""C:\Program Files\Vim\vim64\diff" ' . opt . arg1 . ' ' . arg2 . ' > ' . arg3 . '"'
else
silent execute '!C:\Program" Files\Vim\vim64\diff" ' . opt . arg1 . ' ' . arg2 . ' > ' . arg3
endif
endfunction

Wednesday, March 22, 2006

[Note]Ubuntu on my laptop

I had installed Ubuntu on my notebook(laptop) on Sunday.
And I adjust the theme to make it similar with MacOS in last two days.
What is called peacockery?? :p

ubuntu desktop Screenshot

Friday, March 17, 2006

Nageia nagi was germinated

It was germinated!!
But it seems innutritious... :(

Nageia nagi

[.Net]Regular expression in common use

Because of my private project, I surfed on internet for these regular expression. These regular expression will be used in RegularExpressionValidator.
  • Validate Date
    • dd/mm/yyyy
      ((([0][1-9]|[12][\d])|[3][01])[-/]([0][13578]|[1][02])[-/][1-9]\d\d\d)|((([0][1-9]|[12][\d])|[3][0])[-/]([0][13456789]|[1][012])[-/][1-9]\d\d\d)|(([0][1-9]|[12][\d])[-/][0][2][-/][1-9]\d([02468][048]|[13579][26]))|(([0][1-9]|[12][0-8])[-/][0][2][-/][1-9]\d\d\d)
    • yyyy/mm/dd
      ([1-9]\d\d\d[-/]([0][13578]|[1][02])[-/](([0][1-9]|[12][\d])|[3][01]))|([1-9]\d\d\d)[-/]([0][13456789]|[1][012])[-/](([0][1-9]|[12][\d])|[3][0])|([1-9]\d([02468][048]|[13579][26])[-/][0][2][-/]([0][1-9]|[12][\d]))|([1-9]\d\d\d[-/][0][2][-/]([0][1-9]|[12][0-8]))
  • The number with limited digits
    (^-?\d{1,10}\.$)|(^-?\d{1,10}$)|(^-?\d{0,10}\.\d{1,9}$)
  • Number
    ^(-)?\d+(\.\d\d)?$
  • Validate e-mail
    ^([0-9a-zA-Z]([-.\w]*[0-9a-zA-Z])*@([0-9a-zA-Z][-\w]*[0-9a-zA-Z]\.)+[a-zA-Z]{2,9})$
  • Validate url
    ^(ht|f)tp(s?)\:\/\/[0-9a-zA-Z]([-.\w]*[0-9a-zA-Z])*(:(0-9)*)*(\/?)([a-zA-Z0-9\-\.\?\,\'\/\\\+&%\$#_]*)?$


Reference:

Monday, March 13, 2006

[Cook]蘿蔔茼蒿

在網路上找來的,也找不到出處了...真是抱歉.
原來的材料有用到花椒與高湯,我利用手頭現有的材料,改為大蒜跟高湯粉調製的水。

材料: 白蘿蔔、茼蒿、大蒜、鹽、澱粉水(勾芡用)、高湯水、香油、黑醋。
方法:
1.蘿蔔切條。
2.大蒜爆香。
3.下白蘿蔔條稍煮片刻,再下高湯水。
4.接著再下茼蒿,加上調味料:鹽、味精、黑醋。
5.勾芡...
6.最後再加上香油。

收工。很簡單的一道菜,如果有香菜的話,應該也會不錯。
我們在家試了兩次,第一次沒加黑醋,味道差了點。第二次加了黑醋就好多了。

resize ntfs fail.

After I tried Ubuntu Linux Live CD , Suddenly I am eager to install Ubuntu linux to my Notebook(For performance issue, I don't use virtual machine).

At first, there is a big problem: harddisk partition. How do I re-partition my harddisk partition without reinstalling Windows XP?? I know the famous software is Partition Magic, but I don't have this software, also Partition Magic is not free.

So I surfed for freeware on internet, and I found Ubuntu Live CD had provided the powerful software: GParted.Here are some useful information:

Then I follow the steps:
  1. Defrag my notebook harddisk.
  2. Execute GParted


Everything should be fine now, but the answer is NO.
After I studied, I found GParted use ntfsresize command to resize ntfs partition. And I tried to use ntfsresize directly, ntfsresize reports: You need to use fdisk to delete the original partition, and specifies new size to create new ntfs partition.

I was wrong here. I deleted the original ntfs partition, and I recreated the partition. But I forgot to specified partition type, then my resiz plan is fail.
After a while, I found I forgot to backup my wife's data. :(

How miserable I am!!

Wednesday, March 08, 2006

Ubuntu live cd on Averatec 6200

Several weeks ago, I wanted to install Linux to my notebook - Averatec 6200 (It is actually MSI M630). Because Ubuntu Linux is very popular, I decided to install this distro. So I downloaded Ubuntu Linux Live CD to try.
But how hard I try, I just cannot boot from Live CD. This is a warning, it tell me that this notebook could have some problems.

At this time, I remembered that I visited a web site before, it provide lots of compatibility issues about Linux on laptop. I found this site by Google : Linux on Laptops. Regrettably, there are no information about Averatec 6200.

Time and tide wait for no man...several weeks passed.

I boot with Live again tonight, but this time, I study the boot option (Press F2, F3, F4, F5, F6, F7, you can see different options). And use the following command to boot:
live vga=771 noapic nolapic gdth=disable:y


It works!! :)

And then the problem is about wireless~
Ubuntu Linuxcan detect my wireless chip, so the problems is about wireless settings.
After I study 1~2 hours(In fact, the half time are spend for remembering wep key and key index, :p ),finally I use the following settings in /etc/network/interfaces
iface ra0 inet dhcp
#
wireless-essid your_essid

# keys
wireless-key1 your_key_1
wireless-key2 your_key_2
wireless-key3 your_key_3
wireless-key4 your_key_4

# adjust the value according your key index.
wireless-defaultkey 1

# I use restricted, you can comment this line.
wireless-keymode restricted

auto ra0


After modify settings, restart networking service.
sudo /etc/init.d/networking restart


Reference:

The grape seeds were germinating

I sowed grape seeds in little pot in Chinese New Year. Few days ago, they were germinated.
And I surfed on internet for grape information. In general, the grape are growing in the first year, and fruiting in the following years.
It really make me happy, but I think there are no spaces for fruiting.
Maybe I think too much :p.
If it grows too much in future, I think I will move them to another bigger place.
My next target is orange and tangerine!! :)

grape(1)

Tuesday, March 07, 2006

How to Geotagg with Yuan.CC Maps

This is the second artical to introduce geotag.
I just discover CK writed a new web application: Yuan.CC Maps.

This application is really a killer application for geotagging.
It can find the location via Google Maps / Yahoo Maps / UrMaps, and you can sign in flickr to geotag directly.

The operation is very simple. Mouse click, move....You will see the location in right-top corner is changing when you move the map.
Yuan.CC Maps(3)

After you get the location, you can add "geotagged lat=nn.nnn lon=nnn.nnn" tags in flickr to mark this picture geotagged.

Beside, you can sign in flickr directly (*1), then set filter tag to None, pick up your photo, move map to the location which the photo is pictured. Finally, press the button "Save location" in the right-bottom corner.

And you can browse the photo in the map.
Yuan.CC Maps(1)Yuan.CC Maps(2)

How about this nice applicaton?!
:)

Note:
1. When you sign in at flickr first time, flickr will ask you to allow Yuan.CC Maps to read/write tags. This time, you should press Allow.

Reference:
1. Blog of Flickr Hacks: Yuan.CC Maps

Wednesday, March 01, 2006

[資訊雜記]How to Geotagged with Google earth

太過肉麻的開場白就不介紹了.
薄荷的 blog介紹的很多,也很清楚,不妨直接參考這篇:歡迎加入 Geotagged: Taiwan 群組.

步驟:
  1. 下載Google earth,這裡有三種版本,後兩種是要付費的,選擇第一個免費的版本下載即可.然後進行安裝.
  2. 打開Google earth,進入 [tools][options] 依照下圖調整座標顯示方式.
    GoogleEarthOption
  3. 尋找照片所在座標位置,找到以後,把左下角的位置抄起來.如下圖:
    GoogleEarthLocation
  4. 接著上傳照片到flickr,上傳以後,加上 tag.
    Geo Tags 的格式:
    1. geotagged , 這個 tag 一定要加, 用來辨識這張相片有經緯度.
    2. geo:lat=25.011824, 這是北緯 25.011824
    3. geo:lon=121.527103, 這是東經 121.527103
  5. 大功告成


參考資料: