a second glance at regular expressions

a second glance at regular expressionsSocialTwist Tell-a-Friend

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

insert images, html signature or just any html into gmailSocialTwist Tell-a-Friend

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

Shift to ubuntu series : Try out Ubuntu 8.04 live CDSocialTwist Tell-a-Friend

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.

about me

about meSocialTwist Tell-a-Friend

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..

Jaane Tu Ya Jaane Na Review : youthful entertainer

Jaane Tu Ya Jaane Na Review : youthful entertainerSocialTwist Tell-a-Friend


Jaane Tu… Ya Jaane Na is a simple tale about a group of friends, it focuses on one couple that's in love, but is in a state of denial. Jai (Imran) and Aditi (Genelia) are ‘best friends’ and are extremely possessive of each and long for each other’s company but still wonder why close friends and parents believe that they are in love! So they set out to find themselves a special someone! However they do find their respective ‘special someone’ before they realize that they are in love with each other. Seems a recipe for a perfectly boring Bollwood style love story ? The movie might look like any other love story with some beaten-to-death clichés like the hero mounting on a horse and riding to an airport in the climax to stop his ladylove from leaving for the US. But its never been presented in such as great way – with a perfect dash of humour . Hats off for keeping the story simple and getting a perfect ensemble of characters (including horses) that chip in their bit to the story. Be it Ratna Pathak Shah as the admonishing mother of the protagonist, or Naseerudin Shah as the sword-wielding dead Rajput father who speaks from a photograph. Or be it Paresh Rawal as the typical Mumbai cop . Or be it Arbaaz Khan and Sohail Khan , two macho Rajputs, who ride horses to disco’s and jails. There is something about Genelia D'Souza , the way she smiles and the way she scowls. She has a fine blend of tom boyishness and femininity. She doesn’t have the face of a stunner, but it’s a face you’ll never get bored with. Genelia adds freshness and spontaneity to her scenes. Also, the mischievous look in her eyes conveys sorrow with equal ease. Wish to see more of her in Hindi movies! Imran has an unpretentious, honest face, clear eyes and a voice that is confident and also inhibited. He suits the role of a Rajput who can’t even kill a fly, forget about punching someone or seeing the inside of a jail. The young actors playing the bunch of friends are natural. It’s hard to notice any acting in their performance, its never difficult imitating oneself. Each friend represents a type yet none a stereotype. The music of the film is cheerful and energetic, by A.R. Rahman. Some of the numbers seem silly and amateurish rap ( read pappu cant dance song ) but you gotta see how its amazingly blends into the situation. The “Kabhi Kabhi Aditi Zindagi” is so different from the typical rehman style but still only he could create something like this. Its definitely gonna top the charts this year. So “jaane tu …” is a decent fare that takes me back to my recent collage days, when friends seem to be the be-all and end-all. I’d recommend it for an evening of pure entertainment ( don’t expect anything apart from that) .

Three mistakes of my life - stereotypical but worth a read

Three mistakes of my life - stereotypical but worth a readSocialTwist Tell-a-Friend

It was fun reading "The 3 mistakes of my life" like other two books of Chetan Bhagat. The feeling was like watching some masala movie..romance, emotions, friendship and finally a happy ending. Starting is quite a bit slow..but keeps your attention untill a dramatic ending.

The story : This book contains a story of a guy called Govind Patel who had dreamt of becoming a successful businessman. The book is loosely based on the three mistakes Govind made in his life.
What follows is a mix of cricket, religion, business, love and friendship. Govind sets up a sports shop along with his friends in the temple compound with Omi’s family’s help. The shop prospers as Ishan coaches young boys in cricket and Govind teaches maths to Ishan’s sister Vidya who also captures his heart. Ishan then meets Ali, a child master with a hyper reflex condition that makes him hit each ball for a six ( This is a part i cant digest ) . Ali displays the talent which Ishan never had and Ali’s destiny becomes his own.
Omi’s Bitoo mama , a communal party man bent on converting the young into fighters in the name of Hinduism. Situations come to a head and Ahmedabad burns in riot fires. Omi dies saving Ali and Ishan finds out about Vidya and Govind, a betrayal he does not forgive. These events lead Govind to his death-bed and that is when he writes the email to Bhagat.

The book is quite similar to Chetan Bhagats Five Point Someone with respect to a plethora of aspects. Three young friends, their tryst with destiny, the romantic scenes, the ups and downs, the dark humour, the screw ups.. It’s all there. However, there are a few refreshing aspects to the book- especially the handling of the business mentality, the local Gujarati flavor and the very India style love story.

Lines I loved : Gujarat is the only state in India where people tend to respect you more if you are in businesss than if you are in service (real true!) and 'Gujarat is a dry state.. people here get drunk on food'.

What i cant understand is the importance given to the three mistakes. Does losing money due to bad decisions and unexpected circumstances qualify as a mistake ? especially in case of Gujrati businessmen - who are known for their apetite for risks? And why the huge issue about falling in love with a friends sister as long your sincere with the relationship ?

The story sometimes seems like an illustration of problems that Indians have to live with - Lack of development in smaller towns, sick politicians, religious extremism, lack of sports education/infra-structure in schools etc etc . In some places, simply for the heck of covering many of these problems, creates certain scenarios are created a tad too forcefully. Like Ish's stereotypically grumpy Indian Dad always taunting against his failures, sometimes, simply for the heck of it! or the Ish smashing the guys car- that was little too melodramatic way of portraying his protectiveness towards his sister..

As for the ending, yes it was a bit too melodramatic with half the ppl dying in a RGV movie like scene, but i think that can be spared given the nice plot and a decent pace overall… I like his hinglish writing style a lot.

The reason Chetan Bhagat got so popular in the first place was his refreshing attitude towards writing with a distince indian flavour. Thats what made him a huge hit.

My guess is you'll like it unless your a really seasoned reader of authors like jeffery archer, arthor hailey and so on - from that angle Chetan Bhagat has a lot of catching up to do.
But the plot and the few refreshiong aspects i described above make this book my favourite amongst his 3 offerings.

Finally Its fun filled entertainment and something the indian youth can connect to. worth reading once.

firefox 3 : first look

firefox 3 : first lookSocialTwist Tell-a-Friend

The hype surrounding the release of firefox 3 was unbelievable. Was it due to the interest of the open source community or because a browser has now become integral to our everyday lives?

Anyway, I ended up waiting until midnight 27th(IST) for the release. Everybody discussing ff3 and the boring wait for it over gtalk. And the download wasnt a breeze – the Mozilla site seemed to have conked out with the load and I had to wait for ah hour before i could lay my hands on ff3.

Mozilla were gunning for five million downloads in 24 hours to set a Guinness world record and not surprisingly it exceeded expectations, passing the five million mark in just under 14 hours.

I'll go through a few of the interesting improvements and new features that i found. Please bear with me for repeating some the new features as i'd already covered them in my review of ff3 beta edition earlier.


The Awesome bar

The new location bar ( nicknamed The Awesome Bar) is by far the best and most used improvement in ff3. When you start typing into the Awesome Bar, Firefox starts searching through your browsing history and bookmarks. The Awesome bar shows you a dropdown menu of pages, and when you see the page you want, you can just arrow or mouse down and select it. It also conveniently weights the search results to favor frequently-visited pages and pages you visited more recently.

The smart auto-complete function remembers not just pages' addresses but also their titles. Heres an example of how extremely simple it makes my life. If i want to go a blog with a name Amateurs coding i dont need to remember the url http://www.kgmodi.blogspot.com . juist typing "amateur" is enough for firefox to zero in on the site.


Bookmarking - Quicker and Easier

On the far right side of the location bar is a star. One click and the current page is immediately bookmarked, into an unsorted bookmark section. Click again on the star and you can edit the bookmark, where you can add tags. If you type a tag word into the location bar you will get a list of sites from your history and bookmarks that have also been tagged with that same word. try it out.


Streamlined look and the BACK button

Firefox’s skin now automatically matches the general UI of your OS and looks more streamlined with a focus on a larger back button – possibly the most used button for navigation.
Surprisingly this larger back button is missing on my Ubuntu verion of ff3 !


Add-On Manager Improvements

The addon manager provides a list of recommended add-ons. You can also search for new ones and find more complete add-on descriptions with ratings. installation is pretty simple.


improved Zoom

The new zoom is much better. The entire page zooms in and out, with the graphics, interactive elements, text, and layout all remaining in proportion to one another unlike earlier versions where zooming haphazardly overlaps various elements as you zoom.
Firefox 3 also seems to remembers the zoom setting the site for your next visit.


non intusive password manager

Firefox 3's password manager is much more polite about offering to remember Web passwords. It asks you if you'd like to save your password in an unobtrusive strip atop the browser window, not a pop-up dialog.


online app's support

In the past you’d click on an email address in a Web site and your computer’s default email application would open up to send a message to the linked address—even if you never email through the program ( read Microsoft Outlook ). Now you can choose a Web mail clients (like Hotmail, Gmail or Yahoo! Mail) to launch when you click on that email address.


Reality check , Is firefox good enough to beat ie ?
Internet Explorer, for better or for worse, still enjoys a significant advantage in market share, but data show this advantage eroding. According to study that judged the market share by the traffic at a particular Web site, Firefox gained almost 8 percent over Internet Explorer for the month of May, year over year, moving from just over 26 percent of all visitors to 33 percent. Internet Explorer lost a total of 9 percent to other browsers in that time frame.
And there's Apple's Safari,another competitior that gained almost 3 percent.


Three years in development, over 15,000 bug fixes and feature improvements, remarkable performance gains, multiple OS integration—you could say the several hundred engineers working on Firefox have been busy. And their work has paid off.
a big thumbs up to firefox 3

I'll be reviewing a few good addon's for firefox 3 soon. so keep checking.
and also comment on your experience with firefox 3.

wallpaper 1

wallpaper 1SocialTwist Tell-a-Friend


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.

Code for freedom

Code for freedomSocialTwist Tell-a-Friend

This was one heck of a competition.
2 months...lots of not stop exploring and experimenting and countless sleepless nights.

CFF was organised by SUN, open to students across India, and included contributing towards any of their open source technologies like NetBeans, Open Solaris, Glassfish etc.

We'd heard about the CFF competition long time back but got down to work seriously only in dec. The three of us ( dats kunal, anil and myself) got down to trying to figure out what to contribute. Believe me this part was harder than making the plugins itself.

So we started with a scratchpad and a whiteboard. And later came to develop plugins for many interesting API's like blogger,picasa nd yahoo messenger
We ended up spending our days pouring over our PC's , getting together at one of our places. Getting stuck regularly, getting bugged with the snail speed's that NetBeans ran and ofcourse the thought of the approaching exams but never giving up.

Finally it was feb and we submitted 6 plugins for netbeans + 3 tutorials for the netbeans wiki page.
Whew !! that was a lot, had never thought we'd be submitting even one
And then when few weeks later we heard that we won and got an iPod each , there was nothing that could stop me from jumping up n down ( made nilay n rohit wonder if i'd gone mad).
This was just gr8.... being 3 out of the 10 students across india to get the prize felt just gr8.

And ofcourse a iPod id always welcome !!

BlogCatalog

Travel Blogs - BlogCatalog Blog Directory