Friday, December 01, 2006

Convert .cue/.bin to .iso format

Ok now i will explain how to convert a bin/cue file into an iso image.
install bchunk

apt-get install bchunk


SO now to convert xxx.bin and xxx.cue to xxx.iso file type

bchunk xxx.bin xxx.cue xxx.iso


Then to mount the .iso image type the following commnad

mount -o loop -t iso9660 image.iso /mnt/image


Cedega

This is what Transgamin Corporation has to say about its product
Cedega , TransGaming's flagship Linux portability product, allows Windows games to run on Linux seamlessly and transparently, right out of the box. With Cedega installed on your computer running Linux, you can simply insert your favorite Windows game CD, install and then play that game just as you would on a Windows system.

While installing cedega on my debian machine i git the following error

cedega depends on
xlibs > 4.1.0
But xlibs is not installed

the problem with xlib files was that they would have conflicted with my other xorg files.In order to avoid it, i googled and came up with the following solution:


cd /directory-where-is-cedega.deb/
mkdir cedega
dpkg-deb --extract XXX.deb cedega
dpkg-deb --control XXX.deb cedega/DEBIAN
vim cedega/DEBIAN/control


Remove the Xlib part from the depends list. Save it and exit.

dpkg --build cedega
sudo dpkg -i cedega.deb


Thats is done, now go and play whatever game you want :)

Please not unlike other Linux goodies Cedega is not free ware , unluckily one needs to purchase it :(


SYNAPTIC

As already mentioned in my previous blog, one can use apt-get command to do wonders, but for the lesser mortals, who want to use a GUI in order to install a package in Debian based distros we have something called SYNAPTIC .Synaptic can be viewed as the GUI version of apt-get , has an easy to understand format as well as the powers of apt-get . To run synaptic one must be root

su
synaptic

Once you have opened synaptic, it will refresh its file list from the repositories you have listed.Well i guess its Greek and Latin to you right now, let me tell you in a more simplified manner.

Damn wtf is a repository ?

We can define a repository as a server which acts as a database, containing all the .deb packages needed to install anything in Debian.You can think of it as a source of the .deb files you need.instead of searching all over the net the Debian guys thought it would be much cooler if they could place all the packages at the same place so they came up with the idea of repositories.There are many repositories all over the world which maintain numerous Debian packages.All you need to do is open synaptic and add these repositories in the list.

To change or add repositories click on settings and then select repositories from that.A new window will open up, where you can add the repositories you like.


Ok now how do i get the repository address ?

Well thats not a big thing , just hop on to web and Google for them , else just go on to www.apt-get.org and search for the packages you need, and whoa you have a full list of repos with the packages you need :)

OK how do I install now ?

Since you have already added the repos, and hopefully have configured your web settings for synaptic its installation time.But before we go ahead , just click on the reload button on top left to refresh the file list from the repos.Now you are ready for the force.Well everything is in front of you.Let me demonstrate the usage through an example.

I want to install xmms player.So i click cltr+f, type in xmms and thats it, i end up with the list of the files with the word xmms in them.


Now all you need to do is right click on the packages you want to install and select the install package option.All the dependencies would be automatically installed , you need not worry about them :-) Once you have marked the required packages just click on apply, whoa thats it done, you have installed xmms on your system.

I hope that clears all your doubts regarding usage of synaptic.




Tuesday, October 10, 2006

Package installation in Linux

Well this article is meant for novices in Linux .....
For the starters most of the linux distros are classified based on the package manager they use.

RPM
RPM of Red Hat Packagemanager is the package-manger for Red Hat, Fedora,Mandriva/Mandrake,Centos,Suse etc.

DPKG
DPKG or Debian package manager is the ladder for Debian,Ubuntu,Kubuntu,Dam Small Linux, Knoppix, E-Live etc.

Portage
Well actually we can't define it as a package manger, its based on BSD's port system and is used by my favourite Gentoo :-)) ....Slackware is also of the same kind in terms that it compiles from source like gentoo but it dosen't use portage(well i have no idea wat is the package manger for slackware :O )....

OK WTF r all these ?
In the beginning there was the .tar.gz. Users had to compile each program that they wanted to use on their GNU/Linux systems(well gentoo n slackware users still do it) ..When Debian/Red Hat were created, it was deemed necessary that the system include a method of managing the packages installed on the machine. The name dpkg /rpm were given to the system. I'm not sure wheteher rpm came first or dpkg ..well its upto u to decide.
These packages can be deemed as prepackaged binary stuff for a defined system ..for instance for an i3b6 system the rpm package will be different from that for an amd64 system.because they are filled with pre-defined data for a particular system, unlike the tar.gz package s which are the source codes , and hence can be compiled on any system .. :)(yohooo gentoo wins here hands down)...but the problem with the source packages like tar.gz is that they take a lot of time to compile and install ...and above that manging different versions is a pain in arse ..hence the package managers became very famous ....as the rpm/deb packages are easy to handle and install compared to their lethargic source code bros ....

Ok how do I install an rpm package
Download the rpm package u want to install, for instance if you want to install firefox just search for firefox1.5.i386.rpm package(considering that urs is an i386 machine) .... type the following command in terminal

rpm -i firefox1.5.i386.rpm

That's it , pardon me if there's any mistake since it has been ages since i worked on a red hat system ...
i forgot to mention one can use an interface called yum if u don't wan't to manually download stuff from net ...unluckily i have never used it so i can't advice u on that ....

Wat the fkcu to do with dpkg
Well Debian users have a host of options to select from .Debian based user's should download a package with .deb extension just same as red hat users use.rpm package.Once u download the required .deb package type the following command in terminal
dpkg -i *.deb

Well that's for active guys who wanna give some pain to their fingers by browsing net for packages.For lazy bumps and intellectually superior guys like me i would suggest using apt-get.

more on apt on next blog ...... :)

Sunday, August 27, 2006

pam-login (is blocking sys-apps/shadow-4.0.15-r2)

After doing an “emerge –puD world” on my Gentoo box, the following error appeared and wouldn’t let me update my system: sys-apps/pam-login (is blocking sys-apps/shadow-4.0.14-r2)

So I searched the internet and tried a few things and found this solution, that seemed to help a lot of people:

emerge –buildpkgonly –nodeps shadow && emerge -C pam-login && emerge –usepkgonly shadow

After executing the above, my system was ready to go again. Hope this one helps a few people.

For more info on the above topic do check out the gentoo forums.

Thursday, August 24, 2006

CPU Naming schemes

Generally people always have a confusion regarding the nomenclature of CPU architectures , hence here I have tried to clear sum of those doubts her in this blog.

The X86 processors started with the Intel 8086 processor way back in 1978. Intel released the Intel 386 (i386) in 1980. That was then followed by he 486 (i486), the Pentium (i586), and the Pentium Pro/2/3/4 (i686). At the same time, rival AMD released their Athlon/Duron/T-bird (also i686). So irrespective of the fact whether you have a P4 machine or an AMD athlon they have the same architecture as i686.

The Pentium Celeron is also an X86 processor. The difference between a Pentium/Celeron and an Athlon/Duron or Athlon/Sempron is that Pentium and Athlon are the top-performing, more expensive models whereas the Celeron/Duron/Sempron are cheaper, less powerful chips. They are not a different architecture however.

Since all these processors were based on the same architecture (basically they read/wrote 1's and 0's in the same way), and their names all contained "86", the whole family was collectively called "X86". All the X86 processors including and after the 386 are 32-bit.

The recent trend has been to move toward 64-bit processors, and several different architectures popped up. DEC's Alpha and Motorola's PPC chips have been 64-bit for a while, but Intel's Itanium and Xeon and AMD's Athlon64 are the new kids on the block.

The difference between the Itanium (IA64) and PowerPC (PPC) versus the Athlon64 is that the Itanium and PPC have completely different architectures (they speak different 1 and 0 languages), whereas the Athlon64 speaks the same language as the 32-bit X86 processors, but adds 64-bit memory registers. Therefore the name of the Athlon64 in generic terms is "X86_64".

Intel, not to be outdone, has since redesigned its 64-bit Xeon processors to use the same kind of architecture as the Athlon64, calling it "Intel Extended Memory 64 Technology" (EM64T). Basically they couldn't say they copied AMD without being laughed at in irony (since AMD got its start by simply copying Intel's chips). Both the AMD64 and the Intel EM64T processors are collectively called "X86_64".

Hope this clears the confusion for most of you . in case you stll lingering with the thoughts of what the hell went on ...then dude just chill out have a coffeee and dump your computer in sea.

Tuesday, August 15, 2006

Debian 4.0

Great news for all Debian lovers, the Debian project confirms December 2006 as the date for the next release of its distribution which will be named

Debian GNU/Linux 4.0 alias 'etch'
. This will be the first official release to include the AMD64 architecture. The distribution will be released synchronously for 11 architectures in total.

At this stage, the upcoming release will ship with Linux 2.6.17 as its default kernel. This kernel will be used across all architectures and on the installer. A later version may be selected during a review in October.

New features of this release include the GNU Compiler Collection 4.1 as default compiler. X.Org will replace XFree86 as implementation of the X Window System X11. Secure APT will add extra security by easily supporting strong cryptography and digital signatures to validate downloaded packages.


Tuesday, May 30, 2006

Shifted 2 Gentoo

Dear friends , I have installed Gentoo on my system in place of Debian and from now on it would be all about gentoo in my blogs unless until I change it again .......... :)

Friday, May 19, 2006

Check ur Linux MAC address

On Linux, you can use the ioctl SIOCGIFHWADDR, an open socket and an ifreq structure to retrieve information on any network interface. The MAC address is stored on the ifr_hwaddr member of the ifreq structure:


#include
#include
#include
#include
#include
#include

int main(int argc,char** argv)
{
int fd;
struct ifreq ifbuf;
struct sockaddr_in sa;
unsigned char* hwaddr;

fd = socket(AF_INET, SOCK_DGRAM, 0);

strcpy(ifbuf.ifr_name,argv[1]?argv[1]:"eth0");
ioctl(fd,SIOCGIFHWADDR,&ifbuf);

hwaddr = (unsigned char*) ifbuf.ifr_hwaddr.sa_data;

printf("%2.2X:%2.2X:%2.2X:%2.2X:%2.2X:%2.2X\n",hwaddr[0],hwaddr[1],hwaddr[2],hwaddr[3],hwaddr[4],hwaddr[5]);

return 0;
}

soumya@abracadabra:~/codes/cpp$ gcc -o sucket_out sucket.c
soumya@abracadabra:~/codes/cpp$ ./sucket_out
00:0E:A6:64:2D:39

Tuesday, May 16, 2006

Colourful GREP


This is how GNU defines GREP
" The grep command searches one or more input files for lines containing a match to a specified pattern. By default, grep prints the matching lines. "

grep basically searches. To be more precise,

grep bacteria food returns all the lines that contain a string matching the expression "bacteria" in the file "food".
If we assume an expression as a string. So grep returns all matching lines that contain bacteria as a substring.

Another way of using grep is to have it accept data through STDIN. instead of having it search a file. For example,

ls |grep vindo lists all files in the current directory whose names contain the string "vindo"


Now I guess you know how grep works.In case you are still in doubt about GREP please ask Mr.Google. My main objective of writing this blog is to introduce the normal unix users to the colourful version of grep.So when u search for the term it will become automatically highlighted. Just check out the sreenshot on top.

How can I do it ?

Well one just needs to edit his/her .bashrc file and put up an alias for grep.

alias G=' grep -ni --color=auto '

That's it done .Your colourfull grep is ready for use :)

Saturday, May 13, 2006

Who copied whom



Take a look at new Yahoo Mail beta version and at the some other application called Zimbra. Who copied whom ??

Tuesday, May 09, 2006

Distcc and increasing compiling speed

Distcc allows you to easily distribute your compilation jobs over a number of machines, so even if u have an outdated system still u can compile huge codes pretty fast if u have hooked up ur system with some other using distcc.

The requirments are minimal:

  • Install GCC and distcc on all the machines you wish to use for the "compile farm".

As you can see there are no onerous requirements, common with distributed work. Specifically:

  • You don't need to have the same libraries and development packages on all systems.
  • You don't need to have a single filesystem which all machines can access.
  • The clocks on all the machines don't need to be in sync.
Use apt-get 2 install distcc:

apt-get install distcc

When the package is installed you'll be asked two questions :

  • Should distcc be started on boot?
    • Answer yes if think you will wish to use the package often, or no if not. (No is the default)
  • Which machines should be allowed to connect to the distcc server?
    • Asnwer with the machines you wish to allow, and the localhost

The answers you give will be stored away in the configuration file /etc/default/distcc.

Install the package on all the other machines you wish to use and make sure that each one is allowed to connect to the other.

There are several ways you can specify the hosts which should be used to perform the compilation:

  • Via the environmental variable "DISTCC_HOSTS"
  • Via the a per-user configuration file ~/.distcc/hosts

Assuming that you have two machines appy and abracadabra and wish to compile a job you could run using distcc as follows:

soumya@abracadabra:~/tmp$ export DISTCC_HOSTS="appy abracadabra"
soumya@abracadabra:~/tmp$ make CC=distcc

This specifies the two machines you wish to use for the compilation, and runs make telling it to use distcc as the compiler.

Once you do this you should find that the jobs are spread fairly evenly across the two machines.

Once you've installed the distcc program on each machine you must:

  • Tell the local instance which machines it can contact to compile files upon remotely.
  • Make sure you use "distcc" instead of "gcc" as the compiler command in your Makefile / build system.

Tats it done, now u need not go for coffee while compiling codes :)

Thursday, April 20, 2006

Installing Sun's Java on Debian

Why Sun's Java

There are many applications in Debian which need Java SDK or JRE to function properly , specifically Sun's java environment.Most of these applications are as expected web based applications , and unluckily Sun's java packages are not available directly for debian systems.

So what's the problem dude ?

Sun's java environment package for Linux is available in .bin format and not in .deb format.Whie there is nothing wrong with installing software outside the control of the Debian packaging system, it's not something that should be undertaken lightly as it makes it hard to keep track of installations, and it complicates updating a number of machines from a centralised Debian package repository.

So wats the fucking solution ?

Thankfully there are facilities available which make it a simple job to install Sun's Java as a Debian package.

Two packages we're going to need are java-package and fakeroot. These can be installed simply by typing the following in the terminal:

apt-get install fakeroot java-package

Once the relevent packages have been installed you will need to download the Sun release of the Java package from http://java.sun.com .

Once you agreed to the license presented to you, and have downloaded the file you will have something like jre-1_5_0_03-linux-i586.bin.

To turn this into a Debian package you should run:

fakeroot make-jpkg jre-1_5_0_03-linux-i586.bin
This command will first prompt for confirmation, then :
  • Ask you for your name
  • Ask you for your email address
  • Display a license agreement:
    • Press Space to scroll down, or q to quit.
    • Type "yes" to indicate you agree with the terms.

(The name, and email address, you give will be inserted into the Debian package information - and not sent to Sun.)

Once these questions have been answered the process will inform you that your package has been built shortly afterwards. The final output you should expect to see will look something like this:

The Debian package has been created in the current directory. You can
install the package as root (e.g. dpkg -i sun-j2re1.5_1.5.0+update03_i386.deb).

As the instructions tell you it is now possible for you to install the package by becoming root and running:

dpkg -i sun-j2re1.5_1.5.0+update03_i386.deb

One final step might be for you to ensure the Java software works for Mozilla Firefox, or the Mozilla browser.

The package you've installed should include a plugin for your browser. At the time of writing the most recent Sun Java version we've been using will install a plugin for you at the following location:

/usr/lib/j2re1.5-sun/plugin/i386/ns7/libjavaplugin_oji.so

Create a symlink to this directory in your home directory:

ln -s /usr/lib/j2re1.5-sun/plugin/i386/ns7/libjavaplugin_oji.so  ~/.mozilla/plugins/

If you wish to do this for all users on the current system instead run, as root:

ln -s /usr/lib/j2re1.5-sun/plugin/i386/ns7/libjavaplugin_oji.so \
/usr/lib/mozilla/plugins/

(You might find that the plugin has been automatically installed for all users - so it's worth checking whether you need to complete this last step yourself.)


PS
All the above information was gathered by me from the following website http://www.debian-administration.org

Wednesday, April 12, 2006

Restoring grub for debian

Many Debian newbies often have to reinstall f***ing Windows on the same machine where Debian is installed. Usually the Windows installation does not take care of the Debian booting process, overwriting the master boot record with Windows.There are several ways to recover the grub , but here I will mention the method used by me when I had the same problem.


All that you would need for this is a live CD of any debian based Linux distro like Ubuntu or Knoppix.Once u have a live CD with you just follow the next few steps.
  • Boot from the Live CD( I used Ubuntu CD)
  • Once you are logged in open the terminal.
  • Login as root (type sudo su in Ubuntu) and type cfdisk and check out what is your boot partition (eg. hda8)
  • Make a new directory to mount the boot partition, for example /disk.
  • In case you don't have seperate /boot partition then mount the root partition or / to /disk using the following command

    mount /dev/hda
    x /disk

    x refers to teh boot or root partition.
  • Do a chroot to the root partition by typing

    chroot /disk

  • Type grub and enter grub shell.
  • Type in the root disk for grub, for example

    root (hd0,7)

    This is /dev/hda8 on my system.
  • Type the following command to install grub on /dev/hda

    setup (hd0)

  • Type quit, exit from chroot, unmount all disks and reboot.

Thursday, March 02, 2006

vimrc

Generally vim is the preferred editor for experienced coders , but newbies always find it difficult to handle .Although the initial learning curve is pretty steep , but it resides once you get used to it.By default there is no vimrc file ... u need to crete one and put it in the homefolder.The vimrc file helps to configure the properties of vim.A sample vimrc file has been put below ....

autocmd!


" * Terminal Settings

" `XTerm', `RXVT', `Gnome Terminal', and `Konsole' all claim to be "xterm";
" `KVT' claims to be "xterm-color":
if &term =~ 'xterm'

" `Gnome Terminal' fortunately sets $COLORTERM; it needs and
" fixing, and it has a bug which causes spurious "c"s to appear, which can be
" fixed by unsetting t_RV:
if $COLORTERM == 'gnome-terminal'
execute 'set t_kb=' . nr2char(8)
" [Char 8 is +H.]
fixdel
set t_RV=

" `XTerm', `Konsole', and `KVT' all also need and fixing;
" there's no easy way of distinguishing these terminals from other things
" that claim to be "xterm", but `RXVT' sets $COLORTERM to "rxvt" and these
" don't:
elseif $COLORTERM == ''
execute 'set t_kb=' . nr2char(8)
fixdel

" The above won't work if an `XTerm' or `KVT' is started from within a `Gnome
" Terminal' or an `RXVT': the $COLORTERM setting will propagate; it's always
" OK with `Konsole' which explicitly sets $COLORTERM to "".

endif
endif


" * User Interface

" have syntax highlighting in terminals which can display colours:
if has('syntax') && (&t_Co > 2)
syntax on
endif

" have fifty lines of command-line (etc) history:
set history=50
" remember all of these between sessions, but only 10 search terms; also
" remember info for 10 files, but never any on removable disks, don't remember
" marks in files, don't rehighlight old search patterns, and only save up to
" 100 lines of registers; including @10 in there should restrict input buffer
" but it causes an error for me:
set viminfo=/10,'10,r/mnt/zip,r/mnt/floppy,f0,h,\"100

" have command-line completion (for filenames, help topics, option names)
" first list the available options and complete the longest common part, then
" have further s cycle through the possibilities:
set wildmode=list:longest,full

" use "[RO]" for "[readonly]" to save space in the message line:
set shortmess+=r

" display the current mode and partially-typed commands in the status line:
set showmode
set showcmd

" when using list, keep tabs at their full width and display `arrows':
execute 'set listchars+=tab:' . nr2char(187) . nr2char(183)
" (Character 187 is a right double-chevron, and 183 a mid-dot.)

" have the mouse enabled all the time:
set mouse=a

" don't have files trying to override this .vimrc:
set nomodeline


" * Text Formatting -- General

" don't make it look like there are line breaks where there aren't:
set nowrap

" use indents of 2 spaces, and have them copied down lines:
set shiftwidth=2
set shiftround
set expandtab
set autoindent

" normally don't automatically format `text' as it is typed, IE only do this
" with comments, at 79 characters:
set formatoptions-=t
set textwidth=79

" get rid of the default style of C comments, and define a style with two stars
" at the start of `middle' rows which (looks nicer and) avoids asterisks used
" for bullet lists being treated like C comments; then define a bullet list
" style for single stars (like already is for hyphens):
set comments-=s1:/*,mb:*,ex:*/
set comments+=s:/*,mb:**,ex:*/
set comments+=fb:*

" treat lines starting with a quote mark as comments (for `Vim' files, such as
" this very one!), and colons as well so that reformatting usenet messages from
" `Tin' users works OK:
set comments+=b:\"
set comments+=n::


" * Text Formatting -- Specific File Formats

" enable filetype detection:
filetype on

" recognize anything in my .Postponed directory as a news article, and anything
" at all with a .txt extension as being human-language text [this clobbers the
" `help' filetype, but that doesn't seem to prevent help from working
" properly]:
augroup filetype
autocmd BufNewFile,BufRead */.Postponed/* set filetype=mail
autocmd BufNewFile,BufRead *.txt set filetype=human
augroup END

" in human-language files, automatically format everything at 72 chars:
autocmd FileType mail,human set formatoptions+=t textwidth=72

" for C-like programming, have automatic indentation:
autocmd FileType c,cpp,slang set cindent

" for actual C (not C++) programming where comments have explicit end
" characters, if starting a new line in the middle of a comment automatically
" insert the comment leader characters:
autocmd FileType c set formatoptions+=ro

" for Perl programming, have things in braces indenting themselves:
autocmd FileType perl set smartindent

" for CSS, also have things in braces indented:
autocmd FileType css set smartindent

" for HTML, generally format text, but if a long line has been created leave it
" alone when editing:
autocmd FileType html set formatoptions+=tl

" for both CSS and HTML, use genuine tab characters for indentation, to make
" files a few bytes smaller:
autocmd FileType html,css set noexpandtab tabstop=2

" in makefiles, don't expand tabs to spaces, since actual tab characters are
" needed, and have indentation at 8 chars to be sure that all indents are tabs
" (despite the mappings later):
autocmd FileType make set noexpandtab shiftwidth=8


" * Search & Replace

" make searches case-insensitive, unless they contain upper-case letters:
set ignorecase
set smartcase

" show the `best match so far' as search strings are typed:
set incsearch

" assume the /g flag on :s substitutions to replace all matches in a line:
set gdefault


" * Spelling

" define `Ispell' language and personal dictionary, used in several places
" below:
let IspellLang = 'british'
let PersonalDict = '~/.ispell_' . IspellLang

" try to avoid misspelling words in the first place -- have the insert mode
" +N/+P keys perform completion on partially-typed words by
" checking the Linux word list and the personal `Ispell' dictionary; sort out
" case sensibly (so that words at starts of sentences can still be completed
" with words that are in the dictionary all in lower case):
execute 'set dictionary+=' . PersonalDict
set dictionary+=/usr/dict/words
set complete=.,w,k
set infercase

" correct my common typos without me even noticing them:
abbreviate teh the
abbreviate spolier spoiler
abbreviate Comny Conmy
abbreviate atmoic atomic

" Spell checking operations are defined next. They are all set to normal mode
" keystrokes beginning \s but function keys are also mapped to the most common
" ones. The functions referred to are defined at the end of this .vimrc.

" \si ("spelling interactive") saves the current file then spell checks it
" interactively through `Ispell' and reloads the corrected version:
execute 'nnoremap \si :w:!ispell -x -d ' . IspellLang . ' %:e'

" \sl ("spelling list") lists all spelling mistakes in the current buffer,
" but excludes any in news/mail headers or in ("> ") quoted text:
execute 'nnoremap \sl :w ! grep -v "^>" grep -E -v "^[[:alpha:]-]+: " ' .
\ ' ispell -l -d ' . IspellLang . ' sort uniq'

" \sh ("spelling highlight") highlights (in red) all misspelt words in the
" current buffer, and also excluding the possessive forms of any valid words
" (EG "Lizzy's" won't be highlighted if "Lizzy" is in the dictionary); with
" mail and news messages it ignores headers and quoted text; for HTML it
" ignores tags and only checks words that will appear, and turns off other
" syntax highlighting to make the errors more apparent [function at end of
" file]:
nnoremap \sh :call HighlightSpellingErrors()
nmap \sh

" \sc ("spelling clear") clears all highlighted misspellings; for HTML it
" restores regular syntax highlighting:
nnoremap \sc :if &ft == 'html' sy on
\ else :sy clear SpellError endif
nmap \sc

" \sa ("spelling add") adds the word at the cursor position to the personal
" dictionary (but for possessives adds the base word, so that when the cursor
" is on "Ceri's" only "Ceri" gets added to the dictionary), and stops
" highlighting that word as an error (if appropriate) [function at end of
" file]:
nnoremap \sa :call AddWordToDictionary()
nmap \sa


" * Keystrokes -- Moving Around

" have the h and l cursor keys wrap between lines (like and do
" by default), and ~ covert case over line breaks; also have the cursor keys
" wrap in insert mode:
set whichwrap=h,l,~,[,]

" page down with (like in `Lynx', `Mutt', `Pine', `Netscape Navigator',
" `SLRN', `Less', and `More'); page up with - (like in `Lynx', `Mutt', `Pine'),
" or (like in `Netscape Navigator'):
noremap
noremap
noremap -
" [ by default is like l, like h, and - like k.]

" scroll the window (but leaving the cursor in the same place) by a couple of
" lines up/down with / (like in `Lynx'):
noremap 2
noremap 2
" [ by default is like i, and like x.]

" use to cycle through split windows (and + to cycle backwards,
" where possible):
nnoremap w
nnoremap W

" use +N/+P to cycle through files:
nnoremap :next
nnoremap :prev
" [+N by default is like j, and +P like k.]

" have % bounce between angled brackets, as well as t'other kinds:
set matchpairs+=<:>

" have prompt for a help topic, rather than displaying the introduction
" page, and have it do this from any mode:
nnoremap :help
vmap
omap
map!


" * Keystrokes -- Formatting

" have Q reformat the current paragraph (or selected text if there is any):
nnoremap Q gqap
vnoremap Q gq

" have the usual indentation keystrokes still work in visual mode:
vnoremap >
vnoremap
vmap
vmap

" have Y behave analogously to D and C rather than to dd and cc (which is
" already done by yy):
noremap Y y$


" * Keystrokes -- Toggles

" Keystrokes to toggle options are defined here. They are all set to normal
" mode keystrokes beginning \t but some function keys (which won't work in all
" terminals) are also mapped.

" have \tp ("toggle paste") toggle paste on/off and report the change, and
" where possible also have do this both in normal and insert mode:
nnoremap \tp :set invpaste paste?
nmap \tp
imap \tp
set pastetoggle=

" have \tf ("toggle format") toggle the automatic insertion of line breaks
" during typing and report the change:
nnoremap \tf :if &fo =~ 't' set fo-=t else set fo+=t
\ endif set fo?
nmap \tf
imap \tf

" have \tl ("toggle list") toggle list on/off and report the change:
nnoremap \tl :set invlist list?
nmap \tl

" have \th ("toggle highlight") toggle highlighting of search matches, and
" report the change:
nnoremap \th :set invhls hls?


" * Keystrokes -- Insert Mode

" allow to delete line breaks, beyond the start of the current
" insertion, and over indentations:
set backspace=eol,start,indent

" have (and + where it works) change the level of
" indentation:
inoremap
inoremap
" [+V still inserts an actual tab character.]

" abbreviations:
iabbrev lfpg Llanfairpwllgwyngyllgogerychwyrndrobwllllantysiliogogogoch
iabbrev hse he/she
iabbrev sm Smylers


" * Keystrokes -- For HTML Files

" Some automatic HTML tag insertion operations are defined next. They are
" allset to normal mode keystrokes beginning \h. Insert mode function keys are
" also defined, for terminals where they work. The functions referred to are
" defined at the end of this .vimrc.

" \hc ("HTML close") inserts the tag needed to close the current HTML construct
" [function at end of file]:
nnoremap \hc :call InsertCloseTag()
imap \hca

" \hp ("HTML previous") copies the previous (non-closing) HTML tag in full,
" including attributes; repeating this straight away removes that tag and
" copies the one before it [function at end of file]:
nnoremap \hp :call RepeatTag(0)
imap \hpa
" \hn ("HTML next") does the same thing, but copies the next tag; so \hp and
" \hn can be used to cycle backwards and forwards through the tags in the file
" (like +P and +N do for insert mode completion):
nnoremap \hn :call RepeatTag(1)
imap \hna

" there are other key mappings that it's useful to have for typing HTML
" character codes, but that are definitely not wanted in other files (unlike
" the above, which won't do any harm), so only map these when entering an HTML
" file and unmap them on leaving it:
autocmd BufEnter * if &filetype == "html" | call MapHTMLKeys() | endif
function! MapHTMLKeys(...)
" sets up various insert mode key mappings suitable for typing HTML, and
" automatically removes them when switching to a non-HTML buffer

" if no parameter, or a non-zero parameter, set up the mappings:
if a:0 == 0 || a:1 != 0

" require two backslashes to get one:
inoremap \\ \

" then use backslash followed by various symbols insert HTML characters:
inoremap \& &amp;
inoremap \< <
inoremap \> >
inoremap \. ·

" em dash -- have \- always insert an em dash, and also have _ do it if
" ever typed as a word on its own, but not in the middle of other words:
inoremap \- —
iabbrev _ —

" hard space with +Space, and \ for when that doesn't work:
inoremap \
imap \

" have the normal open and close single quote keys producing the character
" codes that will produce nice curved quotes (and apostophes) on both Unix
" and Windows:
inoremap ` ‘
inoremap ' ’
" then provide the original functionality with preceding backslashes:
inoremap \` `
inoremap \' '

" curved double open and closed quotes (2 and " are the same key for me):
inoremap \2 “
inoremap \" ”

" when switching to a non-HTML buffer, automatically undo these mappings:
autocmd! BufLeave * call MapHTMLKeys(0)

" parameter of zero, so want to unmap everything:
else
iunmap \\
iunmap \&
iunmap \<
iunmap \>
iunmap \-
iunabbrev _
iunmap \
iunmap
iunmap `
iunmap '
iunmap \`
iunmap \'
iunmap \2
iunmap \"

" once done, get rid of the autocmd that called this:
autocmd! BufLeave *

endif " test for mapping/unmapping

endfunction " MapHTMLKeys()


" * `SLRN' Behaviour

" when using `SLRN' to compose a new news article without a signature, the
" cursor will be at the end of the file, the blank line after the header, so
" duplicate this line ready to start typing on; when composing a new article
" with a signature, `SLRN' includes an appropriate blank line but places the
" cursor on the following one, so move it up one line [if re-editing a
" partially-composed article, `SLRN' places the cursor on the top line, so
" neither of these will apply]:
autocmd VimEnter .article if line('.') == line('$') | yank | put |
\ elseif line('.') != 1 | -

" when following up articles from people with long names and/or e-mail
" addresses, the `SLRN'-generated attribution line can have over 80 characters,
" which will then cause `SLRN' to complain when trying to post it(!), so if
" editing a followup for the first time, reformat the line (then put the cursor
" back):
autocmd VimEnter .followup if line('.') != 1 | normal gq${j


" * Functions Referred to Above

function! HighlightSpellingErrors()
" highlights spelling errors in the current window; used for the \sh operation
" defined above;
" requires the ispell, sort, and uniq commands to be in the path;
" requires the global variable IspellLang to be defined above, and to contain
" the preferred `Ispell' language;
" for mail/news messages, requires the grep command to be in the path;
" for HTML documents, saves the file to disk and requires the lynx command to
" be in the path
"
" by Smylers http://www.stripey.com/vim/
" (inspired by Krishna Gadepalli and Neil Schemenauer's vimspell.sh)
"
" 2000 Jun 1: for `Vim' 5.6

" for HTML files, remove all current syntax highlighting (so that
" misspellings show up clearly), and note it's HTML for future reference:
if &filetype == 'html'
let HTML = 1
syntax clear

" for everything else, simply remove any previously-identified spelling
" errors (and corrections):
else
let HTML = 0
if hlexists('SpellError')
syntax clear SpellError
endif
if hlexists('Normal')
syntax clear Normal
endif
endif

" form a command that has the text to be checked piping through standard
" output; for HTML files this involves saving the current file and processing
" it with `Lynx'; for everything else, use all the buffer except quoted text
" and mail/news headers:
if HTML
write
let PipeCmd = '! lynx --dump --nolist % |'
else
let PipeCmd = 'write !'
if &filetype == 'mail'
let PipeCmd = PipeCmd . ' grep -v "^> " | grep -E -v "^[[:alpha:]-]+:" |'
endif
endif

" execute that command, then generate a unique list of misspelt words and
" store it in a temporary file:
let ErrorsFile = tempname()
execute PipeCmd . ' ispell -l -d '. g:IspellLang .
\ ' | sort | uniq > ' . ErrorsFile

" open that list of words in another window:
execute 'split ' . ErrorsFile

" for every word in that list ending with "'s", check if the root form
" without the "'s" is in the dictionary, and if so remove the word from the
" list:
global /'s$/ execute 'read ! echo ' . expand('') .
\ ' | ispell -l -d ' . g:IspellLang | delete
" (If the root form is in the dictionary, ispell -l will have no output so
" nothing will be read in, the cursor will remain in the same place and the
" :delete will delete the word from the list. If the root form is not in the
" dictionary, then ispell -l will output it and it will be read on to a new
" line; the delete command will then remove that misspelt root form, leaving
" the original possessive form in the list!)

" only do anything if there are some misspellings:
if strlen(getline('.')) > 0

" if (previously noted as) HTML, replace each non-alphanum char with a
" regexp that matches either that char or a &...; entity:
if HTML
% substitute /\W/\\(&\\|\&\\(#\\d\\{2,4}\\|\w\\{2,8}\\);\\)/e
endif

" turn each mistake into a `Vim' command to place it in the SpellError
" syntax highlighting group:
% substitute /^/syntax match SpellError !\\
% substitute /$/\\>!/
endif

" save and close that file (so switch back to the one being checked):
exit

" make syntax highlighting case-sensitive, then execute all the match
" commands that have just been set up in that temporary file, delete it, and
" highlight all those words in red:
syntax case match
execute 'source ' . ErrorsFile
call delete(ErrorsFile)
highlight SpellError term=reverse ctermfg=DarkRed guifg=Red

" with HTML, don't mark any errors in e-mail addresses or URLs, and ignore
" anything marked in a fix-width font (as being computer code):
if HTML
syntax case ignore
syntax match Normal !\<[[:alnum:]._-]\+@[[:alnum:]._-]\+\.\a\+\>!
syntax match Normal
\ !\<\(ht\|f\)tp://[-[:alnum:].]\+\a\(/[-_.[:alnum:]/#&=,]*\)\=\>!
syntax region Normal start=!

! end=!
!
syntax region Normal start=!! end=!!
syntax region Normal start=!! end=!!
endif

endfunction " HighlightSpellingErrors()


function! AddWordToDictionary()
" adds the word under the cursor to the personal dictonary; used for the \sa
" operation defined above;
" requires the global variable PersonalDict to be defined above, and to contain
" the `Ispell' personal dictionary;
"
" by Smylers http://www.stripey.com/vim/
"
" 2000 Apr 30: for `Vim' 5.6

" get the word under the cursor, including the apostrophe as a word character
" to allow for words like "won't", but then ignoring any apostrophes at the
" start or end of the word:
set iskeyword+='
let Word = substitute(expand(''), "^'\\+", '', '')
let Word = substitute(Word, "'\\+$", '', '')
set iskeyword-='

" override any SpellError highlighting that might exist for this word,
" `highlighting' it as normal text:
execute 'syntax match Normal #\<' . Word . '\>#'

" remove any final "'s" so that possessive forms don't end up in the
" dictionary, then add the word to the dictionary:
let Word = substitute(Word, "'s$", '', '')
execute '!echo "' . Word . '" >> ' . g:PersonalDict

endfunction " AddWordToDictionary()


function! InsertCloseTag()
" inserts the appropriate closing HTML tag; used for the \hc operation defined
" above;
" requires ignorecase to be set, or to type HTML tags in exactly the same case
" that I do;
" doesn't treat

as something that needs closing;
" clobbers register z and mark z
"
" by Smylers http://www.stripey.com/vim/
" 2000 May 4

if &filetype == 'html'

" list of tags which shouldn't be closed:
let UnaryTags = ' Area Base Br DD DT HR Img Input LI Link Meta P Param '

" remember current position:
normal mz

" loop backwards looking for tags:
let Found = 0
while Found == 0
" find the previous <, then go forwards one character and grab the first
" character plus the entire word:
execute "normal ?\\l"
normal "zyl
let Tag = expand('')

" if this is a closing tag, skip back to its matching opening tag:
if @z == '/'
execute "normal ?\" . Tag . "\"

" if this is a unary tag, then position the cursor for the next
" iteration:
elseif match(UnaryTags, ' ' . Tag . ' ') > 0
normal h

" otherwise this is the tag that needs closing:
else
let Found = 1

endif
endwhile " not yet found match

" create the closing tag and insert it:
let @z = ''
normal `z
if col('.') == 1
normal "zP
else
normal "zp
endif

else " filetype is not HTML
echohl ErrorMsg
echo 'The InsertCloseTag() function is only intended to be used in HTML ' .
\ 'files.'
sleep
echohl None

endif " check on filetype

endfunction " InsertCloseTag()


function! RepeatTag(Forward)
" repeats a (non-closing) HTML tag from elsewhere in the document; call
" repeatedly until the correct tag is inserted (like with insert mode +P
" and +N completion), with Forward determining whether to copy forwards
" or backwards through the file; used for the \hp and \hn operations defined
" above;
" requires preservation of marks i and j;
" clobbers register z
"
" by Smylers http://www.stripey.com/vim/
"
" 2000 May 4: for `Vim' 5.6

if &filetype == 'html'

" if the cursor is where this function left it, then continue from there:
if line('.') == line("'i") && col('.') == col("'i")
" delete the tag inserted last time:
if col('.') == strlen(getline('.'))
normal dF
else
normal dF
if col('.') != 1
normal h
endif
endif
" note the cursor position, then jump to where the deleted tag was found:
normal mi`j

" otherwise, just store the cursor position (in mark i):
else
normal mi
endif

if a:Forward
let SearchCmd = '/'
else
let SearchCmd = '?'
endif

" find the next non-closing tag (in the appropriate direction), note where
" it is (in mark j) in case this function gets called again, then yank it
" and paste a copy at the original cursor position, and store the final
" cursor position (in mark i) for use next time round:
execute "normal " . SearchCmd . "<[^/>].\\{-}>\mj\"zyf>`i"
if col('.') == 1
normal "zP
else
normal "zp
endif
normal mi

else " filetype is not HTML
echohl ErrorMsg
echo 'The RepeatTag() function is only intended to be used in HTML files.'
sleep
echohl None

endif

endfunction " RepeatTag()


To create the vimrc file type the following in the terminal

touch ~/.vimrc

Tuesday, February 07, 2006

Alias

Alias is a really useful command especially for lazy guys like me. Alias literally means "other name", and in linux also it serves the same purpose.When u don't wanna type long commands , what you can do is simply type an alias for it, it's just like making a shortcut.
For example, considering the folowing line

alias movie='mplayer /mnt/win_e/movies/English/Documentary.avi'

If u wanna watch a movie called Documentary which is in the folder /mnt/win_e/movies/English using mplayer , you have to type the full command within the quotes, but if u set an alias like movie, you just need to type movie in terminal.So simple and easy .The alias need not be a word , u can even put letters as aliases.

The aliases which u type last only for the current session, so in order to make them permanent, u need 2 add these aliases in ur bashrc file.
Go to the home folder of which ever user u wanna add the aliases.Using n-e editor open .bashrc file

vim ~/.bashrc

just add the command in the above mentioned format in the .bashrc file and save it.Next time when u restart ur comp , the alias will be a permanent fixture in your path.

few more examples for alias usage:
alias byebye='logout'


So when u type byebye , the logout command is executed. So simple isn't it.
For more info on bashrc and alias i would suggedt u Google.
Else in console type
man alias

Thursday, January 19, 2006

Freedom

In my previous blog I have mentioned about your-freedom.It is a pretty good software used for tunneling, and its GUI does help a lot.Generally the GCJ package available in most of the Linux distros( Fedora and Debian in particular ) do not support the your-freedom applet as well as the Sun's JDK package.Download the latest JDK edition from the Sun's home page.follow the instructions given on that page.

Follow the given instructions in order to make your-freedom work on ur PC

  • I assume that you have installed it in /usr/local/java/
  • type /usr/local/java/jdk1.5/bin/java -jar your-freedom-folder/freedom.jar
You can set an alias for the full command .Aliases are shortcuts, you can assign any command to perform a given task, more on aliases later.Open ~/.bashrc file and add the following line

alias x='/usr/local/java/jdk1.5/bin/java -jar your-freedom-folder/freedom.jar'

The above command adds x in your commands list.Next time you open your terminal u just need to type "x".You need not ype x , you can put any other character as well , but make sure that its not a system command.

Open gaim and in preferences change the proxy settings to SOCKS 5 and the server address as 127.0.0.1 and port 1080.In the yahoo pager address port you have to add 119 , and select proxy settings as SOCKS5

Thats it over your gaim is up and running.

Wednesday, January 18, 2006

Your Freedom and Tunneling

In my campus access to several ports have been blocked via the proxy servers. in general this problem can be easily overcome by using something callled tunneling.One can always forward ports through SSH by tunneling.One software that dose it pretty easily is corkscrew.Debian users can easily obtain it by typing

apt-get install corkscrew

After one install corkscrew, the ~/.ssh/config file needs to be edited( and created in case it dosen't exist). Add the following lines in the ~/.ssh/config file:

Host *
ProxyCommand corkscrew proxy_server port %h %p


the host * command specifies that this is meant for all users,in case if you wanna use it only for present user remove this line. Replace the proxy_server with the name of the proxy server in use and the corresponding port. Once it is done , one has to just type

ssh server_address

Server address refers to the host you wanna ssh through HTTP tunneling.


*********************

now y am i writing all this crap.man is the laziest creature on Earth(at least me).If you download the java package of your-freedom from the site your-freedom.net you can peacefully execute the tunneling job and it can be easily used for IM clients.Dowload the file and unzip it.Browse to the folder and type the following command
java -jar freedom.jar

in order to make it happen u need to have latest version of Sun JDK/JRE/SDK.The GCJ package which comes by default with the OS cannot handle the java work(Especially Debian and Fedora).Once you have done it ..... it will ask you the proxy settings and other things.When it is run for the first time it dose take a lot of time to look foe servers..so plz don't press the panic button in case u don't c ne thing happening........
....


TO BE CONTINUED.................