Learning Python

I have heard about Python over and over and over again and for reasons not known I have ignored Python over and over again!! But not anymore, I have finally decided to learn python and that too in the right way!

So, the other day  while coming back from the college library I picked up two of the books on python(Learning Python and Beginning Python) and have started reading about python. I did read a couple of pages and this is what I have to summarize:

  • Python is dynamic object oriented language
  • works on Windows, Linux/Unix and MAC OSes apart from a range of other OS
  • has simple syntax and is modular with hierarchical packages
  • newer modules can be added and modules written in C/C++, Java and even .net framework supported
  • used extensively and the demand is increasing day by day
  • And finally its open source!

All the above points make python a language I definitely want to learn and I am cursing myself for not learning it for so long.  So, do check back soon as I will post about my progress of learning python. Do suggest any resources/ articles/ books on python that you might know in the comments section.

Posted in python | Tagged | 1 Comment

Value Types and Reference Types in .net

I was reading about Value types and Reference Types for the exam 70-536 which I will be giving soon and there were certain things that I already knew already but some of them were new to me and hence I thought I would have a summary post of what I understand of value types and reference types in .net.

Value Type:

The .net CLR(Common Language Runtime) store the data of the value types in a part of the memory called as the stack. The most basic type of variables like Integers, Booleans, Bytes etc are stored as value types by the .net runtime. Value types can be easily created, updated and removed from the stack by the .net runtime.
There are three types of value types:
•    The built-in types of the .net framework
•    The user defined types
•    Enumerations.

Reference Types:

The .net CLR stores reference types in 2 steps; firstly the address of the memory location, called as a pointer is stored in the stack. This pointer points to the address where the actual data is stored in the part of the memory called as the heap. Reference types which are no longer referenced are garbage collected periodically by the runtime. Reference types are generally very effective in passing parameters to functions.

Some of the examples of reference types include strings, objects (of classes; built-in or otherwise) etc. To illustrate more, I did an experiment which demonstrates value type and reference type and how can it be detected if a variable is a value type or a reference type.

SByte a = 0;
Byte b = 0;
Int16 c = 0;
Int32 d = 0;
Int64 e = 0;
string s = “”;
Exception ex = new Exception();
object[] types = { a, b, c, d, e, s, ex };
foreach (object o in types)
{
string value = “”;
if (o.GetType().IsValueType)
{
value = “Value type”;
}
else
{
value = “Reference type”;
}
Console.WriteLine(”{0},{1}”, o.GetType(), value);
}

In my next post, I will write about how to create your own value type and an example of a reference type used for function calls.

Posted in .NET | Tagged , | 1 Comment

Major updations to the website

I have had a website now for more than 2 years and earlier it was at a .info domain of my name(http://pranavbhat.info) and this was done because the .com was not available then. Recently, I got hold of a .com for my name and hence I have decided to have a website of my own with the popular .com domain.

I am also a big fan of the .net technologies and hence I also wanted to have a website that will have all the information about me and allow me to showcase my work in .net technologies. This prompted to me buy a Windows based web hosting plan from Godaddy.

Now, I can build a website in asp.net which will contain all the information about me(you can start by visiting my homepage) and then following the links in the menu bar to know more about me on the about me page and about the projects that I have done on the projects page(which is under construction as I type this post).

Finally, you can use the contact me page to contact me about anything and everything under the sun. So, I hope you enjoy your time on this new site of mine and I will try and have a detailed post of how did I convert from my old site to the new one and how the mapping of blog posts from the old domain takes place.

Posted in Everything Social, Uncategorized | Tagged | Leave a comment

First Post from ScribeFire!

Just read somewhere about ScribeFire which lets you post articles to your blog right from your browser without even visiting or logging into your blog(well you actually have to login; its just that you dont have to visit your webpage.

So, as soon as i read about Scribefire, i was like “this is the thing i was looking for!!” and hence installed the plugin immidiately and viola; this is my first post from scribefire. If all goes well i will be posting very often using scribefire because this is kind of convinient for me to post this way; so hoping that this works out fine for me!

Posted in Uncategorized | 1 Comment

Fashion Review!

I know this is kind of late since i watched the movie fashion about a week back but i have been busy; but nevertheless heres a review of the movie. The first thing that comes to my mind when i think of the movie is the fact that the movie has failed to surprise me like other movies of madhur bhandarkar; infact the movie has disappointed me. I think the movie is not typical madhur bhandarkar and instead of showing the reality( which madhur bhandarkar) is fameous for; this time he has been politically correct for the movie.

The movie starts like the usual with a small town girl who dreams to make it big in the Indian modelling world and is the usual modest and cheerful girl and then as she gains success and fame she turns bitchy, arrogant and unprofessional.Then she goes into a rehab, treats herself and walks on the ramp once again. I mean thats about the stroyline with things like a couple of hot models; real life incidents from modelling world are put in and so on and so forth. So, the storyline is the same “mom and pop” storyline that is so evident in most of the movies in India; with the difference being glamour and hot chics and some real life incidents and romours put into the movie.

So, overall an average movie but great acting by both Priyanka Chopra and Kangana Ranaut. So, I would recommend fashion as a one time watch!!!!

Posted in Uncategorized | Tagged , | Leave a comment

Happy Independence Day!

Here is Wishing each and every Indian in each and every part of the world a very Happy Independence day. To celebrate this independence day i found this video on youtube which is our national anthem. so, lets sing it together and celebrate our independence day!

Indian National Anthem

Posted in Uncategorized | Leave a comment

Project: Web Hosting Blog

I just started work on a new project which in reality is a web hosting blog. The content of the project will be created by the blog owner and my work includes Search engine optimization of the blog including link building and keyword analysis and optimization. Now, Search engine optimization is pretty challenging in itself and SEO can get very tricky with search engines changing their algorithms every now and then. I must agree this is my first project with respect to search engine optimization and hence this is more of an experiment rather than a project.

I am learning this new field and would post all the latest that i learn with respect to search engine optimization and keep you posted!

Cheers!

Posted in Projects | Tagged , , | Leave a comment

Send Emails using ASP.NET

Sending Emails has always been an important function of any web based application. Many web applications use emails as the basic means of communication with its users. It is used to verify a users email id; so that the user does not put someone else’s mail id instead of his or sending reminder emails, notification and much more. Hence, in this series we see sending of emails from sending the basic email to sending complete HTML pages using various programming languages. I will mainly concentrate on PHP, ASP.NET and Java.

Sending Email using ASP.NET

Sending emails in ASP.NET is very easy especially with the use of MailMessage and the SMTPClient classes. These two classes are available in the System.Net.mail namespace. The MailMessage class creates the mail message to send and it contains all the properties which can be used in a mail message like adding CC and BCC, adding headers and much more.

The SMTPClient class is used to send the email message using the send() function.  This function takes an argument of type MailMessage.

The code to send the email is as follows:

Default.aspx File: (this file merely contains HTML form which will take several fields of Email).

<div id=”EmailForm” runat=”server”>
<form runat=”server”>
<table>
<tr><td>Username</td><td>
<asp:TextBox ID=”userName” runat=”server”></asp:TextBox></td></tr>
<tr><td>Password</td><td><input type=”password” runat=”server” /></td></tr>
<tr><td>Outgoing SMTP server</td><td><asp:TextBox ID=”mailServer” runat=”server”></asp:TextBox></td><td>Port</td><td><asp:TextBox ID=”port” runat=”server” Width=”25″></asp:TextBox></td></tr>
<tr><td>To:</td><td><asp:TextBox ID=”to1″ runat=”server”></asp:TextBox></td></tr>
<tr><td>Subject</td><td>
<asp:TextBox ID=”subjectinfo” runat=”server”></asp:TextBox></td></tr>
<tr><td>Message<td><textarea id=”message” cols=”20″ rows=”2″ runat=”server”></textarea></td></tr>
<tr><td colspan=”2″  align=”center”><asp:Button ID=”Button1″ runat=”server” Text=”Send Email” /></td></tr>

</table>
</form>
<div id=”result” runat=”server”>

</div>
</div>

The default.aspx.vb file which handles the code for the click on the button.

Imports System.Net

Partial Public Class _Default
Inherits System.Web.UI.Page

Protected Sub Page_Load(ByVal sender As Object, ByVal e As System.EventArgs) Handles Me.Load

End Sub

Private Sub Button1_Click(ByVal sender As Object, ByVal e As System.EventArgs) Handles Button1.Click
Dim portno As Integer
If port.Text = “” Then
portno = 25
Else
portno = port.Text
End If
Dim mailmessage As System.Net.Mail.MailMessage = New Mail.MailMessage(userName.Text, to1.Text)
Dim smtp As Mail.SmtpClient = New Mail.SmtpClient(mailServer.Text, portNo)

mailmessage.BodyEncoding = Encoding.Default
mailmessage.IsBodyHtml = False
mailmessage.Subject = subjectinfo.Text
mailmessage.Body = message.Value

Try
smtp.Send(mailmessage)
result.InnerHtml = “<b>Message sent successfully</b>”
userName.Text = “”

Catch ex As Exception
result.InnerHtml = “<b>” & ex.Message & “</b>”

End Try

End Sub
End Class

Now, to send email from a SMTP server that does not require any authentication for outgoing mails can use the above code, but to send emails from an SMTP server that requires authentication( most servers these days do due to SPAM) you can make the following changes to the web.config file.

<system.net>
<mailSettings>

<smtp from=”from@yourdomain.com”>
<network host=”mail.yourdomain.com”
userName=”user@yourdomain.com”
password=”password-here” />
</smtp>
</mailSettings>
</system.net>

You can download the entire source code here. The source code in this file is a bit different than the above code as i made a few modifications at the last minute. Do make appropriate changes to the web.config file as shown in the above. All code in this post is written using vb.net.

I will also be writing code for sending emails using PHP and Java as well as writing code for more advanced functions of Mail. So, do check back for more.

Posted in .NET, Programming | Tagged , | 4 Comments

Steganography on Images (project)

Steganography on Images

I am in the process of updating my blog with a detailed description of my projects so that people can know my programming expertise and hire me for programming jobs!

I did this project sometime back in which i was supposed to hide text into images that user uploads into the system. This text is hidden inside the image and is not displayed when seen by the naked eye. There are many sophesticated algorithm for the project, but we used a simple substitution algorithm for encoding the text into several pixels of the image.

The user who uploads the image also has to give a secret password or a passcode which is used as an encryption key to decide the position of the pixels whose values are substituted to accomodate the position the bits of text to be hidden in the image. This is a project that i did more that 3 years ago and was done in Vb 6.0 as the client had specifically requested at that time. Later on, i did convert the project into the .net platform using asp.net with vb.net.

To do this project in VB 6 was relatively difficult because of the various bit level calculations that we had to perform which is painstaking in vb 6 but using .net i could leverage the power of .net to do this project and to include several other features to this project.

The latest additions to this software was the ability to share and transfer the images with other users giving the software some social features. This software could also watermark images and have visible or invisible copyright information about the images.

Posted in Projects | Tagged , | 6 Comments

How to start a blog?

I was dumbstruck when one of my friend asked me what is a blog and I wrote this article for him and the next obvious question was:

hmm…that sounds interesting? How do I start a blog?

Now, starting a blog is the most easiest and the most challenging thing; yes challenging because you need to have content to post about in your blog and to post content you need to have ideas about blog posts; otherwise your blog would be among those thousands of dead blogs on the internet. Apart from content, what you need is a domain name like pranavbhat.info or pranavbhat.com. Along with a domain name you need to have a web hosting account with a web hosting company to host your blog.

Now, there are several domain name registrars out there who can register domains. Some of the web hosting companies also provide a free domain name with every web hosting account that you purchase. The web hosting company where i host this blog and several other websites is web hosting buzz. This company has been around for quite sometime now since 2002 and hence are really good at it.

Apart from a domain name and a web hosting account you need a good blogging software. Wordpress available at wordpress.org is a popular blogging software and its free too. You can download it at Wordpress.com/download

There are several other free blogging sites which offer to host your blogs for free, but i prefer that freedom which comes with having our own web hosting account and a domain and hosting our blog on it. I did write a post that describes the difference between wordpress.com and wordpress.org sometime back. Wordpress.com is a free blog hosting service where as wordpress.org is a free blogging software which you can download and then install on your own.

Posted in Everything Social | Tagged , | 9 Comments