Letter of Recommendation

It gives me pleasure to recommend XX who has been my student for one and a half years. I have taught her “Theory of Computation”, “Computer Graphics” and “Computer Algorithms”. I also guided her in some of her mini projects.

As a student she is extremely dedicated and diligent. She has a very good academic record and has been securing over 70% marks. She ranks among the top 20% students in her class. From my interactions with her and even from the class room discussions I could make out that she has a thorough understanding of fundamentals and evinces keen interest in her studies. Her questions reflect her quest for knowledge and also that she keeps herself updated with the latest developments in her field.

She sought my guidance in her mini project “Payroll System”. Here she demonstrated her programming skills in C++ and also her clear understanding of DBMS concepts. She put in lot of hard work and some of her ideas were innovative. XX is clear about her objectives and her thinking is logical.

XXXXXXXXX is an amiable and well-mannered student who works harmoniously in a team. She is helpful and maintains good relations with the faculty and also her friends. She is confident and can communicate effectively.

Given her abilities and commitment I believe that XXXXX has the potential to undertake higher studies. I therefore strongly endorse her application for admission and also for financial aid.


Send Email using Gmail SMTP

On September 27, 2009, in .NET, by Vaibhav

In one of my Application called Exxecutive (secret !) I wanted to send email to my clients using my Gmail Account. I wanted to make sure Gmail keeps a copy of my sent emails. If I use SMTP provided by Microsoft IIS, Gmail doesn’t come in the picture. After doing some research I wrote a function that will use Gmail’s SMTP server and send email and also keep a copy in the send mail folder. This function uses .NET’s Mail Namespace.

It is important to note here that Gmail uses port 587 (a new preferred port for mail submission) and SSL

Here is the VB.net code:

    Function SendEmail(ByVal inTo As String, ByVal inSubject As String, ByVal inBody As String)
            Dim MySmtpClient As New System.Net.Mail.SmtpClient()
            Dim MyCredentials As New System.Net.NetworkCredential
            MyCredentials.UserName = "name@gmail.com"
            MyCredentials.Password = "***your password here****"
            MySmtpClient.Host = "smtp.gmail.com"
            MySmtpClient.Port = 587 ' 25
            MySmtpClient.Credentials = MyCredentials
            MySmtpClient.EnableSsl = True
            Dim ToMailAddress As New MailAddress(inTo)
            Dim FromMailAddress As New MailAddress(MyEmailAddress, MyEmailDisplayName)
            Dim MyMailMessage As New System.Net.Mail.MailMessage(FromMailAddress, ToMailAddress)
            MyMailMessage.Subject = inSubject
            MyMailMessage.Body = inBody
            MyMailMessage.IsBodyHtml = True
            Return True
        Catch ex As Exception
            Return False
        End Try
    End Function

Personally I feel it is a good move by Microsoft. We will have to wait and see how it goes. Here is the original text from the Azure Blog

Microsoft, Zend and others launched the Simple API for Cloud Application Services project, a new open source initiative that allows developers to use common application services in the cloud, while enabling them to unlock value-added features available from individual providers.

In essence, this project will allow developers to write basic cloud applications that work in all of the major cloud platforms. More specifically, it gives developers who use the PHP scripting language a “speed dial” to develop basic cloud applications that can be deployed across all major cloud platforms, including Windows Azure, while making it easier to complement software vendors’ fully-featured technology interfaces in a harmonious way.

This is good for our customers because we know they work in mixed environments and this should make it easier to access new technologies from cloud vendors. And its good for our industry because while we’re still in the early stages of collaborating on cloud interoperability issues, we’ve made great progress with our own products and standards support, as well as through industry collaboration such as this project announced today with Zend, IBM, Rackspace and others.

To read more about the “Simple API” project, please read today’s blog post from Vijay Rajagopalan, principal architect, Microsoft at: http://blogs.msdn.com/interoperability/archive/2009/09/22/microsoft-zend-and-others-announce-simple-api-for-cloud-application-services.aspx


I was planning to move my wordpress blog to a new subfolder instead of the current root folder. I had to go through a long process. I did some research and found a few wordpress plugins that will do the job for me but my situation was a little different. I wanted to move all wordpress php files to a subfolder like /blog and also the main blog permalinks.

I read on google webmasters tools website that if you put a permanent redirect (HTTP 301) for your old indexed URL the google bot will update its index with the new URL gradually. Since I just started writing blog I had only about 21 URLs indexed in google but I still dont want to lose those !

Continue reading »


A few years ago while working on a web-scraping tool in .NET I found an amazing library SgmlReader which made my life so easy to convert HTML documents to XHTML. With this I was able to run XPATH queries to extract whatever information I want from any dam website written in worst possible malformed HTML. Had it not been SgmlReader I would have had to write tedious parsing  code to extract the tokens from the HTML string.

With this simple code you cleanup the mess that most web-masters do !!

Here is the function for VB.NET. Please download SgmlReader from the link above.

    Public Function Html2Xml(ByVal txtHTMLString As String) As String
        Dim XHTML As New Sgml.SgmlReader
        Dim sw As StringWriter = New StringWriter()
        Dim w As XmlTextWriter = New XmlTextWriter(sw)
        XHTML.DocType = "HTML"
        XHTML.InputStream = New StringReader(txtHTMLString)
        While (Not XHTML.EOF)
            w.WriteNode(XHTML, True)
        End While
        Return sw.ToString()
    End Function


Recently I encountered a similar need in PHP and I was desperately searching for SgmlReader equivalent and my search zeroed on php_tidy extension. Once you enable this extension you get all the functionality.

	$opts = array("clean" => true, "output-xml" => true); 	
	$xhtml = tidy_parse_file("http://www.example.com", $opts);
	echo $xhtml;


For more information about php_tidy goto http://us.php.net/tidy


CURL Class with cookie support

On September 15, 2009, in PHP, by Vaibhav

If found a really nice PHP class for CURL usage
Source: http://us2.php.net/manual/en/book.curl.php#90821

I have modified the code for my needs.

Example Usage:

$curl = new mycurl("http://www.example.com");
$content = $curl->content();
echo $content; 


Here the code code for the curl class:

class mycurl { 
	protected $_useragent = "Mozilla/5.0 (Windows; U; Windows NT 5.1; en-US; rv: Gecko/20090729 Firefox/3.5.2"; 
	protected $_url; 
	protected $_followlocation; 
	protected $_timeout; 
	protected $_maxRedirects; 
	protected $_cookieFileLocation = './cookie.txt'; 
	protected $_post; 
	protected $_postFields; 
	protected $_referer ="http://www.google.com"; 

	protected $_session; 
	protected $_webpage; 
	protected $_includeHeader; 
	protected $_noBody; 
	protected $_status; 
	protected $_binaryTransfer; 
	public    $authentication = 0; 
	public    $auth_name      = ''; 
	public    $auth_pass      = ''; 

     public function useAuth($use){ 
       $this->authentication = 0; 
       if($use == true) $this->authentication = 1; 

     public function setName($name){ 
       $this->auth_name = $name; 
     public function setPass($pass){ 
       $this->auth_pass = $pass; 

     public function __construct($url,$followlocation = true,$timeOut = 30,$maxRedirecs = 4,$binaryTransfer = false,$includeHeader = false,$noBody = false) 
         $this->_url = $url; 
         $this->_followlocation = $followlocation; 
         $this->_timeout = $timeOut; 
         $this->_maxRedirects = $maxRedirecs; 
         $this->_noBody = $noBody; 
         $this->_includeHeader = $includeHeader; 
         $this->_binaryTransfer = $binaryTransfer; 

         $this->_cookieFileLocation = dirname(__FILE__).'/cookie.txt'; 


     public function setReferer($referer){ 
       $this->_referer = $referer; 

     public function setCookiFileLocation($path) 
         $this->_cookieFileLocation = $path; 

     public function setPost ($postFields) 
        $this->_post = true; 
        $this->_postFields = $postFields; 

     public function setUserAgent($userAgent) 
         $this->_useragent = $userAgent; 

     public function createCurl($url = 'nul') 
        if($url != 'nul'){ 
          $this->_url = $url; 

         $s = curl_init(); 

		$header[] = 'Accept: text/xml,application/xml,application/xhtml+xml,text/html;q=0.9,text/plain;q=0.8,image/png,*/*;q=0.5';
		$header[] = 'Accept-Language: en-us,en;q=0.5'; 
		$header[] = 'Accept-Encoding: gzip,deflate'; 
		$header[] = 'Accept-Charset: ISO-8859-1,utf-8;q=0.7,*;q=0.7'; 

		$header[] = 'Keep-Alive: 300'; 
		$header[] = 'Connection: keep-alive'; 

         curl_setopt($s,CURLOPT_HTTPHEADER, $header); 

         if($this->authentication == 1){ 
           curl_setopt($s, CURLOPT_USERPWD, $this->auth_name.':'.$this->auth_pass); 


         } */
		 curl_setopt($s, CURLINFO_HEADER_OUT, true);

         $this->_webpage = curl_exec($s); 


         $this->_status = curl_getinfo($s,CURLINFO_HTTP_CODE); 


	public function getHttpStatus() 
		return $this->_status; 

	public function content()
		return $this->_webpage; 


On August 29, 2009, in PHP, by Vaibhav

Last night I was trying to use curl for data mining in PHP. The website was built in ASPX and used Session. As we all know ASP.net has server side controls whose state is stored in the hidden __VIEWSTATE variable in the form, I had to send this VIEWSTATE variable as my post variable to get the desired response.

After trying for a few hours with no success I was wondering what was wrong. After some research I came across some article that suggested using LiveHttpHeaders plugin in Firefox to view what exact request is being sent. Then after looking at the Request Header I found that the VIEWSTATE needs to be URL encoded !! and there I got my desired response instantly.

To conclude if we send POST parameters with CURL make sure you encode them and send in the proper order.

Checkout my other post CURL Class that will help you write code to send requests to pages that need cookies.

Also checkout Convert HTML to well-formed XML document (Clean HTML) with SgmlReader or php_tidy post to get insight on how to extract information from HTML.


My First Blog

On October 9, 2008, in General, by Vaibhav

Hello Friends!

Finally today October 9,2008 on the auspicious day of Dussera, I am writing my first blog on my personal website. I wanted to start writing blog many many years ago but never took it seriously. So finally TODAY !

I plan to write about my journey towards my goals in life. Though my life is still evolving I think its the right time to refresh old memories. I would also write about the latest technologies and provide my view of what I feel about it.

 Thats it for now. Keep visiting my website.