Upon my recent post on my transferral from SVN to Git, I’ve now signed myself for a GitHub account.
I’m now in the process of uploading some previous projects up to GitHub for safe keeping which no doubt will prove helpful at some point.
Additionally this will enable me to simply link to a repository on GitHub instead of hosting project zip files here on this blog. This will no doubt make it much easier to give updates on any new changes to the code.
Recently Ive taken the time to learn the Git version control system. Upon previously using SVN for version control, Git seems to be a lot more powerful and user friendly. But perhaps one of the best reasons to use Git is the wealth of choice in online repository services using Git compared to that of SVN.
One of the best and most popular is github.com which provides unlimited public git repositories for free. Not bad at all.
So far my experience with Git has been very positive. Much easier branching/merging than SVN and the online documentation and support is very good. It has provoked me into making the switch from SVN to Git, or moving on with the times as many would say. Well see how it goes.
I’m also going sign up for a GitHub account. Can’t go wrong with unlimited free repositories. Hopefully it will get me into the habit of pushing everything up to online repositories which no doubt will save me one day when I accidentally delete something important.
In Visual Studio 11 the whole interface has been transformed to a monochrome effect that is a lot more pleasing to the eye for long periods than previous versions which barraged the user with layers of colourful and distracting icons.
With the code view open, the main focus is rightly where it should be - on the code. Nothing else is stealing your attention.
Some of the new features including Hubs, Pivots and multi - instancing are explained in the Visual Studio Blog.
Finally the long awaited Consumer Preview of Windows 8 has now been made available for download. ISO images of both 32 and 64 bit versions can be downloaded from the links below. Also remember that this build of Windows 8 is not a final product and as such may have bugs or other quirks that can cause the system to crash or applications to hang.
First impressions of the release point to some styling inconsistencies and annoyances with the new interface. One user encountered three different scrollbar styles and found the lack of a Start Menu compared to the new ‘Charm’ menu frustrating. Whilst others find it very difficult to efficiently multi task as they have to constantly enter and exit the Metro UI by putting the mouse at the bottom or top of the screen. Of course many others like the new Metro interface which seems to work very well on touch based computers. On the other hand such a drastic change could be alienating traditional desktop and laptop users who do not have access to a touchscreen and therefore cannot make the most of the new Metro UI.
UPDATE - Google no longer offers a weather API. The url’s and code in this post will no longer function correctly
As you may or may not know Google has announced over the last couple of months that they plan to bring an end to a load of their services, perhaps the biggest being iGoogle.
Unfortunately one of the services they have already brought an end to is their weather API that I made of use of in this post
The code in the post now no longer works as the request URL is met with this error message
"404. That's an error"
I hope to post another update soon with examples on how to use alternative API’s.
This API will no longer function correctly as the API from Google is no longer available. The code is kept here for reference
You can obtain the current and forecast weather conditions in a user specified city with C# through the free weather API provided by Google. The main concept behind the API is to produce a URL, with a specified city, which then corresponds to an XML file that includes the weather forecast. Handily C# makes it easy to obtain this XML file, parse it, and finally print out the weather on a large variety of cities.
will return an XML file with the weather for London.
Now in C#, we will start by creating a Conditions class that will simply contain a bunch of properties that represent the weather in the city at a point in time -
Now we will move on to the main Weather class that will hold two methods - GetCurrentConditions, and GetForecastConditions. The GetCurrentConditions method will return one Conditions object - representing the current day, and the GetForecastedConditions method will return a List of conditions - one for each day of the forecast. Before we begin, make sure to put the following using statement at the top of the file so that we can use the various classes and methods inside the System.Xml namespace -
Now we can create the public static GetCurrentConditions method that takes one string parameter representing the city -
The first thing we do is create the Conditions object, XMLDocument object (representing the returned XML file), and the XMLTextReader (which will be used to obtain the XML file and put it in our XMLDocument object).
Next, we construct the URL, adding the city string to the end of URL, and load the document into our XMLDocument object. We then do a check to see if the XML document was successfully downloaded (i.e the city is valid). If not we set the conditions object to null, which can be used as error checking in our implementation later on.
If the document is valid, we set each property of the Conditions object to the relevant portion of the XML document. The SelectSingleNode method moves to each element of the file and the data attribute and .InnerText property are used to parse the data from the document into our object. Again, if an exception is thrown, we set the Conditions object to null for error checking. Finally, we close the XMLTextReader and return the Conditions object.
The GetForecastConditions method is very similar. The only difference is the foreach loop that goes through each forecast in the forecast_conditions node, adds the conditions to a new Conditions object, and adds it to the List which is then returned at the end.