Wednesday, September 16, 2009

c errors

incompatible types in assignment
example:
int a[10];
a = malloc(10);

Thursday, September 10, 2009

About VNC

vncserver -- Starting vnc server.
vncserver : 1 -- Starting vnc server with specific session.
vncserver -kill :1 -- Killing the vncsession.
vncconfig & -- to make copy paste work b/w remote to local vice versa.

On linux to have VNC connection to current session:
For this you need to install x11vnc:
x11vnc -display :0 -auth ~/.Xauthority



We can start the vnc during bootup aswell. Please google it for this.


Following is the config file which I use in ~user/.vnc/xstartup file:
**************************
#!/bin/sh
if [ `/bin/uname` = "SunOS" ] ; then
xrdb $HOME/.Xresources
xsetroot -solid grey
vncconfig -iconic -nowin&
xterm -geometry 80x24+10+10 -sb -ls -sl 8000 -title "$VNCDESKTOP Desktop" &
blackbox &
else # Linux
vncconfig -nowin -set AlwaysShared=on &
PATH=$PATH:/usr/X11R6/bin:/usr/bin:/usr/cisco/bin:/usr/X11R6/bin
export PATH
WM=/usr/bin/startxfce4
#WM=/usr/X11R6/bin/twm
#WM=/usr/bin/gnome-session
#WM=/usr/bin/startkde
fi
if [ ! -x $WM ] ; then
# failsafe window manager choice
WM=twm
fi
if [ -r $HOME/.Xdefaults ] ; then
xrdb -merge $HOME/.Xdefaults
fi
## following config is for copy/paste from vnc viewer.
if [ -x /usr/bin/vncconfig ]; then
/usr/bin/vncconfig -nowin &
elif [ -x /usr/cisco/bin/autocutsel ] ; then
/usr/cisco/bin/autocutsel &
fi
exec $WM
*******************************

References:
http://www.karlrunge.com/x11vnc/
http://ubuntuforums.org/showthread.php?t=944187

Sunday, September 6, 2009

Linux Bash Commands

1. echo $SHELL -- to know the current shell
2. chsh -s /bin/bash - to change the current shell.
3. echo $SHELLOPTS - Which shell mode is being used (vi or emacs)
4. set -o emacs - to set shell mode to emacs
5. By default bash doesn't check it's window size after every command. The good thing is that you can make it. Add "shopt -s checkwinsize" to your ~/.bashrc or /etc/profile.
echo "shopt -s checkwinsize" >> ~/.bashrc (or /etc/profile)
source ~/.bashrc
try again
6. Problem: rm: cannot chdir from `festival/' to `config': Permission denied
Solution: chmod -R u+rwx * in the directory
7. Yet to come.

Bash Shell Keyboard Shortcuts:
Moving around:
Ctrl-b - Move a character backwards.
Ctrl-f - Move a character forward.
Alt-b - Move cursor backward one word on the current line.
Alt-f - Move cursor forward one word on the current line.
Ctrl-a - Move to the beginning of the current line.
Ctrl-e - Move to the end of the current line.
Ctrl-x-x - to the start, and to the end again

Cut, copy and paste:
Ctrl-d - Delete the character the cursor is on.
Ctrl-h - Delete a character before the cursor.
Ctrl-u - Delete from the cursor back to the line start.
Ctrl-k - Delete from the cursor to the end of the line.
Ctrl-x Backspace - Delete all characters in the line up till the current cursor position.
Alt-d - Delete the word, starting at the current cursor position.
Alt-Backspace - Delete every character from the current cursor position to the first character of a word that is encountered.
Ctrl-w - Delete the word, untill after the previous word boundary.
Ctrl-y - Yank/Paste previous killed text at the cursor position.
Alt-y - Yank/Paste previous previous killed text at the cursor position.

History
Ctrl-p - Move in history to the previous line.
Ctrl-n - Move in history to the next line.
Ctrl-r - Incrementally search the line history, Backwardly.
Ctrl-s - Incrementally search the line history, Forwardly.
Ctrl-J - End an incremental search.
Ctrl-G - Abort an incremental search and restore the original line.
Alt-Ctrl-y - Yank/Paste arg. 1 of prev. cmnd at the cursor position.
Alt-. OR Alt-_ - Yank/Paste last arg of prev. cmnd at the cursor position.

Undo
Ctrl-_ OR Ctrl-x OR Ctrl-u - Undo the last editing command; you can undo all the way back to an empty line.
Alt-r - Undo all changes made to this line.
Ctrl-l - Clear the screen, reprinting the current line at the top

Completion
TAB - Auto-complete a name.
Alt-/ - Auto-complete a name (without smart completion).
Alt-? - List the possible completions of the preceeding text.
Alt-* - Insert all possible completions of the preceeding text.

Transpose
Ctrl-t - Swap (transpose) the characters the cursor is on, and the character before the cursor.
Alt-t - Swap (transpose) the current word with the previous word.

CASE
Alt-u - Make the word uppercase, starting at the current cursor position.
Alt-l - Make the word lowercase, starting at the current cursor position.
Alt-c - Capitalize the current word character or the next word character that is encountered.

Use "set t_ti= t_te=" in .vimrc
if you don't want clear vim output after exit vim.


References:
http://www.slackbasics.org/html/chap-shell.html

http://faq.programmerworld.net/misc/linux-keyboard-shortcuts.html
http://article.gmane.org/gmane.linux.gentoo.user/57011
http://www.linuxquestions.org/questions/linux-general-1/disable-the-clear-after-you-close-vi-657233/#post3221832
http://www.bigsmoke.us/readline/shortcuts