Thursday, December 18, 2008

Linux:shell:Bash: How to change color of your shell printout


You could use 'echo -e' to change your printout text and background color by some color variables. One of the easiest ways to use them is to define shell variable, for example, define those variables in your shell script:

red='\e[0;31m'
RED='\e[1;31m'

blue='\e[0;34m'

BLUE='\e[1;34m'

cyan='\e[0;36m'

CYAN='\e[1;36m'
NC='\e[0m' # No Color


. '\e[0;36m': 0's place is the color of background (0, no effect, 1, bold, 4, underline) and 36 is the text color. You also can change background colors due to color values in the color table. For example, '\e[41;34m' changes background color to red and text color to blue.

How to print?

echo -e "$red These texts are in red$NC" #you must use '-e' to enable interpretation of the backslash-escaped characters, see echo's help.

or if you want to use it in 'printf':

printf "%s\n" "`echo -e $red`These texts are in red`echo -e $NC`"

There is a table of color values attached (this table is from the link). You can find color values what you want.

Sunday, November 23, 2008

linux:shell: /bin/tar: Argument list too long

When you create a tar archive and have an error: /bin/tar: Argument list too long, then you could try an argument of tar:

-T or --files-from=F

(which allows you to get names to extract or create from file F).

Wednesday, November 12, 2008

linux:shell: broken 'while' loop

When I do a while loop in which there is a command 'ssh', the while loop just goes only one iteration and quits. The problem is from 'ssh' read stdin so that 'while' cannot read anymore and stop afterwards, for example,

while read CompName
do
ssh $CompName 'ls'
echo "Done"
done <>

In the example, only one iteration is conducted (including the echo line). The solutions are provided by google searching. One is general one, I think. 1) Redirect ssh stdin by

< /dev/null ssh $CompName 'ls'

2) ssh-specified trick: use '-n':

ssh -n $CompName 'ls'

Saturday, November 8, 2008

linux:shell:bash:grep: multi-grep

If I want to search multi words by grep, I could do in the way:

egrep "a|b|c|d" my_input_file.txt

then egrep will help you to search OR of a, b, c and d. If searching for AND of multi-words, you can do by pipe:

grep a my_input_file.txt |grep b |grep c |grep d

. However, sometimes, it is not so easy to use pipe in one line for the above usage. You can always build string of the command first and evaluate it. For example,

cmd="grep $var1 my_input_file.txt|grep $var2"
...
cmd="$cmd |grep $var3"
...
eval $cmd

Linux:shell: awk: multiple separators

'awk' is a very useful shell command (also a program language) in linux (unix). You split one text line by it. For example, for the line

line="aa, b c , d , f "

what you can do in shell command (bash) is

echo $line|awk -F "," '{print $1 $2 $3 $4}' # to get different columns separated by ","

However, if you wanna split one line with multi-separators, then you could do in the way, for example,

$ line="aa, bb_ ccd: ee"
$ echo $line |awk -F ",|_|:" '{print $1$2$3}'

Note here "|" will do logic "OR" of all separators. This is similar 'egrep'. If you want to grep multi key words, then you could do in the same way (which has been addressed in my other blog, just search grep ).

Thursday, October 23, 2008

Latex: subfigure: how to get rid of 'counter' of subcaption

The subfigure 's tutorial

If you want to get rid of 'counter' in front of your sub-captions, use to redefine the command: \thesubfigure by:

\renewcommand*{\thesubfigure}{}

(originally one in subfigure.sty is

\renewcommand*{\thesubfigure}{(\alph{subfigure})}

)

Tuesday, October 14, 2008

Linux:command: du and quota

My disk quota is full on my account at Fermilab (.../home/zhiyil/desktop/...). So I have to clean to get more rooms to store files to SAM. Use the command:

du -s * .[a-zA-Z]* | sort -n

get an idea of which file is the largest one so that you could deal with them.

Thursday, October 9, 2008

Linux:command:shell: diff

One of layouts of printout of the command 'diff' is called: --side-by-side or -y which is also useful. Change the column width, just use

-W columns

--width=columns
. An example:

diff --side-by-side -W 130 file1.txt file2.txt

Tuesday, October 7, 2008

Linux:command: seq

When printing a sequence of numbers, use 'seq'. One of arguments is '-w' or '--equal-width' which will equalize width by padding with leading zeros.

Thursday, September 18, 2008

CVS: update

If you want to checkout the newest version of the package, then do

cd
cvs update .

or

cvs update -A FileWhatYouWantToCheckOut
If you want to get an idea of the difference:

cvs diff

statistics:chi-square calculator

A page to calculate chi-square.

http://www.stat.tamu.edu/~west/applets/chisqdemo.html

given freedom.

Tuesday, September 16, 2008

linux:tools: how to edit pdf files

To the Linux Users who need to edit pdf files or figures:
In Linux, you may use pdfedit or xfig etc to edit pdf files, however, they are not good enough. For example, pdfedit is too slow to make users mad ( I am one of victims :-( ). However, you could use an online tool here:

http://www.pdfescape.com

to edit your pdf files. Fast, easy to use...

Linux:shell:command: speed up 'grep'

'grep' is very slow when using it in a UTF-8 mode, specially for a large text file. However, it is fast if using 'C' mode. Use the command 'locale' to check the variable of 'LC_ALL'. Then

export LC_ALL="C"

(from http://tdas.wordpress.com/2008/02/03/speed-up-grep)

I tested it. The "C" mode is faster 50 times than the regular mode!

Monday, August 25, 2008

Linux: how to get cpu and memory information

In linux, look into the files: /proc/cpuinfo and /proc/meminfo to get information about CPU and memory.

Tuesday, August 19, 2008

Latex: change row color of table

An example here:

\usepackage[table]{xcolor}
(if you use pdflatex and/or beamer, perhaps you need to transit 'table' by
\documentclass[xcolor=table..]{beamer} or you will have an error like:
! LaTeX Error: Option clash for package xcolor.
)

\begin{table}
\centering
\rowcolors{2}{gray!10}{}\tiny
\begin{tabular}{c||cc|cc}\hline\hline
....
\end{tabular}
\caption{...}
\end{table}

Monday, August 18, 2008

Linux: /tmp cleanup frequency

kerberos is working well in my laptop. However, since the temp ticket file krb5*** is stored in /tmp which is cleaned up as reboot, I cannot use kinit -R to renew the ticket-granting ticket even within its renewable life. So what I do is to change /tmp cleanup frequency. How? edit the file:

/etc/default/rcS

and check the default value of "TMPTIME", 0 means cleanup as reboot. TMPTIME=14 means that the files in the directory will be deleted in a frequency of 2 weeks.

Friday, August 15, 2008

ROOT: error: `Bool_t' does not name a type

In ROOT all 'new' types are defined in the file RType.h and if you wanna use those types in your cpp code you must include any head file based on TObject.h because each head file in ROOT includes RType.h or you just directly include it.

Thursday, August 14, 2008

Latex: Error: ! LaTeX Error: Too many unprocessed floats.

When using too much floating figures or tables, latex fails to locate those elements, you may counter the error:

! LaTeX Error: Too many unprocessed floats.

. One of solutions is to use the package 'float' and add [H] in your figure environment. Example:

\usepackage{float} %before text body

\begin{figure}[H]
\centering
\includegraphics[width=0.8\textwidth]{fig_tauid/plot_compare_tauprop_allvar_TTauAndTauIDTree_20080814_Tau_dalpha.eps}
\caption{Comparison between different samples used in tau ID study.}
\end{figure}

Saturday, July 26, 2008

linux:ssh:kerberos

Installing proper kereros and connecting with fermilab by ssh are always a bit tricky. Sometimes it needs old version openssh, sometimes it needs more... I don't know. One guy from Fermilab has a post talking about his experience based on ubuntu:

http://ubuntuforums.org/showthread.php?t=486284

I didn't follow his steps (since I just installed a new system, I need to install what I need). The basic idea is:

  • install openssh (I installed newest one)
  • install krb5
  • sudo apt-get install krb5-user
  • copy configure file (/etc/krb5.conf) from any computer of fermilab to your local computer (in the same location)
then you could connect !

Although you could connect, please make sure you have right parameters both in ssh_config and sshd_config due to Fermilab security policy. I have a problem with it (once log in to one computer of clued0, I type klist, nothing found). I got the solution from kerberos-users of fnal:
===
Make sure your SSH client configuration in ssh_config (usually in /etc/ssh/)
contains the lines

GSSAPIAuthentication yes
GSSAPIDelegateCredentials yes
===

Computer:laptop: buy a new laptop, Lenovo T61

Yesterday I got my new laptop: Lenovo thinkpad T61. I am a thinkpad fan and always crazy about its classic design. IBM thinkpad was gone for ever while this branch was sold to Lenovo. My old one is thinkpad T41 following me for more than 4 years. Until now it is still very stable even after several strong damages by my honey heart (you know what this means :-) ). Before it was acted by falling down, I made an order to my new one: T61, yes, Lenovo T61.

Looking: thicker than T41. I guess designers wanna better air flow... although T41 is also very good in emiting heats unlike some other brands (the name beginning with 'com', you know this ;-p) which can be able to be a good heater in winter. Of course, the computer is very solid in looking, feeling and essence.

Layout: I may take a while to be used it. The new layout seems better. for example, mic slot is closer to your ears, more USBs, _shielded_ top light (previous one has a light too, but it is facing your eyes when you looked at it)...

....

Tuesday, July 8, 2008

Shell:Bash:replace substring in string

${string/substring/replacement} Replace first match of $substring with $replacement
${string//substring/replacement} Replace all matches of $substring with $replacement
${string/#substring/replacement} If $substring matches front end of $string, substitute $replacement for $substring
${string/%substring/replacement} If $substring matches back end of $string, substitute $replacement for $substring


Refer to the link for more information.

Wednesday, June 18, 2008

Software: Opera

Firefox released the version of 3.0, however, some favorite add-on are not avaible yet in the mean time. So currently I may not use firefox 3.0. However, a good alternate is opera. Actually I started to use opera since its version of 3.0, now the opera is pretty matual and extremely fast.

At the first, I didn't find how to find or search text in the page what you are browsering, which is not so convenient. Use ctrl+f just actives a window to allow you to search. I want a search function like one in Firefox. Yes, I just find it: use . to active it!

Tuesday, May 13, 2008

Linux:Bash:how to print quotation marks in awk

ls | awk '{print "'\''"$1"'\''"}'

or

awk 'BEGIN { print "Here is a single quote \47" }'

Tuesday, May 6, 2008

Linux:shell: how to change color of your prompt

I find a good paper:

http://www.funtoo.org/en/articles/linux/tips/prompt/

to teach you how to change the color of your prompt. Actually I did this change long time ago, however, there is a problem in my setting. I didn't use "\[" and "\]" to include the string so that my shell cannot precisely calculate word-wrap and once I input long strings in the command line, my line will mass up.

Thursday, April 24, 2008

Linux:command:cut

see 'man cut' for help information. Example here:

$ who am i | cut -f1-2 -d " " #print the first column
$ who am i | cut -f2- -d " " #print non-first columns

Thursday, March 27, 2008

linux: open pdf within a browser window AND how to browse e-books from NetLibrary

Lots of interesting e-books from our SFU library are based on the site of www.netlibrary.com . The readers have to go to the online lib. However, the NetLib didn't provide Linux users about their reader softerware (only for windows users). I notice that essentially when one reads an e-book online, it is a pdf file downloaded (only one page each time). No need special reader at all! However, my browser cannot open pdf file within a browser window so that I have to click a diagostic window to save it or read it by certain pdf software. If I can read pdf files within the browser, then the life becomes simpler. No need to open the pdf file each time, just read the book in the browser! I tried some approaches by following instructions on the internet. Finally I solve the problem. I think the essential steps are also useful for windows users.

- type : about:plugins in your web address blank line to see if acrobat reader plugins over there. If not, see the next
- try to find the lib file which should be located in the directory where acrobat reader is installed, in my case, it is:

/opt/Adobe/Reader8/Browser/intellinux/nppdf.so . copy it over to the directory where

firefox is installed, in my case,

/home/myusername/.mozilla/plugins/

- check about:plugins again. If not, read the next line.
- re-initialize the data base, remove files pluginreg.dat where your firefox is installed.
- I guess the problem should be solved. I refer to the web page here:

http://support.mozilla.com/en-US/kb/Opening+PDF+files+within+Firefox

Sunday, March 9, 2008

Emacs: how to auto-complete word

Both vim and emacs have a function to auto-complete words. For example, in emacs, type "M-/" then it will help you automatically complete the word currently you are typing in. This specially is useful as programming.

Also, I find a good file to compare commands in vim and emacs. In order to avoid the original page is dead, I post it here for reference. The original address is: http://karl-voit.at/vim-emacs-cheatsheet_of_freezing_hell.txt

,----
| emacs-stamp: Time-stamp: <2006-11-07>
| vim-stamp: Latest change: Wed Nov 07 15:34:18 CET 2007
| .... whichever comes last *ggg*
|
| Title: vim7-emacs21-cheatsheet of freezing hell
| ... tries to combine the two editors of choice
|
| Author: Karl Voit
| Purpose: learn emacs21 _and_ vim (for myself)
| License: Creative Commons http://creativecommons.org/licenses/by/2.5/
| Status: constantly modified and enlarged
`----

================================================================================
Editor shortcuts: Emacs and vim vim emacs21
================================================================================

exit :q C-x C-c
save :w :w! C-x C-s
save as :w

save and exit :wq (or: ZZ)
exit without saving :q! (or: ZQ)

open file :e(dit) file C-x C-f
open file read only C-x C-r
re-read file (discard changes) :e(dit)!

edit file under cursor gf (goto file)

undo last changes u (or: C-_) C-_
undo one change :u(ndo)
undo latest changes on current line U
redo C-r

repeat last change .

append text after cursor a
append text after EOL A

insert text after cursor i
insert text before first non-whitesp. I

insert line below cursor and insert o
insert line above cursor and insert O

mark char begin v (column: C-v|C-q) C-Space
mark line begin V

restore last selection gv

copy marked part y M-w
paste marked part p C-y "yank"
cut marked part c C-w
delete marked part d

delete char x DEL
delete line dd (or: :d)
copy current line yy (or: Y)
delete to end of word cw (change word) M-d
delete current word caw
delete to EOL D C-k

toggle overwrite/insert mode INS (or: R) M-x overwrite-mode
replace current char with r

repeat next X times X C-u X

complete word M-/
complete word backward C-P M-/
complete word forward C-N M-/

cancel C-c C-g

redraw C-l

file info C-g
file info (verbose) g C-g

set auto indent :set ai M-x auto-fill-mode
:set textwidth=0

execute shell code :r(ead) !

show whitespaces :set list

insert :r(ead) M-x insert-file

--------------------------------------------------------------------------- Help

show help of cmd XY :help XY
show man-page of current word K
grep help :helpg foobar

------------------------------------------------------------------------ Buffers

close buffer C-w c :clo(se) C-c k
close all buffers but current C-w o :on(ly)

open file for writing C-x C-f
open file for reading C-x C-r

change to previous buffer C-^ C-6 C-x b
change to buffer number <12> <12> C-^ <12> C-6 C-x b
:b <12>
split vertically C-w s :sp(lit)
split horizontally C-w v :vs(split)

duplicate buffer :new

change to (upper) high buffer C-w h
change to lower buffer C-w l

list buffers :ls

--------------------------------------------------------------------- Navigation

goto line <12> <12>G M-x goto-line <12>

up k C-p
Cursor movements left right h l C-f C-f
down j C-n

buffer begin 1G gg M-<>

line begin ... end 0 ... $ C-a ... C-e
line begin (first non-whitespace) ^

word next w M-f
word last b M-b

sentence previous ( M-a
sentence next ) M-e

paragraph begin { M-{
paragraph end } M-}

goto last place C-o
goto next place (if any) C-i

goto begin of last marked part '<>

page up C-b M-v
page down C-f C-v

1/2 page up C-u
1/2 page down C-d

scroll one line down (keep cursor) C-e
scroll one line up (keep cursor) C-y

remember position (as p) m p C-x r m
jump to position (p) ` p C-x r b
jump to last marked position ``
jump to last place edited `.
list all marked positions :marks

place current line in the center z. C-l "locate"

------------------------------------------------------------ Search and replace

current line: goto character X fC
current line: goto character X backw. FC
current line: go before character X tC
current line: go before char. X backw.TC

activate incremental search :set incsearch
search incremental (if activated) / C-s
search incremental backwards (if activated) ? C-r
repeat search n C-s or C-r
repeat search in other direction N

replace s/foo/bar(/gci) M-%

search word under cursor *
search word under cursor backward #
search local variable under cursor gd
search buffer variable under cursor gD

search correspondent brace/bracker/.. %

unhighlight the search patterns :noh

search for regular expressions /REG C-M-s
repeat search for reg. expr. n C-M-s
search in other directory for reg.ex. N C-M-r

--------------------------------------------------------------------- Formatting

lowercase current word :map l viwuW M-l
capitalize current word :map c viwu~W M-c
uppercase current word :map u viwUW M-u
toggle case of current word :map t viw~W
toggle case of char under cursor ~

quote text C-c C-q
format line
format paragraph gqap M-q
format whole document gggqG

shift marked lines to left <<>>
set shiftwidth :set shiftwidth=4


------------------------------------------------------------------------- Macros

begin recording (name: foo) qfoo C-x (
end recording q C-x )

execute macro foo @foo C-x e
repeat macro execution @@

edit macro "ap
end edit macro

save macro

------------------------------------------------------------------------ Columns

mark column begin C-v (Windows: C-q) C-space

set width mark to longest line $

copy column(s) "*y
paste column(s) p C-x r y "yank"
cut column(s) d C-x r k "kill"

insert column text (foo) (visual:) Ifoo ESC C-x r t foo

-------------------------------------------------------------- Folding / Outline

hide all zC C-c C-t
show all zO C-c C-a
toggle hide/show all zi

hide this zc C-c C-d
show this zo C-c C-s

goto previous zk C-c C-p
goto next zj C-c C-n

------------------------------------------------------------- Special Characters

enter carriage return C-q ENTER C-q ENTER
enter newline C-q C-j C-q C-j
enter spoiler character ^L C-q C-l C-q C-l

------------------------------------------------------ Compare/merge differences

start file A and B in compare mode vimdiff A B emerge A B

emacs: goto fast-mode (C-c C-c doesn't have to be used) C-c C-c f
emacs: goto edit-mode e

next difference ]c (C-c C-c) n
previous difference [c (C-c C-c) p
goto difference X C-u X j

change to left file (higher) C-w h
change to right file (lower) C-w l

take this version :[range]diffpu(t) dp
take other version :[range]diffg(et) do

take A-version (C-c C-c) a
take B-version (C-c C-c) b

quit without saving the merge C-]
recenter buffers l

emacs: http://www.cs.cmu.edu/cgi-bin/info2www?(emacs)Merge%20Commands

---------------------------------------------------------------- Version Systems

vim: install vcsnursery from http://www.vim.org/scripts/script.php?script_id=1898

commit changes :VCSCommit C-x v v
show differences between versions :VCSVimDiff C-x v =
show log of current file :VCSLog C-x v l
revert changes to most recent version :VCSRevert C-x v u
update current file from repos :VCSUpdate

add file to repos :VCSAdd C-x v i
show annotations :VCSAnnotate
delete file (incl. from repos) :VCSDelete
show difference to previous version :VCSDiff
view a certain version :VCSReview 42 C-x v r
show detailed infos :VCSStatus


================================================================================
vim specific shortcuts:
================================================================================


================================================================================
Own vim macros
================================================================================

" move line before boxquote into title field of boxquote
map ,vkbqt kDj6lp0

" remove/delete trailing whitespace:
nmap ;tr :%s/\s\+$//
vmap ;tr :s/\s\+$//

"kill quoted sig
map ,kqs G?^> -- $d}

" change subject (Subjectaenderung) (Source: Michael Prokop)
map ,vkcs :set nohlsearch
\:1,/^Subject: /g//s/^\(Subject: \)\(Re: \)\=\(.*\)$/
\\1 (was: \3)/9i

" simple quote (insert quote after this line)
map ,vksq 0jikki

" quote between line (insert quote in between the line)
map ,vkqbl i0kxkkxjxi

" update timestamp (make sure that "set paste" is NOT set
iab Tue Jul 31 13:03:52 CEST 2007 =strftime("%a %b %d %T %Z %Y")
" map ,L 1G/Latest change:\s*/e+1CYDATE
map ,L 1G/Latest change:\s*/e CYDATE

" voit 20070306:
" ESC-c ... capitalize current word (and goto next word)
map c viwu~W
" ESC-l ... lowercase current word (and goto next word)
map l viwuW
" ESC-u ... uppercase current word (and goto next word)
map u viwUW



FIXXME: Bereichsangaben

" Using (g)vim to colorize sourcecode (from: http://barnson.org/node/295#comment-26758)
" used here: Visual Basic syntax
:cal SetSyn("vb")
:syntax on
:set background=light
:runtime! syntax/2html.vim
ggVG (to select all in this top frame)
"+y (to copy to clipboard)


...................................................................
...................................................................
...................................................................
...................................................................
...................................................................
N O T E S F O L L O W I N G
...................................................................
...................................................................
...................................................................
...................................................................
...................................................................

Svens Vortrag:
------------------------------------------------------------------------- Suchen


------------------------------------------------------ Eingabe von Sonderzeichen

Eingabe über ASCII-Nummer:
ß 223 ä 228 ö 246 ü 252

Zwei-Zeichen-Kombination:
Digraph Input! a + : -> ä

automatische Einrücken (indenting)
Clipboards/Register
Markieren von Text
von Position bis Position
zeilenweise (block)
als Rechteck -> Tabelle

Zeile? DOS/Windows, Unix, oder Mac?
Automatische Erkennung
Beliebige Wahl

%page
Anzeige - Grundlegend

Aktuelle Position des Cursors (Lineal,ruler)

%pause
ASCII-Wert von Zeichen

%pause
Sichtbarmachung von speziellen Zeichen
(TABs, trailing spaces)
:set list -> schon oben drinnen

%pause
geteilte Fenster (horizontal,vertikal)
-> TextKopieren, Vergleiche

%page
Anzeige - Fortgeschritten

Syntax Coloring / Highlighting
%pause
Achtung: ersetzt keinen Parser!

%pause
Struktur der Datei anzeigen - Baumstruktur
Text verstecken
Syntax dependant
Kommandos zum Einklappen und Verstecken

%page
Abkürzungen - Abbreviations

%pause
einfache Wortexpansion:
LS -> Leutheuser-Schnarrenberger

%pause
mehrere Worte:
LT -> Linux-Tag Chemnitz

%pause
mehr als nur Buchstaben:
function_mit_viel_bedeutung(*par1,par2)
* = neue Cursorposition

%pause
mehrzeilige Floskeln:

Sehr geehrter Herr Spammer..
..Aufnahme ins Killfile..
Gründe: [Liste]
Mit freundlichen Grüßen

%page
Goodies

Autosave
Backup files
Compiler
Filtering
Sessionfile
Syntax Input

%page
Grenzen - Limits

Endlicher Speicher -> Grenzen

Dateigröße
Dateinamenlänge
Displaybreite

Zeilenlänge
Zeilenanzahl

Bufferanzahl
Registergröße

,----
| 2do
`----

tabs (vim7)

retab + ersetzen:
:set tabstop=4
:set expandtab
:%retab

^M herauslöschen

align-current


query option value :set OPTION?

folding + examples (emacs-2do-list and vim-2do-list)

mika@grml ~ % grep boxes .vimrc
" 040420 introduced history 8-) and slightly modified 'boxes'-stuff
" 030219 VBlockquote.vim - like the tool "boxes" works ;-)
" 030219 Call boxes - with some funny box-styles ;o)
map ;0 :'<,'>!boxes
map ;1 :'<,'>!boxes -d boxquote
map ;2 :'<,'>!boxes -d peek -a c -s 40x5
map ;3 :'<,'>!boxes -d c-cmt
map ;4 :'<,'>!boxes -d dog -a c
map ;5 :'<,'>!boxes -d simple -a
jr
map ;6 :'<,'>!boxes -d headline
--> Test! (FIXXME)
--> boxes = extra-tool!

"boxing" text C-c q
title of box C-c w

Snippets einfügen wie zB :
:he :iabbrev
:he mapmode-i
(Vim7: C-x C-o)

Ranges: . .+3 % ,. .,$


.........................................................

,----
| notes from a former talk:
`----
:set tw=50 ... set texxt width
map gqip ... macro setzen
:set ft=html
:set paste ... Einfuegen ohne Umformatierung
:set nopaste ...
:set sw ... Option vervollstaendigen lassen
:set sw= ... Option plus Wert vervollstaendigen lassen
:set listchars=tab:»·,trail:·,,eol:$ ... wie sollen list-Elemente usw visualisiert werden?
:w datei:.neu ... Kopie mit Anhaengsel ".neu" erstellen, Buffer bleibt bei "datei"
:!ls -l % ... shell-Kommando ls aufrufen (%=aktueller Buffername)
:! ... letzter Befehl, der mit "!" begonnen hat
C-w n ... C-w=Fensterbefehl, n=new
C-w C-r ... unterster Buffer oben einfuegen (rotate)
:help C-v C-w ... show help on windows-commands (C-v nur um C-w einzugeben)

vimdiff
:diffget ... Aenderungen in den Buffer uebernehmen

%%% vim: ft=mgp ai noet ts=2

------------------------------------------
Emacs und ispell:

;; User-Dictionary ohne Nachfrage speichern
(setq ispell-silently-savep t)
(autoload 'flyspell-mode "flyspell" "On-the-fly spelling checking" t)
(autoload 'flyspell-mode "flyspell" "On-the-fly ispell." t)
(setq ispell-program-name "aspell")

;; Initialize spell checking
(setq-default ispell-program-name "aspell")
(set-default 'ispell-change-directory "ndeutsch8-15")
(set-default 'ispell-local-dictionary "ndeutsch8-15")
;; ========================
;; ISPELL
;; ========================
(require 'ispell)
(add-to-list 'ispell-dictionary-alist
'("ndeutsch8-15"
"[a-zA-Z\304\326\334\344\366\337\374]"
"[^a-zA-Z\304\326\334\344\366\337\374]"
"[']" t
("-C" "-d" "german")
"~latin1" iso-8859-15))

;; ========================
;; ISPELL End
;; ========================

;; ========================
;; FLYSPELL
;; ========================
(add-hook 'flyspell-mode-hook
(function (lambda ()
(setq ispell-local-dictionary "ndeutsch8-15")
)))


M-X change-ispell-dictionary

-----------------------------------------------------------
emacs und LaTeX

Added in file c:\.emacs

(require 'tex-site)
(setq tex-dvi-view-command "C:\texmf\miktex\bin\yap.exe")
(custom-set-variables
;; custom-set-variables was added by Custom -- don't edit or cut/paste it!
;; Your init file should contain only one such instance.
'(TeX-output-view-style (quote (("^dvi$" "^pstricks$\\|^pst-\\|^psfrag$" "%(o?)dvips %d -o && gv %f") ("^dvi$" "^a4\\(?:dutch\\|paper\\|wide\\)?\\|sem-a4$" "%(o?)xdvi %dS -paper a4 %d") ("^dvi$" ("^a5\\(?:comb\\|paper\\)?$" "^landscape$") "%(o?)xdvi %dS -paper a5r -s 0 %d") ("^dvi$" "^a5\\(?:comb\\|paper\\)?$" "%(o?)xdvi %dS -paper a5 %d") ("^dvi$" "^b5paper$" "%(o?)xdvi %dS -paper b5 %d") ("^dvi$" ("^landscape$" "^pstricks$\\|^psfrag$") "%(o?)dvips -t landscape %d -o && gv %f") ("^dvi$" "^letterpaper$" "%(o?)xdvi %dS -paper us %d") ("^dvi$" "^legalpaper$" "%(o?)xdvi %dS -paper legal %d") ("^dvi$" "^executivepaper$" "%(o?)xdvi %dS -paper 7.25x10.5in %d") ("^dvi$" "^landscape$" "%(o?)xdvi %dS -paper a4r -s 0 %d") ("^dvi$" "." "%(o?)xdvi %dS %d") ("^pdf$" "." "\"c:\\Programme\\Adobe\\Acrobat 6.0\\Reader\\AcroRd32.exe\" %o") ("^html?$" "." "netscape %o")))))
(custom-set-faces
;; custom-set-faces was added by Custom -- don't edit or cut/paste it!
;; Your init file should contain only one such instance.
)


Change target to PDFLaTeX: C-c C-t C-p
Compiled using C-c C-c



=== [ ENDE ] === ------------------------------------------------------------------------------
%%% Local Variables:
%%% mode: outline
%%% outline-regexp: "\\(\\[\\([1-2][0-9][0-9][0-9][0-1][0-9][0-3][0-9]\\)?\\]\\[\\([1-2][0-9][0-9][0-9][0-1][0-9][0-3][0-9]\\)?\\]\\(\\[.+\\]\\)? .*\\)\\|\\(^=== \\[ .* \\] ===.*\\)"
%%% eval: (auto-fill-mode -1)
%%% eval: (flyspell-mode -1)
%%% eval: (end-of-buffer)
%%% eval: (hide-body)
%%% emerge-set-combine-versions-template: "%a\n%b\n"
%%% End:
%%% OLD-outline-regexp: "\\(\\[\\([1-2][0-9][0-9][0-9][0-1][0-9][0-3][0-9]\\)?\\]\\[\\([1-2][0-9][0-9][0-9][0-1][0-9][0-3][0-9]\\)?\\]\\(\\[\\(maggie\\|lisa\\)\\]\\)? .*\\)"
%%% OLD-outline-regexp nur "[][] Text": "\\(\\[\\([1-2][0-9][0-9][0-9][0-1][0-9][0-3][0-9]\\)?\\]\\[\\([1-2][0-9][0-9][0-9][0-1][0-9][0-3][0-9]\\)?\\] .*\\)"
%%% OLD-outline-regexp inkl. Sterne als Items: "\\(\\[\\([1-2][0-9][0-9][0-9][0-1][0-9][0-3][0-9]\\)?\\]\\[\\([1-2][0-9][0-9][0-9][0-1][0-9][0-3][0-9]\\)?\\] .*\\)\\|\\(*+ \\)"

Tuesday, February 26, 2008

Linux: command: how to use getopt

A simple example is here:
http://tldp.org/LDP/abs/html/extmisc.html#EX33A

From
http://www.tomshardware.com/ucg/commands/getopt-15186.html

getopt

UNIX Shell: Shells (ash, bash, bsh, csh, ksh, sh, tcsh, zsh)

Function
Cleans up and checks options given to a shell script. It split option given together and place each option in its own variable. Any additional arguments is placed after --

Syntax
set -- `getopt optstring $*`
getopt optstring parameter
Linux: [ options... ] -- optstring parameter
Linux: getopt [ options... ] -o optstring [ options... ] [ -- ] parame

optstring Specifies a string of option letters that is recognized by the script.


NOTE: If a letter is followed by a colon (:) it will take an argument.

parameter Specifies the options to check. (This is often $*, the argument list to the script).

set -- Sets the argument list $* .

Linux:

-a Allows long options to start with a single -.

-h Shows help information.

-l longoptions Specifies a long option that will be recognized.

-n progname Specifies a program to use to report errors

-o optstring Specifies a list of short options.

-q Disables error reporting

-Q Doesn't generate any output. Errors are reported unless -q is also given.

-s shell Uses quoting conversions of the specified shell (sh, bash, csh or tcsh)

-u Doesn't quote the output.

-T Will test if this is the enhanced version.

-V Shows version information.

File Name: getopt Directory: /usr/bin/ Type: External

Note:
This is very useful to make easy option check in a shell script.

set -- `getopt ab:c $*`
Specifies that a and c don't take an argument but c will.

If argument is: -ac -b hello
It will be converted to: -a -c -b hello --

If argument is: -bhello ucg
It will be converted to: -b hello -- ucg

set -- `getopt -l help ab:c $*`
Also recognizes the long option --help

Monday, February 25, 2008

Linux:command: sort

'sort' in linux is sometimes very usefult. For example, I have a file like this:
pt 2.9
eta 3.0
phi 4.5
px 2.1
If you want to rank those variables due to the increasing order of the 2nd column, then you can use 'sort -n -k2 yourfile.txt'. '-k2' means the position of the key is the 2nd.

Sunday, February 17, 2008

Firefox: how to check plugins

Type about:plugins in the address line.

Wednesday, February 13, 2008

Linux: X server crashes

Long time ago, I have a problem that my X server crashed when I change my current profile from one network profile in net applet. I had no clue at all then. I remember that I changed .gnome and some directories, then the problem is gone. But I have to use kde then. Today I logon gnome and X server crashed again. I cannot fix it by upgrading using installation disk. And I create a new account, it is working well. And I searched the internet and realized that some people also have the same problem with me. Actually the problem is from 3D effect. I have to edit the file: /etc/X11/xorg.conf to comment two lines which is bad for x server. They are:

Option "Composite"
Option "XaaNoOffscreenPixmaps" "1"

After removal, I can restart X server. :-)

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...)

Locations of visitors to this page