HTML5: The Geolocation API is scary (good)

I read about the HTML5 Geolocation API in the Pro HTML5 Programming book a while ago, and decided to play with it on this lazy Sunday. Using the Geolocation API to make a one-shot position request is very straight-forward. Get a reference to the navigator.geolocation object and call the getCurrentPosition() method, passing in at least a PositionCallback. In this example I’m also passing in a PositionErrorCallback. In the PositionCallback you can examine the properties of the position object. Here I am only using the latitude and longitude properties. ...

December 19, 2010 · 2 min · Jef Claes

HTML5 selectors and jQuery

In my first post on the HTML5 javascript Selector API I wondered how the new methods querySelector() and querySelectorAll() would influence jQuery. At the time, I couldn’t find any information on the subject, but yesterday I found out that jQuery has been taking advantage of these new methods since version 1.4.3. From the release notes.. The performance of nearly all the major traversal methods has been drastically improved. .closest(), .filter() (and as a result, .is()), and .find() have all been greatly improved. ...

December 12, 2010 · 2 min · Jef Claes

HTML5: Drawing images to the canvas gotcha

While I was playing with the Canvas API I came across a weird issue: I was trying to draw an image to the canvas, but the image failed to render very often. Have a look at the source. Do you spot the problem? <!DOCTYPE html> <html> <head> <title>HTML5: Canvas</title> <script type="text/javascript"> window.addEventListener("load", draw, true); function draw(){ var canvas = document.getElementById('canvas'); var context = canvas.getContext('2d'); var img = new Image(); img.src = "logo.png"; context.drawImage(img, 0, 0); } </script> </head> <body> <canvas id="canvas" height="500" width="500"> Looks like canvas isn't supported in your browser! </canvas> </body> </html> It wasn’t until I opened Firebug and saw an unhandled exception in the console that I discovered what was going on. ...

December 5, 2010 · 2 min · Jef Claes

HTML5: More on selectors

Last weekend I blogged on new addittions to the javascript Selector API: querySelector() and querySelectorAll(). These two new methods enable you to find elements by matching against a group of selectors. I only scratched the surface in the previous post, that’s why you can find a few more examples in this post. These examples should demonstrate the power and ease of use of the new Selector API features. It’s impossible to show you all of the selectors usages in just one post, that’s why I strongly encourage you to have a look at the W3C Selectors specifications. ...

December 5, 2010 · 3 min · Jef Claes

HTML5: New in the javascript Selector API

Because I finally got the MCTS 70-536 certification out of the way, I can start experimenting with some fun stuff again. One of the things on the top of my list is HTML5. I started reading the book Pro HTML5 Programming, so expect more posts on HTML5 in the near future. In this post I will show you two new methods in the javascript Selector API which are extremely useful to find elements. ...

November 29, 2010 · 3 min · Jef Claes

Trip Report Denmark (Part 2)

If you missed the first part of this trip report, you can find it here. Funen After three days of Copenhagen we stayed at Funen for two days. This is the smallest of the three big islands of Denmark. Our motel was in a small town called Faaborg. During these two days in Funen the most impressive attraction we went to see was the Egeskov Castle. This castle is Europe’s best preserved Renaissance water castle. You can also walk around in the big park surrounding the castle, or visit the five museums on the Egeskov domain. The vintage automobile and motorcycle museums are awesome! ...

October 14, 2010 · 2 min · Jef Claes

Trip Report Denmark (Part 1)

Last month me and my girlfriend went on a holiday to Denmark for a week. We had a great time, visited a lot of places and took hundreds of pictures. In this post you can find a trip report containing the best pictures and tips on places to see. Copenhagen The first three days of this holiday we visited Copenhagen. These three days were the most interesting, but also the most intensive days of the holiday. There are so many places to visit in Copenhagen! ...

October 13, 2010 · 3 min · Jef Claes

Things good to know about SQL State Server

While installing a SQL State Server last week, I came across a few things worth sharing about the installation and use of SQL State Server. Finding a good tutorial There are lots of tutorials out there on how to install SQL State Server but most of them are not great. To do a basic installation you only need this MSDN documentation on how to run the Aspnet_regsql.exe tool and edit your web.config. All the objects in Session need to be serializable If you try to store an object in Session which isn’t marked as serializible an HttpException will get thrown with following message. ...

September 23, 2010 · 2 min · Jef Claes

Tripping in Holland. Honey, who shrunk Holland?

People who follow me on Twitter might have seen my tweets about going on a weekend to Holland with some friends. Next to excessive eating and drinking, we took the time to do some sightseeing in The Hague. The sight which gave us the most interesting pictures is Madurodam. Madurodam is a miniature city featuring the most famous Dutch buildings and landmarks. Hope you enjoy these pictures!

July 21, 2010 · 1 min · Jef Claes

Switching with non-constant cases in C#

Last week I came across a scenario where I wanted to switch over non-constants (aka variables), but while I was compiling I got Compiler Error CS0150 (A constant value is expected). This is one of those things I always forget. You can’t use variables in your case statements because the C# compiler doesn’t allow you to. It’s very logical though, the compiler forces you to use constants because otherwise there is no way of knowing there are equal case statements. ...

July 14, 2010 · 2 min · Jef Claes