OpenCourseWare from MIT-Harvard-Yale

Graduation Cap

Education provides one of the greatest advantages in life. It is knowledge, that indiscriminantly improves a persons’ position in life. In my experience, it doesn’t matter age, ethnicity, gender or origin, you’re valued by what you know and what you can accomplish.

Yet education isn’t necessarily cheap, not only in terms of money but time as well. In cases where,
for whatever reason, going to (or back to) school is not an option, or you’re simply a self-learner, there is another option.

MIT, in conjunction with several other renowned educational institutes have spear-headed the Open Courseware Initiative, an “open-source” view of education. Many courses spanning across all subjects are provided without charge over the internet. Courses vary in what material is provided, but many include audio/video sessions of actual course classes.

For those interested in Information Technology, Stanford has one of the most comprehensive collections of computer engineering courses called Stanford Engineering Everywhere. Video is provided via YouTube, iTunes U, Vyev, WMU Torrent, and MP4 Torrent and cover the following course schedule:

Introduction to Computer Science

  • Programming Methodology
  • Programming Abstractions
  • Programming Paradigms

Artificial Intelligence

  • Introduction to Robots
  • Natural Language Processing
  • Machine Learning

Linear Systems and Optimization

  • The Fourier Transform and it’s Applications
  • Introduction to Linear Dynamical Systems
  • Convex Optimization I
  • Convex Optimization II

In addition to Stanford, MIT, Yale, UC Berkely, and many other schools offer free courseware. Now you can actually download many of the courses audio/video through iTunes U, a section within the iTunes Store which contains free open courseware content. All of your college classes right on your iPod, can’t beat that!

If you would like to learn more about open courseware, please check out some of the following links and begin reaping the benefits of a free education.

Code Disassembly and Reflection

One of the first tasks I was assigned when I started my new job was to recover some old source code that a contractor had developed for the company several years back. My company had working dll’s but no source code to make changes from. This was my first real exposure to Reflector and disassembling binary code. I’ll be honest, I got a real kick out of, the hacker mentality of my youth came flooding back but without any guilt because this was a legitimate (and legal) reason to disassemble code.

Since then, I’ve found Reflector to be an invaluable tool in a developer’s arsenal for the following scenarios:

  • Retrieving lost source code.
  • As a learning tool to peak into other, possibly more sophisticated code and code architecture.
  • To assist in troubleshooting third-party vendor software (which is certainly not immune to bugs).

These are just a few reasons, but all contribute to advancing your skill as a developer and worth to your client(s)/company.

Where can I get it and how much does it cost?

There probably are a couple out there, but I use Red Gate’s .NET Reflector which you can download a FREE copy.

Red Gate produces various other products that are useful, though many of them are not free.

How do I use it?

Glad you asked; Reflector is pretty easy to use. First, begin by opening Reflector, selecting File > Open and selecting a .NET based DLL that you would like to analyze. For demonstration, I will be using one of the nopCommerce DLL’s, Nop.Common.dll. (nopCommerce is a .NET open-source ecommerce project).

If the Disassemble panel is not already open, go ahead and open it now by right clicking on the assembly you just loaded, and selecting Disassemble.

By drilling down the tree-style panel on the left side, you can see all of the individual namespaces that comprise the DLL.

This takes a bit of digging, but with enough patience you can find what you are looking for. We will now select NopSolutions.NopCommerce.Common.Audit > LogManager to view the code in this class.

Next let’s move to the right side panel and scroll to the very bottom and click “Expand Methods”. This will allow us to see all of the code in the class. A nice touch is that you can view code in your language of preference, such as C# or VB.

You are now able to disassemble .NET code in a breeze, remember, “with great power, comes great responsibility”! Please make sure that whatever you are disassembling you have the right to disassemble it. Good luck on your next project.

Technorati code: zneh8mkst6

Staying in Touch – How to Build a Contact Form

Whether you are a Fortune 500 company or a mom-and-pop shop online, you need some way for visitors to contact you. Most contact forms are pretty much the same, you choose what information you want your visitors to provide to you as well as an open area for any comments/questions they would like to leave. The information is then sent to an administrator email account for correspondence. You may also want to display a confirmation to the user that their email has been sent.

To demonstrate how to do this, I will use my own contact form in ASP.NET (VB.NET) and an old PHP version I used to run a long time ago.


For those of you Microsoft-based developers, here is some sample code that can be used as a base for your contact forms.

ASPX (frontend)

<h1>Contact Nicholas Barger</h1>
<p>Please feel free to contact me with questions, comments, or anything else that you would like to discuss. I appreciate your interest/involvement so I try and respond as quickly as possible.</p>

<p>You can also find me on <i>LinkedIn</i> at: <a href="" target="_blank"></a></p>

<div class="formdisplay">
	<span>Please enter your email address:</span><br />
	<asp:TextBox ID="tbEmail" runat="server" Width="700px"></asp:TextBox><br />
	<span>Please enter a subject for this message:</span><br />
	<asp:TextBox ID="tbSubject" runat="server" Width="700px"></asp:TextBox><br />
	<span>Please enter your message below:</span><br />
	<asp:TextBox ID="tbMessage" runat="server" TextMode="MultiLine" Width="700px" Height="250px"></asp:TextBox><br />

<asp:Button ID="btnSubmit" runat="server" Text="Send Message" />

VB.NET (backend/codebehind)

Protected Sub btnSubmit_Click(ByVal sender As Object, ByVal e As System.EventArgs) Handles btnSubmit.Click
	'Prep basic values
	Dim strFromEmail As String = tbEmail.Text
	Dim strToEmail As String = ConfigurationManager.AppSettings("AdminEmail")
	Dim strSubject As String = tbSubject.Text

	'Prep custom values
	Dim strBody As String = ""
	Dim strFromName As String = ""

	strBody = tbMessage.Text

	Dim oCommonFunc As New Common.Functions
		oCommonFunc.sendEmail(strFromEmail, strFromName, strToEmail, strSubject, strBody, Nothing, Nothing, Nothing, True)
	Catch ex As Exception
		'TODO - Display Error Message
		oCommonFunc = Nothing
	End Try
End Sub

VB.NET (common class/codebehind)

Public Function sendEmail(ByVal strFromEmail As String, _
	ByVal strFromName As String, _
	ByVal strToEmail As String, _
	ByVal strSubject As String, _
	ByVal strBody As String, _
	Optional ByVal strCCEmail As String = Nothing, _
	Optional ByVal strBCCEmail As String = Nothing, _
	Optional ByVal strAttachmentPath As String = Nothing, _
	Optional ByVal bIsHTML As Boolean = False) As Boolean

	'Check for proper from email
	If String.IsNullOrEmpty(strFromEmail) = True Then
		Throw New Exception("From email is not specified.")
	End If

	'Check for proper to email
	If String.IsNullOrEmpty(strToEmail) = True Then
		Throw New Exception("To email is not specified.")
	End If

	'Check for a non-empty message subject
	If String.IsNullOrEmpty(strSubject) = True Then
		Throw New Exception("Subject was not specified.")
	End If

	'Check for a non-empty message body
	If String.IsNullOrEmpty(strBody) = True Then
		Throw New Exception("Body of email was not specified.")
	End If

	'Create mail object
	Dim oMail As New MailMessage()
	'oMail.Host = ConfigurationManager.AppSettings("MailHost")

	'Convert all "," into ";"
	strToEmail = strToEmail.Replace(",", ";")

	'Check if "To" email contains multiple emails
	If strToEmail.IndexOf(";") >= 0 Then 'add multiple emails
		Dim strToArray As String() = Split(strToEmail, ";")
		For i As Integer = 0 To strToArray.Length - 1
	Else 'add single email
	End If

	'If CC exists
	If String.IsNullOrEmpty(strCCEmail) = False Then
		'Convert all "," into ";"
		strCCEmail = strCCEmail.Replace(",", ";")

		'Check if "CC" email contains multiple emails
		If strCCEmail.IndexOf(";") >= 0 Then 'add multiple emails
			Dim strCCArray As String() = Split(strCCEmail, ";")
			For i As Integer = 0 To strCCArray.Length - 1
		Else 'add single email
		End If
	End If

	'If BCC Exists
	If String.IsNullOrEmpty(strBCCEmail) = False Then
		'Convert all "," into ";"
		strBCCEmail = strBCCEmail.Replace(",", ";")

		'Check if "BCC" email contains multiple emails
		If strBCCEmail.IndexOf(";") >= 0 Then 'add multiple emails
			Dim strBCCArray As String() = Split(strBCCEmail, ";")
			For i As Integer = 0 To strBCCArray.Length - 1
		Else 'add single email
		End If
	End If

	'Add additional information to mail object
	oMail.From = New MailAddress(strFromEmail, strFromName)

	oMail.Subject = strSubject
	oMail.Body = strBody

	If bIsHTML = True Then
		'oMail.IsHTML = True
		oMail.IsBodyHtml = True
	End If

	Dim strSMTPUserName As String = ConfigurationManager.AppSettings("SMTPEmail")
	Dim strSMTPPassword As String = ConfigurationManager.AppSettings("SMTPPassword")

	Dim smtpClient As New SmtpClient(ConfigurationManager.AppSettings("MailHost"))
	smtpClient.Credentials = New Net.NetworkCredential(strSMTPUserName, strSMTPPassword)

	oMail.DeliveryNotificationOptions = DeliveryNotificationOptions.OnFailure

	If String.IsNullOrEmpty(strFromEmail) = False Then
		oMail.ReplyTo = New MailAddress(strFromEmail)
	End If

	If String.IsNullOrEmpty(strFromEmail) = False Then
		oMail.Headers.Add("Return-Path", strFromEmail)
		oMail.Headers.Add("Errors-To", strFromEmail)
		oMail.Headers.Add("Bounces_To", strFromEmail)
	End If

	'Add attachment
	If String.IsNullOrEmpty(strAttachmentPath) = False Then
		oMail.Attachments.Add(New Attachment(strAttachmentPath))
	End If

	'Send email
	Catch ex As Exception
		Return getErrorMessage(ErrorMessage.ErrorSendingEmail)
		oMail = Nothing
	End Try

	Return True
End Function


And now for all things open-source, a PHP version.

Disclaimer: I haven’t professionally worked with PHP since 2004, so if you have any suggestions to improve the code please add them to the comments.

All-In-One (spaghetti-code)

if(isset($_POST['btnSubmit'])) { 
	$mailto = "";
	$email = $_POST['tbEmail'];
	$subject = $_POST['tbSubject'];
	$message = $_POST['tbMessage'];
	$headers = 'From: $mailto'."\r\n"
.'Reply-To: $mailto'."\r\n";

	#Mail to Administrator
	if(mail($mailto, $subject, $message, $headers))
		//Display an error

	<title>PHP Contact Page Demo</title>
<h1>Contact Nicholas Barger</h1>
<p>Please feel free to contact me with questions, comments, or anything else that you would like to discuss. I appreciate your interest/involvement so I try and respond as quickly as possible.</p>

<p>You can also find me on <i>LinkedIn</i> at: <a href="" target="_blank"></a></p>

<div class="formdisplay">
	<span>Please enter your email address:</span><br />
	<input type="text" id="tbEmail" name="tbEmail" style="width:700px;"></input><br />
	<span>Please enter a subject for this message:</span><br />
	<input type="text" id="tbSubject" name="tbSubject" style="width:700px;"></input><br />
	<span>Please enter your message below:</span><br />
	<textarea id="tbMessage" name="tbMessage" style="width:700px; height:250px;"></textarea><br />

<input type="submit" id="btnSubmit" name="btnSubmit" value="Send Message" />

Make It Your Own

What I’ve outlined here is just a beginning demonstration. There is still work to be done, such as creating the contact complete page and notifying users that they successfully (or unsucessfully) contacted an administrator. Additionally, you may want to add additional fields to be captured, add field validation to ensure proper data entry, or perhaps add a confirmation email response to the user as well.

Have fun with it, and take a boring contact page and make it something really powerful. Hope this was helpful in getting you started, or refreshed on how to stay in touch with your visitors through a simple contact form!

CSS Zen Garden

For years when trying to convey the power and pupose of CSS I’ve deferred to a single example; CSS Zen Garden. I’ve always been so impressed by the demonstation of this project and contributions from designers all over the world. The basis of CSS Zen Garden is to take the exact same HTML content, and without making ANY changes to the HTML, create a completely unique visual design and portrayal of the content.

For those of you who think CSS is merely changing fonts and colors, try out a few examples found on CSS Zen Garden and you will be amazed at the huge range in presentations.

Here are a few of my favorites:

Care to take a look at the base HTML? Click here to view the HTML without any CSS styling.

CSS Zen Garden: The Book

If you are interested in learning more about the history behind this project, the original creators have released a book which I highly recommend.