2007-08-16

Ethernet Codes: Vendor codes

Ethernet Codes: Vendor codes

Grid Topics

The Globus Alliance

gen()


#include
#include

#define N1 5000
#define N2 5000


void gen( int** a, int** b)
{
int i, j;
for (i = 0; i < N1; i++) {
for (j = 0; j < N2; j++) {
srand( 0 );
a[i][j] = rand() % 5 + 1;
srand( 1 );
b[i][j] = rand() % 5 + 1;
}
//printf("i: %d\n", i);
}
pthread_exit(NULL);
}

void mul( int** a, int** b)
{
int i, j, k;
int c[N1][N2];

for (i = 0; i < N1; i++) {
for (j = 0;j < N2; j++) {
c[i][j] = 0;
for (k = 0; k < N1; k++)
c[i][j] += a[i][k] * b[k][j];
//printf("%d\t", c[i][j]);
}
//printf("\n");
}
}

int main(int argc, char *argv[])
{
int** a = NULL;
int** b = NULL;
int** c = NULL;

a = (int**) malloc( sizeof(int) * N1 * N2);
b = (int**) malloc( sizeof(int) * N1 * N2);
c = (int**) malloc( sizeof(int) * N1 * N2);

pthread_t* thread = NULL;
thread = (pthread_t*) malloc( sizeof(pthread_t) * N1);
int result;

int i;
for (i = 0; i < N1; i++) {
a[i] = (int *) malloc( sizeof(int) * N2);
b[i] = (int *) malloc( sizeof(int) * N2);
c[i] = (int *) malloc( sizeof(int) * N2);
}

gen(a, b);

return 0;
}

$ gcc m1.c && time ./a.out

real 3m55.660s
user 3m55.391s
sys 0m0.184s


This result without threading.

2007-08-12


#include <pthread.h>
#include <stdio.h>

#define N 10

void *test(void *c)
{
printf("\tI am thread: %d\n", (int)c);
pthread_exit(NULL);
}

int main()
{
int i, result;
pthread_t t[N];

for(i = 0; i < N; i++) {
result = pthread_create(&t[i], NULL, test, (void *)(i));
if (result)
printf("Cannot do create.\n");
}

return 0;
}


出來每次結果都不同。 :( 需要明確地等待

BlueGene/L Apply Form

Using BG/L

Cluster Building

NCHC Formosa PC Cluster, 感覺親切。
研討會資料, HP 64bit Cluster
硬體資料
NCHC PC Cluster
國家高速網路與計算中心-PC Cluster 討論區
HIGH PERFORMANCE COMPUTING LAB. // 高效能計算實驗室 //, 東海大學

Reaching the Goal with the Regensburg Marathon-Cluster, Hubert Feyrer
High Performance Computing Training

Books,
*Beowulf Cluster Computing with Linux




*Parallel Programming: Techniques and Applications Using Networked Workstations and Parallel Computers




*An Introduction to Parallel Computing: Design and Analysis of Algorithms

Passing Multidimensional Arrays


#include <iostream>
using std::cout;

void print_m35(int m[3][5]);
void print_mi5(int m[][5], int dim1);
//void print_mij_(int m[][], int dim1, int dim2);
void print_mij(int* m, int dim1, int dim2);


void print_m35(int m[3][5])
{
for (int i = 0; i < 3; i++) {
for (int j = 0; j < 5; j++) cout << m[i][j] << '\t';
cout << '\n';
}
}

void print_mi5(int m[][5], int dim1)
{
for (int i = 0; i < dim1; i++)
for (int j = 0; j < 5; j++) cout << m[i][j] << '\t';
cout << '\n';

}

/*
void print_mij_(int m[][], int dim1, int dim2)
{
for (int i = 0; i < dim1; i++) {
for (int j = 0; j < dim2; j++) cout << [i][j] << '\t';
cout << '\n';
}
}
*/

void print_mij(int* m, int dim1, int dim2)
{
for (int i = 0; i < dim1; i++) {
for (int j = 0; j < dim2; j++) cout << m[i * dim2 + j] << '\t';
cout << '\n';
}
}

int main()
{
int v[3][5];
for (int i = 0; i < 3; i++)
for (int j = 0; j < 3; j++)
v[i][j] = j;

print_m35(v);
print_mi5(v, 3);
print_mij(&v[0][0], 3, 5);

return 0;
}

2007-08-11

libc-dev

I have installed the icc with stdlibc++.so.5 in my box, a box grow on 2.6 series kernel. And I also have the gcc-4.1.2 with libc6 libraries. Then one time, I'd like to debug with an executable file called "a.out", but I have no idea to do it. The gdb says that,

Failed to read a valid object file image from memory

When I run it during debug process.

As the "file" results:

a.out: ELF 32-bit LSB executable, Intel 80386, version 1 (SYSV), for GNU/Linux 2.4.1, dynamically linked (uses shared libs), for GNU/Linux 2.4.1, not stripped

But actually, it should be like below,

a.out: ELF 32-bit LSB executable, Intel 80386, version 1 (SYSV), for GNU/Linux 2.6.0, dynamically linked (uses shared libs), not stripped


I'm not dare to remove the _big_base_ libc6, but I reinstall the "libc-dev" then it returns back to my hoping status. :D

SunFire 15K (Solaris & Debian)

HCL for Solaris OS
Platform Group:   sun4u


Current Status, Debian on SPARC platform
Supported are Sun4m and Sun4u machines (with a 32-bit userland).

UltraLinux

gprof

Linux/Alpha or How to Make Your Applications Fly
Linux Performance Analysis Tools

[Author], David Mosberger

---
Useful Tools tutorial

gprof TIPS:

* Don't optimize before profiling
* Be careful not to optimize before profiling!
* Profile before you optimize.

hahaha~~~ :D I compiled it with -O3 options of icc and gcc. :D

2007-08-07

Apache+Subversion Recipe

subversion with lighty?
Apache+Subversion Recipe, Good boy!!

Linux to Power Google GPhone

HTC

 
 

Sent to you by Alan via Google Reader:

 
 

via OSNews by donotreply@osnews.com (Eugenia Loli-Queru) on Aug 04, 2007

"Google's first mobile phone reportedly will run a Linux operating system on a Texas Instruments "Edge" chipset, and will likely ship to T-Mobile and Orange customers in the Spring of 2008. "GPhone" call minutes and text messages will apparently be funded by mobile advertising, according to reports." The report found at the popular embedded systems Linux news site LinuxDevices.

 
 

Things you can do from here:

 
 

2007-08-06

Matrix Transpose

I did ten thousand times multiplication with 800x800 matrix, each element is raged from one to five, integer type.

yrchen tole me a hint yesterday afternoon, that, the matrices should be tramsposed before did a huge compute. In today's experiment, I wrote two version codes, one doesn't has any transpose loop (called m1), the other does (called m1_t). Both them compiled with gcc, with -O3 optimization. The result is:

m1_t:
real 5m31.300s
user 5m31.245s
sys 0m0.020s


m1:
real 5m30.802s
user 5m30.265s
sys 0m0.008s


It looks like that -O3 did the transpose before has the huge matrices multiplication.


#include
#include

#define DIE 800

void gen( int a[][DIE]);
void mul( int a[][DIE], int b[][DIE]);

int main(int argc, char *argv[])
{
int a[DIE][DIE];
int b[DIE][DIE];

int i;
for (i = 0; i < 10000; i++) {
srand(0);
gen(a);
srand(1);
gen(b);
mul(a, b);
}

return 0;
}

void gen( int a[][DIE] )
{
int i, j;
for (i = 0; i < DIE; i++)
for (j = 0; j < DIE; j++)
a[i][j] = random() % 5 + 1;
}

void mul( int a[][DIE], int b[][DIE])
{
int i, j, k;
int c[DIE][DIE];

//Transpose
for (i = 0; i < DIE; i++)
for (j = 0; j < DIE; j++)
mul[i][j] = b[j][i];

for (i = 0; i < DIE; i++) {
for (j = 0;j < DIE; j++) {
c[i][j] = 0;
for (k = 0; k < DIE; k++)
c[i][j] += a[i][k] * mul[i][k];
//printf("%d\t", c[i][j]);
}
//printf("\n");
}
}

2007-08-04

Matrix Mutiplication Hint

先做轉置 (det)。

因為 CPU 會一次 fetch 1byte in each row, 而 matrix mul 是 col * row,所以可以直接把做一次 det(row) -> col,就能直接 fetch det(row) -> col。速度較快!

不要使用 recursive,因為 OS 要 handle 很多 stacks is a heavy-loading job。直接改用多個 whilie 把 huge-matrix 展開,開 threads 去分割成 strsen algo smaller-matrix.

這是 yrchen 給的 common hint.

2007-07-27

Linux: The 0.01 Release



 
 

Sent to you by Alan via Google Reader:

 
 


"This is a free minix-like kernel for i386(+) based AT-machines," began the Linux version 0.01 release notes in September of 1991 for the first release of the Linux kernel. "As the version number (0.01) suggests this is not a mature product. Currently only a subset of AT-hardware is supported (hard-disk, screen, keyboard and serial lines), and some of the system calls are not yet fully implemented (notably mount/umount aren't even implemented)." Booting the original 0.01 Linux kernel required bootstrapping it with minix, and the keyboard driver was written in assembly and hard-wired for a Finnish keyboard. The listed features were mostly presented as a comparison to minix and included, efficiently using the 386 chip rather than the older 8088, use of system calls rather than message passing, a fully multithreaded FS, minimal task switching, and visible interrupts. Linus Torvalds noted, "the guiding line when implementing linux was: get it working fast. I wanted the kernel simple, yet powerful enough to run most unix software." In a section titled "Apologies :-)" he noted:

"This isn't yet the 'mother of all operating systems', and anyone who hoped for that will have to wait for the first real release (1.0), and even then you might not want to change from minix. This is a source release for those that are interested in seeing what linux looks like, and it's not really supported yet."

read more


 
 
 
 

Lighttpd Configuration Reference

http://trac.lighttpd.net/trac/wiki/Docs%3AConfigurationOptions

2007-07-26

Uninstall DRBL

for i in `acs drbl|cut -f 1 -d " "`; do agr -y "$i";done

Schedule

1. Matrix Multiplication
2. 1 + 2 + 3 + ... + 999999 with pthreads method
3. Dividing the huge matrices into small parts
4. Redo last step with pthreads
5. Knowing how to manipulate icc

pthread

POSIX Threads

Native POSIX Thread Library (NPTL), getconf GNU_LIBPTHREAD_VERSION, NPTL 2.3.6

NPTL Trace Tool

IBM Linux Technology Library, Linux threading models compared: LinuxThreads and NPTL

2007-07-06

HPC Links

Gluster is a GNU cluster distribution aimed at commoditizing Supercomputing and Superstorage. Core of the Gluster provides a platform for developing clustering applications tailored for a specific tasks such as HPC Clustering, Storage Clustering, Enterprise Provisioning, Database Clustering etc.

Z RESEARCH enables System Integrators, with little or no experience in clustering, to build Clustered File Storage, HPC Clusters and Supercomputers from Commodity off the Shelf Components (COTS) using Clustered architecture and Z RESEARCH'S software stack 'Gluster'.

amar, 可愛的網域。 :) 是一位印裔工程師。

白爛的圖片

Computer cluster

2007-07-05

e1000_request_irq: Unable to allocate MSI interrupt Error: -22

結論是,暫時不要用 linux-image-2.6.20-15-generic 或 Feist 的版本。 衝 gutsy!!

Links:
google://
dmesg eth0 e1000_request_irq Unable to allocate MSI interrupt Error: 22

wired ethernet interface missing
e1000 high latency problem, msi error on boot.

2007-06-21

人家只是轉圖檔而已...

竟然造成 kernel panic!! 因為 Out of memory!

for i in `ls -1 *.jpg`;do (convert -quality 48 -crop +0-1000 "$i" tmp/"$i" &); done

如此而已就 :(
寫信來去論壇問看看

2007-06-20

Perldoc, Day 1

perlintro.html

Using my in combination with a use strict; at the top of your Perl scripts means that the interpreter will pick up certain common programming errors. For instance, in the example above, the final print $b would cause a compile-time error and prevent you from running the program. Using strict is highly recommended.

類似 gcc -Wall


unless ( condition )
if (!condition)


Note that the braces are required in Perl, even if you've only got one line in the block.

Too bad


print "LA LA LA\n" while 1;          # loops forever


Cool!!


A list of them is given at the start of perlfunc and you can easily read about any given function by using perldoc -f functionname .



You can read from an open filehandle using the <> operator. In scalar context it reads a single line from the filehandle, and in list context it reads the whole file in, assigning each line to an element of the list:



Reading in the whole file at one time is called slurping. It can be useful but it may be a memory hog.

寫的真傳神! hog *grin* :P


When you're done with your filehandles, you should close() them (though to be honest, Perl will clean up after you if you forget):

哈! 好笑! though to e honest. :P


if ($a =~ /foo/) { ... }  # true if $a contains "foo"

The // matching operator is documented in perlop. It operates on $_ by default, or can be bound to another variable using the =~ binding operator (also documented in perlop).

In [perlop.html],
Binary "=~" binds a scalar expression to a pattern match. Certain operations search or modify the string $_ by default. This operator makes that kind of operation work on some other string. The right argument is a search pattern, substitution, or transliteration. The left argument is what is supposed to be searched, substituted, or transliterated instead of the default $_. When used in scalar context, the return value generally indicates the success of the operation. Behavior in list context depends on the particular operator. See "Regexp Quote-Like Operators" for details and perlretut for examples using these operators.

If the right argument is an expression rather than a search pattern, substitution, or transliteration, it is interpreted as a search pattern at run time.

Binary "!~" is just like "=~" except the return value is negated in the logical sense.



These are documented at great length in perlre, but for the meantime, here's a quick cheat sheet:
XDDD 快速騙人小抄 (quick cheat sheet)



while (<>) {
next if /^$/;
print;
}

我覺得寫的很美!

while ((c = get()) != NULL) {
printf ("%s\n", c);
}



http://cpan.stu.edu.tw/

第一次嘗試 CPAN install Bundle::CPAN 跑出一大堆鬼東西,看起來這個系統寫的很完整,也很大!

2007-06-19

‘Bad fd number’ error in Ubuntu 6.10 (Edgy Eft)

PCMan, Day 1

Demystifying Subclassing
Advice from the creator of C++

A Tour of C++
Procedural Programming
Decide which procedures you want; use the best algorithms you can find.

Modular Programming
Decide which modules you want; partition the program so that data is hidden within modules.

IBM Blade Center
Bjarne Stroustrup's homepage

Separate compilation is an issue in all real programs. It is not simply a concern in programs that present facilities, such as a Stack, as modules. Strictly speaking, using separate compilation isn't a language issue; it is an issue of how best to take advantage of a particular language implementation. However, it is of great practical importance. The best approach is to maximize modularity, represent that modularity logically through language features, and then exploit the modularity physically through files for effective separate compilation.

2007-05-16

How can I get input without having the user hit [Enter]?

Using standard C/C++, you cannot. However, if you're lucky your compiler may have the non-standard conio.h header (which might include getch()), if you're on *nix (UNIX, Linux, etc.) you can try the ncurses library or switching the terminal mode. On Windows, try the different API input routines (such as those included in the Win32 API).

Got this answer from, password input.

2007-05-08

Linus said st in Linux kernel coding style

開宗明義說

10 First off, I'd suggest printing out a copy of the GNU coding standards,
11 and NOT read it. Burn them, it's a great symbolic gesture.

怎麼會這樣啦~

這變成 Humorous Quotes Seen on UseNet 的收藏。

這個東西酷斃了,排版好漂亮!


整篇 Linux Kernel coding style 都是很搞笑,而且文筆寫的很直接,帥氣!! XDDDDD


131 Heretic people all over the world have claimed that this inconsistency
132 is ... well ... inconsistent, but all right-thinking people know that
133 (a) K&R are _right_ and (b) K&R are right. Besides, functions are
134 special anyway (you can't nest them in C).



182 When declaring pointer data or a function that returns a pointer type, the
183 preferred use of '*' is adjacent to the data name or function name and not
184 adjacent to the type name. Examples:
185
186 char *linux_banner;
187 unsigned long long memparse(char *ptr, char **retptr);
188 char *match_strdup(substring_t *s);

很好,因為我這次的 Ch5-1 就是寫在 type name。 :P 因為我覺得滿美觀的呀,尤其是要同時宣告很多這種變數的時候,就一個 * 套用到宣告出來的多個變數。


What is unary
Meaning one; a single entity or operation, or an expression that requires only one operand.



209 C is a Spartan language

我以為看到 三百兄貴


209 C is a Spartan language, and so should your naming be. Unlike Modula-2
210 and Pascal programmers, C programmers do not use cute names like
211 ThisVariableIsATemporaryCounter.


XDDDDDDDD



224 Encoding the type of a function into the name (so-called Hungarian
225 notation) is brain damaged - the compiler knows the types anyway and can
226 check those, and it only confuses the programmer. No wonder MicroSoft
227 makes buggy programs.

brain damaged 翻譯成「頭殼壞掉」是最適合不過了!!整段寫的超搞笑,笑死我了啦~~~~~
我之前學過 Hungarian notation in VB,覺得 btn 代表 Button 這個元件很合適,也很容易閱讀,可是他為甚麼說只要 compiler 知道類型就好了,不考慮人的問題呢?強記?還是看宣告就行了!?



235 If you are afraid to mix up your local variable names, you have another
236 problem, which is called the function-growth-hormone-imbalance syndrome.
237 See chapter 6 (Functions).

看到 function-growth-hormone-imbalance syndrome 還以為什麼專業的單字,害我猛起勁來查 stardict,結果得到 「生長功能荷爾蒙失調併發症」!!幹~~~~ 寫這篇的人到底在寫什麼啦?這篇根本是笑話集!



244 It's a _mistake_ to use typedef for structures and pointers.

我承認 Ch5-1 裡面有用到

typedef struct {...} student;
student* stu;

這種他說的錯誤。而且還犯了兩種錯誤。



397 Comments are good, but there is also a danger of over-commenting. NEVER
398 try to explain HOW your code works in a comment: it's much better to
399 write the code so that the _working_ is obvious, and it's a waste of
400 time to explain badly written code.

所以寫 comment 是為了解釋「工作內容」,而非「如何工作」。



402 Generally, you want your comments to tell WHAT your code does, not HOW.
403 Also, try to avoid putting comments inside a function body: if the
404 function is so complex that you need to separately comment parts of it,
405 you should probably go back to chapter 6 for a while. You can make
406 small comments to note or warn about something particularly clever (or
407 ugly), but try to avoid excess. Instead, put the comments at the head
408 of the function, telling people what it does, and possibly WHY it does
409 it.

盡量避免一個 function or class 做太多功能,這樣才能節省 comment 的長度,和讀者了解的「墾掘深度」。



420 /*
421 * This is the preferred style for multi-line
422 * comments in the Linux kernel source code.
423 * Please use it consistently.
424 *
425 * Description: A column of asterisks on the left side,
426 * with beginning and ending almost-blank lines.
427 */
428
429 It's also important to comment data, whether they are basic types or derived
430 types. To this end, use just one data declaration per line (no commas for
431 multiple data declarations). This leaves you room for a small comment on each
432 item, explaining its use.

一個資料描述一行,逗號後面換行。




437 That's OK, we all do. You've probably been told by your long-time Unix
438 user helper that "GNU emacs" automatically formats the C sources for
439 you, and you've noticed that yes, it does do that, but the defaults it
440 uses are less than desirable (in fact, they are worse than random
441 typing - an infinite number of monkeys typing into GNU emacs would never
442 make a good program).

這未免也太人身攻擊了吧,p 老師就是 emacs 愛用者,該不會 emacs 的使用者都跑去 non-Linux dist 吧!? :P 難怪 Linux kernel loading balancing 沒有比某個 BSD 來的好!



473 recognize the authority of K&R (the GNU people aren't evil, they are
474 just severely misguided in this matter),

哈!我看到這裡,實在是... 想要知道當初是什麼條件讓 Linus Torvalds 願意將 Linux Kernel 以 GPL 釋出!?出櫃? XDDDD

@_@!? 出櫃不是 screw-up... : 出櫃(英文“come out of the closet”的直譯,指暴露同志身份)



RTL : http://www.answers.com/topic/rtl
Register Transfer Level


GNU Manuals Online
JTC1/SC22/WG14 - C
WG14 is the international standardization working group for the programming language C

2007-04-29

Char's pointer's pointer

This is a good example to know how to pass char's pointer to the function.

char *name[3];
name[0] = "a2n";
name[1] = "c9s";
name[2] = "ccn";

Known name at 0x1, and its content is:

{0x100, 0x101, 0x102}

Meaning indicates to "a2n", "c9s" and "ccn", respectively.


The array "name" saves the three string's address in its array space, hence, pass the array "name" to other function might via the address, and access the content of array "name" via address again. In the other word, I shall using "Pointer into Pointer" in the parameters field of array "name". :-)



Example:



void show(char **name)
{
for (int i = 0; i < 3; i++) cout << *name[i] << endl;
}

char *name[3];
name[0] = "a2n";
name[1] = "c9s";
name[2] = "ccn";
show(name);

2007-04-11

How can I create a program alias?

How can I create a program alias?

A. It is possible to create an alias for a program, for example to define johnword.exe to actually run winword.exe. To do this perform the following:

    *Start the registry editor (regedit.exe)
    *Move to HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows\CurrentVersion\App Paths
    *From the Edit menu select New - Key
    *Enter the name of the alias, e.g. johnword.exe and press Enter
    *Move to the new key and double click on the (Default) value (it is blank by default)
    *Set to the fully qualified file name it should run, e.g. C:\Program *Files\Microsoft Office\Office\winword.exe. Click OK
    *Optionally you can create a new String called Path which is where the program will first start running (Edit - New - String Value - Path, double click and set to the starting path)
    *Close the registry editor

If you now select Run from the start menu and type johnword.exe it would start Microsoft Word, cool!

If you type your alias from the command prompt it will not find it, however if you type

C:\> start

it will work fine.

The actual program name does not have to be an .exe program -- it can be any file that has an association (such as "C:\temp\ntfaq.url"). The alias itself can remain as an .exe.

If the alias is an .exe, then the "run" or "start" command does not need to include the extension. If the alias is NOT an .exe, then you need to use the full name but then you are not limited to any extensions (but it must have some extension). Your alias can be John.Savill which you have aliased to "C:\ProgramYadaYadaYada\Winword.exe" and Word will start up just fine.

2007-03-30

Pointer Discrepancy between vc++ & g++


1 #include
2
3 using namespace std;
4
5 int main()
6 {
7 int a = 1, b = 2;
8 int *x;
9
10 cout << "x: " << x << '\t';
11 cout << "*x: " << *x << '\t';
12 cout << "&x: " << &x << '\t';
13
14 cout << endl;
15
16 x = &a;
17 cout << "x = &a" << '\t';
18 cout << "x: " << x << '\t';
19 cout << "*x: " << *x << '\t';
20 cout << "&x: " << &x << '\t';
21
22 cout << endl;
23
24 x = &a - 1;
25 cout << "x = &b" << '\t';
26 cout << "x: " << x << '\t';
27 cout << "*x: " << *x << '\t';
28 cout << "&x: " << &x << '\t';
29
30 cout << endl;
31 return 0;
32 }


Microsoft (R) 32-bit C/C++ Optimizing Compiler Version 12.00.8804 for 80x86 (VC6++)


modified code...

x = &a x: 0012FF7C *x: 1 &x: 0012FF74
x = &a-1 x: 0012FF78 *x: 2 &x: 0012FF74


g++ (GCC) 4.1.2 20060928 (prerelease) (Ubuntu 4.1.1-13ubuntu5)


x: 0xb7f518dc *x: -1 &x: 0xbf97f214
x = &a x: 0xbf97f218 *x: 1 &x: 0xbf97f214
x = &a-1 x: 0xbf97f214 *x: -1080561132 &x: 0xbf97f214



g++ 讓我驚訝!! 結果 VC++ 2005 Expression 也讓我受精。 XD

Microsoft (R) 32-bit C/C++ Optimizing Compiler Version 14.00.50727.762 for 80x86



x = &a x: 0012FF60 *x: 1 &x: 0012FF48
x = &a-1 x: 0012FF5C *x: -858993460 &x: 0012FF48

Pointer sequence #2


1 #include
2
3 using namespace std;
4
5 int main()
6 {
7 int a = 1, b = 2;
8 int *x;
9
10 cout << "x: " << x << '\t';
11 cout << "*x: " << *x << '\t';
12 cout << "&x: " << &x << '\t';
13
14 cout << endl;
15
16 x = &a;
17 cout << "x = &a" << '\t';
18 cout << "x: " << x << '\t';
19 cout << "*x: " << *x << '\t';
20 cout << "&x: " << &x << '\t';
21
22 cout << endl;
23
24 x = &b;
25 cout << "x = &b" << '\t';
26 cout << "x: " << x << '\t';
27 cout << "*x: " << *x << '\t';
28 cout << "&x: " << &x << '\t';
29
30 cout << endl;
31 return 0;
32 }



g++ (GCC) 4.1.2 20060928 (prerelease) (Ubuntu 4.1.1-13ubuntu5)


x: 0xb7f078dc *x: -1 &x: 0xbff350c4
x = &a x: 0xbff350cc *x: 1 &x: 0xbff350c4
x = &b x: 0xbff350c8 *x: 2 &x: 0xbff350c4




Microsoft (R) 32-bit C/C++ Optimizing Compiler Version 12.00.8804 for 80x86 (VC6++)


跑到 line 10 就結束!

then modified code.
x = &a x: 0012FF7C *x: 1 &x: 0012FF74
x = &b x: 0012FF78 *x: 2 &x: 0012FF74

Pointer sequence #1


#include

using namespace std;

int main()
{
int a, b, c, d, e;
int i;

cout << "Input five numbers: \n";
cin >> a >> b >> c >> d >> e;
cout << "A: " << &a << "\nB: " << &b
<< "\nC: " << &c << "\nD: " << &d << "\nE: " << &e;

cout << endl;
return 0;
}



Microsoft (R) 32-bit C/C++ Optimizing Compiler Version 12.00.8804 for 80x86 (VC6++)


1
2
3
4
5
A: 0012FF7C
B: 0012FF78
C: 0012FF74
D: 0012FF70
E: 0012FF6C


g++ (GCC) 4.1.2 20060928 (prerelease) (Ubuntu 4.1.1-13ubuntu5)


1
2
3
4
5
A: 0xbfdc2cec
B: 0xbfdc2ce8
C: 0xbfdc2ce4
D: 0xbfdc2ce0
E: 0xbfdc2cdc




#include

using namespace std;

int main()
{

cout << "Input five numbers: \n";
cin >> a >> b >> c >> d >> e;
for (i = 0; i < 5; i++)
cout << "Var" << i << ":\t"
<< &a - i << " : "
<< *(&a - i) << '\n';

cout << endl;
return 0;
}


Microsoft (R) 32-bit C/C++ Optimizing Compiler Version 12.00.8804 for 80x86 (VC6++)


1
2
3
4
5
Var0: 0012FF7C : 1
Var1: 0012FF78 : 2
Var2: 0012FF74 : 3
Var3: 0012FF70 : 4
Var4: 0012FF6C : 5


g++ (GCC) 4.1.2 20060928 (prerelease) (Ubuntu 4.1.1-13ubuntu5)


1
2
3
4
5
Var0: 0xbfdea9e0 : 1
Var1: 0xbfdea9dc : 2
Var2: 0xbfdea9d8 : 3
Var3: 0xbfdea9d4 : 4
Var4: 0xbfdea9d0 : 5

2007-03-08

All mail -> Gmail

看到 Yi-Feng Tzeng’s Blog用 Gmail 收取外部郵件後,開始動手設定我的幾個信箱都納入 Gmail 管理。

兩個學術單位信箱,Y! 需要付費才有 POP3 收信功能,加上最近的 spam 都直接進入 inbox,所以想要放棄 Y! 了,目前它的功能只剩下 tw.clubs 和網拍的認證而已。

Gmail 方便至極,不用我多說。哈哈,但是我還是覺得有些改進的空間,找個時間去寫 feedback 給他們。

2007-02-18

MITOCW grabber

NAME
    grabber.sh - Grabbing the MIT OCW course data.

SYNOPSIS
    sh grabber.sh

DESCRIPTION
    今天清晨睡不著起來寫的一支小程式,專門用來抓 MIT OCW 的課程資料。獲益就是複習和增進 Regular Expression 的用法,並且搭配很多 Unix pipe (|),小小的心得而已,跟大家分享我的程式。

KNOWN BUGS

    1. Welcome.htm 拉到 index.htm 有瑕疵
    2. URL.txt 裡面有重複的列,因為課程名稱一樣

AUTHOR
    Alan Lu. (alan0098/a/gmail/d/com)




有行數程式碼放在 http://163.26.225.215/~a2n/src/grabber_nu.sh.txt
無行數的程式碼放在 http://163.26.225.215/~a2n/src/grabber.sh.txt


RegExp 小記:

2007-01-13

Remote backup

SSH:
dd if=/dev/foo | ssh foo@foo dd of=foo


FTP:
ftp foo
ftp> bin
ftp> put "| dd if=/dev/foo" foo
ftp> get foo "| dd of=/dev/foo"
ftp> get foo.tar.bz2 "| tar -xj -"


ref: 1. http://www.wsp.krakow.pl/~bar/DOC/ssh_backup.html
2. http://0rz.net/741kp
http://publib.boulder.ibm.com/infocenter/pseries/v5r3/index.jsp?
topic=/com.ibm.aix.doc/infocenter/howto/HT_prftungd_slowTSMbkupperf.htm
google: backup dd if= ftp -ssh

2007-01-11

GNU GLOBAL

GNU GLOBAL is a source code tag system that works the same way across diverse environments.


17:02:46 :: linux-2.6.19.1 $ time gtags

real 25m56.492s
user 1m44.167s
sys 1m47.283s

17:28:48 :: linux-2.6.19.1 $ time htags

real 43m1.615s
user 3m19.044s
sys 21m41.105s

19:09:04 :: linux-2.6.19.1 $ du -sh HTML/
2.1G HTML/


目前轉好兩個專案,分別是 7-zip 和 FileZilla,放在 野人 。提供這種原始碼線上瀏覽的網站,有大名鼎鼎的 Cross-Referencing Linux ,使用 LXR 系統轉換的。

Update: Notepad++ 399 已新增。

2007-01-05

PCman alasing

PCMan for win32 的版本,針對英文與中文文章時,中文的 refresh 速度比英文慢,難道是 TryeType 的問題嗎?

2006-12-25

libc6-dev

stdio.h is in libc-dev package.

GNU C Library: Development Libraries and Header Files

2006-12-18

youtube-dl

youtube-dl is a small command-line program to download videos from YouTube.com. It requires the Python interpreter, version 2.4 or later, and it's not platform specific. It should work in your Unix box, in Windows or in Mac OS X. The latest version is 2006.12.07. It's licensed under the MIT License, which means you can modify it, redistribute it or use it however you like complying with a few simple conditions.

http://www.arrakis.es/~rggi3/youtube-dl/

2006-12-08

agup daily

I've been execute "apup" to "sodu apt-get upgrade" daily, it's more than edgy distribution, so it's a experiment one. I am afraid of that there're many holes in my box, that if I haven't update one.

2006-11-24

Bootcfg

http://www.microsoft.com/resources/documentation/windows/xp/all/proddocs/en-us/bootcfg.mspx?mfr=true

Boot.ini Boot Parameter Reference

http://msdn2.microsoft.com/en-us/library/ms791480.aspx

Info: /cygdrive/c/EmbestIDE/Build/xgcc-arm-elf/bin/arm-elf-ld: cannot find -lc

FAQ

Please set the searching path of c library and gcc library correctly. Select the menu Project> Settings, open project configuration box, select the linked page and the option to add library searching path in drop-down box:
..\..\..\build\xgcc-arm-elf\arm-elf\lib\arm-inter
..\..\..\build\xgcc-arm-elf\lib\gcc-lib\arm-elf\3.0.2\arm-inter

The above path is the relative path of Embest IDE, users can also set absolute path.

2006-11-20

jmsort2.c


#include
//#include "algo.h"

void msort2(int lo, int hi, int S[]);
void mg2(int lo, int mid, int hi, int S[]);


void msort2(int lo, int hi, int S[])
{
int mid;
if ((lo < hi) && ((hi - lo) > 1))
{
mid = (lo + hi) / 2;
//printf(".S[%d]: %d, S[%d]: %d\n", lo, S[lo], mid, S[mid]);
msort2(lo, mid, S);
//printf("..S[%d]: %d, S[%d]: %d\n", mid + 1, S[mid + 1], hi, S[ hi]);
msort2(mid + 1, hi, S);
// Upper is OK
printf("\nlo: %d, mid: %d, hi: %d\n", lo, mid, hi);
mg2(lo, mid, hi, S);
}
}


void mg2(int lo, int mid, int hi, int S[])
{
int i = lo;
int j = mid + 1;
int k = lo;
int U[16];

while ((i <= mid) && (j <= hi))
{
if (S[i] < S[j]) U[k] = S[i++];
else U[k] = S[j++];
k++;
}

int a;
if (i < mid)
for (a = i; a <= mid; a++)
U[a+k] = S[i+a];
else
for (a = j; a <= hi; a++)
U[k+a] = S[j+a];

for (a = lo; a <= hi; a++)
{
S[a] = U[a];
printf("S[%d]: %d, ", a, S[a]);
}
printf("\n");
}


int main(void)
{
int S[] = { 27, 10, 12, 20, 25, 13, 15, 22 };
int sz = sizeof(S) / 4;
int lo = 0;
int hi = sz - 1;

msort2(lo, hi, S);


printf("\nFinally: ");
int a;
for (a = 0; a < 8; a++)
printf("%d, ", S[a]);
printf("\n");

return 0;
}

2006-11-19

HTML <> 的特殊用法

http://www.w3.org/TR/html4/charset.html


"&lt;" represents the < sign.
"&gt;" represents the > sign.
"&amp;" represents the & sign.
"&quot; represents the " mark.

見鬼了,指標無敵啦!

說什麼 in-place 可以節省記憶體空間。只要餵 pointer 過去就無敵了,可是怎麼偵測正確的 sizeof() 呢? o_O? 頭大!


Code:

    #include <stdio.h>

    int foo(int *pA);
    int foo2(int A[]);

    int main(void)
    {
    int A[] = { 5, 7 };
    int *pA = A;

    printf("%d\n", sizeof(A));
    printf("%d\n", sizeof(*pA)); // 其實我是第一個元素的大小
    printf("%d\n", sizeof(*(pA + 1))); // 我是第二個元素的大小
    printf("%d\n", foo(pA));
    printf("%d\n", foo2(A)); // 其實我也是傳第一個指標過去而已
    return 0;
    }

    int foo(int *pA)
    { return sizeof(*pA); }

    int foo2(int A[])
    { return *(A + 1); }


Output:

    8
    4
    4
    4
    7

2006-11-18

終於完成

17:45:29 :: images $ ls -lh
total 503k
-rw-r--r-- 1 a2n None 1.0k Nov 18 17:37 romfs.img
-rwxr-xr-x 1 a2n None 502k Nov 18 17:42 zImage
17:45:30 :: images $


明天的 TODO

    把 MicroWindow 或 MiniGUI 把玩一下。


話說 ARM9 tutorial 我跑不起來,心中有一股怨恨,也想列為 TODO,可是時間上不允許吧。 :-)

Err Log 2006-11-18

在全新的 XP 系統下編譯,在 make clean 出現以下的 err:

--

--
見鬼,重編譯後又沒事。

有個傢伙一直來撞牆



220.134.0.85

要把他 ban 掉!

$grep "220.134.0.85" auth.log |wc -l
346

從 Nov 18 11:00:09 開始撞,Nov 18 11:06:04 結束。

*為了不出現把自己鎖在牆外的窘境,先把作業寫好再說。

[有進步] Once I've used freopen, how can I get the original stdout (or stdin) back?

今天遇到的,有進步。

http://c-faq.com/stdio/undofreopen.html


FILE *fp;
freopen("foo.txt", "w", stdout);
fprintf(fp, "Hello, World\n");
fclose(fp);
printf("Hello, World2\n");


#Output
Hello, World2

And the "Hello, World" is write into *fp points to, "foo.txt".


Mistake example


    FILE *fp = freopen("foo.txt", "w", stdout);
    printf("Hello, World\n");
    fclose(fp);
    printf("Hello, World2\n");


    #Output
    (nothing)

    Because the "Hello, World" was be redirect to "foo.txt", althought it was already excused fclose(fp), but we got nothing from stdout. So the better way is to using fprintf().

2006-11-17

Err Log

pushd: not found
Makefile:40: WARNING: No kernel PCMCIA support found and PCMCIA_PATH is not defined
Makefile:47: WARNING: Linux wireless extensions, CONFIG_NET_RADIO, not enabled in the kernel
make[2]: *** [include/bits/getopt.h] Error 1
configure: error: `LDFLAGS' was not set in the previous run
configure: error: `CFLAGS' was not set in the previous run
configure: error: `CC' was not set in the previous run
configure: error: changes in the environment can compromise the build
configure: error: run `make distclean' and/or `rm config.cache' and start over
make[2]: *** [config.status] Error 1
make[2]: [_mopup] Error 1 (ignored)
make[2]: [_mopup] Error 1 (ignored)
make[3]: *** No rule to make target `clean'. Stop.
make[2]: [_tidy] Error 2 (ignored)
../../miniperl: not found
make[3]: *** No rule to make target `clean'. Stop.
../../miniperl: not found
make[3]: *** No rule to make target `clean'. Stop.
../../miniperl: not found
make[3]: *** No rule to make target `clean'. Stop.
../../miniperl: not found
make[3]: *** No rule to make target `clean'. Stop.
../../../miniperl: not found
make[3]: *** No rule to make target `clean'. Stop.
../../../miniperl: not found
make[3]: *** No rule to make target `clean'. Stop.
../../../miniperl: not found
make[3]: *** No rule to make target `clean'. Stop.
../../miniperl: not found
make[3]: *** No rule to make target `clean'. Stop.
../../../miniperl: not found
make[3]: *** No rule to make target `clean'. Stop.
../../miniperl: not found
make[3]: *** No rule to make target `clean'. Stop.
../../../miniperl: not found
make[3]: *** No rule to make target `clean'. Stop.
../../miniperl: not found
make[3]: *** No rule to make target `clean'. Stop.
../../miniperl: not found
make[3]: *** No rule to make target `clean'. Stop.
../../miniperl: not found
make[3]: *** No rule to make target `clean'. Stop.
../../miniperl: not found
make[3]: *** No rule to make target `clean'. Stop.
../../miniperl: not found
make[3]: *** No rule to make target `clean'. Stop.
../../../miniperl: not found
make[3]: *** No rule to make target `clean'. Stop.
../../../miniperl: not found
make[3]: *** No rule to make target `clean'. Stop.
../../miniperl: not found
make[3]: *** No rule to make target `clean'. Stop.
make[2]: [_tidy] Error 2 (ignored)
make[2]: *** No rule to make target `clean'. Stop.
awk: build-config.awk:16: fatal: cannot open file `Config.h' for reading (No such file or directory)
make[2]: *** [config.h] Error 2
configure: error: C compiler cannot create executables
See `config.log' for more details.
make[2]: *** [config.status] Error 77

BlueScreen Screen Saver v3.2

好物!

BlueScreen Screen Saver v3.2

Author 是 Mark Russinovich,害我以為是上次我去要 Logitech 的好人,哈哈。

2006-11-09

[Windows script] backup.bat



:: Author: Alan Lu
:: Date: 2006-11-09
:: Purpose: Backing up one directory by 7-zip compressor.
:: Ref: http://www.microsoft.com/technet/abouttn/flash/tips/tips_053106_2.mspx
:: Usage:
:: $> backup.bat
:: or
:: $> at 03:00 /every:Sunday backup.bat


@echo off
cls


::
:: %workspace% is a directory name where you want backup.
:: Don't forgot modify the %workspace%'s default value.
set workspace=foo

:: Setting environment variables with todoy's date values
for /f "tokens=1-4 delims=/" %%i IN ('date /t') DO (
set year=%%i
set month=%%j
set day=%%k
)

for /f "tokens=1-3 delims=:" %%i IN ('time /t') DO (
set hour=%%i
set minute=%%j
)

7z a -mx=9 "%year%-%month%-%day%-%hour%-%minute%.7z" %workspace%

2006-10-21

Cool!!!

make -j

-j jobs
Specifies the number of jobs (commands) to run simultaneously. If
there is more than one -j option, the last one is effective. If
the -j option is given without an argument, make will not limit
the number of jobs that can run simultaneously.


XDDD PID 爆量跟記憶體瞬間餵飽!超讚!我愛!

How to Remove Files with Reserved Names in Windows XP

http://support.microsoft.com/kb/315226/en-us
http://support.microsoft.com/?kbid=120716

2006-10-20

[Windows Batch] Getting MAC by ping

$ for /l %i IN (1, 1, 254) DO ping -f -n 1 -w 1 -s 1 -r 1 -i 1 -l 1 zz.xx.cc.%i


$for /l %j IN (1, 1, 220) DO
for /l %i IN (1, 1, 254) DO ping -f -n 1 -w 1 -s 1 -r 1 -i 1 -l 1 zz.xx.cc.%i

2006-10-13

[Windows Batch] for

因為幫辦公室妹妹轉 JPG into PDF,想到 ImageMagick convert。但是 cygwin 無法處理中文檔名,所以就翻 Windows Help 找 "for" 的用法,以下是一行解。


for /R %i IN (*.jpg) DO convert "%i" "%~dpni".pdf

2006-10-08

Memory Management

http://www.memorymanagement.org/bib/f.html
http://www.memorymanagement.org/
http://en.wikipedia.org/wiki/Memory_debugger

好站!繼續衝,今天看到 Ch.8 的 "Pointer & Dynamic memory",遇到 malloc() & free() 就軟掉了,因為我沒有 ANSI C 的手冊可以查,所以 code 看的很暈,其實自己也對 codes 有恐懼跟軟掉感,哈哈,加油啊!

想買 C++ Primer 的衝動,先借來看看吧。

Michael C. Daconta

2006-10-07

C的指標和動態記憶體管理



某個週末和佑安去探訪二手書坊,買了一本〝 C的指標和動態記憶體管理 (C pointers and dynamic memory management)〞,這本書讓我比較了解指標的用法,目前我看到 Ch5.  Array & Pointer。


我只花了 NT$ 70 買,應該是處超超超所值啦,後~~ ^_________^


以下是延伸的資源:

2006-10-06

NAND Flash

NAND memories



NAND flash memories cannot provide execute-in-place due to their different construction principles. These memories are accessed much like block devices such as hard disks or memory cards. The blocks are typically 512 or 2048 bytes in size. Associated with each block are a few bytes (typically 12–16 bytes) that should be used for storage of an error detection and correction block checksum.



NAND devices typically have software-based bad block management. This means that when a logical block is accessed it is mapped to a physical block, and the device has a number of blocks set aside for compensating bad blocks and for storing primary and secondary mapping tables.



The error-correcting and detecting checksum will typically correct an error where one bit in the block is incorrect. When this happens, the block is marked bad in a logical block allocation table, and its (still undamaged) contents are copied to a new block and the logical block allocation table is altered accordingly. If more than one bit in the memory is corrupted, the contents are partly lost, i.e. it is no longer possible to reconstruct the original contents. Some devices may even come with a pre-programmed bad block table from the manufacturer, since it is sometimes impossible to manufacture error-free NAND memories.



The first error-free physical block (block 0) is always guaranteed to be readable and free from errors. Hence, all vital pointers for partitioning and bad block management for the device must be located inside this block (typically a pointer to the bad block tables etc). If the device is used for booting a system, this block must contain the master boot record.



When executing software from NAND memories, virtual memory strategies are used: memory contents must first be paged or copied into memory-mapped RAM and executed there. A memory management unit (MMU) in the system is helpful, but this can also be accomplished with overlays.



For this reason, some systems will use a combination of NOR and NAND memories, where a smaller NOR memory is used as software ROM and a larger NAND memory is partitioned with a file system for use as a random access storage area.

 

NOR Flash

http://en.wikipedia.org/wiki/NOR_flash 


NOR memories

The read-only mode of NOR memories is similar to reading from a common memory, provided address and data bus is mapped correctly, so NOR flash memory is much like any address-mapped memory. NOR flash memories can be used as execute-in-place memory (XIP), meaning it behaves as a ROM memory mapped to a certain address. NOR flash memories have no intrinsic bad block management, so when a flash block is worn out, either the software using it has to handle this, or the device breaks.

When unlocking, erasing or writing NOR memories, special commands are written to the first page of the mapped memory. These commands are defined as the Common Flash memory Interface (defined by Intel) and the flash circuit will provide a list of all available commands to the physical driver.

Apart from being used as a ROM, the NOR memories can, of course, also be partitioned with a file system and used as any storage device.

2006-10-04

How do I uninstall all of Cygwin?


http://www.cygwin.com/faq/faq_2.html#SEC20


Setup has no automatic uninstall facility. The recommended method to
remove all of Cygwin is as follows:

Remove all Cygwin services. If a service is currently running, it must first be stopped with `cygrunsrv -E name', where `name' is the name of the service. Then use `cygrunsrv -R name' to uninstall the service from the registry. Repeat this for all services that you installed. Common services that might have been installed are sshd, cron, cygserver, inetd, apache, and so on.


Stop the X11 server if it is running, and terminate any Cygwin programs that might be running in the background. Remove all mount information by typing `umount -A' and then exit the command prompt and ensure that no Cygwin processes remain. Note: If you want to save your mount points for a later reinstall, first save the output of `mount -m' as described at http://cygwin.com/cygwin-ug-net/using-utils.html#mount.


Delete the Cygwin root folder and all subfolders. If you get an error that an object is in use, then ensure that you've stopped all services and closed all Cygwin programs. If you get a 'Permission Denied' error then you will need to modify the permissions and/or ownership of the files or folders that are causing the error. For example, sometimes files used by system services end up owned by the SYSTEM account and not writable by regular users. The quickest way to delete the entire tree if you run into this problem is to change the ownership of all files and folders to your account. To do this in Windows Explorer, right click on the root Cygwin folder, choose Properties, then the Security tab. Select Advanced, then go to the Owner tab and make sure your account is listed as the owner. Select the 'Replace owner on subcontainers and objects' checkbox and press Ok. After Explorer applies the changes you should be able to delete the entire tree in one operation. Note that you can also achieve this in Cygwin by typing `chown -R user /' or by using other tools such as CACLS.EXE.


Delete the Cygwin shortcuts on the Desktop and Start Menu, and anything left by setup.exe in the download directory. However, if you plan to reinstall Cygwin it's a good idea to keep your setup.exe download directory since you can reinstall the packages left in its cache without redownloading them.


If you added Cygwin to your system path, you should remove it unless you plan to reinstall Cygwin to the same location. Similarly, if you set your CYGWIN environment variable system-wide and don't plan to reinstall, you should remove it.


Finally, if you want to be thorough you can delete the registry tree `Software\Cygnus Solutions' under HKEY_LOCAL_MACHINE and/or HKEY_CURRENT_USER. However, if you followed the directions above you will have already removed all the mount information which is typically
the only thing stored in the registry.

--
Alan Lu, a man, enjoy programming & UNIX.
My website: http://alan0098.googlepages.com/

搞笑漫畫日和1 No.4

 

落下女-追辣妹的方法

 

2006-10-02

骯髒

因為 ARM9 Linux 做不好,所以就覺得大陸寫的教材很骯髒,其實是自己沒有能力去 hacking 那些東西,幹幹幹,幹麻做在 cygwin 呢? :'(


要怎麼拆解?或是怎麼做才會順利呢?煩心 ~~~~~~ :( 

[Bash] .

Generating a script named "start.sh" file like below,

#!/bin/sh
export PATH=/foo/foo:$PATH

Then, we need excute ". start.sh".

$ man 1 bash

BASH_ARGC
An array variable whose values are the number of parameters in each
frame of the current bash execution call stack. The number of
parameters to the current subroutine (shell function or script
executed with . or source) is at the top of the stack. When a
subroutine is executed, the number of parameters passed is pushed onto
BASH_ARGC. The shell sets BASH_ARGC only when in extended debugging
mode (see the description of the extdebug option to the shopt builtin
below)


--
Alan Lu, a man, enjoy programming & UNIX.
My website: http://alan0098.googlepages.com/

2006-09-29

ANSI C, lvalue

Value (computer science) 


In C: L-value and r-value

Some languages use the idea of l-value and r-value. L-values are values that have addresses, meaning they are variables or dereferenced references to a certain place. R-value is either l-value or non-l-value — a term only used to distinguish from l-value. In C, the term l-value originally meant something that could be assigned (coming from left-value, indicating it was on the left side of the = operator), but since 'const' was added to the language, this now is termed a 'modifiable l-value'.

An l-value is an expression that designates (refers to) an object. A non-modifiable l-value is addressable, but not assignable. A modifiable l-value allows the designated object to be changed as well as examined. An r-value is any expression that is not an l-value, it refers to a data value that is stored at some address in memory.

2006-09-28

NTFS sucks!

In cygwin with NTFS of WindowsXP sp2 environment, I''d input:

mv uClinux-dist /usr/local/src


take me about 30minutes, it's really sucks!!


In Linux box, the inode will help it shorter. But why?  Let me study in the Ch.11 FileSystem.

patch -p0

-pnum or --strip=num

Strip the smallest prefix containing num leading slashes from each file name found in the patch file. A sequence of one or more adjacent slashes is counted as a single slash. This controls how file names found in the patch file are treated, in case you keep your files in a different directory than the person who sent out the patch. For example, supposing the file name in the patch file was


    /u/howard/src/blurfl/blurfl.c



setting -p0 gives the entire file name unmodified, -p1 gives

    u/howard/src/blurfl/blurfl.c



without the leading slash, -p4 gives

    blurfl/blurfl.c



and not specifying -p at all just gives you blurfl.c. Whatever you end up with is looked for either in the current directory, or the directory specified by the -d option.

2006-09-14

Google Reader -> Bloglines



Ya, I did it in today, 'cuz the AJAX operation is such slowly in Opera 9.00, and some error often occured in operation.  So that, I exported all of feed to bloglines.

My buddy, Howl suggests me some useful RSS reader, I've never tried it yet, 'cuz now I prefer the on-line service (a.k.a API application).  Maybe next time, I'll try these good tool. :-)

2006-08-26

for

To untar all tarballs
$ for i in `ls -1 --color=never`;do tar -xjf "$i";done


Zipping all directory to echo directory which with prefix as $i

$ for i in `ls -1d --color=never */`;do 7z a -mx=9 "$i".7z "$i";done

Zipping all directory to current direcotry with directory name as its prefix

$ for i in $(ls -1d --color=never *`;do 7z a -mx=9 $i.7z $i;done

2006-08-22

www.STUT.edu.tw

從原本的 RedHat Enterprise 4 換成 Windows 系列了。這個比較表滿有意思的。來找找其他的比較表格。

2006-08-20

Acer Veriton 3200 使用手冊

S58M MB99135-1
48.38H01.011M.1.T

Acer Veriton 3200 使用手冊

Acer─使用手冊及文件下載 -> 桌上型電腦 -> 搜尋

Realtek 8139



One day, we've a network curriculum in FEC, Ralph told us that the Realtek 8139 ethernet chip is good than others, 'cuz it can be program and control as we hope.


Util today, I's visited the Realtek 8139 spec webpage, the last one is 75 pages, well~ well~ well~ it's more better than the D-Link 530Tx+ for me.


Extend:
*RTL8139C(L)+
*RTL8139C(L)
*Network Interface Controllers (list all)

2006-08-16

2006-08-04

New House LAN

Getway: 192.168.0.1

**$telnet 192.168.0.1 80
HTTP/1.0 400 Bad Request
Content-type: text/html
Pragma: no-cache
Date: Fri, 04 Aug 2006 14:06:10 GMT
Last-modified: Fri, 04 Aug 2006 14:06:10 GMT
Accept-Ranges: bytes
Connection: close


**$nmap -O 192.168.0.1
Starting Nmap 4.11 ( http://www.insecure.org/nmap ) at 2006-08-04 22:02 台北標準時間
Interesting ports on 192.168.0.1:
Not shown: 1678 closed ports
PORT STATE SERVICE
80/tcp open http
8080/tcp open http-proxy
MAC Address: 00:0E:A0:00:08:84 (NetKlass Technology)
Device type: general purpose
Running: Linux 2.4.X|2.5.X
OS details: Linux 2.4.0 - 2.5.20
Uptime 0.492 days (since Fri Aug 04 10:14:05 2006)

Nmap finished: 1 IP address (1 host up) scanned in 8.734 seconds


**$tracert www.ntu.edu.tw
Tracing route to w3.cc.ntu.edu.tw [140.112.8.130]
over a maximum of 30 hops:

1 2 ms 2 ms 2 ms 192.168.0.1
2 35 ms 45 ms 34 ms 218-175-144-254.dynamic.hinet.net [218.175.144.2
54]
3 44 ms 42 ms 32 ms tn-st-c6r1.router.hinet.net [168.95.54.18]
4 33 ms 43 ms 42 ms tn-st-c12r12.router.hinet.net [220.128.27.118]
5 38 ms 44 ms 32 ms kh-c12r12.router.hinet.net [220.128.25.30]
6 39 ms 50 ms 39 ms tp-s2-c12r12.router.hinet.net [220.128.2.14]
7 55 ms 40 ms 51 ms tp-s2-c12r2.router.hinet.net [220.128.2.113]
8 45 ms 50 ms 38 ms tp-s2-c76r2.router.hinet.net [211.22.35.213]
9 40 ms 52 ms 64 ms 211.22.35.177
10 52 ms 41 ms 54 ms 211.20.43.121
11 52 ms 40 ms 54 ms w3.cc.ntu.edu.tw [140.112.8.130]

Trace complete.