Archive for May, 2012

Get Weather Data for your website!!

May 30th, 2012

I have been looking at a few options on how to get live weather data for the web and I came across the Weather Underground’s weather API found HERE.  I have posted the code snippet below that will populate the divs with the according weather data using JQuery, I left out my API key for obvious reasons, but you can get a free one my following my link above and registering as a developer, enjoy!

                url: "<Your API Key>/geolookup/conditions/q/KY/Murray.json",
                dataType: "jsonp",
                success: function (parsed_json) {
                    $('#skyCondValue').append($('<option>', { value: "skyCond" }).text(parsed_json['current_observation']['weather']));
                    $("#windDirVal").append($('<option>', { value: "windDir" }).text(parsed_json['current_observation']['wind_dir']));
                    $('#envInfo').text(parsed_json['current_observation']['temp_f'] + " " + parsed_json['current_observation']['weather'] + " " + parsed_json['current_observation']['dewpoint_f'] + " " +
                    parsed_json['current_observation']['wind_mph'] + " " + parsed_json['current_observation']['wind_dir']);

Windows Azure Error: Not running in a hosted service or the Development Fabric.

May 23rd, 2012

You may get this error sometime when you are trying to launch your azure project out of studio and it will show up in the Yellow Screen of Death or YSOD, here is a screenshot of it.

Basically you will get this error if you either didn’t set your Azure Project as the startup project or you didn’t load Visual Studio under administrative privileges, I hope that this helps.

Windows Azure ServiceBus Demo

May 18th, 2012

Recently I was put to task with doing some research on the Windows Azure ServiceBus for an upcoming project at my workplace and I was rather impressed with what I found. I have put a repo out on github for anybody that is interested. I began down the road of something like what is seen on this site: The problem with following those directions on the link I just sent is that it defaults to some custom port that is not 80 and that wouldn’t work in my situation due to the fact that our app would be out in the public and I didn’t want to burden my clients with having to open up that port on their firewalls, so I went with a REST-based implementation.

The demo has two wpf windows in which you will need to make a couple of changes to work with your azure account, I have a snippet below that shows the spots that need to be changed.

 static string serviceNamespace = "<YourNamespace>";
 static string baseAddress;
 static string token;
 const string issuer = "owner";
 const string key = "<YourKey>";
 const string sbHostName = "";
 const string acsHostName = "";

Here is the link to the GitHub repo:


How to resolve issues with embedded images in email.

May 10th, 2012

I am embedding an image into an email that the server is generating using the SmtpClient in .net and I was having an issue with it caching images in certain situations and then Internet Explorer wouldn’t display the images at all, which is probably a security feature of IE, but the images did show up in Firefox and Chrome. Anyways, here is the code below that will make all of it work correctly in IE and should always show the images correctly, it generates a new Guid to always have a unique image Id so that caching won’t happen and then also tells the client that the ContentType is a jpeg which apparently IE needs to display the image correctly.

Guid contentId = Guid.NewGuid().ToString();

AlternateView htmlView = AlternateView.CreateAlternateViewFromString(
  "This is a sample JPG embedded image<br><img src="cid:" + contentId + "">", 
  null, "text/html");

ContentType ct = new ContentType(MediaTypeNames.Image.Jpeg);

LinkedResource EmbeddedObjects1 = new LinkedResource("PathToImage\image1.jpg", ct);
EmbeddedObjects1.ContentId = contentId;

Setting Input and Selects via JQuery

May 4th, 2012

I thought I would post this quick little blurb about setting your HTML controls from JQuery. Here are the 2 lines that set those property types:

$('#id2').append($('<option>', { value: "Your_Value" }).text("Your_String");

And here is the complete Ajax call where I am setting those properties off the returned JSON:

function() {
                url: "",
		        dataType: "jsonp",
		        success: function(parsed_json) {
			        var location = parsed_json['location']['city'];
                                $('#id2').append($('<option>', { value: "Your_Value" }).text("Your_String");