Sunday, January 27, 2008

c++: animated process bar in c++

A process bar is useful to present the current processing status, here is my example:
void ProcessBar(int thisevt, int totalevt) {
if ( thisevt%1000 != 0 ) return ;
int totalc = 30;
int ic = (int)1.*totalc*thisevt/totalevt;
cout << "Status: [";
for (int a=0; a
cout << "=";
for (int b=0; b
cout << " ";
cout << "]";

printf("%6.2f%%", 100.*thisevt/totalevt);

//backspace
for(int a = 0; a <>
cout << "\b";
}

(of course, the code is specially for high energy physics analysis on event level, you could change it for timing etc...)

Friday, November 30, 2007

linux: how to merge/split pdf files

In linux, there is no professional acrobat avaible, which means that sometimes if you edit your pdf files, for example, merge, split pdf files, you may not have clue to do that. Lots of ppl in the net would recommend "pdftk" (pdf toolket) for you. I try to install, but some lib is needed. I have no time to install other dependent lib so I recalled I have a java tool: Multivalent. Just google it and find its page.

Usage:
java -classpath ~/Multivalent20060102.jar tool.pdf.Merge file1.pdf file2.pdf ...

That is it. You also can split your pdf file to separated ones. Of course, you need to download Multivalent20060102.jar from somewhere of the net. Yes, you can use "convert" to merge, but bad resolution and very slow, not recommended.

Wednesday, November 28, 2007

linux:how to download a whole site by wget

wget -r -p -np -k http://Your.Website.ToBeDownloaded.com

Tuesday, November 20, 2007

Linux: gaim: how to change lib of smiley

Go to the place where your gaim searches for:
/usr/share/pixmaps/gaim/smileys/default/
in my lap.

Edit the file: theme.

Sunday, September 30, 2007

emacs: how to delete a block of region

Mark (Ctrl+Space) the beginning of first line and move cursor to the the last line, and move it to the right n chars. Then do “Alt+x kill-rectangle” (Ctrl+x r k). This command can be used to delete any rectangular block of text, not just at the beginning of lines.

From: http://xahlee.org/emacs/emacs.html

Tuesday, September 25, 2007

Linux:command: vim

  加密和解密
  
  加密和解密文件
  
  在命令模式输入“:X”命令,接着输入密码、确认输入密码,最后输入“:wq”命令保存退出。文件就已经被加密了。
  
  经过上面方法加密后的文件变成密文文件。要阅读原来的明文,则在打开文件后,会提示用户输入密码。如果密码输入正确,就能看到原来的明文。另外可以看到,在最后的状态行上有此文件已被加密的提示。

需要什么来搜一搜吧so.bitsCN.com

  
  取消加密
  
  取消加密的方法很简单。在命令模式输入“:X”命令,首先会提示输入密码,这时直接敲回车键。接下来在提示重复输入密码时也直接敲回车键,最后输入“:wq”命令保存退出。这样文件的加密就被取消了。
  
  注意,以上加密方法是运行在Red Hat Linux 9.0上的vim中。在其它平台可能略有差异,请以实际平台或版本的帮助为准。
From http://www.bitscn.com/linux/command/200604/6563.html

Linux:command: some useful text commands

uniq
  (=unique-----唯一的)去掉已排序的文件中的重复行。例如:sort myfile | uniq

fold –w 30 –s my_file.txt > new_file.txt
  用空格将文本文件 my_file.txt 中的每行截成30个字符,并输出到 new_file.txt.

fmt –w 75 my_file.txt > new_file.txt
  格式化文件中的每行为75个字符。把超过75个字符的行截短,把少于75个字符的行补齐,但不会移去空行。

nl myfile > myfile_lines_numbered
  给文件 myfile 的每行标上行号。把结果输出给文件 myfiles_lines_numbered。

indent –kr –i8 –ts8 –sob –l80 –ss –bs –psl “$@” *.c
  通过插入或删除空格来改变“C”源码的外观。上面例子里格式的选项是和 Linux 内核的源码的风格是一至的(script /usr/src/linux/scripts/Lindent)。 看 man indent 来了解各个选项的意义。存在的文件先被备份然后就被格式化好的文件给替代了。

rev filename > filename1
  打印文件 filename,每行字符以相反顺序显示。上面的例子里结果直接输入到文件 filename1。

shred filename
  用垃圾字符重复并覆盖文件 filename 的内容,使任何人都无法再去阅读文件的内容。

paste file1 file2 > file3
  按行把两个或多个文件合并,用作默认分界符(用选项”d=”来选择自己的分界符)。

如果文件 file1 的内容是:
1
2
3

并且文件 file2 的是:
a
b
c
d

那么结果 file3 里的内容就该是:

1 a
2 b
3 c
d

join file1 file2 > file3

  把两个文本文件里有相同域的行连成一行。Join 和数据库的“表连接”操作是类似的,但它只是对两个文本文件进行操作。默认的分界符是空格。如果你想用其它的操作符,你可用 man join 去查看里面的选项。

如果 file1 里的内容是:

1 Barbara
2 Peter
3 Stan
4 Marie

并且 file2 的是:
2 Dog
4 Car
7 Cat

那么结果 file3 就该是:
2 Peter Dog
4 Marie Car

des –e plain_file encrypted_file
  (=”Data Encryption Standard” 数据加密标准)加密文件 plain_file。你会被要求输入一个键值用于加密算法使用。加密后的结果存放到文件“encrypted_file”。解密就用:
des –d encrypted_file decrypted_file.

gpg
  “Gnu Privacy Guard-----GNU 的私人警卫”—一个和 PGP(“Pretty Good Privacy”)功能一样的免费软件。gpg 比 PGP 更安全并且没有使用有专利的算法。gpg 主要用于给你的 email 加签名并且检查其它信息的签名。你也可用它来给你的信息加密解密。http://www.gnupg.org/上有所有的详细信息,包括一个易读和详细的手册。

   开始,我需要一对匙值:个人匙和公共匙。个人匙用于给我的信息签字。公共匙用于传给他人来确认我的信息的签名在他们收到我的信息后来确认我的信息的签 字。(某人还可用公共匙来给信息加密这样这个信息就只能通过我的个人匙加密并阅读)。我用下面的命令来生成这一对匙值:

from http://www.networkdictionary.cn/software/Linux75.php

Locations of visitors to this page