Thursday, June 11, 2009

Removing borders of HTML iframe on all browsers

You can add an iframe on your page without the borders (iframe will fit into your page as like <div>, <p>, etc )

< allowtransparency="true" src="http://www.google.com" style="left: 0pt; top: 0pt;" vspace="0" scrolling="no" width="728" frameborder="0" height="300"> </iframe>

Wednesday, May 13, 2009

java class for sending email

//imports
import java.security.Security;
import java.util.Properties;
import javax.mail.Message;
import javax.mail.MessagingException;
import javax.mail.PasswordAuthentication;
import javax.mail.Session;
import javax.mail.Transport;
import javax.mail.internet.InternetAddress;
import javax.mail.internet.MimeMessage;

//class does all the mail functionalities

class MyMailer {
private static final String SMTP_HOST_NAME = "smtp.gmail.com";
private static final String SMTP_PORT = "465";
private static final String SSL_FACTORY = "javax.net.ssl.SSLSocketFactory";

public void sendSSLMessage(String recipients[], String subject, String message, String from) throws MessagingException {

Security.addProvider(new com.sun.net.ssl.internal.ssl.Provider());
boolean debug = false;
Properties props = new Properties();
props.put("mail.smtp.host", SMTP_HOST_NAME);
props.put("mail.debug", "false");
props.put("mail.smtp.port", SMTP_PORT);
props.put("mail.smtp.socketFactory.port", SMTP_PORT);
props.put("mail.smtp.socketFactory.class", SSL_FACTORY);
props.put("mail.smtp.socketFactory.fallback", "false");
props.put("mail.smtp.auth", "true");
props.put("mail.smtp.starttls.enable","true");

Session session = Session.getDefaultInstance(props,
new javax.mail.Authenticator() {

protected PasswordAuthentication getPasswordAuthentication() {
return new PasswordAuthentication("xxxx@gmail.com", "xxxxx");
}
});

session.setDebug(debug);
Message msg = new MimeMessage(session);
InternetAddress addressFrom = new InternetAddress(from);
msg.setFrom(addressFrom);

InternetAddress[] addressTo = new InternetAddress[recipients.length];
for (int i = 0; i < recipients.length; i++) {
addressTo[i] = new InternetAddress(recipients[i]);
}
msg.setRecipients(Message.RecipientType.TO, addressTo);

// Setting the Subject and Content Type
msg.setSubject(subject);
msg.setContent(message, "text/plain");
Transport.send(msg);
}
}



method call:
==========
new MyMailer().sendSSLMessage(sendTo, emailSubjectTxt,emailMsgTxt, emailFromAddress);



Note : mail.jar is needed. Change your SMTP settings according to your needs. I have tried with Gmail.

Tuesday, May 12, 2009

email validation in Java using apache.commons-validator

Validating the mail very effectively, is little difficult. Here is a simple code for validating your email in Java. It is using the apache.commons-validator.jar and oro-gump-18012007.jar.

// Code email validation

public static boolean validateEmailAddress(String sEmail){
       EmailValidator emailValidator = EmailValidator.getInstance();
       return emailValidator.isValid(sEmail);
}

Commons validator, validates true for '%$^^%$$@$%$#.com'. Don't get affraid, '%$^^%$$@$%$#.com' is a correct email id according to http://en.wikipedia.org/wiki/E-mail_address.

Monday, May 11, 2009

K-I-S-S

Here is a good article on techcrunch, by MG Siegler
K-I-S-S. I liked it very much !!.

Subversion over Apache 2 on Ubuntu

Sunday, March 04, 2007

Inspiring speech by Steve Jobs ( CEO, Apple Inc.)

This is a very interesting and inspiring speech by Apple CEO at stanford in the year 2005. Watch it here

Startups to watch

Here is the 25 interesting startups figured by the cnnMoney.com .May be the future Google or Yahoo from it. Read it, Its very interesting.

Thursday, December 21, 2006

Web space - - - - 2006

I think it was a good year for the world of internet with development of great technologies with success stories as well as some big disappointments.


The year 2006 made internet more popular to the naive users by the help of Web 2.0 concepts like social networking, photo sharing, etc.. Some of great start-up companies bubbled up with interesting ideas and technologies.. Our local Indian scenario also have changed a lot with most of the start-ups having office spaces in and around IT cities like Bangalore, Delhi, Gurgaon, etc..

The some of the start-ups/technologies attracted me is ::

1) Riya.com, like.com
2) Ugenie
3) Uzanto
4) Mingle box
5) Onyomo
6) Polarrose (expected to come out with beta version by first quarter of 2007, report on GigaOM )



In the above list riya made a big disappointment on 2006, came up with big expectations and hype but flopped, but it was a courageous move by CEO Munjal Shaw. A good leader never fails, Munjal came up with an interesting concept of visual shopping website (like.com), where he used the core technology of riya.com ( visual search engine with accuracy of about 50 - 70% ). It is a good example of shifting focus to a failed technology to the new area. Good luck Munjal !! , may be 2007 will be your's.

The conceptual wise i rank Ugenie after riya because the concept of comparison shopping interests me a lot, I think there is lot more to tap on this area. May be we can expect a comparison shopping engine for India in 2007, lot of experienced geeks are working in ugenie, I think we can expect more from them, ( i feel, need to change UI and AJAX ).

Uzanto, came up with a good product slide share, making lot of hypes on the technology meet ups and bar camps other product is mind canvas ( I don't have much idea.. ). I think it is one of the first company to come up with the full implementation of a product on much hyped technology ROR, expecting more in 2007.

Mingle Box, its a true Indian startup focusing on social networking, with local flavors, I don't know much about future of social networking, as there are solid players like orkut ( Which has got second highest number of users from India after Brazil ), Myspace, etc...

Onyomo again a true Indian start up search engine, good concept but i think it should come out metros by 2007 ( Covering all the cities and villages),

Polarrose, start up from Sweden, announced their beta release date yesterday, beta will come out by first quarter of 2007. No rivals as such, like riya had, but if they can search the photos as accurately as 70 - 80% it will be a huge success story with change of search concept( may be next Google on photo search... ). They did not make much hype as riya did , but i feel they will do something great. Let's wait for it.


Lets hope for something innovative and revolutionary change on the web in 2007, like what google did years back on text search.

like.com is a javascript junk ???


Have a look at the above error populated on FF JS console by like.com, the whole website get unbrowsable by this error,
you need to reload the page to get out of this error. Anyway this error helped me to get an interesting code snippet for the
color picker used in like.com ( Damn good !!! ).

Wednesday, November 29, 2006

Better to detect the browser features than detecting the browser

I have came across a code snippet on a famous WEB 2.0 product, Just have a look at it : ( I have copied this code from FF Javascript debugger console )

function getXY(e)
{

if(navigator.appVersion.match(/\bMSIE\b/))
{
return getXYIE(e);
}
else
{
return getXYMozilla(e);
}
}


function getXYMozilla(e)
{
xyArray = new Array(2);
var some_handler = document.getElementById("some_id");
xyArray[0] = e.layerX - some_handler.offsetLeft;
xyArray[1] = e.layerY - some_handler.offsetTop;
return xyArray;
}

function getXYIE(e)
{
xyArray = new Array(2);
xyArray[0] = e.offsetX;
xyArray[1] = e.offsetY;
return xyArray;
}


I think we can do the same functionality with the below code ( Without detecting the browser , but only detecting the browser features ). Just have a look into it :


function getXY(e)
{
return myCode(e);
}


function myCode(e)
{
xyArray = new Array(2);
var some_handler = document.getElementById("some_id");
alert(e.offsetX);
xyArray[0] = e.offsetX ? e.offsetX : (e.layerX - some_handler.offsetLeft);
xyArray[1] = e.offsetY ? e.offsetY : (e.layerY - some_handler.offsetTop);
return xyArray;
}

Open to suggestions.