November 2011 Entries

Programming Windows 8: The Sublime To The Strange

Microsoft unveiled Windows 8 at the //build/ conference in September. Since then I've spent time seeing how to put together Windows 8 metro applications with HTML and JavaScript. The Sublime The following is all you need for a native Windows 8 Metro application. <!DOCTYPE html> <html> <head> <meta charset="utf-8" /> <title>Hello App</title> </head> <body> <h1>Hello!</h1> </body> </html> There are some other small administrative details, like a manifest file. And, the above application is plain looking without styles or colors, but it is a real, native Metro application. To the...

Getting Intrinsic HTML5 Video Dimensions

The HTML 5 DOM interface for a video element allows you to get the underlying video's width and height in pixels, but, be careful not to ask for the dimensions too early. If you ask as soon as the DOM is ready, like in the following code, you'll probably see width and height as 0. $(function () { var video = $("#video").get(0); var width = video.videoWidth; var height = video.videoHeight; // ... }); You'll want to wait for the video element to raise the loadedmetadata event before asking...

Composing Entity Framework Fluent Configurations

The canonical example for fluent configuration with the Entity Framework is to take a few simple entity definitions: public class Product { public int Id { get; set; } public string Name { get; set; } public byte[] Version { get; protected set; } } ... and configure them all inside of the DbContext's OnModelCreating method: protected override void OnModelCreating( DbModelBuilder modelBuilder) { modelBuilder.Entity<Product>().ToTable("products"); // ... more configuration base.OnModelCreating(modelBuilder); } This approach doesn't scale well as we add more entities, so let's try an alternate...

Modernizr.js: Polyfills

In the last post we looked at feature detection with Modernizr. Before moving forward, let me answer a few questions that came up. First, you can build a custom Modernizr download containing only the tests you care about when you visit  http://www.modernizr.com/download/. If you don't care about the geolocation APIs, then don't check the geolocation checkbox. The script file you download will be smaller, and more importantly there are fewer tests to run when the script hits the browser. Chances are good you will only care about a handful of the possible tests. Secondly, Modernizr doesn't...

Scott Allen
Posts - 869
Comments - 4493
Stories - 14