Warning
This post is about how you were able to create and insert Google Gadgets onto Sites- Since first writing about it, Google has now closed down Gadgets and I have moved my site away from Sites.
I am however leaving the page as is should you find some interesting some useful piece to reuse

To make sure that your blogger and your site always reference the same (latest) version of your code samples, and that the formatting is consistent across your site and your blog, you should consider using github to be the master for all your code samples. Take a look at how to embed gist in Blogger in this post. Here we’ll cover how to do the same thing in Google Sites (which is hosting this site).

GitHub

This is a free repository (and version management system) for code samples. Just register and you’re ready to create your first code sample (or gist as they are referred to). Of course Google Sites restricts what you can do, so although github provides a perfectly good piece of javaScript to embed a sample, you have to implement a gadget to host it. I came across this gadget from derquinse, so let’s use that one.

Example

We’ll use the code sample for Simple implementation of R- melt to embed the code from this gist. 

Using Google Apps Script

Another way is to use the caja prettifier wrapped up in Google Apps Script. You can read about how this works here. This time we use a simple iFrame gadget, and embed a URL like this

https://storage.googleapis.com/toasty/p/gaspubcontainer.html?source=gist&library=3357942

The code below would have been displayed in the created gadget. 

See Get Started Snippets for more topics like this. In the meantime why not join our forum,follow the blog or follow me on twitter to ensure you get updates when they are available.