Webshims – HTML5 For The Masses

I’ve been researching the available shimming libaries out there that provide old browsers with modern features.  The Webshims library does this in an efficient and unobtrusive way, always defering to the browser’s built in feature if it exists natively.  With 2 lines of code you tell it where to find its shim scripts and then to discover and patch any missing HTML5 features in your browser.  I’ve provided a complete working sample of how to ensure the HTML5 localStorage API in all browsers.

<!DOCTYPE html>

<html lang=”en”>

<head>

<meta http-equiv=”Content-Type” content=”text/html; charset=utf-8″>

<script src=”http://ajax.googleapis.com/ajax/libs/jquery/1.4.4/jquery.min.js”></script>

<script src=”/scripts/js-webshim/dev/polyfiller.js”></script>

<script>

//path is path of polyfiller.js-code + shims/

$.webshims.loader.basePath += ‘shims/’;

//load and implement all unsupported features

$.webshims.polyfill();

</script>

<script>

$.webshims.ready(‘json-storage’, function () {

//work with JSON and localStorage

localStorage.setItem(“name”, “Hello World!”); //saves to the database, “key”, “value”

document.write(window.localStorage.getItem(“name”)); //Hello World!

localStorage.removeItem(“name”); //deletes the matching item from the database

});

</script>

<title>localStorage() – Sample</title>

</head>

<body>

</body>

</html>

Metaprogramming in Ruby and C#

First read this and understand metaprogramming in Ruby: http://www.devsource.com/c/a/Languages/An-Exercise-in-Metaprogramming-with-Ruby/

It seems that C# dynamic supports a similar scenario, but in a different way. C# dynamic objects are in fact not new Types created at runtime, but rather individual compiler-safe bags of key/value pairs that self expose the keys as properties. Thus C# dynamic objects are only available as defined at the instance level and those instances are of type DynamicObject.

The technique I demonstrate in this post: https://uberpwn.wordpress.com/2009/12/21/property-copying-with-dynamic-objects-in-net-4-0/ could be modified to take its key/value pair input from a csv to achieve the same result.