tar file with file list
tar -zcvf allfiles.tar.gz -T mylist.txt
在Eclipse中使用picasso
1. 什么是picasso?
它是Eclipse的插件,用来debug SWT布局问题很有用。
2. 如何使用?
2.1. clone picasso from picasso
http://git.eclipse.org/c/pde/eclipse.pde.incubator.git/
using:
git clone http://git.eclipse.org/gitroot/pde/eclipse.pde.incubator.git
2.2. import picasso to your workspace
3.3. enable picasso trace from run config and debug you app
Eclipse的preference的位置
Eclipse的preference位置一般在workspace目录下面的:.metadata/.plugins/org.eclipse.core.runtime/.settings/目录下,
你转到这个目录下,使用grep就可以查找你自己的key。
注意,如果你是第一次使用这个workspace,然后你在Eclipse中修改了你的preference,这时你的改动是不会立马同步到磁盘上的,
你需要关闭Eclipse,让它们同步到磁盘上,这样你才可以在磁盘上看到它们。
Linux下getc vs fgetc
1. From the Advanced Programming in Unix Environment
:
…
The difference between
getc
andfgetc
is thatgetc
can be
implemented as a macro, whereasfgetc
cannot be implemented as a macro.
This means three things:
- The argument to
getc
should not be an expression with side effects.
- Since
fgetc
is guaranteed to be a function, we can take its address.
This allows us to pass the address offgetc
as an argument to another
function.
- Calls to fgetc probably take longer than calls to
getc
, as it
usually takes more time to call a function.
…
2.
Seems like the differences are, in 99.9% of the cases, meaningless.
One point which may make a difference - The man page
says getc() may be implemented as a
macro which evaluates stream more than once
.
It could lead to strange behavior in some (not very useful) cases, e.g.:
FILE *my_files[10] = {...}, *f=&my_files[0];
for (i=0; i<10; i++) {
int c = getc(f++); // Parameter to getc has side effects!
}
If getc
evaluates f++
more than once, it will advance f
more than
once per iteration. In comparison, fgetc
is safe in such situations.
http://stackoverflow.com/questions/18480982/getc-vs-fgetc-what-are-the-
major-differences
Clock time, User CPU time and System CPU time in UNIX?
The clock time, sometimes called wall clock time, is the amount of time the
process takes
to run, and its value depends on the number of other processes being run on
the system.
The user CPU time is the CPU time attributed to user instructions.
The system CPU time is the CPU time attributed to the kernel when it executes
on behalf of the process.
Wall-clock time is the time that a clock on the wall (or a stopwatch in hand)
would measure as having elapsed between the start of the process and ‘now’.
从程序起点到现在的时间
The user-cpu time and system-cpu time are pretty much as you said - the amount
of time spent in user code and the amount of time spent in kernel code.
程序在系统code和用户code上运行的CPU时间
The units are seconds (and subseconds, which might be microseconds or
nanoseconds).
The wall-clock time is not the number of seconds that the process has spent on
the CPU; it is the elapsed time, including time spent waiting for its turn on
the CPU (while other processes get to run).
refs:
APUE
Linux下的snprintf
snprintf是将format之后的字符传保存到s所指向的地方,但是最大的长度是由n指定的。
见例子:
#include <stdio.h>
#include <string.h>
int main()
{
char tmp[2];
char tmp2[25];
int cx2 = snprintf(tmp, 7, "%s", "ddd22d");
snprintf(tmp2, 25, "%d", cx2);
puts(tmp2);
puts(tmp);
puts("\n");
return 0;
}
上面的例子输出:
_6
ddd22d _
如果将snprintf中的7改成6,输出:
_6
ddd22 _
如果将snprintf中的7改成5,输出:
_6
ddd2 _
注意我的tmp的长度只是2,但是在三次的输出时每次的长度都不一样,这时因为snprintf会将format之后的字符串保存到n-1个长度的char
数组中去,
然后将第n个位置为\0. puts方法输出字符串是寻找\0结尾,所以每次的输出不一样,这个会不会也可以做成溢出来利用呢?
Eclipse 正式支持Java 8
现在的Eclipse对Java 8的支持需要自己下载插件,见网址: http://www.eclipse.org/downloads/java8/
在今年5月9号的Release中会包含Java 8的支持,不需要单独下载。