Nasser Heidari

November 7, 2009

HTML Redirect

Filed under: Miscellaneous — Nasser Heidari @ 12:40 pm

To create an HTML redirect page, you use the HTML meta tag, along with the ‘http-equiv’ and ‘content’ attributes.

<META HTTP-EQUIV="refresh" CONTENT="seconds;URL=the-other-url">

E.G:

<HTML> <HEAD> <META HTTP-EQUIV="refresh" CONTENT="0;URL=http://linax.wordpress.com"> </HEAD> <BODY> </BODY> </HTML>

November 3, 2009

Gcc and Header issues

Filed under: Miscellaneous — Nasser Heidari @ 7:22 pm

http://gcc.gnu.org/gcc-4.3/porting_to.html

The missing headers:

If missing Then include this header
find, for_each, sort <algorithm>
ostream_iterator, istream_iterator <iterator>
auto_ptr <memory>
typeid <typeinfo>
isalnum, toupper <cctype>
INT_MIN, INT_MAX, RAND_MAX <climits>
printf <cstdio>
atoi, free, rand, exit <cstdlib>
EXIT_FAILURE <cstdlib>
strcmp, strdup, strcpy, memcpy <cstring>

Removal of Pre-ISO headers

Various backwards and deprecated headers have been removed.

If missing Then include this header
<algobase.h> <algorithm>
<algo.h> <algorithm>
<alloc.h> <memory>
<bvector.h> <vector>
<complex.h> <complex>
<defalloc.h> <memory>
<deque.h> <deque>
<fstream.h> <fstream>
<function.h> <functional>
<hash_map.h> <tr1/unordered_map>
<hashtable.h> <tr1/unordered_map> or <tr1/unordered_set>
<heap.h> <queue>
<iomanip.h> <iomanip>
<iostream.h> <iostream>
<istream.h> <istream>
<iterator.h> <iterator>
<list.h> <list>
<map.h> <map>
<multimap.h> <map>
<multiset.h> <set>
<new.h> <new>
<ostream.h> <ostream>
<pair.h> <utility>
<queue.h> <queue>
<rope.h> <ext/rope>
<set.h> <set>
<slist.h> <ext/slist>
<stack.h> <stack>
<streambuf.h> <streambuf>
<stream.h> <iostream>
<tempbuf.h> <ext/memory>
<tree.h> <ext/rb_tree> or <ext/pb_ds/assoc_container.hpp>
<vector.h> <vector>

November 1, 2009

Vim Jump-Start

Filed under: Linux — Nasser Heidari @ 8:11 pm

Thanks goes to roqet

vi (and vim) runs in 2 modes: insert and command, ESC changes to command mode.

This command list was made while using vim (vi improved), all commands may not work in other versions of vi.

In this document, c stands for ctrl and m for alt.

% usually represents the whole buffer

If you’re having trouble starting vim in a console, try vim -X

See the “additions to the vimrc configuration file” section to enable ms-windows-like editor commands.

basic commands

quit : :q (closes the editor, use :bd to just close the buffer)

write/save : :w

quit with write : :wq

quit without save : :q!

close buffer : :bd

open file : :e (filename)

new file : :new

page up : c-u or page-up

page down : c-d or page-down

up : k or up-arrow

down : j or down-arrow

left : h or left-arrow

right : l or right-arrow

go to file start : gg

go to file end : G

go to line : nG (where n = a number)

go to line end : $

go to line start : 0

jump forward word : w

jump forward word : b

begin typing/insert : i

insert at end of line : A

join lines : J (nJ to join more than 2 lines – n = a number)

indent a block : v (then select the block) > (or < to go left)

undo last command : u

redo : c-r

repeat last command : :<up arrow>

repeat last change : .

select : v (then select text, and choose y to copy or x to cut)

copy line : cc

delete line : dd

delete character : x

delete word : dw

delete till end of line : d$

delete several lines : :dn eg :d3

delete a specific line : :nd (where n = a number, not to be confused with above)

paste (after character/line) : p

paste (before character/line) : P

search forwards : / (followed by word to search) (/ alone to search next)

search backwards : ? (followed by word to search) (? alone to search next)

search files : :vimgrep /love/ *.txt follow this with the command :cwindow to see a list of all the files found

change case : n~ (where n = a number)

replace/substitute : :%s/old/new/g (% says to do this for each line, % can also be a set number)

replace single character : r<character>

match parenthesis : % (after placing the cursor on the first parenthesis)

code complete : ctrl-x ctrl-o

word wrap : :set wrap

no word wrap : :set nowrap

line numbering : :set number

no line numbering : :set nonumber

execute an external command : :! (followed by command)

read in results of a command : :r!command or !!command (eg :r!date)

insert an external file : :r (filename)

open a shell : :sh

create a page break : while in the insert mode, CTRL-l (that’s an “L”); “^L” will appear in your text and will cause the printer to start a new page.

execute perl : :!perl -wc % (for syntax check, drop the “c” for normal run)

compile java : :!javac -verbose %

run java : :!java %< (the < removes the extension)

compile c#: :!csc %

spell check : :!ispell % (or :!aspell check %)

new buffer : :new

next buffer : :bn

last buffer : :bl

change buffers : :( n)b

close buffer : :bd (close specific buffer = :bd 3 (can have more by putting a space between the numbers))

change between split windows : c-w

make current window the only one visible : :o nly (or) c-w o

change/set options : :o ptions (these can also be set in the .vimrc/.gvimrc

files)

create/run a macro : qa to begin recording into register ‘a‘, followed by q to stop recording, then @a to repeat the commands you recorded. You can record into 26 other registers (for each letter of the alphabet).

create a fold : zfap (position the cursor at the start of the block of code first)

open a fold : zo

close a fold : zc

open all the folds : zr

close all the folds : zm

Make current line uppercase : gUU

Make current line lowercase : guu

htmlize a syntax-highlighted file : :runtime! syntax/2html.vim this will convert a file that has been syntax highlighted into html (handy for use on websites and such)

additions to the .vimrc configuration file

set nocompatible
source $VIMRUNTIME/mswin.vim
" adds recent filelist; downloaded from:
" http://vim.sourceforge.net/scripts/script.php?script_id=194)
source $VIMRUNTIME/MRU.vim
behave mswin

" OS-specific settings
if has("win32")
  " windows preferred font...
  set guifont=HE_TERMINAL:h10
else
  " linux preferred font...
  set guifont=-dec-terminal-medium-r-normal-*-*-140-*-*-c-*-iso8859-1
endif

" slow down the default cursor blink
set guicursor=a:blinkon600-blinkoff400
" or if you don't like blinking cursors, switch it off
"set guicursor=a:blinkon0

" remove gui toolbar
set guioptions-=T

" set tab width to 4 and insert 4 spaces for each tab
set tabstop=4
set shiftwidth=4
set expandtab

" keymapping; when editing, just use the comma command, eg: ,s (no : first)
" (results go into another buffer):
" launch SQL*Plus
map ,q :new:r!sqlplus roqetman/password@roqdb @#
" check Perl syntax
map ,p :new:r!perl -wc #
" compile Java
map ,j :new:r!javac #
" compile C#
map ,c :new:r!csc #
" Map ctrl-f and F3 for windows-type find
":map  /
:imap  :promptfind
:nmap  :promptfind
:map  /
" launch spell checker
map ,s :!aspell check %

" change comment colors for command line
highlight Comment gui=NONE ctermfg=Green

additions to syntax highlighting

These are my preferred additions to the $VIM/filetype.vim file:

" Delphi forms
au BufNewFile,BufRead *.dfm			setf pascal
" ChangeLog addendum
au BufNewFile,BufRead *.changelog		setf changelog
" useful if you use vim to read your SQL*Plus buffer (afiedt.buf)
au BufNewFile,BufRead *.buf 			setf plsql

Printing specific line of a file

Filed under: Linux — Nasser Heidari @ 8:50 am

# sed -n '15p' abc.txt or # awk 'NR==15{print}' abc.txt or # head -15 abc.txt | tail -1

October 10, 2009

Freeradius checkval module

Filed under: Linux — Nasser Heidari @ 5:14 pm

radiusd.conf:



checkval NAS_IP {
item-name = NAS-IP-Address
check-name = NAS-IP-Address
data-type = ipaddr
nofound-reject = no
}


authorize {
preprocess


sql_auth
NAS_IP


}

And then we need A/V Pair for each user like this:

test Auth-Type := Local, User-Password := 123321, NAS-IP-Address :=
1.2.3.4

October 3, 2009

Kernel vfs_cache_pressure

Filed under: Linux — Nasser Heidari @ 6:02 pm

vfs_cache_pressure Controls the tendency of the kernel to reclaim the memory which is used for caching of directory and inode objects.

At the default value of vfs_cache_pressure = 100 the kernel will attempt to reclaim dentries and inodes at a “fair” rate with respect to pagecache and swapcache reclaim. Decreasing vfs_cache_pressure causes the kernel to prefer to retain dentry and inode caches. Increasing vfs_cache_pressure beyond 100 causes the kernel to prefer to reclaim dentries and inodes.

September 28, 2009

kernel behavior on panic

Filed under: Linux — Nasser Heidari @ 9:32 am

By default, the kernel will not reboot after a panic, there is an option that you can set as a kernel parameter on grub.conf that will cause a kernel reboot after N seconds. For example following boot parameter will force to reboot Linux after 10 seconds :

kernel /vmlinuz-2.6.18-128.1.16.el5 ro root=/dev/VolGroup00/LogVol00 panic=10

Linux CPU Utilization

Filed under: Linux — Nasser Heidari @ 8:32 am

# yum install sysstat

# mpstat -P ALL

# sar -u -P ALL 2 5

# iostat -xtc 2

top 10 CPU Killing Process :
# ps -eo pcpu,pid,user,args | sort -r -k1 | less

September 26, 2009

Slackware – Apache 2 and PHP Installation

Filed under: Linux — Nasser Heidari @ 3:30 pm

If you need to use php on apache , after installing slackware , there is dummy package that won’t install with default installation process .

# wget http://mirrors.usc.edu/pub/linux/distributions/slackware\ /slackware-13.0/slackware/l/t1lib-5.1.2-i486-1.txz # installpkg t1lib-5.1.2-i486-1.txz # echo "Include /etc/httpd/mod_php.conf" >> /etc/httpd/httpd.conf # apachectl restart

Slackware boot on CCISS Dev

Filed under: Linux — Nasser Heidari @ 1:34 pm

Today , after Installing Slackware 13 on HP DL360 , i found out that lilo can not write the MBR and eventually the OS could not be loaded !
After a bit Googling, i solved my problem , here is the solution :

After Slackware installation finished , before rebooting to OS follow the below commands:

# mkdir /mnt/root # mount /dev/cciss/c0d0p1 /mnt/root (c0d0p1 is my / Partition) # mount -o bind /dev /mnt/root/dev # mount -t proc none /mnt/root/proc # chroot /mnt/root

After chrooting edit your lilo configuration file and change boot device:

boot = /dev/cciss/c0d0p4

and then :

# lilo -M /dev/cciss/c0d0 mbr # lilo

and then reboot to your new OS .

Next Page »

Blog at WordPress.com.