Thursday, December 7, 2006

V2.6.19

The latest release of the linux kernel is out. You can get it at kernel.org

Tuesday, November 28, 2006

Mutt and Exchange

So apparently the mutt client and exchange servers has issues. Everytime i send a mail from mutt to an exchange account it will automatically redirect it to the junk mail folder.

Now i don't know if this is a issue with Exchange or mutt but for now i am blaming it on the Exchange server. Will try to research on this more

Sunday, November 19, 2006

GNU screen

What is GNU screen?
A free terminal developed by the GNU Project. It allows a user to access multiple separate terminal sessions inside a single terminal window or remote terminal session. It is useful for dealing with multiple programs from the command line, and for separating programs from the shell that started the program.

This is said to be a text version of the graphical window manager. This program together with irssi allows me to stay idling on irc all the time, GNU screen is basically where the magic happens.

Using GNU screen however takes a bit of learning first. So if you are on a UNIX terminal type
screen


This will bring you into a new screen session and if you type
screen -list


It will show you the number of screen sessions you currently have

[limed@shell][~]# screen -list
There is a screen on:
17206.pts-0.shell (Attached)
1 Socket in /var/run/screen/S-limed.


Now every screen command has the format Ctrl-A, and since we are in a screen session now we will can detach from a screen session by hitting Ctrl-A,d When this is done you will see your terminal will print out the word [Detached], and this indicates that you are no longer in a screen session, but whatever application you are running in the screen session is still running.

So now let say we want to reattach back to the screen session on the terminal we type the following command

[limed@shell][~]# screen -rd

The -r switch indicates that you want to resume the screen session, -d switch means that if you have a screen session somewhere it detaches it and resumes on your current machine you are working on. Now you should be able to use screen

That is a simple introduction to GNU screen, and here are more commands for GNU screen

C-a 0 (select 0)
... ...
C-a 9 (select 9) Cycles through the screen sessions you have
C-a C-a (other) Toggle to the window displayed previously.
C-a a (meta) Send the command character (C-a) to window. See escape
command.
C-a A (title) Allow the user to enter a name for the current window.
C-a c
C-a C-c (screen) Create a new window with a shell and switch to that window.
C-a C (clear) Clear the screen.
C-a d
C-a C-d (detach) Detach screen from this terminal.
C-a D D (pow_detach) Detach and logout.
C-a k
C-a C-k (kill) Destroy current window.
C-a space
C-a n
C-a C-n (next) Switch to the next window.
C-a w
C-a C-w (windows) Show a list of window.
C-a ? (help) Show key bindings.

Note that C-a means Ctrl-a

Credits:
Wikipedia - GNU Screen entry
irssi - Documentation page

Tuesday, November 14, 2006

IRC

Just the other day i was talking to one of my TA's (Teach assistant) and he mentioned how IRC was still widely used among the developer circle. Although i am not a developer but i still use IRC a lot especially when it comes to getting quick responses from admins. So what is IRC you ask well let me explain

What is IRC? (Totally jacked from wikipedia)
Internet Relay Chat (IRC) is a form of realtime Internet chat. It is mainly designed for group (many-to-many) communication in discussion forums called channels, but also allows one-to-one communication via private message.

So having IRC is one thing we also need to connect to an IRC network to be able to talk in channels. There are a few major IRC networks, and they are Freenode, EFNet, GameSurge and more

People would usually connect to this servers using IRC clients and join chat channels. There are few chat clients out there that are free for us to use

mIRC
xChat
irssi <-- my personal favourite
Bersirc

And here are a few basic IRC commands that you should know

/SERVER { Server name } connects you to a particular IRC network
/LIST [ [ { flags } ] { channel mask } ] Lists all current channels.
/QUIT Quits IRC client
/NICK { Nickname } Changes your nickname to whatever you like.
/AWAY [ Away message ] Sets your status as away with some info.
/WHOIS { Nickname } Shows information about someone.



I usually connect to a shell server and start up irssi on a shell server with a screen session running. That way i am always idling on the channels

What is a screen session? More on this on the next post

Sunday, November 12, 2006

PHP Headers

Here's a cool tip i learned using php headers the other day. You can header redirect it to a mailto command. So instead of redirecting you back to a page it will open up your mail client and will bring up a compose email box. So here is an example


<?php

$email = 'foo@bar.com';
$sub = 'Hello World!';
$body = 'Hello World!';

header('Location: mailto:'.$email.'?subject='.$sub.'&body='.$body);

?>


This will open up a compose email dialog box, sending it to foo@bar.com with the subject and body containing Hello World!

Saturday, November 11, 2006

vimrc

Vim can be one of the most powerful editors, however there is several annoyances that come with here. But thankfully its highly customizable, to customize vim you will need a file called a .vimrc file and you put this in your home directory. Here is how mine look like with comments


"----------------------------------------------------
" vimrc file for ed lim
" @author - Ed Lim
"----------------------------------------------------

"------------ editor behaviour block ------------------
set ruler " show curser position at all times
set sw=8 " Use 8 spaces when text is indented
set tabstop=8 " sets how many spaces a tab is
"set ai " auto indent
"set si " smart indent - attempts to guess where to indent
set et " tabs converted to spaces, uncomment when needed
set incsearch " incremental search
set nohlsearch " no highlight on searching
set nowrapscan " turn off search wrapping
set nowrap " no text wraps
set backspace=indent,eol,start " allow backspacing over everything in insert mode
set term=ansi
"set background=dark " user brighter color if xterm has a dark background
set noerrorbells " do not beep on errors
set ttyfast " Smoother scrolling
set mouse=a " have mouse enabled at all time
set virtualedit=all " allows curser to roam freely
set backspace=2 " allows backspacing over everything
set showmode " show current mode you are in
set showcmd " display incomplete commands
set showmatch " show matching braces
set undolevels=500 " set the number of undo's
set novisualbell " no sound on error
set t_vb= " turn off error bells
set noerrorbells " No sound on error
set title " Shows title in console window
set ls=2 " always show status line
set foldmethod=marker " fold method using markers
"set foldmethod=indent " fold method using indent

"-------------- backup block ------------------
set backup
set backupdir=$HOME/.VimData/vimbak
set directory=$HOME/.VimData/vimtmp
set errorfile=$HOME/.VimData/vimtmp/errors.vim

"------------ Graphical block -----------------
syntax on " Turns on syntax highlighting
set nu " Line numbers

"------------- Color definitions ----------------
hi Comment terM=bold cterm=NONE ctermfg=DarkGreen ctermbg=NONE gui=NONE guifg=Blue guibg=NONE
hi Constant term=underline cterm=NONE ctermfg=DarkRed ctermbg=NONE gui=NONE guifg=Magenta guibg=NONE
hi Special term=bold cterm=NONE ctermfg=DarkMagenta ctermbg=NONE gui=NONE guifg=SlateBlue guibg=NONE
"hi Identifier term=bold cterm=NONE ctermfg=Black ctermbg=NONE gui=NONE guifg=DarkCyan guibg=NONE
hi Statement term=bold cterm=NONE ctermfg=DarkBlue ctermbg=NONE gui=bold guifg=Brown guibg=NONE
hi PreProc term=underline cterm=NONE ctermfg=DarkMagenta ctermbg=NONE gui=NONE guifg=Purple guibg=NONE
hi Type term=underline cterm=NONE ctermfg=DarkBlue ctermbg=NONE gui=bold guifg=SeaGreen guibg=NONE
hi Underlined term=underline cterm=underline ctermfg=DarkMagenta gui=underline guifg=SlateBlue
hi Ignore term=NONE cterm=NONE ctermfg=white ctermbg=NONE gui=NONE guifg=bg guibg=NONE
"hi LineNr term=underline ctermfg=Black guifg=Black

" --------- key mappings --------------
" F1 show buffers
map <f1> :buffer<cr>

" F2 select buffer
map <f2> :buffer

Vi

What is VI?
A screen based Unix text editor.

Why VI?
Because its basic and it always come with any unix based operating system. In other words its always there!

Warning: Vi can be extremely confusing to use for a beginner but it is very powerful once mastered.

Basic Vi commands
How to get Vi to work?
On the Unix command prompt type
     vi filename
Where filename is the name of the file you want to open or create

There are basically 3 different types of mode in Vi
1) Insert mode --> to get into text mode just hit the i key
2) Command mode --> to get into command mode from text mode just hit the Esc key
3) Visual mode --> to get into this mode hit the v key, this keys allows you to highlight portions of your code


Vi commands
Undo Command
u - undo the last command.

Cursor Positioning Commands
j - Moves cursor down one line, same column.
k - Moves cursor up one line, same column.
h -Moves cursor back one character.
l - Moves cursor forward one character.
$ - Moves cursor to end of current line.
:n - Moves cursor to beginning of line n.

Text Insertion Commands
i - Inserts text before cursor. Terminated by the escape key.
I - Inserts text at the beginning of the line. Terminated by the escape key.
DEL - Overwrites last character during text insertion.
ESC - Stops text insertion.

Text Deletion Commands
x - Deletes current character.
dd - Deletes current line.
dw - Deletes the current word.
d) - Deletes the rest of the current sentence.
D, d$ - Deletes from cursor to end of line.
P - Puts back text from the previous delete.

Cut and Paste Commands
yy - Puts the current line in a buffer. Does not delete the line from its current position.
p - Places the line in the buffer after the current position of the cursor.

Exiting vi
ZZ - Exits vi and saves changes.
:wq - Writes changes to current file and quits edit session.
:q! - Quits edit session (no changes made).

Code folding
-
Highlight the block of code you want to fold first, once highlighted you can hit the following key combination:
zc - creates the fold
zo - opens fold
zd - deletes fold

Split screen
To split a screen type this command in vi :sp where filename is the other file you want to open. If you just type :sp it will split the screen with the current file you are in

For vertical split, type :vs this splits it vertically

To navigate through the splits first hit Ctrl-W and then the arrow key to the direction of the split