Linux basics : alternatives system

The alternatives system is used (on red hat and similar distro's ) to automatically maintain symbolic links to binary files on a priority based system.

For example:

/usr/bin/java - > /etc/alternatives/java -> /path-to-binary-files

This configuration adds a layer of abstraction so you can update, switch versions, and/or switch vendors with out breaking applications.

Want to switch to a newer version of java, yet do not want to remove or relocate your existing java, then this is your answer.

To see a list of alternatives for a given link group, you can use the --display option.

sudo /usr/sbin/alternatives --config java

output :

There are 2 programs which provide 'java'.

Selection Command-----------------------------------------------

* 1 /usr/lib/jvm/jre-1.4.2-gcj/bin/java

+ 2 /usr/java/jdk1.6.0_24/bin/java

Enter to keep the current selection[+], or type selection number:

When you install a new binary file via RPM it gets listed here with a default priority. So you can go ahead to install a new java version then just modify the alternatives. Want to roll back to an older version ? that's done easily.

Note : for configuring the jdk, you need to configure both java and javac with the alternatives system.

And here comes the real reason i'm writing this post.

I installed a new java rpm , but its not listed in the alternatives list. What do i do ?

If not picked up automatically by alternatives, you can manually register it as follows

sudo /usr/sbin/alternatives --install "/usr/bin/java" "java" "/usr/java/jdk1.6.0_24/bin/java" 1

sudo /usr/sbin/alternatives --install "/usr/bin/javac" "javac" "/usr/java/jdk1.6.0_24/bin/javac" 1

Then go ahead and select it from the alternatives list.

a second glance at regular expressions

i remember learning all about regular expressions, grammer and the like in college but it was only last week when i looking for a quick method for email parsing and validation that i realised its practical use.

Using a good regex engine and a well-writen regular expression, one can perform all kinds of text-manipulation tasks.  Regular expressions can be used to identify for certain conditions or charater sequences in a text file or data stream.
The most common place you'd find regular expressions is email address validation and search - replace functions . A search for " email validation using regular expressions" on google would prove my point.
 
So what do you need to start using regular expressions ? nothin you dont already have. Regular expressions are supported by most languages and tools in use.
i've used the  java.util.regex  API in java.

so here's a simple example in java for email validation that should give you an idea of how regular expressions can be used.

public static void main(String[] args){
String email="svwaingankar@gmail.com";
email=email.trim();

//  Email Address validation
Pattern p=Pattern.compile("[a-zA-Z]*[0-9]*@[a-zA-Z]*\\.[a-zA-Z]*");

/* If you need a more detailed validation
Pattern p=Pattern.compile("^[a-zA-Z][\\w\\.-]*[a-zA-Z0-9]@[a-zA-Z0-9][\\w\\.-]*[a-zA-Z0-9]\\.[a-zA-Z][a-zA- Z\\.]*[a-zA-Z]$");
*/
Matcher m=p.matcher(email);
boolean result=m.matches();

if (result==true)
System.out.println( email + "  is a VALID email address");
else
System.out.println( email + "  is an INVALID email address");

}

What it means 
[a-zA-Z]*[0-9]*@[a-zA-Z]*\\.[a-zA-Z]*

[a-zA-Z]  --- any characted from the union of a to z and A-Z
[a-zA-Z]*  --- the * means zero or more occurences
similarly for [0-9]*
\\. --- a dot ( \\ is escape character  )

some more examples of character classes ( anything in [] )
[^x] - any character except x
[a-z && [x-z]] - x, or z  ie- intersection

predefianed character classes
\d   --- any digit
\w  --- a word character ( ie [a-zA-Z_0-9])
.  --- any character

 
Cons : Regular expressions are easier to write than they are to read. so use it only if there arent too many people apart from you maintaining the code.

insert images, html signature or just any html into gmail

Ever wondered how you can insert images or html into a gmail message ? gmail does not support html like yahoo or Outlook.

there's a simple solution using and website editor like googlepages.com or frontpage ( if you have microsoft office) .

Open up frontpage and paste the html code into the html view tab of the webpage. Then go to the preview tab and just use Ctrl+A to select the contents. Now just paste it into your gmail Compose page and your done.

If you want to insert an image first upload it somplace like picasa and then use this simple html
">

If you want to use googlepages instead of front page the procedure is just the same. Open a new web page. Click edit HTML and paste html. then go back and copy the preview.

Shift to ubuntu series : try out ubuntu 8.04 live CD

Labels: , , , , , , ,

The first step in shifting to Ubuntu is trying the live CD version for a while. So here's small guide for first time users. The live CD version means that whenever you want to use Ubuntu you just pop in the CD and reboot the PC, you can then try out Ubuntu without affecting your computer in anyway. All you have to do is shut down, remove CD and restart comp to restore your PC to original condition and use Windows. No installation, no partitioning needed.

Step 1 Download Ubuntu 8.04 from here. download the desktop 8.04 LTS version for your PC configuration. the defaut selections on the page will mostly work for you. This version includes the Ubuntu installation + a live CD version. Next burn the downloaded iso image onto a CD using any CD writing software.
Step 2 Boot the live Ubuntu version throught the CD.
Just pop in the CD and restart your computer. It should now proceed with loading Ubuntu. If not, follow the steps below to ensure the PC boots from the Ubuntu CD and not into Windows.

How to change boot opitions ? ( you need to do this only once)
* Immediatelly on switching on the computer keep pressing the Esc button ( or
Del button on some PC's ). You'll see a boot prompt coming up.
* Look for a list in the prompt called a boot priority / boot order. Edit the list so
that your CD drive is first in the list and then your hard disc.
* Now select option Save Changes and Exit. It should now proceed to load Ubuntu.



Once Ubuntu boots you'll have a screen with options to try out live CD or install Ubuntu.
Select the first option thats "Try Ubuntu without any change to your computer".


Your done with this. Now go ahead with exploring Ubuntu.

Step 3 : Restoring your computer. Actually this might not even qualify as a step.
All you have to do is select shutdown option in Ubuntu and remove CD when its done. Its that simple.

Enjoy Ubuntu and once you are familiar you can go ahead with installing Ubuntu on your PC. That'll give you much better performance and let you personalise your Ubuntu and install other interesting software

For total newbie here are few softwares commonly used in Windows and their open source eqiuivalent you can try out in Ubuntu
Open Office Suite for Microsoft Office
Firefox browser for Internet Explorer
GIMP graphic editing s/w for Photoshop
RythmBox music player for Windows Media Player.
Archive manager for WinZip/ WinRar

Also try out interesting games and the file explorer in Ubuntu. Check out the dual desptop feature . You can decluster windows and organise your work into two seperate windows. You can shift windows using the option provided at the bottom right corner of ur desktop. Also try out the Windows+Tab shortcut to switch wondows to get a taste of the awesome UI if Ubuntu 8.04.

contact me

Labels: ,

fastest way to get in touch , mail me at svwaingankar@gmail.com
or catch me on gtalk.

snail mail :
276/ B - J.Shankarshet Rd,
83-Surya Mahal, 2nd flr,
Mumbai -400004
India

network :
blog svwaingankar.blogspot.com
orkut profile
linkedIn profile

about me

Labels: , , , , , ,

Professionally, I am an amateur web developer, a java freak and an open source source enthusiast. I'm just graduating with a Bachelors degree in
Software
Engineering from Mumbai University.
Love exploring new technologies. Expertise in java and j2ee web development. Worked on NetBeans plugin development and some Goolge API's in my final year. Currently exploring the Drupal web application framework and the Grizzly server.

Enjoy making websites and blogs. Love tinkering with Photoshop and Corel Draw and designed innumerable newsletters, magazines, posters etc in college. Great fan of Ubuntu and the raw power it gives me. And ofcourse Ubuntu, NetBeans and Firefox are the first things I install on my PC.

Personally, I enjoy photography, adventure travel, hiking, camping and painting. I have varied interests, from following indian politics to the stock market, and you will find many of my interests being talked about of my blog posts.

I've been exploring the remotest of villages, the beautiful beaches and trekking trails in konkan (the coastal regions of Maharashtra ), and really appreciate its beauty, its people and of course its food. Also trying my hand at some astronomy and bird watching recently.

Commit to the occasional social work that I believe in as something worth the time and effort of any human being.

I worship humour. . i like to be myself...and make a lot of friends...cant live without the net, good food and a phone..

wallpaper 1

Labels: ,


Heres a wall paper i designed in photoshop. Actually cant say i designed it but more like accidently created it while fiddling with some interesting tools in photoshop. hoping to come up soon with many more.