user-avatar
Today is Thursday
November 28, 2024

August 15, 2009

Check List of essential features of websites for small businesses

by viggy — Categories: Uncategorized — Tags: , , , , Leave a comment

A well written article on this subject can be found here. This is just a check–list i created after going through that web-site.
1) Basic:

  1. Thier Location
  2. Their Hours of Operation
  3. Contact Information

2) About:

  1. Business of the company
  2. Profiles of founder and other importent staff of the company.

3) Offering: Products and services

4) Portfolio: Examples of ongoing projects or previous commitments

5) NEWS Room: Articles and Accolades

6) Links: Other presence of the company on the web

7) Photo Gallery:

8) Calendar: To inform about the upcoming events

9) Blog:

10) Contact:

11) Send to Friend & share:

12) Printer Friendly Pages:

13) Email Signup:

14) E-commerce:

15) Donations:

August 2, 2009

renaissance

by viggy — Categories: Uncategorized — Tags: Leave a comment

Finally I have made my blog public again. Since I had made it private, I found no reasons to write a personal blog. Somehow I always feel that when I write a blog, it is followed by many people and they like reading it. Hope someday this will become true. :). Anyways let me update you with whats happened in my life recently.
Well I am no longer in college. Sadly my college days are over. My four years of vacation is over. It was a difficult time as I was going away from all my friends and more importantly the environment that I had become so accustomed to. However change is the rule of life.
And the change could not have been better. I have now joined a company started by one of our own seniors. It is more of fun then work. It is a very informal company and hence it could not have suited me better. Just yesterday Dabba was mentioning that it was the perfect extension after 4 years of vacation in Durgapur. What is more important to me is I have finally found programming and computer science interesting. Now I spend most of my time gaining more and more knowledge about linux and programming and it is fun. My mind always is filled with things that I am required to do and I am getting more and more confident about programming. So at present my life is going on the right track even after I wasted 4 years without getting any much knowledge. The only useful thing academically I had done during college was used linux. That was again thanks to Dabba. At present I work on perl and javascript. Please forgive me if i get any technical in this blog as nowadays I am more into it then think philosophically. But whenever I get any crazy idea or a feeling, I will mention it over here and keep most of the technical stuff to my other blog which I have started.

July 30, 2009

Customizing Terminator using terminator_config

by viggy — Categories: Uncategorized — Tags: , , , Leave a comment

After about one month since I started using Terminator as my regular console, I finally thought that it was time that I wake up from my hibernation and find some solution to the problems i faced in it which were the following:

  • The default font size was very small and I had to increase it to 4 times its size to get a normal font.
  • The colour of text was #AAAAAA, which was very dull.

So finally I searched for some solutions and indeed it was just a few minutes job.
All you need to do is edit the config file of terminator which can generally be found in “${XDG_CONFIG_HOME}/terminator/config” (usually “~/.config/terminator/config”). If this file does not exist, create it. Then you just need to add the options that you need for your Terminator. You can find the list of options from the man page of terminator_config
$man terminator_config
So I went through the man page and edited my terminator_config file. Here is what my terminator config file looked after editing.

font = Mono 14
use_theme_colors = false
background_color = black
background_darkness = 0.0
foreground_color = #00FF00
copy_on_selection = true
focus = sloppy
enable_real_transparency = true

So finally my Terminator looked normal and now I dont have any problems using it. Though I still have to do lots of customization like adding a background image.

?

July 27, 2009

Customizing VIM

by viggy — Categories: Uncategorized — Tags: , Leave a comment

Vim is an editor designed to work like that most venerable of UNIX editors, vi. Vim doesn’t just clone vi; it extends vi with features like multi-level undo, a graphical interface (if you want it), windows, block operations, on-line help and syntax coloring.

Along with the new features, Vim 5.5 (the current version as I write) has 196 options you can set. Practically any behavior you might have found obnoxious in plain vi can be configured to your liking in Vim. To download or get more information on Vim, see the Vim home page at http://www.vim.org/. Within Vim, you can view the on-line help at any time by pressing ESC, typing :help and pressing ENTER.

I’ll admit that the thought of trudging through 196 options on the off chance that one or two will do what I want might seem a bit daunting, so here are several of my favorite Vim customizations just to get you started. These customizations have saved me much frustration and helped make a regular Vim user out of me.

Saving Your Customizations

Before I talk about specific Vim customizations, however, let me explain how to save your customizations so they are loaded each time you start Vim. When you first start using Vim, it will be 100% compatible with vi. You won’t notice any of Vim’s fancy features until you activate them.

This behavior is nice: it allows system administrators to replace /bin/vi with a link to Vim without their users rising up against them screaming, “vi is broken. Fix it!” In fact, some people have used Vim for years this way without realizing they were using anything fancier than vi. But strict vi emulation can confuse people who expect to see all of Vim’s bells and whistles right from the start.

Luckily, it’s easy to convince Vim that we know we’re actually in Vim and not in vi. Vim customizations are stored in a file called .vimrc in your home directory. If Vim sees that you have a .vimrc file—even if that file is empty—Vim will turn off vi-compatibility mode, which will configure Vim as Vim, rather than vi.

If you don’t have a .vimrc file, but you do have an .exrc file that you have used to customize your vi sessions in the past, execute the command

mv ~/.exrc ~/.vimrc

to rename your .exrc file to .vimrc.

If you have neither a .exrc file nor a .vimrc file, execute the command

touch ~/.vimrc

to create an empty .vimrc file.

You’re now ready to begin configuring Vim in earnest. You can add commands to your .vimrc file in the same way you would add them to your .exrc file. That is, if you tried Vim’s incremental searching feature (which I’ll describe shortly) by pressing the ESC key and entering the command

:set incsearch

and decided you wanted to make incremental searching the default behavior for future Vim sessions, you could do it by putting the line

set incsearch

into your .vimrc file on a line by itself. Note the lack of a leading colon.

Finding it Fast: incsearch

Suppose you have the following text file to edit:

In Xanadu did Kubla Khan
A stately pleasure-dome decree:
Where Alph, the sacred river, ran
Through caverns measureless to man
Down to a sunless sea.

Your cursor is on the I in the first line. You need to get to the first occurrence of the word “measureless”. How do you do it?

One way is to press / to put Vim into search mode, type in “measureless”, and press ENTER. Vim will find the first “measureless” after the current cursor position and leave your cursor on the m. Easy, in principle, that is. I’m not such a great typist. When I try to search forward for the word “measureless”, I’m just as likely to misspell it as not. And if I misspell it as “measurless”, I won’t realize my mistake until I press ENTER and Vim returns “Pattern not found: measurless”.

I could increase my chances of typing the search pattern correctly by searching for a substring of “measureless”. For example, if I search for “measu”, I have fewer characters to type, which means fewer ways I can mistype my search pattern. However, that means I have to guess how many characters will specify a unique substring of the word I want to find. If I don’t type in enough for my search pattern, I’ll end up in the wrong location. For example, if search for “me”, I’ll end up in “pleasure-dome” on line two rather than where I want to be, which is on line four. I’d then have to search again by pressing n.

Vim’s incremental search feature can help with both of these problems. To try it out, press the ESC key to enter command mode, then type

:set incsearch

and press ENTER.

Incremental searching means that as you enter your search pattern, Vim will show you the next match as you type each letter. So when you start your search for “measureless” by pressing m, Vim will immediately search forward for the first m in the file following the current cursor position. In this case, it’s the m in “pleasure-dome” on line two. Vim will then highlight in the text the pattern it has matched so far for you. Since “pleasure-dome” isn’t where you wanted to go, you need to type more letters in your search pattern. When you press e, “pleasure-dome” still matches the substring me, so Vim will highlight the “me” in “pleasure-dome” and wait for more input. When you press a, “pleasure-dome” no longer matches the substring mea, so Vim will highlight the next match for mea, which is “measureless” on line four. Jackpot! Since that’s the word you are looking for, press ENTER, and Vim will leave your cursor on the m in “measureless”.

With incremental searching, you always know what the results of your search will be, because the results are highlighted on your screen at all times. If you misspell your search pattern, Vim will no longer show you a highlighted match for your search pattern. When your highlighted match string disappears from the screen, you know immediately that you should back up by using the BACKSPACE key, and fix your search pattern. If you change your mind about what you wish to search for, you can press the ESCAPE key, and Vim will return the cursor to its previous location.

Even Better Searching: ignorecase and smartcase

Programmers often don’t capitalize code consistently. I’m no exception here. From one program to another—and sometimes even, to my shame, within the same program—my capitalization scheme changes.

“Let’s see, was that subroutine named “CrashAndBurn”, “CRASHANDBURN”, “crashandburn” or “Crashandburn”?” If your editor is too picky about distinguishing upper-case from lower-case letters in its search patterns, you’ll have a hard time matching the string. On the other hand, sometimes case is significant, and you do want to find “CrashAndBurn” and not “crashandburn”. What to do?

By default, both vi and Vim won’t match anywhere in the text where the capitalization isn’t exactly the same as the search pattern you entered; however, we can change this default behavior. Vim has a couple of options that, when used together, can take the pain out of upper/lower-case confusion. You can try these options by pressing the ESCAPE key, then typing the following two commands, pressing ENTER after each one:

:set ignorecase
:set smartcase

The ignorecase option is supported in vi as well as in Vim. It entirely disregards upper- and lower-case distinctions in search patterns. With ignorecase set, a search for the pattern “crashandburn” will match “CrAsHaNdBuRn” and “crashANDburn” as well as “crashandburn” in the text.

This is an improvement over the default behavior in some cases, but what if I really do want to search based on case distinctions? Will I have to set and unset ignorecase each time I want to search a different way?

In vi, the answer, unfortunately, is yes. Vim is a little more subtle, though, in that it offers the smartcase option as well. If both ignorecase and smartcase are set, Vim will ignore the case of the search only if the search pattern is all in lower-case. But if there are any upper-case characters in the search pattern, Vim will assume you really want to do a case-sensitive search and will do its matching accordingly.

For example, with both ignorecase and smartcase turned on, Vim will match “crashandburn” with both “CrashAndBurn” and “crashandburn”. If you enter “CrashAndBurn” as your search pattern, however, Vim will only match the string “CrashAndBurn” in the text. It won’t match “crashaNDBUrn”.

In practice, this combination of options works out to be a good compromise, letting you balance case-sensitive and case-insensitive searches nicely without having to set or unset an option to do them.

Keep Some Context: scrolloff

When I’m editing a program or document, I like to have a little context around my work by keeping the line of text I’m working on a couple of lines away from the edge of the window at all times.

In vi, I would maintain this bit of context by scrolling a few lines either above or below the line I wished to edit, then moving back to my destination and doing my editing. It wasn’t great, but it was better than typing blind, which is how I felt whenever I worked on the first or last line of the screen.

Luckily, Vim can maintain some context for you automatically through the use of the scrolloff option. You can try setting this option by pressing the ESC key and entering

:set scrolloff=2

The 2 means I want at least two lines of context visible around the cursor at all times. You can set this to any number you like. Vim will scroll your file so that your cursor will never be closer to the top and bottom edge of the screen than the number of lines you specify.

Vim won’t always be able to honor your scrolloff specification. If you’re near the bottom or top of the file, there may not be enough lines left between your cursor and the file’s beginning or end to give you the context you asked for. It will do the best it can, though.

I recommend the scrolloff feature highly. It’s been a great help to me.

File Name Completion: wildmode

I hate typing file names. Why should I have to type out a file name like “thelongestfilenameintheworld.html” if the starting characters “thelong” will uniquely identify it from all other files in the current subdirectory? I also have the habit of wanting to edit a file deep within an unfamiliar directory structure.

Luckily, Vim has file name completion. File name completion lets you enter a partial file name into Vim, then press the TAB key to have Vim search for a file or directory name that could complete it. If Vim finds exactly one file or directory that matches, it fills in the rest of the name. If Vim can’t find any match, it beeps.

What if Vim finds more than one file or directory name that matches? You can specify what Vim does next in this case by setting the wildmode option. The default setting for wildmode is “full”. When wildmode is set like this, the first time you press TAB, Vim will fill in one of the files or directory names that match what you have typed so far. If you hit TAB again, Vim will show you another file that completes your match. As you keep pressing TAB, Vim will go through all the possible completions. When it runs out, the next time you press TAB, Vim will show you the original incomplete string you entered. Now you’re back where you started. If you press TAB again, Vim will show you the first match again.

While this is good, I prefer my file name completion to work a little differently. Here’s how I like to have wildmode set:

:set wildmode=longest,list

Setting wildmode this way makes Vim act as follows. When I enter part of a file name and press TAB, Vim completes my file name to the longest common string among the alternatives. It then waits for me to do one of the following: press ENTER to accept that as the file name, keep typing the file name from that place, press ESC to cancel the command, or press TAB again. The second time I press TAB, Vim will list all possible files that could complete my partial file or directory name.

Don’t like either of the file completion methods I listed above? Not to worry: wildmode has many different options. For details, enter

:help wildmode

and Vim will show you every possible option.

Conclusion

Enjoy customizing Vim. If you take one step at a time, you’ll find that using Vim becomes more and more pleasant as time goes by. I think the more you make Vim work your way rather than its default way, the more you’ll come to like it.

Coutsey : Dan Puckett supports configuration management software for a rather large telecommunications firm. He is a writer and actor. He welcomes your comments at puckett@acm.org.

http://www.linuxjournal.com/article/3805#comment-340004

July 23, 2009

how to add different vim color schemes

by viggy — Categories: Uncategorized — Tags: , , , 1 Comment

If you do any significant amount of text editing in vi, you could benefit from syntax highlighting. Turning on syntax highlighting in Vi (or VIM rather) is as simple as adding
set nocompatible and syntax on to your ~/.vimrc file. While you are editing your .vimrc file, there are a ton of other cool things you can tweak which I recommend as well (ex. tabstop, nowrap, ignorecase, bs, etc). Once you have syntax highlighting on, you may decide you want a different color scheme. This is also simple.

You can put color scheme definition files in the ~/.vim/colors/ directory. The files will have a “vim” extension. You can load a color scheme by typing :colors [scheme_name] while in vi. In most OS installs there are a ton of schemes included, in OS X these are in “/usr/share/vim/vim62/colors/”. Included for me are: darkblue, desert, elflord, evening, koehler, morning, murphy, pablo, peachpuff, ron, shine, shine, torte, and zellner. If none of these tickle your fancy, there are a bunch available here or you could always build your own.

You may also add any color schemes that you got from internet. To do that, obtain the file from internet, it must be a .vim extension file. Check out which is your VIM’s home directory. You can get it by executing the following in vim “:echo $home”. Go to that directory. You will find a “colors” directory. Add your .vim extension file in it. Also then make the necessary changes in .vimrc file also.

Courtsey: http://nosheep.net/story/vi-color-schemes/

July 21, 2009

How to search a perl function’s man page

by viggy — Categories: perl — Tags: , , Leave a comment

If you know the name of the function and you want to see the man page for that function, then you can use the following command.

perldoc -f “function name” //without quotes

for example,

perldoc -f our
perldoc -f sysopen

July 21, 2009

Perl-error “.pm did not return a true value at”

by viggy — Categories: perl — Tags: , , Leave a comment

This is one of the errors that I got when I started using perl modules.
It was because I had not put “1;” at the end of my perl module. So I did not get the error after I put “1;” at the end of the perl module.

why is the “1;” necessary at the end of perl modules?

Typically, a module contains a bunch of subroutine definitions.  A
module may also contain code which is not part of a subroutine. This
code is executed at the time the module is loaded, so it can be used
to initialize the module. For example, the module might open
adatatbase connection or initialize some time at the time it is
loaded.


Such code might be successful, or it might fail. Perl allows the
module to indicate the result by returning a true or false value back
to its caller. If the value is false, Perl aborts the compilation
with an error message.

Unfortunately, the default return value is *false*, so a module which
just defines a bunch of subroutines, and which has no initialization
code, accidentally returns a false value back to the caller, and Perl
aborts. So we insert "1;" at the end to suppress this misbehavior.

http://dev.perl.org/rfc/269.pod
http://dev.perl.org/rfc/269.html

discusses this in some more detail.

For documentation, see perldiag:

%s did not return a true value
(F) A required (or used) file must return a true value
to indicate that it compiled correctly and ran its
initialization code correctly. It's traditional to
end such a file with a "1;", though any true value
would do. See the require entry in the perlfunc man-
page.

and the relevant part of 'perlfunc':

The file must return true as the last statement
to indicate successful execution of any initialization code, so
it's customary to end such a file with "1;" unless you're sure
it'll return true otherwise. But it's better just to put the
"1;", in case you add more statements.

Courtsey: http://lists.netisland.net/archives/phlpm/phlpm-2001/msg00426.html

July 17, 2009

cd // ??

by viggy — Categories: Uncategorized — Tags: , , Leave a comment

I executed the following command by mistake instead of “cd ..”

  • cd //

and strangely i was in some folder //
When I tried the command “pwd” i got the output as “//”.
When I tried the command “ls” i got the same output as if it was the “/” directory.
When I tried the command “cd ..” I was in the same directory as happens in “/” directory.
So I could conclude that it is the same “/” directory. But its existence did not make any sense then.

July 7, 2009

adding alias for commands in Bash

by viggy — Categories: Uncategorized — Tags: , Leave a comment

Courtesy to hypexr.org.

If you have used UNIX for a while, you will know that there are many commands available and that some of them have very cryptic names and/or can be invoked with a truckload of options and arguments. So, it would be nice to have a feature allowing you to rename these commands or type something simple instead of a list of options. Bash provides such a feature : the alias .
Aliasses can be defined on the command line, in .bash_profile, or in .bashrc, using this form :

alias name=command

This means that name is an alias for command. Whenever name is typed as a command, Bash will substitute command in its place. Note that there are no spaces on either side of the equal sign. Quotes around command are necessary if the string being aliassed consists of more than one word. A few examples :

  • alias ls=’ls -aF –color=always’
  • alias ll=’ls -l’
  • alias search=grep
  • alias mcd=’mount /mnt/cdrom’
  • alias ucd=’umount /mnt/cdrom’
  • alias mc=’mc -c’
  • alias ..=’cd ..’
  • alias …=’cd ../..’

The first example ensures that ls always uses color if available, that dotfiles are listed as well,that directories are marked with a / and executables with a *. To make ls do the same on FreeBSD, the alias would become :

  • alias ls=’/bin/ls -aFG’

To see what aliasses are currently active, simply type alias at the command prompt and all active aliasses will be listed. To “disable” an alias type unalias followed by the alias name.

One more important thing. After you have added alias in .bashrc, you need to inform your system about the changes and hence execute the following command:

  • source .bashrc

July 7, 2009

OpenSSH Public Key authentication

by viggy — Categories: Uncategorized — Tags: , , Leave a comment

Please refer to man pages of SSH command for latest updates.

This is method is used usually when you are a server administrator and usually work by logging through SSH in to the server. You will not like to enter the password everytime you want to log in. For this you can follow this method.

Host-based authentication works as follows: If the machine the user logs
in from is listed in /etc/hosts.equiv or /etc/shosts.equiv on the remote
machine, and the user names are the same on both sides, or if the files
~/.rhosts or ~/.shosts exist in the user’s home directory on the remote
machine and contain a line containing the name of the client machine and
the name of the user on that machine, the user is considered for login.
Additionally, the server must be able to verify the client’s host key
(see the description of /etc/ssh/ssh_known_hosts and ~/.ssh/known_hosts,
below) for login to be permitted. This authentication method closes se-
curity holes due to IP spoofing, DNS spoofing, and routing spoofing.
[Note to the administrator: /etc/hosts.equiv, ~/.rhosts, and the
rlogin/rsh protocol in general, are inherently insecure and should be
disabled if security is desired.]

Public key authentication works as follows: The scheme is based on pub-
lic-key cryptography, using cryptosystems where encryption and decryption
are done using separate keys, and it is unfeasible to derive the decryp-
tion key from the encryption key. The idea is that each user creates a
public/private key pair for authentication purposes. The server knows
the public key, and only the user knows the private key. ssh implements
public key authentication protocol automatically, using either the RSA or
DSA algorithms. Protocol 1 is restricted to using only RSA keys, but
protocol 2 may use either. The HISTORY section of ssl(8) contains a
brief discussion of the two algorithms.

The file ~/.ssh/authorized_keys lists the public keys that are permitted
for logging in. When the user logs in, the ssh program tells the server
which key pair it would like to use for authentication. The client
proves that it has access to the private key and the server checks that
the corresponding public key is authorized to accept the account.

The user creates his/her key pair by running ssh-keygen(1). This stores
the private key in ~/.ssh/identity (protocol 1), ~/.ssh/id_dsa (protocol
2 DSA), or ~/.ssh/id_rsa (protocol 2 RSA) and stores the public key in
~/.ssh/identity.pub (protocol 1), ~/.ssh/id_dsa.pub (protocol 2 DSA), or
~/.ssh/id_rsa.pub (protocol 2 RSA) in the user’s home directory. The us-
er should then copy the public key to ~/.ssh/authorized_keys in his/her
home directory on the remote machine. The authorized_keys file corre-
sponds to the conventional ~/.rhosts file, and has one key per line,
though the lines can be very long. After this, the user can log in with-
out giving the password.

The most convenient way to use public key authentication may be with an
authentication agent. See ssh-agent(1) for more information.

Challenge-response authentication works as follows: The server sends an
arbitrary “challenge” text, and prompts for a response. Protocol 2 al-
lows multiple challenges and responses; protocol 1 is restricted to just
one challenge/response. Examples of challenge-response authentication
include BSD Authentication (see login.conf(5)) and PAM (some non-OpenBSD
systems).

Finally, if other authentication methods fail, ssh prompts the user for a
password. The password is sent to the remote host for checking; however,
since all communications are encrypted, the password cannot be seen by
someone listening on the network.

ssh automatically maintains and checks a database containing identifica-
tion for all hosts it has ever been used with. Host keys are stored in
~/.ssh/known_hosts in the user’s home directory. Additionally, the file
/etc/ssh/ssh_known_hosts is automatically checked for known hosts. Any
new hosts are automatically added to the user’s file. If a host’s iden-
tification ever changes, ssh warns about this and disables password au-
thentication to prevent server spoofing or man-in-the-middle attacks,
which could otherwise be used to circumvent the encryption. The
StrictHostKeyChecking option can be used to control logins to machines
whose host key is not known or has changed.

When the user’s identity has been accepted by the server, the server ei-
ther executes the given command, or logs into the machine and gives the
user a normal shell on the remote machine. All communication with the
remote command or shell will be automatically encrypted.