2011/02/13

The chr() in Ruby.

Cause I have to write bytes string using Ruby.

I  collation some rules of chr() to clarify my mind.

At first. create new file.

file = File.new("helloRuby", "w+")

 

There are three way to get the same result :

file.write(65.chr)

file.write(Integer(0x41).chr)

file.write("A")

upon three all get the hexdump result like :

00000000  41                                                |A|


And if using String.hex , ruby will write the string of hex number to file

file.write("A".hex)

00000000  31 30                                             |10|

 

Then, if I want to write the real hex byte to file.

I can using

file.write("A".hex.chr)

file.write(Integer(10).chr)

00000000  0a 0a                                             |..|


Important note :

chr() of Number form and chr() of String form will get the different result !

 

2011/02/08

Cannot identify SD card partition! (mmcblk0: unknown partition table )

Situation :

When I  plug-in my SD card into some EVB board.

SD driver can detect mmcblk0, but cannot detect SD partition.

like below:

# mmc0: new high speed SDHC card at address f7c1
mmcblk0: mmc0:f7c1 SD08G 3.50 GiB
mmcblk0: unknown partition table

 

But if I want to mount SD card to some folder,

I'll need to identify partition of SD card file system.

 

Solution :

After tracing...

Only need to enable CONFIG_MSDOS_PARTITION of kernel config.

then, the partition will be identify!!

# mmc0: new high speed SDHC card at address f7c1
mmcblk0: mmc0:f7c1 SD08G 3.50 GiB
mmcblk0: p1

 

螢幕快照 2011 02 09 下午3 54 36

 

 

 

2010/09/27

UNIX Programming

9/28 Present at Alpha networks.

Reference Books:
Advanced Programming in the UNIX Environment 2nd.
(W. Richard Stevens & Stephen A. Rago)


2010/09/06

Linux Man-Pages Release - 3.26

Linux Man-Pages 3.26 release.


Download from git :

git clone git://git.kernel.org/pub/scm/docs/man-pages/man-pages.git

Downliad tarball


Release Notes:
http://www.kernel.org/doc/man-pages/changelog.html#release_3.26

2010/08/22

Vim plugin - Doxygen

# 1. DoxygenToolkit.vim

let g:doxygenToolkit_authorName="your name"

Usages:

:Dox
:DoxAuthor
:DoxBlock
:DoxUndoc(DEBUG)
:DoxLic


# 2. Doxygen.vim
cd ~/.vim/after/syntax;
ln -s doxygen.vim c.vim;
ln -s doxygen.vim cpp.vim;
ln -s doxygen.vim java.vim;

2010/08/10

vimgrep


:vimgrep /pattern/[g][j] file1 file2 ... fileN

vimgrep is using to search pattern from following filelist.

vimgrep accept to ignore case,
If want to using this feature, put /\c in the pattern to ignore case.
ex:  vimgrep /pattern\c/ filename

or put /\C in the pattern to match it.
ex:  vimgrep /PaTtErn\c/ filename

Without flag 'j', vim jumps to the first match.
With flag 'j', vim only quickfix list is updated.

You can using :clist to list all match location.
and using :cc N to jump to the match.

:cn can jump to the next match location.
:cN can jump back prior match.


more usage, please using :help vimgrep

2010/07/19

vim 一次註解多行


使用VIM時, 註解多行的方式如下:

1. 進入 command mode ,
2. 按ctrl-V, 然後圈選要註解的區塊
3. 按 I 進入 Insert mode
4. 鍵入註解符號或要輸入的內容
5. 按 ESC 兩次, 就可以看到輸入的註解已經套用在所選擇的那幾行

note: 步驟三的 I 可以替換成 A, 這樣就會變成在行尾註解


在C/C++ 註解多行其實可以透過下面的方式簡單完成,
但 VIM 的多行註解則適用於各式語言喔!

#if 0

... 要註解的部份

#endif